Search in sources :

Example 6 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.

the class XmlMapOutputZoneToolBar method addTable.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#addTable()
     */
@Override
protected void addTable() {
    final OutputXmlTree createOutputXmlTree = XmlmapFactory.eINSTANCE.createOutputXmlTree();
    CommandStack commandStack = externalPart.getViewer().getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            if (externalPart.getViewer() instanceof XmlMapGraphicViewer) {
                XmlMapGraphicViewer viewer = (XmlMapGraphicViewer) externalPart.getViewer();
                MapperManager manager = viewer.getMapperManager();
                String outputName = manager.getMapperUI().openNewOutputCreationDialog();
                if (outputName == null) {
                    return;
                }
                createOutputXmlTree.setName(outputName);
                externalData.getOutputTrees().add(createOutputXmlTree);
                MetadataTable metadataTable = new MetadataTable();
                metadataTable.setLabel(outputName);
                metadataTable.setTableName(outputName);
                mapperComponent.getMetadataList().add(metadataTable);
                mapperComponent.getProcess().addUniqueConnectionName(outputName);
                int indexOf = externalPart.getModelChildren().indexOf(createOutputXmlTree);
                if (indexOf != -1) {
                    externalPart.getViewer().select((EditPart) externalPart.getChildren().get(indexOf));
                }
                if (!min_size.isEnabled()) {
                    min_size.setEnabled(true);
                }
                // check problem for created output incase input main is multiloop
                mapperManger.getProblemsAnalyser().checkProblems(createOutputXmlTree);
                mapperManger.getMapperUI().updateStatusBar();
            }
        }
    });
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) MapperManager(org.talend.designer.xmlmap.ui.tabs.MapperManager) Command(org.eclipse.gef.commands.Command) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) EditPart(org.eclipse.gef.EditPart) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Example 7 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.

the class XmlMapOutputZoneToolBar method removeTable.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.treetools.zone.OutputZoneToolBar#removeTable()
     */
@Override
protected void removeTable() {
    CommandStack commandStack = graphicViewer.getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            OutputXmlTreeEditPart currentSelectedOutputXmlTree = graphicViewer.getFiguresManager().getCurrentSelectedOutputTable();
            if (currentSelectedOutputXmlTree != null) {
                OutputXmlTree outputTree = (OutputXmlTree) currentSelectedOutputXmlTree.getModel();
                int indexOf = externalPart.getModelChildren().indexOf(outputTree);
                mapperComponent.getProcess().removeUniqueConnectionName(outputTree.getName());
                removeMetadataTableByName(outputTree.getName());
                for (OutputTreeNode treeNode : outputTree.getNodes()) {
                    XmlMapUtil.detachConnectionsSouce(treeNode, externalData);
                }
                externalData.getOutputTrees().remove(outputTree);
                XmlMapUtil.detachFilterSource(outputTree, externalData);
                indexOf = indexOf - 1;
                if (indexOf > -1 && (EditPart) externalPart.getChildren().get(indexOf) instanceof OutputXmlTreeEditPart) {
                    graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf));
                } else if (indexOf > -1 && indexOf + 1 < externalPart.getChildren().size() && (EditPart) externalPart.getChildren().get(indexOf + 1) instanceof OutputXmlTreeEditPart) {
                    graphicViewer.select((EditPart) externalPart.getChildren().get(indexOf + 1));
                } else {
                    mapperManger.getMapperUI().getTabFolderEditors().getOutputMetaEditorView().setMetadataTableEditor(null);
                }
                mapperManger.getProblemsAnalyser().clearProblemsForTree(outputTree);
                mapperManger.getMapperUI().updateStatusBar();
            }
            if (externalData.getOutputTrees().isEmpty() && min_size.isEnabled()) {
                min_size.setEnabled(false);
            }
        }
    });
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) Command(org.eclipse.gef.commands.Command) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) EditPart(org.eclipse.gef.EditPart) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart)

Example 8 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.

the class NodePart method performRequest.

@Override
public void performRequest(Request req) {
    Node node = (Node) getModel();
    IExternalData oldExternalData = node.getExternalData();
    if (req.getType().equals(RequestConstants.REQ_OPEN)) {
        IExternalNode externalNode = null;
        if (node.isExternalNode()) {
            IElementParameter externalParam = node.getElementParameterFromField(EParameterFieldType.EXTERNAL);
            if (externalParam != null && externalParam.isShow(node.getElementParameters())) {
                externalNode = ExternalUtilities.getExternalNodeReadyToOpen(node);
            }
        }
        IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
            boolean isOriginalNode = false;
            ITestContainerProviderService testContainerService = null;
            if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
                testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
                if (testContainerService != null) {
                    isOriginalNode = testContainerService.isOriginalNode(node);
                    if (isOriginalNode) {
                        testContainerService.renameConnection(node, true);
                    }
                }
            }
            int returnValue = externalNode.open(getViewer().getControl().getShell());
            if (!node.isReadOnly()) {
                if (returnValue == SWT.OK) {
                    Command cmd = new ExternalNodeChangeCommand(node, externalNode, oldExternalData);
                    CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
                    cmdStack.execute(cmd);
                } else {
                    externalNode.setExternalData(oldExternalData);
                }
            }
            if (isOriginalNode && (testContainerService != null)) {
                testContainerService.renameConnection(node, false);
            }
        } else {
            // add for feature 13361
            boolean isJoblet = false;
            if (PluginChecker.isJobLetPluginLoaded()) {
                AbstractProcessProvider jobletProcessProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
                final IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
                boolean isAvoidShowJobletAfterDoubleClick = false;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
                    IComponentsLocalProviderService componentService = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
                    if (componentService != null) {
                        isAvoidShowJobletAfterDoubleClick = componentService.isAvoidToShowJobletAfterDoubleClick();
                    }
                }
                if (service != null && service.isJobletComponent(node) && !isAvoidShowJobletAfterDoubleClick) {
                    isJoblet = true;
                    String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
                    final Item jobletItem = jobletProcessProvider.getJobletItem(node, version);
                    RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {

                        @Override
                        protected void run() throws LoginException, PersistenceException {
                            if (jobletItem != null) {
                                service.openJobletItem((JobletProcessItem) jobletItem);
                            }
                        }
                    };
                    repositoryWorkUnit.setAvoidUnloadResources(true);
                    CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
                }
            }
            if (!isJoblet) {
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                String processName = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
                String version = (String) node.getPropertyValue(EParameterName.PROCESS_TYPE_VERSION.getName());
                boolean isAvoidShowJobAfterDoubleClick = false;
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsLocalProviderService.class)) {
                    IComponentsLocalProviderService service = (IComponentsLocalProviderService) GlobalServiceRegister.getDefault().getService(IComponentsLocalProviderService.class);
                    if (service != null) {
                        isAvoidShowJobAfterDoubleClick = service.isAvoidToShowJobAfterDoubleClick();
                    }
                }
                // bug 20796
                boolean isSelectUseDynamic = false;
                Object useDynamicJobValue = node.getPropertyValue(EParameterName.USE_DYNAMIC_JOB.getName());
                if (useDynamicJobValue != null && useDynamicJobValue instanceof Boolean) {
                    isSelectUseDynamic = (Boolean) useDynamicJobValue;
                }
                if (processName != null && !"".equals(processName) && !isAvoidShowJobAfterDoubleClick && !isSelectUseDynamic) {
                    //$NON-NLS-1$
                    ItemCacheManager.clearCache();
                    ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
                    if (processItem == null) {
                        return;
                    }
                    Property updatedProperty = null;
                    try {
                        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(processItem)), processName).getProperty();
                    } catch (PersistenceException e) {
                        CommonExceptionHandler.process(e);
                    }
                    // update the property of the node repository object
                    // node.getObject().setProperty(updatedProperty);
                    processItem = (ProcessItem) updatedProperty.getItem();
                    final ProcessItem item = processItem;
                    RepositoryWorkUnit<Object> repositoryWorkUnit = new RepositoryWorkUnit<Object>("", this) {

                        @Override
                        protected void run() throws LoginException, PersistenceException {
                            try {
                                if (item != null) {
                                    ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(item);
                                    IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
                                    editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(item, true));
                                }
                            } catch (PartInitException e) {
                                MessageBoxExceptionHandler.process(e);
                            }
                        }
                    };
                    repositoryWorkUnit.setAvoidUnloadResources(true);
                    CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().executeRepositoryWorkUnit(repositoryWorkUnit);
                } else {
                    try {
                        // modified for feature 2454.
                        page.showView(ComponentSettingsView.ID);
                    } catch (PartInitException e) {
                        CommonExceptionHandler.process(e);
                    }
                }
            }
        }
    }
    super.performRequest(req);
}
Also used : IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) AbstractProcessProvider(org.talend.designer.core.model.process.AbstractProcessProvider) IComponentsLocalProviderService(org.talend.core.ui.services.IComponentsLocalProviderService) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IElementParameter(org.talend.core.model.process.IElementParameter) PartInitException(org.eclipse.ui.PartInitException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) IExternalNode(org.talend.core.model.process.IExternalNode) CommandStack(org.eclipse.gef.commands.CommandStack) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IJobEditorHandler(org.talend.core.ui.editor.IJobEditorHandler) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService) Point(org.eclipse.draw2d.geometry.Point) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) IJobletProviderService(org.talend.core.ui.IJobletProviderService) Project(org.talend.core.model.general.Project) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ExternalNodeChangeCommand(org.talend.designer.core.ui.editor.cmd.ExternalNodeChangeCommand) Command(org.eclipse.gef.commands.Command) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IExternalData(org.talend.core.model.process.IExternalData)

Example 9 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.

the class MultipleThreadDynamicComposite method dispose.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.widgets.Widget#dispose()
     */
@Override
public synchronized void dispose() {
    CommandStack cmdStack = getCommandStack();
    if (cmdStack != null) {
        cmdStack.removeCommandStackEventListener(commandStackEventListener);
    }
    disposeChildren();
    if (widgetFactory != null) {
        widgetFactory.dispose();
    }
    super.dispose();
    process = null;
    elem = null;
    part = null;
    generator.dispose();
    generator = null;
    hashCurControls.clear();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack)

Example 10 with CommandStack

use of org.eclipse.gef.commands.CommandStack in project tdi-studio-se by Talend.

the class DynamicComposite method dispose.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.widgets.Widget#dispose()
     */
@Override
public void dispose() {
    CommandStack cmdStack = getCommandStack();
    if (cmdStack != null) {
        cmdStack.removeCommandStackEventListener(commandStackEventListener);
    }
    if (widgetFactory != null)
        widgetFactory.dispose();
    super.dispose();
    process = null;
    elem = null;
    part = null;
    generator.dispose();
    generator = null;
    hashCurControls.clear();
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack)

Aggregations

CommandStack (org.eclipse.gef.commands.CommandStack)34 Command (org.eclipse.gef.commands.Command)15 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)13 INode (org.talend.core.model.process.INode)10 EditPart (org.eclipse.gef.EditPart)9 Node (org.talend.designer.core.ui.editor.nodes.Node)9 PersistenceException (org.talend.commons.exception.PersistenceException)8 ArrayList (java.util.ArrayList)6 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)6 Item (org.talend.core.model.properties.Item)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 IEditorPart (org.eclipse.ui.IEditorPart)5 IExternalNode (org.talend.core.model.process.IExternalNode)5 Property (org.talend.core.model.properties.Property)5 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)5 List (java.util.List)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 IProcess (org.talend.core.model.process.IProcess)4 IProcess2 (org.talend.core.model.process.IProcess2)4