Search in sources :

Example 51 with IEditorPart

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

the class SaveJobBeforeRunAction method run.

public void run() {
    boolean saveMyself = false;
    List<? extends INode> nodes = filterTRunJobNode();
    if (nodes.isEmpty()) {
        return;
    }
    IEditorReference[] references = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
    for (int i = 0; i < references.length; i++) {
        IEditorPart part = references[i].getEditor(false);
        if (!(part instanceof MultiPageTalendEditor)) {
            continue;
        }
        MultiPageTalendEditor editor = (MultiPageTalendEditor) part;
        saveJob(nodes, editor);
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) MultiPageTalendEditor(org.talend.designer.core.ui.MultiPageTalendEditor) IEditorPart(org.eclipse.ui.IEditorPart)

Example 52 with IEditorPart

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

the class OpentRunJobComponentAction method run.

@Override
public void run() {
    List selection = getSelectedObjects();
    Object input = selection.get(0);
    if (input instanceof NodePart) {
        NodePart part = (NodePart) input;
        Node node = (Node) part.getModel();
        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());
        if (processName != null && !"".equals(processName)) {
            //$NON-NLS-1$
            try {
                ItemCacheManager.clearCache();
                ProcessItem processItem = ItemCacheManager.getProcessItem(processName, version);
                if (processItem != null) {
                    ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true);
                    IEditorPart editorPart = page.findEditor(fileEditorInput);
                    if (editorPart == null) {
                        ERepositoryObjectType repObjType = ERepositoryObjectType.getItemType(processItem);
                        IJobEditorHandler editorInputFactory = JobEditorHandlerManager.getInstance().extractEditorInputFactory(repObjType.getType());
                        editorInputFactory.openJobEditor(editorInputFactory.createJobEditorInput(processItem, true));
                    } else {
                        page.activate(editorPart);
                    }
                }
            } catch (PartInitException e) {
                MessageBoxExceptionHandler.process(e);
            } catch (PersistenceException e) {
                MessageBoxExceptionHandler.process(e);
            }
        } else {
            try {
                // modified for feature 2454.
                page.showView(ComponentSettingsView.ID);
            } catch (PartInitException e) {
                ExceptionHandler.process(e);
            }
        }
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) IEditorPart(org.eclipse.ui.IEditorPart) IJobEditorHandler(org.talend.core.ui.editor.IJobEditorHandler) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) ProcessItem(org.talend.core.model.properties.ProcessItem) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) List(java.util.List) PartInitException(org.eclipse.ui.PartInitException) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 53 with IEditorPart

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

the class JobSettingsView method getProcess.

private IProcess getProcess(IRepositoryViewObject viewObject) {
    boolean isOpen = RepositoryManager.isOpenedItemInEditor(viewObject);
    if (isOpen) {
        final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
        if (activeEditor != null && activeEditor instanceof AbstractMultiPageTalendEditor) {
            AbstractTalendEditor talendEditor = ((AbstractMultiPageTalendEditor) activeEditor).getTalendEditor();
            IProcess process = talendEditor.getProcess();
            return process;
        }
    }
    return null;
}
Also used : AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) AbstractTalendEditor(org.talend.designer.core.ui.editor.AbstractTalendEditor) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Example 54 with IEditorPart

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

the class JobSettingsView method getCategories.

/**
     * set the category.
     */
private EComponentCategory[] getCategories(Object obj) {
    List<EComponentCategory> category = new ArrayList<EComponentCategory>();
    boolean isOfflineMode = CorePlugin.getDefault().getProxyRepositoryFactory().getRepositoryContext().isOffline();
    if (obj instanceof Process) {
        Process process = (Process) obj;
        category.add(EComponentCategory.MAIN);
        boolean isJoblet = AbstractProcessProvider.isExtensionProcessForJoblet(process);
        if (process.getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
            category.add(EComponentCategory.EXTRA);
        }
        if (!isJoblet && process.getComponentsType().equals(ComponentCategory.CATEGORY_4_DI.getName())) {
            category.add(EComponentCategory.STATSANDLOGS);
        }
        if (allowVerchange) {
            category.add(EComponentCategory.VERSIONS);
        }
        if (!isJoblet && !ProcessUtils.isTestContainer(process) && ERepositoryObjectType.getItemType(process.getProperty().getItem()) != ERepositoryObjectType.PROCESS_ROUTELET) {
            category.add(EComponentCategory.DEPLOYMENT);
        }
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IHeaderFooterProviderService.class)) {
            IHeaderFooterProviderService headerFooterService = (IHeaderFooterProviderService) GlobalServiceRegister.getDefault().getService(IHeaderFooterProviderService.class);
            if (headerFooterService.isVisible()) {
                category.add(EComponentCategory.HEADERFOOTER);
            }
        }
        // if svn remote connection, added by nma
        if (svnService != null && svnService.isProjectInSvnMode() && !isOfflineMode) {
            category.add(EComponentCategory.SVNHISTORY);
        }
        if (gitService != null && gitService.isProjectInGitMode() && !isOfflineMode) {
            category.add(EComponentCategory.GITHISTORY);
        }
    } else if (obj instanceof IRepositoryViewObject) {
        category.add(EComponentCategory.MAIN);
        if (allowVerchange) {
            category.add(EComponentCategory.VERSIONS);
        }
        if (svnService != null && svnService.isProjectInSvnMode() && !isOfflineMode && (((IRepositoryViewObject) obj).getRepositoryObjectType() == ERepositoryObjectType.JOBLET || ERepositoryObjectType.getAllTypesOfProcess().contains(((IRepositoryViewObject) obj).getRepositoryObjectType()))) {
            category.add(EComponentCategory.SVNHISTORY);
        } else if (gitService != null && gitService.isProjectInGitMode() && !isOfflineMode && (((IRepositoryViewObject) obj).getRepositoryObjectType() == ERepositoryObjectType.JOBLET || ERepositoryObjectType.getAllTypesOfProcess().contains(((IRepositoryViewObject) obj).getRepositoryObjectType()))) {
            category.add(EComponentCategory.GITHISTORY);
        }
    } else if (obj instanceof IEditorPart) {
        if (CorePlugin.getDefault().getDiagramModelService().isBusinessDiagramEditor((IEditorPart) obj)) {
            category.add(EComponentCategory.MAIN);
            category.add(EComponentCategory.APPEARANCE);
            category.add(EComponentCategory.RULERS_AND_GRID);
            if (allowVerchange) {
                category.add(EComponentCategory.VERSIONS);
            }
        }
    } else {
        BusinessType type = CorePlugin.getDefault().getDiagramModelService().getBusinessModelType(obj);
        if (BusinessType.SHAP.equals(type) || BusinessType.CONNECTION.equals(type)) {
            category.add(EComponentCategory.APPEARANCE);
            category.add(EComponentCategory.ASSIGNMENT);
        } else if (BusinessType.NOTE.equals(type)) {
            category.add(EComponentCategory.APPEARANCE);
        }
    }
    return category.toArray(new EComponentCategory[0]);
}
Also used : IHeaderFooterProviderService(org.talend.core.ui.IHeaderFooterProviderService) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessType(org.talend.core.model.business.BusinessType) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) IEditorPart(org.eclipse.ui.IEditorPart) EComponentCategory(org.talend.core.model.process.EComponentCategory)

Example 55 with IEditorPart

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

the class JobSettingsView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    // tabFactory = new HorizontalTabFactory();
    this.parent = parent;
    tabFactory.initComposite(parent, false);
    tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
            if (descriptor == null) {
                return;
            }
            if (currentSelectedTab != null) {
                if ((!currentSelectedTab.getData().equals(descriptor.getData()) || currentSelectedTab.getData() != descriptor.getData() || currentSelectedTab.getCategory() != descriptor.getCategory())) {
                    for (Control curControl : tabFactory.getTabComposite().getChildren()) {
                        curControl.dispose();
                    }
                }
            }
            if (element == null || !element.equals(descriptor.getData()) || currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
                Object data = descriptor.getData();
                if (data instanceof Element) {
                    element = (Element) data;
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), element, descriptor.getCategory());
                } else if (data instanceof IRepositoryViewObject) {
                    IRepositoryViewObject viewObject = (IRepositoryViewObject) data;
                    IProcess process = getProcess(viewObject);
                    if (process != null && process instanceof Element && process.getId().equals(viewObject.getId()) && process.getVersion().equals(viewObject.getVersion())) {
                        data = process;
                    }
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), data, descriptor.getCategory());
                } else if (data instanceof IEditorPart) {
                    currentSelectedTab = descriptor;
                    IRepositoryViewObject repObj = retrieveBusiness((IEditorPart) data);
                    if (repObj != null) {
                        IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), repObj, descriptor.getCategory());
                    }
                } else {
                    currentSelectedTab = descriptor;
                    IDynamicProperty propertyComposite = createTabComposite(tabFactory.getTabComposite(), null, descriptor.getCategory());
                }
                selectedPrimary = false;
            }
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Element(org.talend.core.model.process.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) EmptyRepositoryObject(org.talend.core.model.repository.EmptyRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

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