Search in sources :

Example 31 with AbstractMultiPageTalendEditor

use of org.talend.designer.core.ui.AbstractMultiPageTalendEditor 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 32 with AbstractMultiPageTalendEditor

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

the class DesignerColorsPreferencePage method switchToCurrentColor.

/**
     * zli Comment method "switchToCurrentColor".
     */
private void switchToCurrentColor() {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow != null) {
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        if (activePage != null) {
            for (IEditorReference ref : activePage.getEditorReferences()) {
                IEditorPart editor = ref.getEditor(true);
                if (editor instanceof AbstractMultiPageTalendEditor) {
                    AbstractMultiPageTalendEditor pageEditor = (AbstractMultiPageTalendEditor) editor;
                    AbstractTalendEditor talendEditor = pageEditor.getTalendEditor();
                    ProcessPart processPart = talendEditor.getProcessPart();
                    processPart.ajustReadOnly();
                    changeMRGroupColor(processPart);
                }
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart)

Example 33 with AbstractMultiPageTalendEditor

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

the class DownloadComponenentsAction method selectPaletteEntry.

private void selectPaletteEntry(String componentName) {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow != null) {
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        if (activePage != null) {
            IEditorReference[] editorReferences = activePage.getEditorReferences();
            if (editorReferences != null) {
                for (IEditorReference er : editorReferences) {
                    IEditorPart part = er.getEditor(false);
                    if (part instanceof AbstractMultiPageTalendEditor) {
                        AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
                        AbstractTalendEditor talendEditor = editor.getTalendEditor();
                        try {
                            ComponentPaletteUtilities.setSkipUpdatePalette(true);
                            talendEditor.selectPaletteEntry(componentName);
                        } catch (Exception e) {
                            ExceptionHandler.process(e);
                        }
                        return;
                    }
                }
            }
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 34 with AbstractMultiPageTalendEditor

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

the class ToggleSubjobsAction method run.

@Override
public void run() {
    boolean display = isChecked();
    getGlobalStore().setValue(TalendDesignerPrefConstants.DISPLAY_SUBJOBS, display);
    IEditorReference[] editorParts = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
    for (IEditorReference reference : editorParts) {
        if (!(reference.getId().equals(MultiPageTalendEditor.ID) || reference.getId().equals(JOBLET_ID) || MAP_REDUCE_MULTIPAGE_EDITOR_ID.equals(reference.getId()) || TEST_CASE_DI_EDITOR.equals(reference.getId()))) {
            continue;
        }
        IEditorPart editorPart = reference.getEditor(false);
        if (editorPart == null) {
            continue;
        }
        if (editorPart instanceof AbstractMultiPageTalendEditor) {
            AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) editorPart;
            IProcess2 process = editor.getTalendEditor().getProcess();
            if (process == null) {
                continue;
            }
            List<? extends ISubjobContainer> subjobs = process.getSubjobContainers();
            for (ISubjobContainer subjobContainer : subjobs) {
                subjobContainer.updateSubjobDisplay();
            }
        }
    }
}
Also used : ISubjobContainer(org.talend.core.model.process.ISubjobContainer) IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IProcess2(org.talend.core.model.process.IProcess2) IEditorPart(org.eclipse.ui.IEditorPart)

Example 35 with AbstractMultiPageTalendEditor

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

the class AbstractNotePropertySection method setInput.

@Override
public void setInput(IWorkbenchPart part, ISelection selection) {
    super.setInput(part, selection);
    if (part instanceof AbstractMultiPageTalendEditor) {
        multiPageTalendEditor = (AbstractMultiPageTalendEditor) part;
    } else {
        multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    }
    if (getSelection() instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) getSelection();
        if (structuredSelection.getFirstElement() instanceof NoteEditPart) {
            NoteEditPart noteEditPart = (NoteEditPart) structuredSelection.getFirstElement();
            note = (Note) noteEditPart.getModel();
        }
    }
}
Also used : AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) NoteEditPart(org.talend.designer.core.ui.editor.notes.NoteEditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)53 IEditorPart (org.eclipse.ui.IEditorPart)26 INode (org.talend.core.model.process.INode)16 Node (org.talend.designer.core.ui.editor.nodes.Node)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)14 CommandStack (org.eclipse.gef.commands.CommandStack)13 AbstractTalendEditor (org.talend.designer.core.ui.editor.AbstractTalendEditor)12 GraphicalViewer (org.eclipse.gef.GraphicalViewer)10 IExternalNode (org.talend.core.model.process.IExternalNode)10 IProcess (org.talend.core.model.process.IProcess)10 ArrayList (java.util.ArrayList)9 List (java.util.List)8 EditPart (org.eclipse.gef.EditPart)8 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorReference (org.eclipse.ui.IEditorReference)7 PersistenceException (org.talend.commons.exception.PersistenceException)7 IProcess2 (org.talend.core.model.process.IProcess2)7 Property (org.talend.core.model.properties.Property)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 Process (org.talend.designer.core.ui.editor.process.Process)7