Search in sources :

Example 6 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class AbstractTalendEditor method initializeGraphicalViewer.

// ------------------------------------------------------------------------
// Abstract methods from GraphicalEditor
@Override
protected void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    // this uses the PartFactory set in configureGraphicalViewer
    // to create an EditPart for the diagram and sets it as the
    // content for the viewer
    IProcess2 process = getProcess();
    getGraphicalViewer().setContents(process);
    // containers are not correctly updated by default, so update them after all nodes have been added
    if (process != null) {
        for (ISubjobContainer subjobContainer : process.getSubjobContainers()) {
            subjobContainer.updateSubjobContainer();
        }
    }
    getGraphicalViewer().getControl().addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            updateActions(getSelectionActions());
        }
    });
    talendEditorDropTargetListener = new TalendEditorDropTargetListener(this);
    getGraphicalViewer().addDropTargetListener(talendEditorDropTargetListener);
}
Also used : ISubjobContainer(org.talend.core.model.process.ISubjobContainer) MouseEvent(org.eclipse.swt.events.MouseEvent) TalendEditorDropTargetListener(org.talend.designer.core.ui.editor.process.TalendEditorDropTargetListener) IProcess2(org.talend.core.model.process.IProcess2) MouseAdapter(org.eclipse.swt.events.MouseAdapter)

Example 7 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class JobletUtil method cloneNode.

public Node cloneNode(Node node, IProcess process, Map<String, List<? extends IElementParameter>> paraMap, boolean lockByOther) {
    NodePart nodePart = new NodePart();
    IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
    boolean isInOut = false;
    if (service != null) {
        isInOut = service.isJobletInOutComponent(node);
    }
    Node cloneNode = new Node(node.getComponent(), (IProcess2) process, node.getUniqueName());
    nodePart.setModel(cloneNode);
    if (lockByOther) {
        cloneNode.setReadOnly(true);
    } else {
        cloneNode.setReadOnly(false);
    }
    cloneNode.setDummy(node.isDummy());
    cloneNode.setActivate(node.isActivate());
    List<? extends IElementParameter> elementParas = null;
    if (paraMap.containsKey(node.getUniqueName())) {
        elementParas = paraMap.get(node.getUniqueName());
    } else {
        elementParas = node.getElementParameters();
    }
    for (IElementParameter elementPara : elementParas) {
        if (elementPara.getName() != null && !elementPara.getName().equals("UNIQUE_NAME")) {
            IElementParameter cloneElement = cloneNode.getElementParameter(elementPara.getName());
            Object paValue = elementPara.getValue();
            if (paValue instanceof List) {
                List list = new ArrayList();
                list.addAll((List) paValue);
                cloneElement.setValue(list);
            } else {
                // TDI-25599
                cloneElement.setContextMode(elementPara.isContextMode());
                cloneElement.setValue(elementPara.getValue());
            }
            if (lockByOther) {
                cloneElement.setReadOnly(true);
            } else {
                cloneElement.setReadOnly(elementPara.isReadOnly());
            }
            if (elementPara.getChildParameters() != null) {
                Map<String, IElementParameter> elementParaChild = elementPara.getChildParameters();
                Map<String, IElementParameter> cloneElementChild = cloneElement.getChildParameters();
                Iterator<Entry<String, IElementParameter>> ite = elementParaChild.entrySet().iterator();
                while (ite.hasNext()) {
                    Entry<String, IElementParameter> entry = ite.next();
                    String key = entry.getKey();
                    IElementParameter c = entry.getValue();
                    if (key != null && c != null) {
                        IElementParameter cloneC = cloneElementChild.get(key);
                        if (cloneC != null) {
                            cloneC.setValue(c.getValue());
                            if (lockByOther) {
                                cloneC.setReadOnly(true);
                            } else {
                                cloneC.setReadOnly(c.isReadOnly());
                            }
                        }
                    }
                }
            }
        }
    }
    for (IElementParameter param : cloneNode.getElementParameters()) {
        String repositoryValue = param.getRepositoryValue();
        if (param.isShow(cloneNode.getElementParameters()) && (repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && param.getFieldType() != EParameterFieldType.MEMO_SQL) {
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        }
    }
    cloneNode.setMetadataList(node.getMetadataList());
    cloneNode.setListConnector(node.getListConnector());
    cloneNode.setConnectionName(node.getConnectionName());
    cloneNode.setLocation(node.getLocation());
    IExternalNode externalNode = cloneNode.getExternalNode();
    if (externalNode != null) {
        if (node.getExternalData() != null) {
            try {
                externalNode.setExternalData(node.getExternalData().clone());
            } catch (CloneNotSupportedException e) {
                ExceptionHandler.process(e);
            }
            cloneNode.setExternalData(externalNode.getExternalData());
        }
        if (node.getExternalNode().getExternalEmfData() != null) {
            externalNode.setExternalEmfData(EcoreUtil.copy(node.getExternalNode().getExternalEmfData()));
        }
        // when copy a external node, should also copy screeshot
        if (node.getExternalNode() != null) {
            ImageDescriptor screenshot = node.getExternalNode().getScreenshot();
            if (screenshot != null) {
                externalNode.setScreenshot(screenshot);
            }
        }
    }
    if (node.getElementParameter(EParameterName.LABEL.getName()) != null) {
        cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getElementParameter(EParameterName.LABEL.getName()).getValue());
    } else {
        cloneNode.setPropertyValue(EParameterName.LABEL.getName(), node.getLabel());
    }
    boolean found = false;
    for (INode inode : process.getGraphicalNodes()) {
        if (inode.getUniqueName().equals(cloneNode.getUniqueName())) {
            found = true;
        }
    }
    if (!found) {
        ((IProcess2) process).removeUniqueNodeName(cloneNode.getUniqueName());
    }
    return cloneNode;
}
Also used : INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) JobletNode(org.talend.designer.joblet.model.JobletNode) ArrayList(java.util.ArrayList) IJobletProviderService(org.talend.core.ui.IJobletProviderService) Entry(java.util.Map.Entry) IProcess2(org.talend.core.model.process.IProcess2) IElementParameter(org.talend.core.model.process.IElementParameter) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) IExternalNode(org.talend.core.model.process.IExternalNode)

Example 8 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class JobletUtil method openedInJob.

public boolean openedInJob(JobletProcessItem jobletItem, Node currNode) {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart[] editors = page.getEditors();
    for (IEditorPart editor : editors) {
        if (editor instanceof AbstractMultiPageTalendEditor) {
            IProcess2 pro = ((AbstractMultiPageTalendEditor) editor).getProcess();
            if (currNode != null) {
                IProcess2 currPro = (IProcess2) currNode.getProcess();
                if (currPro.getId().equals(pro.getId())) {
                    List<? extends INode> currNodeList = currPro.getGraphicalNodes();
                    for (INode node : currNodeList) {
                        if (node == currNode) {
                            continue;
                        } else {
                            if (((Node) node).isJoblet() && jobletItem.getProperty() != null) {
                                if (jobletItem.getProperty().getId().equals(node.getComponent().getProcess().getId()) && jobletItem.getProperty().getVersion().equals(node.getComponent().getVersion())) {
                                    boolean haveOpened = !((Node) node).getNodeContainer().isCollapsed();
                                    if (haveOpened) {
                                        return true;
                                    }
                                }
                            }
                        }
                    }
                    continue;
                }
            }
            List<? extends INode> nodeList = pro.getGraphicalNodes();
            for (INode node : nodeList) {
                if (((Node) node).isJoblet() && jobletItem.getProperty() != null) {
                    if (jobletItem.getProperty().getId().equals(node.getComponent().getProcess().getId()) && jobletItem.getProperty().getVersion().equals(node.getComponent().getVersion())) {
                        boolean haveOpened = !((Node) node).getNodeContainer().isCollapsed();
                        if (haveOpened) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : INode(org.talend.core.model.process.INode) 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) JobletNode(org.talend.designer.joblet.model.JobletNode) IProcess2(org.talend.core.model.process.IProcess2) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 9 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class IconSelectionController method createCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
     */
public Command createCommand(Button button) {
    Object data = button.getData(NAME);
    if (data != null) {
        if (ICON_SELECTION.equals(data)) {
            FileDialog dial = new FileDialog(composite.getShell(), SWT.NONE);
            //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            dial.setFilterExtensions(new String[] { "*.jpg", "*.png", "*.gif" });
            String propertyName = (String) button.getData(PARAMETER_NAME);
            String file = dial.open();
            if (file != null) {
                if (!file.equals("")) {
                    //$NON-NLS-1$
                    if (!elem.getPropertyValue(propertyName).equals(file)) {
                        ImageData imageData = new ImageData(file);
                        if (ImageUtils.checkSize(ImageDescriptor.createFromImageData(imageData), ImageUtils.ICON_SIZE.ICON_32)) {
                            if (elem instanceof IProcess2) {
                                refreshIcon(imageData);
                                return new IconSelectionCommand((IProcess2) elem, ImageDescriptor.createFromImageData(imageData), file);
                            }
                        } else {
                            MessageDialog.openError(composite.getShell(), //$NON-NLS-1$ 
                            Messages.getString("IconSelectionController.MessageTitle"), //$NON-NLS-1$ 
                            Messages.getString("IconSelectionController.Messages"));
                        }
                    }
                }
            }
        } else if (ICON_REVERT.equals(data)) {
            if (elem instanceof IProcess2) {
                Image defaultIcon = RepositoryLabelProvider.getDefaultJobletImage(((IProcess2) elem).getProperty().getItem());
                ImageDescriptor imageData = ImageDescriptor.createFromImage(defaultIcon);
                refreshIcon(defaultIcon.getImageData());
                return new IconSelectionCommand((IProcess2) elem, imageData, null);
            }
        }
    }
    return null;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) IProcess2(org.talend.core.model.process.IProcess2) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image) FileDialog(org.eclipse.swt.widgets.FileDialog)

Example 10 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class UpdateNodeParameterCommand method execute.

@Override
public void execute() {
    if (result == null) {
        return;
    }
    Object updateObject = result.getUpdateObject();
    if (updateObject == null || (!(updateObject instanceof Node)) || (!(result.getJob() instanceof IProcess))) {
        return;
    }
    // instance of node before might not be good (loaded while check updates needed)
    // so get the instance of the node of the current job in this object.
    IProcess process = (IProcess) result.getJob();
    for (INode node : process.getGraphicalNodes()) {
        if (node.getUniqueName().equals(((Node) updateObject).getUniqueName())) {
            updateObject = node;
            result.setUpdateObject(updateObject);
            break;
        }
    }
    IUpdateItemType updateType = result.getUpdateType();
    if (updateType instanceof EUpdateItemType) {
        switch((EUpdateItemType) updateType) {
            case NODE_PROPERTY:
                updateProperty();
                break;
            case NODE_SCHEMA:
                updateSchema();
                break;
            case NODE_QUERY:
                updateQuery();
                break;
            case NODE_SAP_FUNCTION:
                updateSAPParameters();
                break;
            case NODE_SAP_IDOC:
                updateSAPIDocParameters();
                break;
            case NODE_VALIDATION_RULE:
                updateValidationRule();
                break;
            default:
                return;
        }
    }
    // else { // for extension
    Node node = (Node) updateObject;
    if (node.getProcess() instanceof IProcess2) {
        PropertyChangeCommand pcc = new PropertyChangeCommand(node, EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
        boolean executed = false;
        if (process instanceof IGEFProcess) {
            IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
            if (designerCoreUIService != null) {
                executed = designerCoreUIService.executeCommand((IGEFProcess) process, pcc);
            }
        }
        if (!executed) {
            pcc.execute();
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) IProcess(org.talend.core.model.process.IProcess) IGEFProcess(org.talend.core.ui.process.IGEFProcess)

Aggregations

IProcess2 (org.talend.core.model.process.IProcess2)115 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 ArrayList (java.util.ArrayList)30 ProcessItem (org.talend.core.model.properties.ProcessItem)30 Item (org.talend.core.model.properties.Item)28 IProcess (org.talend.core.model.process.IProcess)24 PersistenceException (org.talend.commons.exception.PersistenceException)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)19 List (java.util.List)17 IElementParameter (org.talend.core.model.process.IElementParameter)15 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)14 Property (org.talend.core.model.properties.Property)14 CoreException (org.eclipse.core.runtime.CoreException)12 IConnection (org.talend.core.model.process.IConnection)11 HashSet (java.util.HashSet)10 IEditorReference (org.eclipse.ui.IEditorReference)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)7