Search in sources :

Example 6 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 7 with ProcessEditorInput

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

the class CreateProcess method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    final NewProcessWizard processWizard;
    if (isToolbar()) {
        processWizard = new NewProcessWizard(null);
    } else {
        ISelection selection = getSelection();
        if (selection == null) {
            return;
        }
        Object obj = ((IStructuredSelection) selection).getFirstElement();
        IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
        IPath path = service.getRepositoryPath((IRepositoryNode) obj);
        if (RepositoryConstants.isSystemFolder(path.toString())) {
            // Not allowed to create in system folder.
            return;
        }
        processWizard = new NewProcessWizard(path);
    }
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
    if (dlg.open() == Window.OK) {
        if (processWizard.getProcess() == null) {
            return;
        }
        ProcessEditorInput fileEditorInput;
        try {
            // Set readonly to false since created job will always be editable.
            fileEditorInput = new ProcessEditorInput(processWizard.getProcess(), false, true, false);
            IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(fileEditorInput.getItem().getProperty().getId(), false);
            fileEditorInput.setRepositoryNode(repositoryNode);
            IWorkbenchPage page = getActivePage();
            page.openEditor(fileEditorInput, MultiPageTalendEditor.ID, true);
        // // use project setting true
        // ProjectSettingManager.defaultUseProjectSetting(fileEditorInput.getLoadedProcess());
        } catch (PartInitException e) {
            // TODO Auto-generated catch block
            ExceptionHandler.process(e);
        } catch (PersistenceException e) {
            MessageBoxExceptionHandler.process(e);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NewProcessWizard(org.talend.designer.core.ui.wizards.NewProcessWizard) ISelection(org.eclipse.jface.viewers.ISelection) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IRepositoryService(org.talend.repository.model.IRepositoryService) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 8 with ProcessEditorInput

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

the class ReadProcess method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    ISelection selection = getSelection();
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    RepositoryNode node = (RepositoryNode) obj;
    ProcessItem processItem = (ProcessItem) node.getObject().getProperty().getItem();
    IWorkbenchPage page = getActivePage();
    try {
        ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true, null, true);
        checkUnLoadedNodeForProcess(fileEditorInput);
        IEditorPart editorPart = page.findEditor(fileEditorInput);
        if (editorPart == null) {
            fileEditorInput.setRepositoryNode(node);
            page.openEditor(fileEditorInput, MultiPageTalendEditor.ID, true);
        } else {
            page.activate(editorPart);
        }
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (PersistenceException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) ISelection(org.eclipse.jface.viewers.ISelection) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) RepositoryNode(org.talend.repository.model.RepositoryNode) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Example 9 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)

Aggregations

ProcessEditorInput (org.talend.designer.core.ui.editor.ProcessEditorInput)9 ProcessItem (org.talend.core.model.properties.ProcessItem)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 PartInitException (org.eclipse.ui.PartInitException)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 IEditorPart (org.eclipse.ui.IEditorPart)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 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 Node (org.talend.designer.core.ui.editor.nodes.Node)2 RepositoryNode (org.talend.repository.model.RepositoryNode)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 Point (org.eclipse.draw2d.geometry.Point)1 CompoundSnapToHelper (org.eclipse.gef.CompoundSnapToHelper)1 RootEditPart (org.eclipse.gef.RootEditPart)1