org.netbeans.api.visual.widget.Widget Java Examples

The following examples show how to use org.netbeans.api.visual.widget.Widget. 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: ControlFlowScene.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void select(Widget widget, Point point, boolean change) {
    if (widget == this) {
        clearSelection();
    } else {

        assert widget instanceof BlockWidget;
        BlockWidget bw = (BlockWidget) widget;
        if (change) {
            if (selection.contains(bw)) {
                removeFromSelection(bw);
            } else {
                addToSelection(bw);
            }
        } else {
            if (!selection.contains(bw)) {
                clearSelection();
                addToSelection(bw);
            }
        }
    }
}
 
Example #2
Source File: MoveControlPointAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public State mousePressed (Widget widget, WidgetMouseEvent event) {
    if (isLocked ())
        return State.createLocked (widget, this);
    if (event.getButton () == MouseEvent.BUTTON1  &&  event.getClickCount () == 1) {
        if (widget instanceof ConnectionWidget) {
            ConnectionWidget conn = (ConnectionWidget) widget;
            controlPointIndex = conn.getControlPointHitAt (event.getPoint ());
            if (controlPointIndex >= 0) {
                movingWidget = conn;
                controlPointLocation = new Point (conn.getControlPoints (). get (controlPointIndex));
                lastLocation = new Point (event.getPoint ());
                return State.createLocked (widget, this);
            } else {
                movingWidget = null;
            }
        }
    }
    return State.REJECTED;
}
 
Example #3
Source File: ControlFlowScene.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void select(Widget widget, Point point, boolean change) {
    if (widget == this) {
        clearSelection();
    } else {

        assert widget instanceof BlockWidget;
        BlockWidget bw = (BlockWidget) widget;
        if (change) {
            if (selection.contains(bw)) {
                removeFromSelection(bw);
            } else {
                addToSelection(bw);
            }
        } else {
            if (!selection.contains(bw)) {
                clearSelection();
                addToSelection(bw);
            }
        }
    }
}
 
Example #4
Source File: FaultsWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createContent() {
    model = new FaultsTableModel(method);
    populateContentWidget(getContentWidget());
    getContentWidget().setBorder(BorderFactory.createEmptyBorder(0,1,1,1));
    headerLabelWidget = new ImageLabelWidget(getScene(), getIcon(), getTitle(), 
            "("+method.getFaults().size()+")");
    headerLabelWidget.setLabelFont(getScene().getFont().deriveFont(Font.BOLD));
    getHeaderWidget().addChild(new Widget(getScene()),5);
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),4);

    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.CENTER, 8));

    buttons.addChild(getExpanderWidget());

    getHeaderWidget().addChild(buttons);
}
 
Example #5
Source File: ControlFlowScene.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void select(Widget widget, Point point, boolean change) {
    if (widget == this) {
        clearSelection();
    } else {

        assert widget instanceof BlockWidget;
        BlockWidget bw = (BlockWidget) widget;
        if (change) {
            if (selection.contains(bw)) {
                removeFromSelection(bw);
            } else {
                addToSelection(bw);
            }
        } else {
            if (!selection.contains(bw)) {
                clearSelection();
                addToSelection(bw);
            }
        }
    }
}
 
Example #6
Source File: TwoStatedMouseHoverAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void widgetHovered (Widget widget) {
    if (widget instanceof Scene)
        widget = null;

    if (lastWidget == widget)
        return;

    if (lastWidget != null)
        provider.unsetHovering (lastWidget);

    lastWidget = widget;

    if (widget != null)
        provider.setHovering (widget);
}
 
Example #7
Source File: DiagramScene.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void stateChanged(ChangeEvent e) {
    Point p = DiagramScene.this.getScrollPane().getViewport().getViewPosition();
    if (oldPosition == null || !p.equals(oldPosition)) {
        for (Widget w : relativePositions.keySet()) {
            Point curPoint = relativePositions.get(w);
            Point newPoint = new Point(p.x + curPoint.x, p.y + curPoint.y);
            w.setPreferredLocation(newPoint);
            DiagramScene.this.validate();
        }
        oldPosition = p;
    }
}
 
Example #8
Source File: TextFieldInplaceEditorProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void notifyClosing (EditorController controller, Widget widget, JTextField editor, boolean commit) {
    editor.getDocument ().removeDocumentListener (documentListener);
    editor.removeFocusListener (focusListener);
    editor.removeKeyListener (keyListener);
    if (commit) {
        this.editor.setText (widget, editor.getText ());
        if (widget != null)
            widget.getScene ().validate ();
    }
}
 
Example #9
Source File: WidgetAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Called for handling a mouseExited event.
 * @param widget the widget where the action is assigned
 * @param event  the mouse event
 * @return the event state
 */
public State mouseExited(Widget widget, WidgetMouseEvent event) {
    WidgetAction[] actionsArray = actions.toArray(new WidgetAction[actions.size()]);
    State chainState = State.REJECTED;
    for (WidgetAction action : actionsArray) {
        State state = action.mouseExited(widget, event);
        if (state.isConsumed())
            return state;
        if (state.isLockedInChain())
            chainState = State.CONSUMED;
    }
    return chainState;
}
 
Example #10
Source File: MouseOverAction.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public State mouseMoved(Widget widget, WidgetMouseEvent event) {
    long id = event.getEventID();
    if (id != eventID) {
        eventID = id;
        provider.widgetHovered(widget);
    }
    return State.REJECTED;
}
 
Example #11
Source File: AbsoluteLayout.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void layout (Widget widget) {
    Collection<Widget> children = widget.getChildren ();
    for (Widget child : children) {
        if (child.isVisible ())
            child.resolveBounds (child.getPreferredLocation (), null);
        else
            child.resolveBounds (null, new Rectangle ());
    }
}
 
Example #12
Source File: AcceptAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public State dropActionChanged (Widget widget, WidgetDropTargetDragEvent event) {
    ConnectorState acceptable = provider.isAcceptable (widget, event.getPoint (), event.getTransferable ());

    if (acceptable == ConnectorState.ACCEPT) {
        event.acceptDrag (DnDConstants.ACTION_COPY_OR_MOVE);
        return State.CONSUMED;
    } else if (acceptable == ConnectorState.REJECT_AND_STOP) {
        event.rejectDrag ();
        return State.CONSUMED;
    }
    return State.REJECTED;
}
 
Example #13
Source File: ControlFlowScene.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected Widget attachNodeWidget(InputBlock node) {
    BlockWidget w = new BlockWidget(this, node);
    mainLayer.addChild(w);
    w.getActions().addAction(hoverAction);
    w.getActions().addAction(selectAction);
    w.getActions().addAction(moveAction);
    return w;
}
 
Example #14
Source File: ControlFlowScene.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void setNewLocation(Widget widget, Point location) {
    Point originalLocation = getOriginalLocation(widget);
    int xOffset = location.x - originalLocation.x;
    int yOffset = location.y - originalLocation.y;
    for (Widget w : this.selection) {
        Point p = new Point(w.getPreferredLocation());
        p.translate(xOffset, yOffset);
        w.setPreferredLocation(p);
    }

}
 
Example #15
Source File: QueryBuilderGraphFrame.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JPopupMenu getPopupMenu (Widget widget, Point localLocation) {
if (widget instanceof QBGraphScene) 
	return _backgroundPopup;
else {
    // We have a Widget wrapping a QBNodeComponent
    QBNodeComponent qbNC = (QBNodeComponent)_scene.findObject(widget);
    this._selectedNode = qbNC;
    return _tableTitlePopup;
}
   }
 
Example #16
Source File: FigureWidget.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public JPopupMenu getPopupMenu(Widget widget, Point point) {
    JPopupMenu m = diagramScene.createPopupMenu();

    JMenu predecessors = new JMenu("Predecessors");
    addFigureToSubMenu(predecessors, getFigure(), false, DEPTH);

    JMenu successors = new JMenu("Successors");
    addFigureToSubMenu(successors, getFigure(), true, DEPTH);

    m.addSeparator();
    m.add(predecessors);
    m.add(successors);
    return m;
}
 
Example #17
Source File: DocumentWidget.java    From jeddict with Apache License 2.0 5 votes vote down vote up
public Map<String, List<Widget>> getNodeCategories() {
    JavaClass javaClass = this.getBaseElementSpec().getJavaClass();
    List<Attribute> attributes;
    if (javaClass.getJsonbPropertyOrder().isEmpty()) {
        attributes = javaClass.getAttributes().getAllAttribute();
        attributes.sort(Comparator.comparing(Attribute::getName));
    } else {
        attributes = javaClass.getAllJsonbPropertyOrder();
    }
    return Collections.singletonMap("", attributes.stream()
            .map(attr -> getJSONNodeWidget(attr))
            .collect(toList()));
}
 
Example #18
Source File: ObjectScene.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an object which is assigned to a widget.
 * If the widget is not mapped to any object then the method recursively searches for an object of the parent widget.
 * @param widget the widget
 * @return the mapped object; null if no object is assigned to a widget or any of its parent widgets
 */
public final Object findObject (Widget widget) {
    while (widget != null) {
        Object o = widget2object.get (widget);
        if (o != null)
            return o;
        widget = widget.getParentWidget ();
    }
    return null;
}
 
Example #19
Source File: ExtendedPanAction.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
    if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) {
        scene = widget.getScene();
        scrollPane = findScrollPane(scene.getView());
        if (scrollPane != null) {
            lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint()));
            SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView());
            return State.createLocked(widget, this);
        }
    }
    return State.REJECTED;
}
 
Example #20
Source File: DiagramScene.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Set<Integer> getSelectedNodes() {
    Set<Integer> result = new HashSet<Integer>();
    for (Widget w : selectedWidgets) {
        if (w instanceof FigureWidget) {
            FigureWidget fw = (FigureWidget) w;
            if (fw.getState().isSelected()) {
                result.addAll(fw.getFigure().getSource().getSourceNodesAsSet());
            }
        }
    }
    return result;
}
 
Example #21
Source File: DiagramScene.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Set<Figure> getSelectedFigures() {
    Set<Figure> result = new HashSet<Figure>();
    for (Widget w : selectedWidgets) {
        if (w instanceof FigureWidget) {
            FigureWidget fw = (FigureWidget) w;
            if (fw.getState().isSelected()) {
                result.add(fw.getFigure());
            }
        }
    }
    return result;
}
 
Example #22
Source File: WsitWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void determineVisibility() {
    for(Widget button:configButtons.getChildren()) {
        if(button.isVisible()) {
            setVisible(true);
            return;
        }
    }
    setVisible(false);
}
 
Example #23
Source File: SelectAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public State keyTyped (Widget widget, WidgetKeyEvent event) {
    if (! aiming  &&  event.getKeyChar () == KeyEvent.VK_SPACE) {
        provider.select (widget, null, (event.getModifiersEx () & MouseEvent.CTRL_DOWN_MASK) != 0);
        return State.CONSUMED;
    }
    return State.REJECTED;
}
 
Example #24
Source File: Highlighter.java    From jlibs with Apache License 2.0 5 votes vote down vote up
public void setHovering(Widget widget){
    widget = resolve(widget);
    if(widget==null)
        return;
    ((NBLRWidget)widget).highLight(true);

    if(delegate!=null)
        delegate.setHovering(widget);
}
 
Example #25
Source File: PreferredLocationAnimator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setPreferredLocation (Widget widget, Point preferredLocation) {
    assert widget != null;
    assert preferredLocation != null;
    if (!sourceLocations.isEmpty()) {
        sourceLocations.clear ();
    }
    targetLocations.put (widget, preferredLocation);
    start ();
}
 
Example #26
Source File: InputSlotWidget.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public InputSlotWidget(InputSlot slot, DiagramScene scene, Widget parent, FigureWidget fw) {
    super(slot, scene, parent, fw);
    inputSlot = slot;
    //init();
    //getFigureWidget().getLeftWidget().addChild(this);
    Point p = inputSlot.getRelativePosition();
    p.x -= this.calculateClientArea().width / 2;
    p.y += Figure.SLOT_START;
    this.setPreferredLocation(p);
}
 
Example #27
Source File: ExtendedPanAction.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
    if (event.getButton() == MouseEvent.BUTTON2 || event.getButton() == MouseEvent.BUTTON1 && ((event.getModifiers() & MouseEvent.CTRL_MASK) != 0)) {
        scene = widget.getScene();
        scrollPane = findScrollPane(scene.getView());
        if (scrollPane != null) {
            lastLocation = scene.convertSceneToView(widget.convertLocalToScene(event.getPoint()));
            SwingUtilities.convertPointToScreen(lastLocation, scrollPane.getViewport().getView());
            return State.createLocked(widget, this);
        }
    }
    return State.REJECTED;
}
 
Example #28
Source File: ControlFlowScene.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void setNewLocation(Widget widget, Point location) {
    Point originalLocation = getOriginalLocation(widget);
    int xOffset = location.x - originalLocation.x;
    int yOffset = location.y - originalLocation.y;
    for (Widget w : this.selection) {
        Point p = new Point(w.getPreferredLocation());
        p.translate(xOffset, yOffset);
        w.setPreferredLocation(p);
    }

}
 
Example #29
Source File: CycleFocusAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public State keyTyped (Widget widget, WidgetKeyEvent event) {
    boolean state = false;
    if (event.getKeyChar () == KeyEvent.VK_TAB) {
        if ((event.getModifiers () & KeyEvent.SHIFT_MASK) == KeyEvent.SHIFT_MASK)
            state = provider.switchPreviousFocus (widget);
        else
            state = provider.switchNextFocus (widget);
    }
    return state ? State.CONSUMED : State.REJECTED;
}
 
Example #30
Source File: MouseOverAction.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public State mouseMoved(Widget widget, WidgetMouseEvent event) {
    long id = event.getEventID();
    if (id != eventID) {
        eventID = id;
        provider.widgetHovered(widget);
    }
    return State.REJECTED;
}