Search in sources :

Example 1 with NodeTreeEditPart

use of org.talend.designer.core.ui.editor.outline.NodeTreeEditPart 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 2 with NodeTreeEditPart

use of org.talend.designer.core.ui.editor.outline.NodeTreeEditPart 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 3 with NodeTreeEditPart

use of org.talend.designer.core.ui.editor.outline.NodeTreeEditPart 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)

Example 4 with NodeTreeEditPart

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

the class AbstractTalendEditor method getCommonKeyHandler.

/**
     * DOC qzhang Comment method "getCommonKeyHandler".
     * 
     * @return
     */
public KeyHandler getCommonKeyHandler() {
    if (sharedKeyHandler == null) {
        sharedKeyHandler = new KeyHandler();
        sharedKeyHandler.put(KeyStroke.getPressed(SWT.F1, 0), new Action() {

            @Override
            public void run() {
                ISelection selection = getGraphicalViewer().getSelection();
                if (selection != null) {
                    if (selection instanceof IStructuredSelection) {
                        Object input = ((IStructuredSelection) selection).getFirstElement();
                        Node node = null;
                        if (input instanceof NodeTreeEditPart) {
                            NodeTreeEditPart nTreePart = (NodeTreeEditPart) input;
                            node = (Node) nTreePart.getModel();
                        } else {
                            if (input instanceof NodePart) {
                                EditPart editPart = (EditPart) input;
                                node = (Node) editPart.getModel();
                            }
                        }
                        if (node != null) {
                            String helpLink = (String) node.getPropertyValue(EParameterName.HELP.getName());
                            String requiredHelpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
                            if (helpLink == null || "".equals(helpLink) || !requiredHelpLink.equals(helpLink)) {
                                helpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
                            }
                            PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpLink);
                        }
                    }
                }
            }
        });
        sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));
    // deactivate the F2 shortcut as it's not used anymore
    // sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
    // getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
    }
    return sharedKeyHandler;
}
Also used : ModifyConnectionOrderAction(org.talend.designer.core.ui.action.ModifyConnectionOrderAction) GEFDeleteAction(org.talend.designer.core.ui.action.GEFDeleteAction) GEFPasteAction(org.talend.designer.core.ui.action.GEFPasteAction) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) ToggleSubjobsAction(org.talend.designer.core.ui.action.ToggleSubjobsAction) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) ModifyOutputOrderAction(org.talend.designer.core.ui.action.ModifyOutputOrderAction) IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) ModifyMergeOrderAction(org.talend.designer.core.ui.action.ModifyMergeOrderAction) ToggleGridAction(org.eclipse.gef.ui.actions.ToggleGridAction) Action(org.eclipse.jface.action.Action) GEFRedoAction(org.talend.designer.core.ui.action.GEFRedoAction) GEFCopyAction(org.talend.designer.core.ui.action.GEFCopyAction) ToggleSnapToGeometryAction(org.eclipse.gef.ui.actions.ToggleSnapToGeometryAction) GEFUndoAction(org.talend.designer.core.ui.action.GEFUndoAction) 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) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) ISelection(org.eclipse.jface.viewers.ISelection) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) TalendDrawerEditPart(org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EventObject(java.util.EventObject) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) KeyHandler(org.eclipse.gef.KeyHandler)

Example 5 with NodeTreeEditPart

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

the class TalendTabbedPropertySheetPage method selectionChanged.

@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    ISelection newSelection;
    if (part instanceof AbstractMultiPageTalendEditor) {
        AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
        newSelection = mpte.getTalendEditor().getViewer().getSelection();
        if (selection instanceof StructuredSelection) {
            StructuredSelection structSel = (StructuredSelection) newSelection;
            if (structSel.size() != 1) {
                return;
            }
            if (structSel.getFirstElement() instanceof EditPart) {
                if (structSel.equals(oldSelection)) {
                // if (getCurrentTab() != null) {
                // getCurrentTab().setInput(part, selection);
                // }
                } else {
                    super.selectionChanged(part, selection);
                }
                oldSelection = structSel;
            }
        }
    } else if (part instanceof ContentOutline) {
        ContentOutline outline = (ContentOutline) part;
        newSelection = outline.getSelection();
        if (selection instanceof StructuredSelection) {
            StructuredSelection structSel = (StructuredSelection) newSelection;
            if (structSel.size() != 1) {
                return;
            }
            if (structSel.getFirstElement() instanceof NodeTreeEditPart) {
                if (structSel.equals(oldSelection)) {
                // this.getCurrentTab().setInput(part, selection);
                } else {
                    super.selectionChanged(part, selection);
                }
                oldSelection = structSel;
            }
        }
    }
}
Also used : NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) EditPart(org.eclipse.gef.EditPart) ContentOutline(org.eclipse.ui.views.contentoutline.ContentOutline)

Aggregations

NodeTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeTreeEditPart)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 Node (org.talend.designer.core.ui.editor.nodes.Node)4 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)4 EditPart (org.eclipse.gef.EditPart)3 INode (org.talend.core.model.process.INode)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)3 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)3 NodeReturnsTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeReturnsTreeEditPart)3 ISelection (org.eclipse.jface.viewers.ISelection)2 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)2 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)2 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)2 Process (org.talend.designer.core.ui.editor.process.Process)2 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)2 ArrayList (java.util.ArrayList)1 EventObject (java.util.EventObject)1 List (java.util.List)1 PlatformObject (org.eclipse.core.runtime.PlatformObject)1