Search in sources :

Example 26 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.

the class NodesPasteCommand method execute.

@SuppressWarnings("unchecked")
@Override
public void execute() {
    // create the node container list to paste
    createNodeContainerList();
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    // save old selection
    if (!multipleCommand) {
        oldSelection = new ArrayList<EditPart>();
        for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
            oldSelection.add(editPart);
        }
        // remove the old selection
        viewer.deselectAll();
    }
    // creates the different nodes
    for (NodeContainer nodeContainer : nodeContainerList) {
        ((Process) process).addNodeContainer(nodeContainer);
    }
    // check that the created connections exists now, or create them if needed
    for (String newConnectionName : createdNames) {
        if (process.checkValidConnectionName(newConnectionName, true)) {
            process.addUniqueConnectionName(newConnectionName);
        }
    }
    process.checkStartNodes();
    process.checkProcess();
    // set the new node as the current selection
    if (!multipleCommand) {
        EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
        if (processPart instanceof ProcessPart) {
            // can only be
            // ProcessPart but still
            // test
            List<EditPart> sel = new ArrayList<EditPart>();
            for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
                if (editPart instanceof SubjobContainerPart) {
                    for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
                        if (subjobChildsPart instanceof NodeContainerPart) {
                            if (nodeContainerList.contains(((NodeContainerPart) subjobChildsPart).getModel())) {
                                NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
                                if (jobletNodeToExpand.contains(((Node) nodePart.getModel()).getNodeContainer())) {
                                    PropertyChangeCommand ppc = new PropertyChangeCommand(((Node) nodePart.getModel()).getNodeContainer(), EParameterName.COLLAPSED.getName(), false);
                                    ppc.execute();
                                    for (EditPart jobletChildren : (List<EditPart>) subjobChildsPart.getChildren()) {
                                        if (jobletChildren instanceof NodePart) {
                                            sel.add(jobletChildren);
                                        }
                                    }
                                } else if (nodePart != null) {
                                    sel.add(nodePart);
                                }
                            }
                        }
                    }
                }
                if (editPart instanceof NodePart) {
                    Node currentNode = (Node) editPart.getModel();
                    if (nodeContainerList.contains(currentNode.getNodeContainer())) {
                        sel.add(editPart);
                    }
                }
            }
            if (!isJunitCreate() && !isJobletRefactor()) {
                StructuredSelection s = new StructuredSelection(sel);
                viewer.setSelection(s);
            }
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) List(java.util.List) ArrayList(java.util.ArrayList) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 27 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.

the class NodesMoveCommond method undo.

@SuppressWarnings("unchecked")
@Override
public void undo() {
    // remove the current selection
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    if (!multipleCommand) {
        viewer.deselectAll();
    }
    for (NodeContainer nodeContainer : nodeContainerList) {
        // remove the connections name from the list
        for (Connection connection : (List<Connection>) nodeContainer.getNode().getOutgoingConnections()) {
            process.removeUniqueConnectionName(connection.getName());
        }
        ((Process) process).removeNodeContainer(nodeContainer);
    }
    // check that the created connections are removed, remove them if not
    for (String newConnectionName : createdNames) {
        if (!process.checkValidConnectionName(newConnectionName, true)) {
            process.removeUniqueConnectionName(newConnectionName);
        }
    }
    process.checkStartNodes();
    process.checkProcess();
    // set the old selection active
    if (!multipleCommand) {
        StructuredSelection s = new StructuredSelection(oldSelection);
        viewer.setSelection(s);
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) List(java.util.List) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process)

Example 28 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.

the class MultiplePasteCommand method undo.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.commands.CompoundCommand#undo()
     */
@Override
public void undo() {
    // remove the current selection
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    viewer.deselectAll();
    super.undo();
    // set the old selection active
    StructuredSelection s = new StructuredSelection(oldSelection);
    viewer.setSelection(s);
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 29 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.

the class MultiplePasteCommand method execute.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.commands.CompoundCommand#execute()
     */
@Override
public void execute() {
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    oldSelection = new ArrayList<EditPart>();
    for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
        oldSelection.add(editPart);
    }
    // remove the old selection
    viewer.deselectAll();
    super.execute();
    EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
    if (processPart instanceof ProcessPart) {
        // can only be ProcessPart but still test
        List<EditPart> sel = new ArrayList<EditPart>();
        for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
            if (editPart instanceof NodePart) {
                Node currentNode = (Node) editPart.getModel();
                if (nodeCmd.getNodeContainerList().contains(currentNode.getNodeContainer())) {
                    sel.add(editPart);
                }
            } else if (editPart instanceof NoteEditPart) {
                Note currentNode = (Note) editPart.getModel();
                if (noteCmd.getNoteList().contains(currentNode)) {
                    sel.add(editPart);
                }
            } else if (editPart instanceof SubjobContainerPart) {
                // add for the bug TDI-7706
                for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
                    if (subjobChildsPart instanceof NodeContainerPart) {
                        if (nodeCmd.getNodeContainerList().contains(((NodeContainerPart) subjobChildsPart).getModel())) {
                            NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
                            if (nodePart != null) {
                                sel.add(nodePart);
                            }
                        }
                    }
                }
            }
        }
        StructuredSelection s = new StructuredSelection(sel);
        viewer.setSelection(s);
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) Note(org.talend.designer.core.ui.editor.notes.Note) ArrayList(java.util.ArrayList) List(java.util.List) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 30 with StructuredSelection

use of org.eclipse.jface.viewers.StructuredSelection in project tdi-studio-se by Talend.

the class StatsAndLogsTabPropertySection method setInput.

public void setInput(final IWorkbenchPart workbenchPart, final ISelection selection) {
    Object input = ((IStructuredSelection) selection).getFirstElement();
    if (input instanceof RepositoryNode) {
        // This is the only RepositoryNode that displays the Job.
        Process process = StatsAndLogsSectionFilter.getProcessPartByRepositoryNode((RepositoryNode) input);
        if (process == null) {
            return;
        }
        // make a mock processPart here for super.setInput();
        ProcessPart part = new ProcessPart();
        part.setModel(process);
        StructuredSelection sel = new StructuredSelection(part);
        super.setInput(workbenchPart, sel);
    } else {
        super.setInput(workbenchPart, selection);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) RepositoryNode(org.talend.repository.model.RepositoryNode)

Aggregations

StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1376 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)782 ArrayList (java.util.ArrayList)212 ISelection (org.eclipse.jface.viewers.ISelection)177 Composite (org.eclipse.swt.widgets.Composite)167 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)133 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)128 GridData (org.eclipse.swt.layout.GridData)112 List (java.util.List)93 IFile (org.eclipse.core.resources.IFile)92 GridLayout (org.eclipse.swt.layout.GridLayout)87 SelectionEvent (org.eclipse.swt.events.SelectionEvent)82 Label (org.eclipse.swt.widgets.Label)79 TreeViewer (org.eclipse.jface.viewers.TreeViewer)78 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)68 EObject (org.eclipse.emf.ecore.EObject)67 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)66 TableViewer (org.eclipse.jface.viewers.TableViewer)64 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)61 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)60