Search in sources :

Example 31 with SubjobContainerPart

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

the class GEFPasteAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    Object o;
    try {
        o = Clipboard.getDefault().getContents();
    } catch (RuntimeException e) {
        return false;
    }
    org.eclipse.swt.dnd.Clipboard systemClipboard = new org.eclipse.swt.dnd.Clipboard(Display.getCurrent());
    Object systemObject = null;
    if (systemClipboard != null) {
        systemObject = systemClipboard.getContents(TextTransfer.getInstance());
    }
    List obj = getSelectedObjects();
    if (o == null && systemObject != null && systemObject instanceof String && obj != null && obj.size() == 1 && (obj.get(0) instanceof NodeLabelEditPart || obj.get(0) instanceof ConnLabelEditPart || obj.get(0) instanceof NoteEditPart)) {
        return true;
    }
    if (o instanceof String) {
        return true;
    }
    if (!(o instanceof List)) {
        return false;
    }
    List objects = (List) o;
    if (objects.isEmpty()) {
        return false;
    }
    for (Object currentObject : objects) {
        if (!(currentObject instanceof NodePart) && !(currentObject instanceof NoteEditPart) && !(currentObject instanceof SubjobContainerPart)) {
            return false;
        }
    }
    return true;
}
Also used : NodeLabelEditPart(org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ArrayList(java.util.ArrayList) List(java.util.List) Clipboard(org.eclipse.gef.ui.actions.Clipboard) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 32 with SubjobContainerPart

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

the class DisableParallelizationAction method calculateEnabled.

@Override
protected boolean calculateEnabled() {
    List parts = getSelectedObjects();
    if (parts.isEmpty()) {
        return false;
    }
    if (parts.size() == 1) {
        Object o = parts.get(0);
        if (o instanceof SubjobContainerPart) {
            SubjobContainerPart part = (SubjobContainerPart) o;
            SubjobContainer subjob = (SubjobContainer) part.getModel();
            Node subStartNode = subjob.getSubjobStartNode();
            if (subjob.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
                if (subjob.isDisplayed() && ParallelExecutionUtils.isExistPartitioningCon(subStartNode)) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else if (o instanceof NodePart) {
            NodePart part = (NodePart) o;
            Node node = (Node) part.getModel();
            if (node.getProcess().getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
                if (node.isStart() && ParallelExecutionUtils.isExistPartitioningCon(node)) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    return false;
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 33 with SubjobContainerPart

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

the class DisplaySubjobAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
public void run() {
    List editparts = getSelectedObjects();
    if (editparts.size() == 1) {
        Object o = editparts.get(0);
        if (o instanceof NodePart) {
            NodePart part = (NodePart) o;
            Node node = (Node) part.getModel();
            if (node.getJobletNode() != null) {
                node = (Node) node.getJobletNode();
            }
            DisplaySubjobCommand displaySubjobCommand = new DisplaySubjobCommand(node.getNodeContainer().getSubjobContainer());
            execute(displaySubjobCommand);
        } else if (o instanceof SubjobContainerPart) {
            SubjobContainerPart part = (SubjobContainerPart) o;
            SubjobContainer subjob = (SubjobContainer) part.getModel();
            DisplaySubjobCommand displaySubjobCommand = new DisplaySubjobCommand(subjob);
            execute(displaySubjobCommand);
        }
    }
}
Also used : DisplaySubjobCommand(org.talend.designer.core.ui.editor.cmd.DisplaySubjobCommand) SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 34 with SubjobContainerPart

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

the class ComponentChooseDialog method handleDrop.

// private void checkRequiredModules() {
// Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
// if (newObject instanceof Node) {
// IComponent component = ((Node) newObject).getComponent();
// Shell shell = Display.getCurrent().getActiveShell();
// ModulesInstallerUtil.installModules(new Shell(shell), component);
// }
// }
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.dnd.TemplateTransferDropTargetListener#handleDrop()
     */
@Override
protected void handleDrop() {
    updateTargetRequest();
    updateTargetEditPart();
    // checkRequiredModules();
    if (fromPalette && getTargetRequest() instanceof CreateRequest) {
        if (selectedConnectionPart != null) {
            CreateRequest req = ((CreateRequest) getTargetRequest());
            Object o = req.getNewObject();
            Point location = req.getLocation();
            if (o instanceof Node) {
                createComponentOnLink((Node) o, location);
            }
            // checkRequiredModules();
            return;
        } else if (getTargetEditPart() instanceof ProcessPart) {
            // for palette dnd, feature 6457
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
            // checkRequiredModules();
            return;
        } else if (getTargetEditPart() instanceof SubjobContainerPart) {
            // TDI-24985:for palette dnd.
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null) {
                Command command = getCommand();
                if (command != null) {
                    execCommandStack(command);
                }
            }
            return;
        } else if (getTargetEditPart() instanceof JobletContainerPart) {
            JobletContainerPart jobletPart = (JobletContainerPart) getTargetEditPart();
            if (isLock(jobletPart)) {
                Shell shell = Display.getCurrent().getActiveShell();
                ChooseJobletDialog dialog = new ChooseJobletDialog(new Shell(shell), getDropLocation());
                if (dialog.open() == dialog.OK) {
                    EditPart part = getTargetEditPart();
                    if (dialog.addToJoblet()) {
                        AbstractMultiPageTalendEditor openEditor = getJobletPart((JobletContainerPart) part);
                        part = openEditor.getDesignerEditor().getProcessPart();
                        // editor = openEditor.getTalendEditor();
                        setTargetEditPart(part);
                        Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
                        if (newObject != null) {
                            Command command = getCommand();
                            if (command != null) {
                                CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
                                if (commandStack != null) {
                                    commandStack.execute(command);
                                } else {
                                    command.execute();
                                }
                            }
                        }
                        // checkRequiredModules();
                        return;
                    } else {
                        part = getParentPart(part);
                        setTargetEditPart(part);
                        Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
                        if (newObject != null) {
                            Command command = getCommand();
                            if (command != null) {
                                execCommandStack(command);
                            }
                        }
                        // checkRequiredModules();
                        return;
                    }
                }
            }
        }
    }
    List<Object> sources = getSelectSource();
    if (containsContextSource(sources)) {
        createContext(sources);
    } else {
        if (!(getTargetEditPart() instanceof NodeContainerPart)) {
            try {
                createNewComponent(getCurrentEvent());
            } catch (OperationCanceledException e) {
                return;
            }
        } else {
            if (containsSQLPatternSource(sources)) {
                createSQLPattern(sources);
            } else {
                Object obj = getSelection().getFirstElement();
                createSchema(obj, getTargetEditPart());
                createQuery(obj, getTargetEditPart());
                createProperty(obj, getTargetEditPart());
                createChildJob(obj, getTargetEditPart());
                createValidationRule(obj, getTargetEditPart());
                if (obj instanceof IRepositoryNode) {
                    propaHadoopCfgChanges((IRepositoryNode) obj);
                }
                for (IExtendedNodeHandler hander : ExtendedNodeManager.getExtendedNodeHandler()) {
                    boolean updated = hander.updateComponent(obj, getTargetEditPart(), editor.getCommandStack());
                    if (updated) {
                        break;
                    }
                }
            }
        }
    }
    // in case after drag/drop the editor is dirty but can not get focus
    if (editor.isDirty()) {
        editor.setFocus();
    }
    this.eraseTargetFeedback();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CreateRequest(org.eclipse.gef.requests.CreateRequest) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) HL7FileNode(org.talend.core.model.metadata.builder.connection.HL7FileNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) XMLFileNode(org.talend.core.model.metadata.builder.connection.XMLFileNode) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) TalendScalableFreeformRootEditPart(org.talend.designer.core.ui.editor.TalendScalableFreeformRootEditPart) RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) PaletteEditPart(org.eclipse.gef.ui.palette.editparts.PaletteEditPart) JobletContainerPart(org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart) Point(org.eclipse.draw2d.geometry.Point) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) ChooseJobletDialog(org.talend.designer.core.ui.dialog.mergeorder.ChooseJobletDialog) IExtendedNodeHandler(org.talend.designer.core.IExtendedNodeHandler) Shell(org.eclipse.swt.widgets.Shell) ConnectionCreateCommand(org.talend.designer.core.ui.editor.cmd.ConnectionCreateCommand) RepositoryChangeMetadataForSAPCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForSAPCommand) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) ConnectionReconnectCommand(org.talend.designer.core.ui.editor.cmd.ConnectionReconnectCommand) RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) RepositoryChangeMetadataForEBCDICCommand(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForEBCDICCommand) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) RepositoryChangeMetadataForHL7Command(org.talend.core.ui.metadata.command.RepositoryChangeMetadataForHL7Command) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) QueryRepositoryObject(org.talend.core.repository.model.repositoryObject.QueryRepositoryObject) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) SAPIDocRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPIDocRepositoryObject)

Aggregations

SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)34 List (java.util.List)23 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)23 Node (org.talend.designer.core.ui.editor.nodes.Node)19 ArrayList (java.util.ArrayList)18 EditPart (org.eclipse.gef.EditPart)18 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)15 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)14 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)13 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)12 SubjobContainer (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer)10 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)8 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)7 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)7 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)6 IExternalNode (org.talend.core.model.process.IExternalNode)6 INode (org.talend.core.model.process.INode)6 JobletContainerPart (org.talend.designer.core.ui.editor.jobletcontainer.JobletContainerPart)6 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5