Java Code Examples for org.netbeans.api.visual.action.WidgetAction#State

The following examples show how to use org.netbeans.api.visual.action.WidgetAction#State . 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
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 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: 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 4
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 5
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 6
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 7
Source File: DoubleClickAction.java    From TencentKona-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 8
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State operate (WidgetAction action, Widget widget, WidgetAction.WidgetEvent event) {
    return action.dropActionChanged (widget, (WidgetAction.WidgetDropTargetDragEvent) event);
}
 
Example 9
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State operate (WidgetAction action, Widget widget, WidgetAction.WidgetEvent event) {
    return action.mouseMoved (widget, (WidgetAction.WidgetMouseEvent) event);
}
 
Example 10
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private WidgetAction.State processLocationOperator (Operator operator, WidgetAction.WidgetLocationEvent event) {
    Point oldSceneLocation = scene.getLocation ();
    Rectangle oldVisibleRect = getVisibleRect ();
    Point viewPoint = event.getPoint ();
    Point oldScenePoint = scene.convertViewToScene (viewPoint);
    event.setPoint (new Point (oldScenePoint));

    WidgetAction.State state;
    Point location;
    String tool = scene.getActiveTool ();

    WidgetAction.Chain priorActions = scene.getPriorActions ();
    if (! priorActions.getActions ().isEmpty ()) {
        location = scene.getLocation ();
        event.translatePoint (location.x, location.y);
        if (operator.operate (priorActions, scene, event).isConsumed ())
            return WidgetAction.State.CONSUMED;
        event.translatePoint (- location.x, - location.y);
    }

    if (lockedAction != null) {
        location = lockedWidget.convertSceneToLocal (new Point ());
        event.translatePoint (location.x, location.y);
        state = operator.operate (lockedAction, lockedWidget, event);
        event.translatePoint (- location.x, - location.y);

        if (! state.isConsumed ()) {
            location = scene.getLocation ();
            event.translatePoint (location.x, location.y);
            state = processLocationOperator (operator, tool, scene, event);
        }
    } else {
        location = scene.getLocation ();
        event.translatePoint (location.x, location.y);
        state = processLocationOperator (operator, tool, scene, event);
    }

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

    if (lockedAction != null) {
        Point sceneLocation = scene.getLocation ();
        Rectangle visibleRect = getVisibleRect ();
        int xadd = (int) ((sceneLocation.x - oldSceneLocation.x) * scene.getZoomFactor ());
        int yadd = (int) ((sceneLocation.y - oldSceneLocation.y) * scene.getZoomFactor ());
        if (xadd != 0  ||  yadd != 0)
            scrollRectToVisible (new Rectangle (oldVisibleRect.x + xadd, oldVisibleRect.y + yadd, visibleRect.width, visibleRect.height));
        scrollRectToVisible (new Rectangle (scene.convertSceneToView (oldScenePoint)));
    }

    return state;
}
 
Example 11
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State operate (WidgetAction action, Widget widget, WidgetAction.WidgetEvent event) {
    return action.mousePressed (widget, (WidgetAction.WidgetMouseEvent) event);
}
 
Example 12
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void dropActionChanged (DropTargetDragEvent e) {
    WidgetAction.State state = processLocationOperator (Operator.DROP_ACTION_CHANGED, new WidgetAction.WidgetDropTargetDragEvent (++ eventIDcounter, e));
    if (! state.isConsumed ())
        e.rejectDrag ();
}
 
Example 13
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State operate (WidgetAction action, Widget widget, WidgetAction.WidgetEvent event) {
    return action.mouseExited (widget, (WidgetAction.WidgetMouseEvent) event);
}
 
Example 14
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State operate (WidgetAction action, Widget widget, WidgetAction.WidgetEvent event) {
    return action.focusGained (widget, (WidgetAction.WidgetFocusEvent) event);
}
 
Example 15
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State operate (WidgetAction action, Widget widget, WidgetAction.WidgetEvent event) {
    return action.dragExit (widget, (WidgetAction.WidgetDropTargetEvent) event);
}
 
Example 16
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State operate (WidgetAction action, Widget widget, WidgetAction.WidgetEvent event) {
    return action.focusLost (widget, (WidgetAction.WidgetFocusEvent) event);
}
 
Example 17
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void keyTyped (KeyEvent e) {
    WidgetAction.State state = processKeyOperator (Operator.KEY_TYPED, new WidgetAction.WidgetKeyEvent (++ eventIDcounter, e));
    if (state.isConsumed ())
        e.consume ();
}
 
Example 18
Source File: ConnectAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State mouseDragged (Widget widget, WidgetAction.WidgetMouseEvent event) {
    return move (widget, event.getPoint ()) ? State.createLocked (widget, this) : State.REJECTED;
}
 
Example 19
Source File: SceneComponent.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State operate (WidgetAction action, Widget widget, WidgetAction.WidgetEvent event) {
    return action.mouseDragged (widget, (WidgetAction.WidgetMouseEvent) event);
}
 
Example 20
Source File: ConnectAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WidgetAction.State mousePressed (Widget widget, WidgetAction.WidgetMouseEvent event) {
    if (isLocked ())
        return WidgetAction.State.createLocked (widget, this);
    return mousePressedCore (widget, event);
}