Search in sources :

Example 6 with IEditorReference

use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.

the class ProblemsView method selectInDesigner.

private void selectInDesigner(BasicJobInfo jobInfo, String nodeName) {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorReference[] editorParts = page.getEditorReferences();
    for (IEditorReference reference : editorParts) {
        IEditorPart editor = reference.getEditor(false);
        if (editor instanceof AbstractMultiPageTalendEditor) {
            AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) editor;
            if (mpte.getTalendEditor().getProcess().getId().equals(jobInfo.getJobId()) && mpte.getTalendEditor().getProcess().getVersion().equals(jobInfo.getJobVersion())) {
                page.bringToTop(mpte);
                mpte.selectNode(nodeName);
            }
        }
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 7 with IEditorReference

use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method updateRunJobContext.

protected void updateRunJobContext() {
    final JobContextManager manager = (JobContextManager) getProcess().getContextManager();
    if (manager.isModified()) {
        final Map<String, String> nameMap = manager.getNameMap();
        // gcui:add a progressDialog.
        Shell shell = null;
        Display display = PlatformUI.getWorkbench().getDisplay();
        if (display != null) {
            shell = display.getActiveShell();
        }
        if (shell == null) {
            display = Display.getCurrent();
            if (display == null) {
                display = Display.getDefault();
            }
            if (display != null) {
                shell = display.getActiveShell();
            }
        }
        ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            @Override
            public void run(final IProgressMonitor monitor) {
                //$NON-NLS-1$
                monitor.beginTask(Messages.getString("AbstractMultiPageTalendEditor_pleaseWait"), IProgressMonitor.UNKNOWN);
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
                        factory.executeRepositoryWorkUnit(new //$NON-NLS-1$
                        RepositoryWorkUnit<Object>(//$NON-NLS-1$
                        "..", //$NON-NLS-1$
                        this) {

                            @Override
                            protected void run() throws LoginException, PersistenceException {
                                try {
                                    IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
                                    Set<String> curContextVars = getCurrentContextVariables(manager);
                                    IProcess2 process2 = getProcess();
                                    String jobId = process2.getProperty().getId();
                                    IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
                                    List<IProcess2> processes = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
                                    // gcui:if nameMap is empty it do nothing.
                                    if (!nameMap.isEmpty()) {
                                        UpdateRunJobComponentContextHelper.updateItemRunJobComponentReference(factory, nameMap, jobId, curContextVars);
                                        UpdateRunJobComponentContextHelper.updateOpenedJobRunJobComponentReference(processes, nameMap, jobId, curContextVars);
                                    }
                                    // add for bug 9564
                                    List<IRepositoryViewObject> all = factory.getAll(ERepositoryObjectType.PROCESS, true);
                                    List<ProcessItem> allProcess = new ArrayList<ProcessItem>();
                                    for (IRepositoryViewObject repositoryObject : all) {
                                        Item item = repositoryObject.getProperty().getItem();
                                        if (item instanceof ProcessItem) {
                                            ProcessItem processItem = (ProcessItem) item;
                                            allProcess.add(processItem);
                                        }
                                    }
                                    UpdateRunJobComponentContextHelper.updateRefJobRunJobComponentContext(factory, allProcess, process2);
                                } catch (PersistenceException e) {
                                    // e.printStackTrace();
                                    ExceptionHandler.process(e);
                                }
                                manager.setModified(false);
                            }
                        });
                    }
                });
                monitor.done();
                if (monitor.isCanceled()) {
                    try {
                        //$NON-NLS-1$
                        throw new InterruptedException("Save Fail");
                    } catch (InterruptedException e) {
                        ExceptionHandler.process(e);
                    }
                }
            }
        };
        try {
            progressDialog.run(true, true, runnable);
        } catch (InvocationTargetException e1) {
            ExceptionHandler.process(e1);
        } catch (InterruptedException e1) {
            ExceptionHandler.process(e1);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) Shell(org.eclipse.swt.widgets.Shell) IEditorReference(org.eclipse.ui.IEditorReference) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) JobContextManager(org.talend.core.model.context.JobContextManager) Display(org.eclipse.swt.widgets.Display)

Example 8 with IEditorReference

use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.

the class ActiveProcessTracker method partOpened.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
     */
@Override
public void partOpened(IWorkbenchPart part) {
    boolean existedJobOpened = false;
    if (part instanceof AbstractMultiPageTalendEditor) {
        AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
        if (mpte.isJobAlreadyOpened()) {
            mpte.updateChildrens();
            // close the first editor and keep the new one. (so only one will remain)
            IEditorReference[] ref = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findEditors(mpte.getEditorInput(), mpte.getEditorId(), IWorkbenchPage.MATCH_INPUT);
            IEditorPart editorPart = ref[0].getEditor(false);
            editorPart.doSave(new NullProgressMonitor());
            ((AbstractMultiPageTalendEditor) editorPart).setKeepPropertyLocked(true);
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editorPart, false);
            existedJobOpened = true;
        }
    } else {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class)) {
            CorePlugin.getDefault().getDiagramModelService().handleNewEditorAction(part);
        }
    }
    IProcess2 process = getJobFromActivatedEditor(part);
    if (part instanceof AbstractMultiPageTalendEditor && process instanceof Process) {
        ((Process) process).setEditor((AbstractMultiPageTalendEditor) part);
    }
    if (process != null && currentProcess != process && lastProcessOpened != process) {
        lastProcessOpened = process;
        addJobInProblemView(process);
    } else if (existedJobOpened) {
        currentProcess = process;
        for (IJobTrackerListener listener : jobTrackerListeners) {
            listener.focusOnJob(process);
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IEditorReference(org.eclipse.ui.IEditorReference) IProcess2(org.talend.core.model.process.IProcess2) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IEditorPart(org.eclipse.ui.IEditorPart)

Example 9 with IEditorReference

use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.

the class EditPropertiesAction method getCorrespondingEditor.

/**
     * Find the editor that is related to the node.
     * 
     * @param node
     * @return
     */
protected IEditorPart getCorrespondingEditor(final IRepositoryNode node) {
    IEditorReference[] eidtors = getActivePage().getEditorReferences();
    for (IEditorReference eidtor : eidtors) {
        try {
            IEditorInput input = eidtor.getEditorInput();
            if (!(input instanceof RepositoryEditorInput)) {
                continue;
            }
            RepositoryEditorInput repositoryInput = (RepositoryEditorInput) input;
            if (node.getId() != null && node.getId().equals(repositoryInput.getId())) {
                IPath path = repositoryInput.getFile().getLocation();
                return eidtor.getEditor(false);
            }
        } catch (PartInitException e) {
            continue;
        }
    }
    return null;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IPath(org.eclipse.core.runtime.IPath) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput)

Example 10 with IEditorReference

use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.

the class DesignerCoreService method refreshComponentView.

@Override
public void refreshComponentView(Item item) {
    try {
        IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        IEditorReference[] editors = activePage.getEditorReferences();
        for (IEditorReference er : editors) {
            IEditorPart part = er.getEditor(false);
            if (part instanceof AbstractMultiPageTalendEditor) {
                AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
                CommandStack stack = (CommandStack) editor.getTalendEditor().getAdapter(CommandStack.class);
                if (stack != null) {
                    IProcess process = editor.getProcess();
                    for (final INode processNode : process.getGraphicalNodes()) {
                        if (processNode instanceof Node) {
                            checkRepository((Node) processNode, item, stack);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommandStack(org.eclipse.gef.commands.CommandStack) INode(org.talend.core.model.process.INode) IEditorReference(org.eclipse.ui.IEditorReference) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) DataNode(org.talend.designer.core.model.process.DataNode) ConvertRepositoryNodeToProcessNode(org.talend.designer.core.ui.editor.process.ConvertRepositoryNodeToProcessNode) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess) JavaModelException(org.eclipse.jdt.core.JavaModelException) ProcessorException(org.talend.designer.runprocess.ProcessorException)

Aggregations

IEditorReference (org.eclipse.ui.IEditorReference)174 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)83 IEditorPart (org.eclipse.ui.IEditorPart)78 PartInitException (org.eclipse.ui.PartInitException)59 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)55 IFile (org.eclipse.core.resources.IFile)50 IEditorInput (org.eclipse.ui.IEditorInput)49 ArrayList (java.util.ArrayList)34 FileEditorInput (org.eclipse.ui.part.FileEditorInput)28 Item (org.talend.core.model.properties.Item)17 IWorkbench (org.eclipse.ui.IWorkbench)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 IOException (java.io.IOException)12 CoreException (org.eclipse.core.runtime.CoreException)12 ProcessItem (org.talend.core.model.properties.ProcessItem)11 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)10 Path (org.eclipse.core.runtime.Path)10 IProcess2 (org.talend.core.model.process.IProcess2)10