org.netbeans.api.visual.action.WidgetAction Java Examples

The following examples show how to use org.netbeans.api.visual.action.WidgetAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SceneComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void keyPressed (KeyEvent e) {
    // HACK for invoking tooltip using Ctrl+F1 because a condition in ToolTipManager.shouldRegisterBindings cannot be satisfied
    if (e.getKeyCode () == KeyEvent.VK_F1  && (e.getModifiers () & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
        MouseContext context = new MouseContext ();
        resolveContext (scene.getFocusedWidget (), context);
        context.commit (this);

        Widget focusedWidget = scene.getFocusedWidget ();
        Point location = focusedWidget.getScene ().convertSceneToView (focusedWidget.convertLocalToScene (focusedWidget.getBounds ().getLocation ()));
        MouseEvent event = new MouseEvent (this, 0, 0, 0, location.x, location.y, 0, false);

        ToolTipManager manager = ToolTipManager.sharedInstance ();
        manager.mouseEntered (event);
        manager.mouseMoved (event);
    }

    WidgetAction.State state = processKeyOperator (Operator.KEY_PRESSED, new WidgetAction.WidgetKeyEvent (++ eventIDcounter, e));
    if (state.isConsumed ())
        e.consume ();
}
 
Example #2
Source File: SceneComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private WidgetAction.State processKeyOperator (Operator operator, WidgetAction.WidgetKeyEvent event) {
    WidgetAction.State state;
    String tool = scene.getActiveTool ();

    WidgetAction.Chain priorActions = scene.getPriorActions ();
    if (! priorActions.getActions ().isEmpty ())
        if (operator.operate (priorActions, scene, event).isConsumed ())
            return WidgetAction.State.CONSUMED;

    if (lockedAction != null) {
        state = operator.operate (lockedAction, lockedWidget, event);
        if (! state.isConsumed ())
            state = processKeyOperator (operator, tool, scene, event);
    } else
        state = processKeyOperator (operator, tool, scene, event);

    lockedWidget = state.getLockedWidget ();
    lockedAction = state.getLockedAction ();
    scene.validate ();

    if (lockedWidget != null)
        scrollRectToVisible (scene.convertSceneToView (lockedWidget.convertLocalToScene (lockedWidget.getBounds ())));

    return state;
}
 
Example #3
Source File: SceneComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private WidgetAction.State processParentOperator (Operator operator, String tool, Widget widget, WidgetAction.WidgetKeyEvent event) {
    while (widget != null) {
        WidgetAction.State state;

        state = operator.operate (widget.getActions (), widget, event);
        if (state.isConsumed ())
            return state;

        WidgetAction.Chain actions = widget.getActions (tool);
        if (actions != null) {
            state = operator.operate (actions, widget, event);
            if (state.isConsumed ())
                return state;
        }

        widget = widget.getParentWidget ();
    }

    return WidgetAction.State.REJECTED;
}
 
Example #4
Source File: SceneComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private WidgetAction.State processSingleOperator (Operator operator, String tool, Widget widget, WidgetAction.WidgetEvent event) {
    WidgetAction.State state;

    state = operator.operate (widget.getActions (), widget, event);
    if (state.isConsumed ())
        return state;

    WidgetAction.Chain actions = widget.getActions (tool);
    if (actions != null) {
        state = operator.operate (actions, widget, event);
        if (state.isConsumed ())
            return state;
    }

    return WidgetAction.State.REJECTED;
}
 
Example #5
Source File: SceneComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private WidgetAction.State processOperator (Operator operator, WidgetAction.WidgetEvent event) {
    WidgetAction.State state;
    String tool = scene.getActiveTool ();

    WidgetAction.Chain priorActions = scene.getPriorActions ();
    if (! priorActions.getActions ().isEmpty ())
        if (operator.operate (priorActions, scene, event).isConsumed ())
            return WidgetAction.State.CONSUMED;

    if (lockedAction != null) {
        state = operator.operate (lockedAction, lockedWidget, event);
        if (! state.isConsumed ())
            state = processOperator (operator, tool, scene, event);
    } else
        state = processOperator (operator, tool, scene, event);

    lockedWidget = state.getLockedWidget ();
    lockedAction = state.getLockedAction ();
    scene.validate ();

    if (lockedWidget != null)
        scrollRectToVisible (scene.convertSceneToView (lockedWidget.convertLocalToScene (lockedWidget.getBounds ())));

    return state;
}
 
Example #6
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private WidgetAction createActionMapAction(Page page) {
    InputMap inputMap = new InputMap();
    ActionMap actionMap = new ActionMap();
    Action[] actions = page.getActions(true);
    for (Action action : actions) {
        KeyStroke keyStroke = (KeyStroke) action.getValue(javax.swing.Action.ACCELERATOR_KEY);
        if (keyStroke != null) {
            inputMap.put(keyStroke, action.toString());
            actionMap.put(action.toString(), action);
        }
    }
    if (actionMap.size() < 1) {
        return null;
    }
    /* Not sure if it is the right thing to create a new action map
     * should I be adding it?
     */
    return new MyActionMapAction(inputMap, actionMap);


    //return  ActionFactory.createActionMapAction(inputMap, actionMap);
}
 
Example #7
Source File: SlotWidget.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void handleDoubleClick(Widget w, WidgetAction.WidgetMouseEvent e) {
    Set<Integer> hiddenNodes = new HashSet<>(diagramScene.getModel().getHiddenNodes());
    if (diagramScene.isAllVisible()) {
        hiddenNodes = new HashSet<>(diagramScene.getModel().getGraphToView().getGroup().getAllNodes());
    }

    boolean progress = false;
    for (Figure f : diagramScene.getModel().getDiagramToView().getFigures()) {
        for (Slot s : f.getSlots()) {
            if (DiagramScene.doesIntersect(s.getSource().getSourceNodesAsSet(), slot.getSource().getSourceNodesAsSet())) {
                progress = true;
                hiddenNodes.removeAll(f.getSource().getSourceNodesAsSet());
            }
        }
    }

    if (progress) {
        this.diagramScene.getModel().showNot(hiddenNodes);
    }
}
 
Example #8
Source File: TableWidget.java    From jeddict with Apache License 2.0 6 votes vote down vote up
@Override
public WidgetAction.State mousePressed(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) {
        TableWidget tableWidget = TableWidget.this;
        ModelerFile file = tableWidget.getModelerScene().getModelerFile();
        Node tablesNode = (Node) file.getAttribute(Node.class.getSimpleName());

        Optional<Node> nodeOptional = Arrays.stream(tablesNode.getChildren().getNodes())
                .filter(tableNode -> tableNode.getName().equalsIgnoreCase(tableWidget.getName()))
                .findFirst();
        if (nodeOptional.isPresent()) {
            ViewDataAction viewDataAction = new ViewDataAction();
            viewDataAction.performAction(new Node[]{nodeOptional.get()});
            return WidgetAction.State.CONSUMED;
        }
    }
    return WidgetAction.State.REJECTED;
}
 
Example #9
Source File: InplaceEditorAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
    public State mouseReleased(Widget widget, WidgetAction.WidgetMouseEvent event) {
//        if (editor != null)
//            closeEditor (true);
//        return State.REJECTED;

        if (editor != null) {
            Container parent = editor.getParent();
            if (parent != null) {
                parent.requestFocusInWindow();
            }
            closeEditor(true);
        }
        return State.REJECTED;
    }
 
Example #10
Source File: ConnectAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public WidgetAction.State mouseReleased (Widget widget, WidgetAction.WidgetMouseEvent event) {
    Point point = event.getPoint ();
    boolean state = move (widget, point);
    if (state) {
        if (targetWidget != null)
            if (Math.abs (startingPoint.x - point.x) >= MIN_DIFFERENCE  ||  Math.abs (startingPoint.y - point.y) >= MIN_DIFFERENCE)
                provider.createConnection (sourceWidget, targetWidget);
        cancel ();
    }
    return state ? State.CONSUMED : State.REJECTED;
}
 
Example #11
Source File: ExtendedConnectAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public WidgetAction.State mouseReleased(Widget widget, WidgetAction.WidgetMouseEvent event) {
    macLocking = false;
    if (isLocked ())
        return super.mouseReleased(widget,event);
    else
        return State.REJECTED;
}
 
Example #12
Source File: SceneComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void drop (DropTargetDropEvent e) {
    WidgetAction.State state = processLocationOperator (Operator.DROP, new WidgetAction.WidgetDropTargetDropEvent (++ eventIDcounter, e));
    if (! state.isConsumed ())
        e.rejectDrop ();
    else
        e.dropComplete (true);
}
 
Example #13
Source File: ExtendedConnectAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public WidgetAction.State mousePressed(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (isLocked ())
        return State.createLocked (widget, this);
    if ((event.getModifiers () & modifiers) == modifiers) {
        if ((Utilities.getOperatingSystem () & Utilities.OS_MAC) != 0)
            macLocking = true;
        return super.mousePressedCore(widget,event);
    }
    return State.REJECTED;
}
 
Example #14
Source File: SceneComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void mouseMoved (MouseEvent e) {
    MouseContext context = new MouseContext ();
    Point point = scene.convertViewToScene (e.getPoint ());
    resolveContext (scene, point, context);
    context.commit (this);
    processLocationOperator (Operator.MOUSE_MOVED, new WidgetAction.WidgetMouseEvent (++ eventIDcounter, e));
}
 
Example #15
Source File: SceneComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private WidgetAction.State processOperator (Operator operator, String tool, Widget widget, WidgetAction.WidgetEvent event) {
    if (! widget.isVisible ()  ||  ! widget.isEnabled ())
        return WidgetAction.State.REJECTED;

    WidgetAction.State state;

    List<Widget> children = widget.getChildren ();
    Widget[] childrenArray = children.toArray (new Widget[children.size ()]);

    for (int i = childrenArray.length - 1; i >= 0; i --) {
        Widget child = childrenArray[i];
        state = processOperator (operator, tool, child, event);
        if (state.isConsumed ())
            return state;
    }

    state = operator.operate (widget.getActions (), widget, event);
    if (state.isConsumed ())
        return state;

    WidgetAction.Chain actions = widget.getActions (tool);
    if (actions != null) {
        state = operator.operate (actions, widget, event);
        if (state.isConsumed ())
            return state;
    }

    return WidgetAction.State.REJECTED;
}
 
Example #16
Source File: DoubleClickAction.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public WidgetAction.State mouseClicked(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getClickCount() > 1) {
        handler.handleDoubleClick(widget, event);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}
 
Example #17
Source File: DoubleClickAction.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public WidgetAction.State mouseClicked(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getClickCount() > 1) {
        handler.handleDoubleClick(widget, event);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}
 
Example #18
Source File: SceneComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private WidgetAction.State processKeyOperator (Operator operator, String tool, Scene scene, WidgetAction.WidgetKeyEvent event) {
    Widget focusedWidget = scene.getFocusedWidget ();
    WidgetAction.State state;
    Widget disabledWidget;
    switch (scene.getKeyEventProcessingType ()) {
        case ALL_WIDGETS:
            return processOperator (operator, tool, scene, event);
        case FOCUSED_WIDGET_AND_ITS_PARENTS:
            disabledWidget = resolveTopMostDisabledWidget (focusedWidget);
            return processParentOperator (operator, tool, disabledWidget != null ? disabledWidget.getParentWidget () : focusedWidget, event);
        case FOCUSED_WIDGET_AND_ITS_CHILDREN:
            disabledWidget = resolveTopMostDisabledWidget (focusedWidget);
            if (disabledWidget != null)
                return WidgetAction.State.REJECTED;
            state = processSingleOperator (operator, tool, focusedWidget, event);
            if (state.isConsumed ())
                return state;
            return processOperator (operator, tool, focusedWidget, event);
        case FOCUSED_WIDGET_AND_ITS_CHILDREN_AND_ITS_PARENTS:
            disabledWidget = resolveTopMostDisabledWidget (focusedWidget);
            if (disabledWidget == null) {
                state = processSingleOperator (operator, tool, focusedWidget, event);
                if (state.isConsumed ())
                    return state;
                state = processOperator (operator, tool, focusedWidget, event);
                if (state.isConsumed ())
                    return state;
            }
            return processParentOperator (operator, tool, disabledWidget != null ? disabledWidget.getParentWidget () : focusedWidget.getParentWidget (), event);
        default:
            throw new IllegalStateException ();
    }
}
 
Example #19
Source File: Widget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new widget which will be used in a specified scene.
 * @param scene the scene where the widget is going to be used
 */
public Widget (Scene scene) {
    if (scene == null)
        scene = (Scene) this;
    this.scene = scene;
    children = new ArrayList<Widget> ();
    childrenUm = Collections.unmodifiableList (children);

    actionsChain = new WidgetAction.Chain ();

    opaque = false;
    font = null;
    background = (new DefaultLookFeel()).getBackground();//Color.WHITE;
    foreground = (new DefaultLookFeel()).getForeground();//Color.BLACK;
    border = BorderFactory.createEmptyBorder ();
    layout = LayoutFactory.createAbsoluteLayout ();
    preferredLocation = null;
    preferredBounds = null;
    checkClipping = false;
    enabled = true;

    location = new Point ();
    bounds = null;
    calculatedPreferredBounds = null;
    requiresFullValidation = true;
    requiresPartValidation = true;
}
 
Example #20
Source File: Widget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns an action chain for a specified tool.
 * @param tool the tool
 * @return the action chain
 */
public final WidgetAction.Chain createActions (String tool) {
    if (tool == null)
        return actionsChain;
    if (toolsActions == EMPTY_HASH_MAP) {
        toolsActions = new HashMap<String, WidgetAction.Chain> ();
        toolsActions.put (null, actionsChain);
    }
    WidgetAction.Chain chain = toolsActions.get (tool);
    if (chain == null) {
        chain = new WidgetAction.Chain ();
        toolsActions.put (tool, chain);
    }
    return chain;
}
 
Example #21
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void destoryPageFlowScene() {
    removeObjectSceneListener(pfObjectSceneListener, ObjectSceneEventType.OBJECT_SELECTION_CHANGED);
    pfObjectSceneListener = null;
    
    popupProvider = null;
    
    fpnl.unregisterListeners(this);
    fpnl = null;
    router = null;
    
    Chain chainActions = getActions();
    for( WidgetAction action : new ArrayList<WidgetAction>(chainActions.getActions()) ){
        chainActions.removeAction(action);
    }
}
 
Example #22
Source File: PageFlowScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private WidgetAction createActionMap() {

        ActionMap actionMap = refPageFlowView.get().getActionMap();
        CallbackSystemAction a = (CallbackSystemAction) SystemAction.get(DeleteAction.class);
        actionMap.put(a.getActionMapKey(), new PageFlowDeleteAction(this));

        //Temporary workaround  ISSUE# 107506
        return new MyActionMapAction(MapActionUtility.initInputMap(), MapActionUtility.initActionMap());
        //return ActionFactory.createActionMapAction(MapActionUtility.initInputMap(), MapActionUtility.initActionMap());
    }
 
Example #23
Source File: DoubleClickAction.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public WidgetAction.State mouseClicked(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getClickCount() > 1) {
        handler.handleDoubleClick(widget, event);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}
 
Example #24
Source File: DoubleClickAction.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public WidgetAction.State mouseClicked(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getClickCount() > 1) {
        handler.handleDoubleClick(widget, event);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}
 
Example #25
Source File: DoubleClickAction.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public WidgetAction.State mouseClicked(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getClickCount() > 1) {
        handler.handleDoubleClick(widget, event);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}
 
Example #26
Source File: DoubleClickAction.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public WidgetAction.State mouseClicked(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getClickCount() > 1) {
        handler.handleDoubleClick(widget, event);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}
 
Example #27
Source File: DoubleClickAction.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public WidgetAction.State mouseClicked(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getClickCount() > 1) {
        handler.handleDoubleClick(widget, event);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}
 
Example #28
Source File: NodeContextModel.java    From jeddict with Apache License 2.0 5 votes vote down vote up
private static WidgetAction[] getConnectActions(
        IModelerScene scene, 
        String connectionContextToolId,
        Function<EdgeWidgetInfo, IEdgeWidget> edgeWidgetFunction) {
    SceneConnectProvider connector = new SceneConnectProvider(connectionContextToolId, edgeWidgetFunction);
    LayerWidget layer = scene.getInterractionLayer();
    WidgetAction action = new ConnectAction(new ContextPaletteConnectDecorator(), layer, connector);
    WidgetAction[] retVal = new WidgetAction[]{action};
    return retVal;
}
 
Example #29
Source File: OpenSourceCodeAction.java    From jeddict with Apache License 2.0 5 votes vote down vote up
@Override
public WidgetAction.State mousePressed(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2) {
        openSourceCode(true);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}
 
Example #30
Source File: TableWidget.java    From jeddict with Apache License 2.0 5 votes vote down vote up
@Override
public WidgetAction.State mousePressed(Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (event.getButton() == MouseEvent.BUTTON1  && event.getClickCount()==2) {
        SQLEditorUtil.openDBTable(TableWidget.this);
        return WidgetAction.State.CONSUMED;
    }
    return WidgetAction.State.REJECTED;
}