Search in sources :

Example 51 with Process

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

the class JobletConnectionReconnectCommand method undo.

@Override
public void undo() {
    if (newSource != null) {
        INodeConnector connector = oldSource.getConnectorFromName(connectorName);
        connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() + 1);
        connector = newSource.getConnectorFromName(connectorName);
        connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() - 1);
        if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
            boolean builtInNewSource = newSource.getConnectorFromName(connectorName).isMultiSchema();
            boolean builtInOldSource = oldSource.getConnectorFromName(connectorName).isMultiSchema();
            if ((!builtInNewSource) && (!builtInOldSource)) {
                setSchemaToNotBuiltInNode(newSource, oldSource, oldMetadataTable);
                if (oldSource.getJobletNode() != null) {
                    connection.setMetaName(oldSource.getJobletNode().getUniqueName());
                } else
                    connection.setMetaName(oldSource.getUniqueName());
            } else {
                if (!builtInNewSource) {
                    oldSource.getMetadataList().add(oldMetadataTable);
                    connection.setMetaName(oldMetadataTable.getTableName());
                }
                if (!builtInOldSource) {
                    int num = 0;
                    for (int i = 0; i < newSource.getMetadataList().size(); i++) {
                        IMetadataTable meta = newSource.getMetadataList().get(i);
                        if (meta.getTableName().equals(connection.getUniqueName())) {
                            num = i;
                        }
                    }
                    newSource.getMetadataList().remove(num);
                    setSchemaToNotBuiltInNode(newSource, oldSource, oldMetadataTable);
                    if (oldSource.getJobletNode() != null) {
                        connection.setMetaName(oldSource.getJobletNode().getUniqueName());
                    } else
                        connection.setMetaName(oldSource.getUniqueName());
                }
                if ((builtInOldSource) && (builtInNewSource)) {
                    int num = 0;
                    for (int i = 0; i < newSource.getMetadataList().size(); i++) {
                        IMetadataTable meta = newSource.getMetadataList().get(i);
                        if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
                            num = i;
                        }
                    }
                    newSource.getMetadataList().remove(num);
                    oldSource.getMetadataList().add(oldMetadataTable);
                }
            }
            if (newSourceSchemaType != null) {
                for (ChangeMetadataCommand cmd : metadataChanges) {
                    cmd.undo();
                }
                newSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), newSourceSchemaType);
            }
            if (oldSourceSchemaType != null) {
                oldSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), oldSourceSchemaType);
            }
        } else {
            if (oldSource.getJobletNode() != null) {
                connection.setMetaName(oldSource.getJobletNode().getUniqueName());
            } else
                connection.setMetaName(oldSource.getUniqueName());
        }
    } else if (newTarget != null) {
        INodeConnector connector = oldTarget.getConnectorFromType(oldLineStyle);
        connector.setCurLinkNbInput(connector.getCurLinkNbInput() + 1);
        connector = newTarget.getConnectorFromType(newLineStyle);
        connector.setCurLinkNbInput(connector.getCurLinkNbInput() - 1);
        if (newTargetSchemaType != null) {
            for (ChangeMetadataCommand cmd : metadataChanges) {
                cmd.undo();
            }
            newTarget.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), newTargetSchemaType);
        }
    }
    connection.reconnect(oldSource, oldTarget, oldLineStyle);
    connection.updateName();
    ((Process) oldSource.getProcess()).checkStartNodes();
    ((Process) oldSource.getProcess()).checkProcess();
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Process(org.talend.designer.core.ui.editor.process.Process) INodeConnector(org.talend.core.model.process.INodeConnector)

Example 52 with Process

use of org.talend.designer.core.ui.editor.process.Process 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 53 with Process

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

Example 54 with Process

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

the class SubjobContainerLayoutEditPolicy method getCreateCommand.

// ------------------------------------------------------------------------
// Abstract methods from LayoutEditPolicy
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
     */
protected Command getCreateCommand(final CreateRequest request) {
    if (((SubjobContainer) getHost().getModel()).isReadOnly()) {
        return null;
    }
    Rectangle constraint = (Rectangle) getConstraintFor(request);
    Process linkedProcess = (Process) ((SubjobContainer) getHost().getModel()).getProcess();
    Command command = null;
    if (Note.class.equals(request.getNewObjectType())) {
        command = new CreateNoteCommand(linkedProcess, (Note) request.getNewObject(), constraint.getLocation());
    } else if (request.getNewObject() instanceof Node) {
        Node node = (Node) request.getNewObject();
        NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
        command = new CreateNodeContainerCommand(linkedProcess, nodeContainer, constraint.getLocation());
    }
    return command;
}
Also used : CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) MoveNodeLabelCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeLabelCommand) MoveNodeCommand(org.talend.designer.core.ui.editor.cmd.MoveNodeCommand) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) MoveNoteCommand(org.talend.designer.core.ui.editor.cmd.MoveNoteCommand) Command(org.eclipse.gef.commands.Command) Note(org.talend.designer.core.ui.editor.notes.Note) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Process(org.talend.designer.core.ui.editor.process.Process) CreateNoteCommand(org.talend.designer.core.ui.editor.cmd.CreateNoteCommand) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)

Example 55 with Process

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

Aggregations

Process (org.talend.designer.core.ui.editor.process.Process)119 Node (org.talend.designer.core.ui.editor.nodes.Node)69 INode (org.talend.core.model.process.INode)48 ArrayList (java.util.ArrayList)45 IComponent (org.talend.core.model.components.IComponent)36 IElementParameter (org.talend.core.model.process.IElementParameter)28 Test (org.junit.Test)26 List (java.util.List)25 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IProcess (org.talend.core.model.process.IProcess)24 Connection (org.talend.designer.core.ui.editor.connections.Connection)24 Property (org.talend.core.model.properties.Property)23 INodeConnector (org.talend.core.model.process.INodeConnector)22 IConnection (org.talend.core.model.process.IConnection)20 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)20 FakePropertyImpl (org.talend.core.model.repository.FakePropertyImpl)15 ProcessItem (org.talend.core.model.properties.ProcessItem)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)11 HashMap (java.util.HashMap)10 Before (org.junit.Before)9