Search in sources :

Example 56 with IEditorPart

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

the class JobSettingsView method refresh.

public void refresh(boolean force, Object obj) {
    if (force) {
        cleanDisplay();
    }
    final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
    if (obj == null) {
        if (activeEditor != null && activeEditor instanceof AbstractMultiPageTalendEditor) {
            AbstractTalendEditor talendEditor = ((AbstractMultiPageTalendEditor) activeEditor).getTalendEditor();
            IProcess process = talendEditor.getProcess();
            if (process != null && process instanceof Element) {
                this.selectedPrimary = true;
                this.cleaned = force;
                this.element = (Element) process;
                // remove "Job" or "Joblet" from title
                String title = activeEditor.getTitle();
                if (title.startsWith(VIEW_NAME_JOBLET)) {
                    title = title.substring(VIEW_NAME_JOBLET.length() + 1);
                } else if (title.startsWith(getViewNameLable())) {
                    title = title.substring(getViewNameLable().length() + 1);
                }
                setElement(element, title, null);
                return;
            }
        } else {
            IDiagramModelService diagramModelService = CorePlugin.getDefault().getDiagramModelService();
            if (diagramModelService != null && diagramModelService.isBusinessDiagramEditor(activeEditor)) {
                this.selectedPrimary = true;
                this.cleaned = force;
                IRepositoryViewObject object = retrieveBusiness(activeEditor);
                if (object != null) {
                    //$NON-NLS-1$
                    String title = object.getLabel() + " " + object.getVersion();
                    Object type = object.getRepositoryObjectType();
                    setElement(activeEditor, type + SEPARATOR + title, null);
                }
                return;
            }
        }
    } else {
        this.selectedPrimary = true;
        this.cleaned = force;
        IRepositoryViewObject object = retrieveBusiness(activeEditor);
        if (object != null) {
            //$NON-NLS-1$
            String title = object.getLabel() + " " + object.getVersion();
            Object type = object.getRepositoryObjectType();
            setElement(obj, type + SEPARATOR + title, null);
        }
        return;
    }
    cleanDisplay();
}
Also used : IDiagramModelService(org.talend.designer.business.diagram.custom.IDiagramModelService) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Example 57 with IEditorPart

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

the class JobSettingsView method setElement.

/**
     *
     * DOC ggu Comment method "setElement".
     *
     * @param obj
     */
private void setElement(Object obj, final String title, Image image) {
    EComponentCategory[] categories = null;
    if (obj != null && obj instanceof Process) {
        process = (Process) obj;
        if (currentSelectedTab != null && currentSelectedTab.getData().equals(process) && !cleaned) {
            return;
        }
        categories = getCategories(process);
    } else if (obj != null && obj instanceof IRepositoryViewObject) {
        categories = getCategories(obj);
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        IProcess process = getProcess(viewObject);
        if (process != null && process instanceof Element && process.getId().equals(viewObject.getId()) && process.getVersion().equals(viewObject.getVersion())) {
            categories = getCategories(process);
        }
    } else if (obj instanceof IEditorPart) {
        if (CorePlugin.getDefault().getDiagramModelService().isBusinessDiagramEditor((IEditorPart) obj)) {
            categories = getCategories(obj);
        }
    } else {
        BusinessType type = CorePlugin.getDefault().getDiagramModelService().getBusinessModelType(obj);
        if (BusinessType.NOTE.equals(type) || BusinessType.SHAP.equals(type) || BusinessType.CONNECTION.equals(type)) {
            categories = getCategories(obj);
        } else {
            cleanDisplay();
            return;
        }
    }
    final List<TalendPropertyTabDescriptor> descriptors = new ArrayList<TalendPropertyTabDescriptor>();
    for (EComponentCategory category : categories) {
        TalendPropertyTabDescriptor d = new TalendPropertyTabDescriptor(category);
        d.setData(obj);
        descriptors.add(d);
    }
    tabFactory.setInput(descriptors);
    setPartName(title, image);
    cleaned = false;
    tabFactory.setSelection(new IStructuredSelection() {

        @Override
        public Object getFirstElement() {
            return null;
        }

        @Override
        public Iterator iterator() {
            return null;
        }

        @Override
        public int size() {
            return 0;
        }

        @Override
        public Object[] toArray() {
            return null;
        }

        @Override
        public List toList() {
            List<TalendPropertyTabDescriptor> d = new ArrayList<TalendPropertyTabDescriptor>();
            if (descriptors.size() > 0) {
                if (currentSelectedTab != null) {
                    for (TalendPropertyTabDescriptor ds : descriptors) {
                        if (ds.getCategory() == currentSelectedTab.getCategory()) {
                            d.add(ds);
                            return d;
                        }
                    }
                }
                d.add(descriptors.get(0));
            }
            return d;
        }

        @Override
        public boolean isEmpty() {
            return false;
        }
    });
}
Also used : Element(org.talend.core.model.process.Element) BusinessType(org.talend.core.model.business.BusinessType) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IEditorPart(org.eclipse.ui.IEditorPart) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Iterator(java.util.Iterator) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) EComponentCategory(org.talend.core.model.process.EComponentCategory)

Example 58 with IEditorPart

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

the class SaveJobBeforeRunAction method run.

@Override
public void run() {
    List<? extends INode> nodes = activeProcess.getGraphicalNodes();
    if (nodes.isEmpty()) {
        return;
    }
    IEditorPart part = null;
    if (activeProcess instanceof IProcess2) {
        // save the editor directly.
        part = ((IProcess2) activeProcess).getEditor();
    } else {
        // try to save current active editor
        part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    }
    if (part != null && part.isDirty()) {
        if (part != null && part instanceof AbstractMultiPageTalendEditor) {
            AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
            editor.doSave(new NullProgressMonitor());
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IProcess2(org.talend.core.model.process.IProcess2) IEditorPart(org.eclipse.ui.IEditorPart)

Example 59 with IEditorPart

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

the class RunProcessShortcutAction method run.

public void run() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
    IEditorPart activeEditor = page.getActiveEditor();
    if (CorePlugin.getDefault().getDesignerCoreService().isTalendEditor(activeEditor)) {
        JobLaunchShortcutManager.run(activeEditor);
    } else {
        new RunProcessAction().run();
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

Example 60 with IEditorPart

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

the class TalendImportUtil method openJobs.

private static void openJobs(List<IRepositoryNode> nodes) {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    for (IRepositoryNode node : nodes) {
        Property property = node.getObject().getProperty();
        if (property != null) {
            Item item = property.getItem();
            if (!(item instanceof ProcessItem)) {
                continue;
            }
            try {
                ProcessItem processItem = (ProcessItem) item;
                final JobEditorInput fileEditorInput = getEditorInput(processItem);
                // checkUnLoadedNodeForProcess(fileEditorInput);
                final IEditorPart editorPart = page.findEditor(fileEditorInput);
                if (editorPart == null) {
                    fileEditorInput.setRepositoryNode(node);
                    page.openEditor(fileEditorInput, getEditorId(), true);
                } else {
                    ((AbstractMultiPageTalendEditor) editorPart).setReadOnly(fileEditorInput.setForceReadOnly(false));
                    page.activate(editorPart);
                }
            } catch (Throwable e) {
                CommonExceptionHandler.process(e);
            }
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ProcessItem(org.talend.core.model.properties.ProcessItem) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) Property(org.talend.core.model.properties.Property)

Aggregations

IEditorPart (org.eclipse.ui.IEditorPart)401 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)137 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)127 PartInitException (org.eclipse.ui.PartInitException)73 IFile (org.eclipse.core.resources.IFile)58 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)53 IEditorReference (org.eclipse.ui.IEditorReference)52 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)45 ArrayList (java.util.ArrayList)43 QueryEditorPart (com.cubrid.common.ui.query.editor.QueryEditorPart)41 IEditorInput (org.eclipse.ui.IEditorInput)37 IViewPart (org.eclipse.ui.IViewPart)34 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)33 Test (org.junit.Test)31 ISelection (org.eclipse.jface.viewers.ISelection)30 FileEditorInput (org.eclipse.ui.part.FileEditorInput)29 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)27 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)26 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)26 IXliffEditor (net.heartsome.cat.ts.ui.editors.IXliffEditor)24