Search in sources :

Example 16 with AbstractMultiPageTalendEditor

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

the class UIManager method closeMapper.

/**
     * DOC amaumont Comment method "closeMapperDialog".
     * 
     * @param ok
     */
public void closeMapper(int response) {
    boolean save = true;
    for (DataMapTableView dataMapTableView : getInputsTablesView()) {
        dataMapTableView.notifyFocusLost();
    }
    for (DataMapTableView dataMapTableView : getOutputsTablesView()) {
        dataMapTableView.notifyFocusLost();
    }
    for (DataMapTableView dataMapTableView : getVarsTablesView()) {
        dataMapTableView.notifyFocusLost();
    }
    if ((response == SWT.OK || response == SWT.APPLICATION_MODAL) && mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(false)) {
        save = MessageDialog.openConfirm(getMapperContainer().getShell(), //$NON-NLS-1$
        Messages.getString("UIManager.SaveDespiteErrors.Title"), //$NON-NLS-1$
        Messages.getString("UIManager.SaveDespiteErrors.Message"));
    }
    if (save) {
        Composite parent = mapperUI.getMapperUIParent();
        prepareClosing(response);
        if (parent instanceof Shell) {
            if (response == SWT.OK || response == SWT.CANCEL) {
                ((Shell) parent).close();
            } else {
                IExternalNode externalNode = mapperManager.getAbstractMapComponent().getExternalNode();
                IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
                if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
                    INode node = externalNode.getOriginalNode();
                    if (node != null && node instanceof Node) {
                        Command cmd = new ExternalNodeChangeCommand((Node) node, externalNode);
                        CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
                        cmdStack.execute(cmd);
                    }
                }
            }
        }
    }
}
Also used : ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) CommandStack(org.eclipse.gef.commands.CommandStack) Shell(org.eclipse.swt.widgets.Shell) INode(org.talend.core.model.process.INode) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) Command(org.eclipse.gef.commands.Command) DataMapTableViewSelectedCommand(org.talend.designer.mapper.ui.commands.DataMapTableViewSelectedCommand) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) InputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView) OutputDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView) VarsDataMapTableView(org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IExternalNode(org.talend.core.model.process.IExternalNode)

Example 17 with AbstractMultiPageTalendEditor

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

the class NodesMoveCommond 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 (nodePart != null) {
                                    sel.add(nodePart);
                                }
                            }
                        }
                    }
                }
                if (editPart instanceof NodePart) {
                    Node currentNode = (Node) editPart.getModel();
                    if (nodeContainerList.contains(currentNode.getNodeContainer())) {
                        sel.add(editPart);
                    }
                }
            }
            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 18 with AbstractMultiPageTalendEditor

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

the class NodesPasteCommand 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 19 with AbstractMultiPageTalendEditor

use of org.talend.designer.core.ui.AbstractMultiPageTalendEditor 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 20 with AbstractMultiPageTalendEditor

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

Aggregations

AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)53 IEditorPart (org.eclipse.ui.IEditorPart)26 INode (org.talend.core.model.process.INode)16 Node (org.talend.designer.core.ui.editor.nodes.Node)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)14 CommandStack (org.eclipse.gef.commands.CommandStack)13 AbstractTalendEditor (org.talend.designer.core.ui.editor.AbstractTalendEditor)12 GraphicalViewer (org.eclipse.gef.GraphicalViewer)10 IExternalNode (org.talend.core.model.process.IExternalNode)10 IProcess (org.talend.core.model.process.IProcess)10 ArrayList (java.util.ArrayList)9 List (java.util.List)8 EditPart (org.eclipse.gef.EditPart)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorReference (org.eclipse.ui.IEditorReference)7 PersistenceException (org.talend.commons.exception.PersistenceException)7 IProcess2 (org.talend.core.model.process.IProcess2)7 Property (org.talend.core.model.properties.Property)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 Process (org.talend.designer.core.ui.editor.process.Process)7