Search in sources :

Example 6 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project tdi-studio-se by Talend.

the class InputBusinessItemNameEditPart method createDefaultEditPolicies.

/**
     * @generated
     */
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {

        protected List createSelectionHandles() {
            List handles = new ArrayList();
            NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
            return handles;
        }

        public Command getCommand(Request request) {
            return null;
        }

        public boolean understandsRequest(Request request) {
            return false;
        }
    });
}
Also used : LabelDirectEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy) Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) Request(org.eclipse.gef.Request) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) List(java.util.List) ArrayList(java.util.ArrayList) NonResizableEditPolicy(org.eclipse.gef.editpolicies.NonResizableEditPolicy) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 7 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project tdi-studio-se by Talend.

the class TalendConnectionCreationTool method selectAddedObject.

protected void selectAddedObject(EditPartViewer viewer, Collection objects) {
    final List editparts = new ArrayList();
    final EditPart[] primaryEP = new EditPart[1];
    for (Iterator i = objects.iterator(); i.hasNext(); ) {
        Object object = i.next();
        if (object instanceof IAdaptable) {
            Object editPart = viewer.getEditPartRegistry().get(((IAdaptable) object).getAdapter(View.class));
            if (editPart instanceof GraphicalEditPart) {
                editparts.add(editPart);
            }
        }
    }
    if (!editparts.isEmpty()) {
        viewer.setSelection(new StructuredSelection(editparts));
        // automatically put the first shape into edit-mode
        Display.getCurrent().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (primaryEP[0] == null) {
                    primaryEP[0] = (EditPart) editparts.get(0);
                }
                // code is being executed. (see RATLC00527114)
                if (primaryEP[0].isActive()) {
                    primaryEP[0].performRequest(new Request("direct edit"));
                }
            }
        });
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) ArrayList(java.util.ArrayList) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Request(org.eclipse.gef.Request) View(org.eclipse.gmf.runtime.notation.View) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 8 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project tdi-studio-se by Talend.

the class NodeLabelEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    Node node = ((NodeLabel) getModel()).getNode();
    // Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
    String text = ((NodeLabel) getModel()).getLabelText();
    SimpleHtmlFigure htmlFig = (SimpleHtmlFigure) this.getFigure();
    htmlFig.setText(text);
    Point loc = node.getLocation().getCopy();
    Point offset = ((NodeLabel) getModel()).getOffset();
    Point textOffset = new Point();
    Dimension size = htmlFig.getPreferredSize();
    textOffset.y = node.getSize().height;
    textOffset.x = (node.getSize().width - size.width) / 2;
    ((NodeLabel) getModel()).setTextOffset(textOffset);
    loc.translate(textOffset.x + offset.x, textOffset.y + offset.y);
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : 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) SimpleHtmlFigure(org.talend.commons.ui.utils.workbench.gef.SimpleHtmlFigure)

Example 9 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project tdi-studio-se by Talend.

the class NodeErrorEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    Node node = ((NodeContainer) ((NodeContainerPart) getParent()).getModel()).getNode();
    NodeLabel nodeLabel = node.getNodeLabel();
    NodeErrorFigure errorFig = (NodeErrorFigure) this.getFigure();
    Point loc = node.getLocation().getCopy();
    Dimension size = errorFig.getSize();
    loc.x = loc.x + (node.getSize().width - size.width) / 2;
    loc.y = loc.y + node.getSize().height + (nodeLabel.getLabelSize().height);
    Rectangle rectangle = new Rectangle(loc, size);
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 10 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project tdi-studio-se by Talend.

the class NodePart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
@SuppressWarnings("unchecked")
protected void refreshVisuals() {
    Node node = (Node) this.getModel();
    Point loc = node.getLocation();
    Rectangle rectangle = new Rectangle(loc, node.getSize());
    ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), rectangle);
}
Also used : IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Aggregations

GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)36 ArrayList (java.util.ArrayList)14 List (java.util.List)14 Command (org.eclipse.gef.commands.Command)13 Request (org.eclipse.gef.Request)12 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)12 Rectangle (org.eclipse.draw2d.geometry.Rectangle)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 IFigure (org.eclipse.draw2d.IFigure)10 Point (org.eclipse.draw2d.geometry.Point)10 Dimension (org.eclipse.draw2d.geometry.Dimension)6 EditPart (org.eclipse.gef.EditPart)3 HANode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode)2 HANodePart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)2 Iterator (java.util.Iterator)2 UnexecutableCommand (org.eclipse.gef.commands.UnexecutableCommand)2 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)2