Search in sources :

Example 31 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project yamcs-studio by yamcs.

the class WidgetXYLayoutEditPolicy method getResizeChildrenCommand.

// This has been overriden to fix a bug when handle bounds does not equal with bounds. For example, polyline figue.
/* (non-Javadoc)
     * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getResizeChildrenCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
     */
@Override
protected Command getResizeChildrenCommand(ChangeBoundsRequest request) {
    CompoundCommand resize = new CompoundCommand();
    Command c;
    GraphicalEditPart child;
    List<?> children = request.getEditParts();
    for (int i = 0; i < children.size(); i++) {
        child = (GraphicalEditPart) children.get(i);
        c = createChangeConstraintCommand(request, child, translateToModelConstraint(getConstraintForResize(request, child)));
        resize.add(c);
    }
    return resize.unwrap();
}
Also used : WidgetSetConstraintCommand(org.csstudio.opibuilder.commands.WidgetSetConstraintCommand) SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) AddWidgetCommand(org.csstudio.opibuilder.commands.AddWidgetCommand) ChangeGuideCommand(org.csstudio.opibuilder.commands.ChangeGuideCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) WidgetCreateCommand(org.csstudio.opibuilder.commands.WidgetCreateCommand) CloneCommand(org.csstudio.opibuilder.commands.CloneCommand) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 32 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project dbeaver by serge-rider.

the class PropertyAwarePart method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent evt) {
    String property = evt.getPropertyName();
    if (ERDObject.CHILD.equals(property)) {
        handleChildChange(evt);
    }
    if (ERDObject.REORDER.equals(property)) {
        handleReorderChange(evt);
    } else if (ERDObject.OUTPUT.equals(property)) {
        handleOutputChange(evt);
    } else if (ERDObject.INPUT.equals(property)) {
        handleInputChange(evt);
    } else if (ERDObject.NAME.equals(property)) {
        commitNameChange(evt);
    }
    //not use the Graph animation, if automatic layout is being used
    if (ERDObject.NAME.equals(property)) {
        GraphicalEditPart graphicalEditPart = (GraphicalEditPart) (getViewer().getContents());
        IFigure partFigure = graphicalEditPart.getFigure();
        partFigure.getUpdateManager().performUpdate();
    }
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 33 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project cubrid-manager by CUBRID.

the class GefViewerKeyHandler method moveHANodesByKey.

/**
	 * move figures by keyboard.
	 * 
	 * @param event KeyEvent
	 * @return if handled the event return true else return false.
	 */
private boolean moveHANodesByKey(KeyEvent event) {
    List<?> selectedEditParts = getViewer().getSelectedEditParts();
    boolean flag = false;
    for (Object obj : selectedEditParts) {
        if (!(obj instanceof HANodePart)) {
            continue;
        }
        GraphicalEditPart editPart = (GraphicalEditPart) obj;
        Command command = null;
        if ((event.stateMask & SWT.ALT) == 0 && (event.stateMask & SWT.CTRL) == 0 && (event.stateMask & SWT.SHIFT) == 0 && (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT || event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP)) {
            HANode node = (HANode) editPart.getModel();
            ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
            request.setLocation(node.getLocation());
            request.setEditParts(editPart);
            //get move delta
            Point moveDelta = null;
            switch(event.keyCode) {
                case SWT.ARROW_LEFT:
                    moveDelta = new Point(-1, 0);
                    break;
                case SWT.ARROW_RIGHT:
                    moveDelta = new Point(1, 0);
                    break;
                case SWT.ARROW_UP:
                    moveDelta = new Point(0, -1);
                    break;
                case SWT.ARROW_DOWN:
                    moveDelta = new Point(0, 1);
                    break;
                default:
                    return true;
            }
            request.setMoveDelta(moveDelta);
            command = editPart.getCommand(request);
        }
        if (command != null && !(command instanceof UnexecutableCommand)) {
            command.execute();
            flag = true;
        }
    }
    return flag;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) Command(org.eclipse.gef.commands.Command) Point(org.eclipse.draw2d.geometry.Point) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) HANodePart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)

Example 34 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project cubrid-manager by CUBRID.

the class NodePart method refreshVisuals.

/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
	 */
protected void refreshVisuals() {
    Node node = (Node) getModel();
    Point loc = node.getLocation();
    Dimension size = new Dimension(node.getSize());
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Node(com.cubrid.cubridmanager.ui.replication.editor.model.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 35 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project cubrid-manager by CUBRID.

the class HANodePart method refreshVisuals.

/**
	 * Refreshes this EditPart's <i>visuals</i>. This method is called by
	 * {@link #refresh()}, and may also be called in response to notifications
	 * from the model.
	 */
protected void refreshVisuals() {
    HANode node = (HANode) getModel();
    Point loc = node.getLocation();
    ((AbstractMonitorFigure) getFigure()).setMinimized(isMinimized());
    //figure's size is stable
    Rectangle rectangle = new Rectangle(loc, figure.getSize());
    GraphicalEditPart graphicalEditPart = (GraphicalEditPart) getParent();
    graphicalEditPart.setLayoutConstraint(this, getFigure(), rectangle);
    getFigure().repaint();
}
Also used : AbstractMonitorFigure(com.cubrid.cubridmanager.ui.mondashboard.editor.figure.AbstractMonitorFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Aggregations

GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)53 ArrayList (java.util.ArrayList)17 List (java.util.List)16 Rectangle (org.eclipse.draw2d.geometry.Rectangle)15 Command (org.eclipse.gef.commands.Command)15 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)13 Point (org.eclipse.draw2d.geometry.Point)12 Request (org.eclipse.gef.Request)12 IFigure (org.eclipse.draw2d.IFigure)11 NonResizableEditPolicy (org.eclipse.gef.editpolicies.NonResizableEditPolicy)11 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)11 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)11 LabelDirectEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy)11 EditPart (org.eclipse.gef.EditPart)7 Dimension (org.eclipse.draw2d.geometry.Dimension)6 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)4 Iterator (java.util.Iterator)3 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)3 EditPartViewer (org.eclipse.gef.EditPartViewer)3 AbstractWorkflowPortBarEditPart (org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart)3