Search in sources :

Example 11 with ProcessEditorInput

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

the class SaveAsProcessAction method run.

@Override
public void run() {
    SaveAsProcessWizard processWizard = new SaveAsProcessWizard(editorPart);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
    if (dlg.open() == Window.OK) {
        try {
            // Set readonly to false since created job will always be editable.
            JobEditorInput newJobEditorInput = new ProcessEditorInput(processWizard.getProcess(), true, true, false);
            IWorkbenchPage page = getActivePage();
            IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(newJobEditorInput.getItem().getProperty().getId(), false);
            newJobEditorInput.setRepositoryNode(repositoryNode);
            // close the old editor
            page.closeEditor(((AbstractTalendEditor) this.editorPart).getParent(), false);
            // open the new editor, because at the same time, there will update the jobSetting/componentSetting view
            page.openEditor(newJobEditorInput, MultiPageTalendEditor.ID, true);
        } catch (Exception e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Job could not be saved" + " : " + e.getMessage());
            ExceptionHandler.process(e);
        }
    }
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IRepositoryNode(org.talend.repository.model.IRepositoryNode) SaveAsProcessWizard(org.talend.designer.core.ui.wizards.SaveAsProcessWizard) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 12 with ProcessEditorInput

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

the class DesignerCoreService method getProcessItem.

@Override
public Item getProcessItem(MultiPageEditorPart talendEditor) {
    ProcessEditorInput processEditorInput = (ProcessEditorInput) talendEditor.getEditorInput();
    Item item = processEditorInput.getItem();
    return item;
}
Also used : Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 13 with ProcessEditorInput

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

the class JobLaunchConfigurationDelegate method findProcessFromRepository.

/**
     * DOC bqian Comment method "findProcessFromRepository".
     * 
     * @param jobName
     * @return
     */
private IProcess2 findProcessFromRepository(String jobId, String version) {
    try {
        ItemCacheManager.clearCache();
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId, version);
        if (processItem != null) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
                IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
                IProcess process = service.getProcessFromItem(processItem);
                if (process instanceof IProcess2) {
                    return (IProcess2) process;
                }
            }
            // keep old code for now, but it should never be called.
            ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true, true, true);
            IProcess2 process = fileEditorInput.getLoadedProcess();
            return process;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return null;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) CoreException(org.eclipse.core.runtime.CoreException) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 14 with ProcessEditorInput

use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tmdm-studio-se by Talend.

the class NewProcessAction method closeEditor.

private void closeEditor(String processName) {
    IWorkbenchPage activePage = getActivePage();
    IEditorReference[] editorRef = activePage.getEditorReferences();
    for (IEditorReference ref : editorRef) {
        IEditorInput editorInput = ref.getEditor(false).getEditorInput();
        if (editorInput instanceof ProcessEditorInput) {
            ProcessEditorInput processInput = (ProcessEditorInput) editorInput;
            ProcessItem jobItem = (ProcessItem) processInput.getItem();
            if (jobItem.getProperty().getLabel().equals(processName)) {
                activePage.closeEditors(new IEditorReference[] { ref }, false);
                IRepositoryViewObject jobViewObject = RepositoryResourceUtil.findViewObjectByName(ERepositoryObjectType.PROCESS, processName);
                if (jobViewObject != null) {
                    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
                    try {
                        factory.deleteObjectPhysical(jobViewObject);
                    } catch (PersistenceException e) {
                        log.error(e.getMessage(), e);
                    }
                }
                break;
            }
        }
    }
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorInput(org.eclipse.ui.IEditorInput) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 15 with ProcessEditorInput

use of org.talend.designer.core.ui.editor.ProcessEditorInput in project tmdm-studio-se by Talend.

the class LockedDirtyObjectDialog method isDirtyMdmViewObj.

private boolean isDirtyMdmViewObj(List<IRepositoryViewObject> inputObjs, IRepositoryViewObject viewObj) {
    if (editorRefMap == null) {
        editorRefMap = new HashMap<String, IEditorPart>();
        // collect all ids
        Set<String> ids = new HashSet<String>();
        for (IRepositoryViewObject viewObject : inputObjs) {
            String id = viewObject.getId();
            if (id != null) {
                ids.add(id);
            }
        }
        // 
        if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
            IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
            for (IEditorReference ref : activePage.getEditorReferences()) {
                try {
                    String id = null;
                    IEditorInput editorInput = ref.getEditorInput();
                    if (editorInput instanceof IRepositoryViewEditorInput) {
                        IRepositoryViewObject viewObject = ((IRepositoryViewEditorInput) editorInput).getViewObject();
                        if (viewObject != null) {
                            id = viewObject.getId();
                        }
                    } else if (editorInput instanceof ProcessEditorInput) {
                        id = ((ProcessEditorInput) editorInput).getId();
                    }
                    if (id != null && ids.contains(id)) {
                        IEditorPart editor = ref.getEditor(false);
                        if (editor != null && editor.isDirty()) {
                            editorRefMap.put(id, editor);
                        }
                    }
                } catch (PartInitException e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    }
    return editorRefMap.containsKey(viewObj.getId());
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) IRepositoryViewEditorInput(org.talend.mdm.repository.ui.editors.IRepositoryViewEditorInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) HashSet(java.util.HashSet) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Aggregations

ProcessEditorInput (org.talend.designer.core.ui.editor.ProcessEditorInput)15 ProcessItem (org.talend.core.model.properties.ProcessItem)8 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 PartInitException (org.eclipse.ui.PartInitException)6 PersistenceException (org.talend.commons.exception.PersistenceException)6 IEditorInput (org.eclipse.ui.IEditorInput)5 IEditorPart (org.eclipse.ui.IEditorPart)5 IEditorReference (org.eclipse.ui.IEditorReference)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 IFile (org.eclipse.core.resources.IFile)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)2 Item (org.talend.core.model.properties.Item)2 Property (org.talend.core.model.properties.Property)2 Node (org.talend.designer.core.ui.editor.nodes.Node)2 IRepositoryNode (org.talend.repository.model.IRepositoryNode)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1