Search in sources :

Example 1 with NodeLabelEditPart

use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart in project tdi-studio-se by Talend.

the class NodeContainerLayoutEditPolicy method createChangeConstraintCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#createChangeConstraintCommand(org.eclipse.gef.EditPart,
     * java.lang.Object)
     */
@Override
protected Command createChangeConstraintCommand(final EditPart child, final Object constraint) {
    if (child instanceof NodeLabelEditPart) {
        boolean nodeSelected;
        // if (((NodeLabelEditPart) child).getNodePart().getSelected() != 0) {
        // nodeSelected = true;
        // } else {
        nodeSelected = false;
        // }
        MoveNodeLabelCommand locationCommand = new MoveNodeLabelCommand((NodeLabel) child.getModel(), ((Rectangle) constraint).getLocation(), nodeSelected);
        return locationCommand;
    } else if (child instanceof NodePart) {
        if (((Node) child.getModel()).isReadOnly() && !((Node) child.getModel()).isForceReadOnly()) {
            return null;
        }
        MoveNodeCommand locationCommand = new MoveNodeCommand((Node) child.getModel(), ((Rectangle) constraint).getLocation());
        return locationCommand;
    } else {
        return null;
    }
}
Also used : MoveNodeLabelCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand) MoveNodeCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 2 with NodeLabelEditPart

use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart in project tdi-studio-se by Talend.

the class TalendSelectionManager method appendSelection.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.SelectionManager#appendSelection(org.eclipse.gef.EditPart)
     */
@Override
public void appendSelection(EditPart arg0) {
    // judge whether the refresh operation is executed.
    // see bug 3315.
    boolean needRefresh = false;
    if (getSelection() instanceof StructuredSelection) {
        StructuredSelection selection = (StructuredSelection) getSelection();
        Object selected = null;
        for (Object element : selection.toArray()) {
            selected = element;
        }
        if (getSelection().isEmpty() || (selected instanceof ProcessPart)) {
            this.selectionType = ETalendSelectionType.SINGLE;
            needRefresh = true;
        }
        if (!(arg0 instanceof NodeLabelEditPart) && !(arg0 instanceof ConnLabelEditPart) && !(arg0 instanceof ConnectionPart)) {
            // removes old selections of labels by calling setSelection
            for (Object element : selection.toArray()) {
                if (element instanceof NodeLabelEditPart) {
                    this.deselect(((AbstractGraphicalEditPart) element));
                } else if (element instanceof ConnLabelEditPart) {
                    this.deselect(((AbstractGraphicalEditPart) element));
                } else if (element instanceof ConnectionPart) {
                    this.deselect(((AbstractConnectionEditPart) element));
                }
            }
            needRefresh = true;
        }
        if (arg0 instanceof ConnectionPerformanceEditPart && getSelectPoint() != null) {
            if (needRefresh) {
                EditPart transferPart = transferFocus((ConnectionPerformanceEditPart) arg0);
                if (transferPart == null) {
                    needRefresh = false;
                    setSelectPoint(null);
                    return;
                }
                super.appendSelection(transferPart);
                needRefresh = false;
                return;
            }
        }
        if (needRefresh) {
            super.appendSelection(arg0);
            needRefresh = false;
            setSelectPoint(null);
        }
    }
}
Also used : AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) ConnectionPerformanceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionPerformanceEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 3 with NodeLabelEditPart

use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method getSelectedGraphicNode.

/**
     * DOC amaumont Comment method "getSelectedNode".
     * 
     * @return
     */
public Node getSelectedGraphicNode() {
    Node node = null;
    List selections = designerEditor.getViewer().getSelectedEditParts();
    if (selections.size() == 1) {
        Object selection = selections.get(0);
        if (selection instanceof NodeTreeEditPart) {
            NodeTreeEditPart nTreePart = (NodeTreeEditPart) selection;
            node = (Node) nTreePart.getModel();
        } else {
            if (selection instanceof NodePart) {
                NodePart editPart = (NodePart) selection;
                node = (Node) editPart.getModel();
            } else if (selection instanceof NodeLabelEditPart) {
                NodeLabelEditPart editPart = (NodeLabelEditPart) selection;
                node = ((NodeLabel) editPart.getModel()).getNode();
            }
        }
    }
    return node;
}
Also used : NodeLabel(org.talend.designer.core.ui.editor.nodes.NodeLabel) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) ArrayList(java.util.ArrayList) List(java.util.List) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 4 with NodeLabelEditPart

use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart in project tdi-studio-se by Talend.

the class GefEditorLabelProvider method getImage.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
     */
public Image getImage(Object objects) {
    Node node = null;
    if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
        return null;
    }
    if (!(objects instanceof IStructuredSelection)) {
        return null;
    }
    final boolean[] multiple = { false };
    Object object = getObject(objects, multiple);
    if (object == null) {
        return null;
    }
    if ((object instanceof NodeTreeEditPart)) {
        node = (Node) ((NodeTreeEditPart) object).getModel();
    } else {
        if (object instanceof NodeReturnsTreeEditPart) {
            node = lastNode;
        } else {
            if (object instanceof ProcessPart) {
                return ImageProvider.getImage(ECoreImage.PROCESS_ICON);
            }
            if (object instanceof ConnectionPart) {
                return ImageProvider.getImage(EImage.RIGHT_ICON);
            }
            if (object instanceof NoteEditPart) {
                return ImageProvider.getImage(ECoreImage.CODE_ICON);
            }
            if (object instanceof ConnLabelEditPart) {
                return ImageProvider.getImage(EImage.RIGHT_ICON);
            }
            if ((object instanceof NodeLabelEditPart)) {
                node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
            }
            if (!(object instanceof NodePart)) {
                return null;
            }
            if (node == null) {
                node = (Node) ((NodePart) object).getModel();
            }
        }
    }
    if (lastNode != node) {
        lastNode = node;
    }
    return CoreImageProvider.getComponentIcon(node.getComponent(), ICON_SIZE.ICON_24);
}
Also used : NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Node(org.talend.designer.core.ui.editor.nodes.Node) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 5 with NodeLabelEditPart

use of org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart in project tdi-studio-se by Talend.

the class GefEditorLabelProvider method getText.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
     */
public String getText(Object objects) {
    Node node = null;
    if (objects == null || objects.equals(StructuredSelection.EMPTY)) {
        //$NON-NLS-1$
        return "No items selected";
    }
    if (!(objects instanceof IStructuredSelection)) {
        return null;
    }
    final boolean[] multiple = { false };
    Object object = getObject(objects, multiple);
    if (object == null) /* || ((IStructuredSelection) objects).size() > 1 */
    {
        //$NON-NLS-1$
        return "No items selected";
    } else {
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nContainer = (NodeContainerPart) object;
            Process process = (Process) nContainer.getParent().getModel();
            return process.getName();
        } else if (object instanceof ProcessPart) {
            Process process = (Process) ((ProcessPart) object).getModel();
            return process.getLabel();
        } else if (object instanceof ProcessTreeEditPart) {
            Process process = (Process) ((ProcessTreeEditPart) object).getModel();
            return process.getName();
        }
        if (object instanceof ConnectionPart) {
            Connection conn = (Connection) ((ConnectionPart) object).getModel();
            return conn.getName();
        }
        if (object instanceof NoteEditPart) {
            return Note.class.getSimpleName();
        }
        if (object instanceof ConnLabelEditPart) {
            Connection conn = (Connection) ((ConnectionLabel) ((ConnLabelEditPart) object).getModel()).getConnection();
            return conn.getName();
        }
        if (object instanceof NodeTreeEditPart) {
            node = (Node) ((NodeTreeEditPart) object).getModel();
        } else {
            if (object instanceof NodeReturnsTreeEditPart) {
                node = lastNode;
            } else {
                if (object instanceof NodeLabelEditPart) {
                    node = ((NodeContainer) ((NodeLabelEditPart) object).getParent().getModel()).getNode();
                }
                if (!(object instanceof NodePart)) {
                    return null;
                }
                if (node == null) {
                    node = (Node) ((NodePart) object).getModel();
                }
            }
        }
        if (lastNode != node) {
            lastNode = node;
        }
        String name = node.getUniqueName();
        // }
        return name;
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) Node(org.talend.designer.core.ui.editor.nodes.Node) Connection(org.talend.designer.core.ui.editor.connections.Connection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ProcessTreeEditPart(org.talend.designer.core.ui.editor.outline.ProcessTreeEditPart) NodeReturnsTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Aggregations

NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)12 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)10 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)10 Node (org.talend.designer.core.ui.editor.nodes.Node)9 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)8 List (java.util.List)5 ArrayList (java.util.ArrayList)4 EditPart (org.eclipse.gef.EditPart)4 Clipboard (org.eclipse.gef.ui.actions.Clipboard)4 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)4 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 Text (org.eclipse.swt.widgets.Text)3 MoveNodeCommand (org.talend.designer.core.ui.editor.cmd.MoveNodeCommand)3 MoveNodeLabelCommand (org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand)3 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)3 Note (org.talend.designer.core.ui.editor.notes.Note)3 NodeTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeTreeEditPart)3 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)3 Map (java.util.Map)2