Search in sources :

Example 1 with TalendEditorConnectionTargetAssist

use of org.talend.designer.core.assist.TalendEditorConnectionTargetAssist in project tdi-studio-se by Talend.

the class ProcessLayoutEditPolicy method getConnectionAndEndCommands.

protected Command getConnectionAndEndCommands(CreateConnectionRequest request) {
    CompoundCommand cc = new CompoundCommand("CreateNodeCommand");
    ProcessPart processPart = (ProcessPart) this.getHost();
    final GraphicalViewer graphicalViewer = (GraphicalViewer) processPart.getViewer();
    final CommandStack commandStack = processPart.getViewer().getEditDomain().getCommandStack();
    final String categoryName = ComponentsFactoryProvider.getInstance().getComponentsHandler().extractComponentsCategory().getName();
    final IProcess2 process = (IProcess2) processPart.getModel();
    TalendEditorConnectionTargetAssist assist = new TalendEditorConnectionTargetAssist(categoryName, graphicalViewer, commandStack, process);
    char start = '*';
    assist.showComponentCreationAssist(start);
    ConnectionCreateCommand cmd = (ConnectionCreateCommand) request.getStartCommand();
    if (assist.getComponentName() == null) {
        assist.releaseText();
        return cmd;
    }
    IComponent component = TalendEditorComponentCreationUtil.getComponentsInCategory(categoryName).get(assist.getComponentName());
    if (component == null) {
        assist.releaseText();
        return cmd;
    }
    assist.releaseText();
    Node newNode = new Node(component);
    NodeContainer nodeContainer = ((Process) newNode.getProcess()).loadNodeContainer(newNode, false);
    CreateNodeContainerCommand command = new CreateNodeContainerCommand((org.talend.designer.core.ui.editor.process.Process) newNode.getProcess(), nodeContainer, request.getLocation());
    cc.add(command);
    cmd.setTarget(newNode);
    cc.add(cmd);
    return cc;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) GraphicalViewer(org.eclipse.gef.GraphicalViewer) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) IProcess2(org.talend.core.model.process.IProcess2) TalendEditorConnectionTargetAssist(org.talend.designer.core.assist.TalendEditorConnectionTargetAssist)

Aggregations

GraphicalViewer (org.eclipse.gef.GraphicalViewer)1 CommandStack (org.eclipse.gef.commands.CommandStack)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 IComponent (org.talend.core.model.components.IComponent)1 IProcess2 (org.talend.core.model.process.IProcess2)1 IGraphicalNode (org.talend.core.ui.process.IGraphicalNode)1 TalendEditorConnectionTargetAssist (org.talend.designer.core.assist.TalendEditorConnectionTargetAssist)1 ConnectionCreateCommand (org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand)1 CreateNodeContainerCommand (org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand)1 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)1 Node (org.talend.designer.core.ui.editor.nodes.Node)1