Search in sources :

Example 11 with RepositoryEditorInput

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

the class OpenExistVersionProcessWizard method openAnotherVersion.

protected void openAnotherVersion(final RepositoryNode node, final boolean readonly) {
    try {
        if (node.getObject() != null) {
            final Item item = node.getObject().getProperty().getItem();
            final IWorkbenchPage page = getActivePage();
            final RepositoryEditorInput fileEditorInput = getEditorInput(item, readonly, page);
            if (fileEditorInput != null) {
                IEditorPart editorPart = page.findEditor(fileEditorInput);
                if (editorPart == null) {
                    fileEditorInput.setRepositoryNode(node);
                    if (item instanceof ProcessItem) {
                        page.openEditor(fileEditorInput, MultiPageTalendEditor.ID, readonly);
                    } else if (item instanceof BusinessProcessItem) {
                        CorePlugin.getDefault().getDiagramModelService().openBusinessDiagramEditor(page, fileEditorInput);
                    } else {
                        ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
                        //$NON-NLS-1$ //$NON-NLS-2$
                        String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
                        page.openEditor(fileEditorInput, talendEditorID);
                    }
                } else {
                    page.activate(editorPart);
                }
            } else {
                // TDI-19014:open another version of jobScript
                if (item instanceof JobScriptItem) {
                    IProject fsProject = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
                    openXtextEditor(node, fsProject, readonly);
                }
            }
        }
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) JobScriptItem(org.talend.core.model.properties.JobScriptItem) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) Item(org.talend.core.model.properties.Item) JobScriptItem(org.talend.core.model.properties.JobScriptItem) RoutineItem(org.talend.core.model.properties.RoutineItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) SystemException(org.talend.commons.exception.SystemException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 12 with RepositoryEditorInput

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

the class JobLaunchShortcut method launch.

/**
     * Locates a launchable entity in the given active editor, and launches an application in the specified mode.
     * 
     * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
     * 
     * @param editor the active editor in the workbench
     * @param mode one of the launch modes defined by the launch manager
     * @see org.eclipse.debug.core.ILaunchManager
     */
@Override
public void launch(IEditorPart editor, String mode) {
    IEditorInput input = editor.getEditorInput();
    if (input instanceof RepositoryEditorInput) {
        RepositoryEditorInput rInput = (RepositoryEditorInput) input;
        launch(rInput.getItem(), mode);
    }
}
Also used : RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IEditorInput(org.eclipse.ui.IEditorInput)

Example 13 with RepositoryEditorInput

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

the class AbstractMultiPageTalendEditor method createPage2.

// create jobscript editor
protected void createPage2() {
    if (!GlobalServiceRegister.getDefault().isServiceRegistered(ICreateXtextProcessService.class)) {
        return;
    }
    String scriptValue = "";
    try {
        IProject currentProject = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
        String jobScriptVersion = "";
        if (getEditorInput() != null && getEditorInput() instanceof RepositoryEditorInput) {
            Item item = ((RepositoryEditorInput) getEditorInput()).getItem();
            if (item != null) {
                Property property = item.getProperty();
                if (property != null) {
                    jobScriptVersion = "_" + property.getVersion();
                }
            }
        }
        IFile file = currentProject.getFolder("temp").getFile(getEditorInput().getName() + jobScriptVersion + "_job" + ".jobscript");
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(scriptValue.getBytes());
        if (file.exists()) {
            file.delete(true, null);
            file.create(byteArrayInputStream, true, null);
            file.setContents(byteArrayInputStream, 0, null);
        } else {
            file.create(byteArrayInputStream, true, null);
        }
        String pointId = "org.talend.metalanguage.jobscript.JobScriptForMultipage";
        // the way to get the xtextEditor programmly
        IEditorInput editorInput = new FileEditorInput(file);
        IExtensionPoint ep = RegistryFactory.getRegistry().getExtensionPoint("org.eclipse.ui.editors");
        IExtension[] extensions = ep.getExtensions();
        IExtension ex;
        IConfigurationElement confElem = null;
        for (IExtension extension : extensions) {
            ex = extension;
            if (ex.getContributor().getName().equals("org.talend.metalanguage.jobscript.ui")) {
                for (IConfigurationElement c : ex.getConfigurationElements()) {
                    if (c.getName().equals("editor") && c.getAttribute("id").equals(pointId)) {
                        confElem = c;
                        break;
                    }
                }
            }
        }
        if (confElem != null) {
            jobletEditor = (AbstractDecoratedTextEditor) confElem.createExecutableExtension("class");
            if (jobletEditor != null) {
                int index = addPage(jobletEditor, editorInput);
                setPageText(index, "Jobscript");
            }
        }
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    }
}
Also used : RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IFile(org.eclipse.core.resources.IFile) ICreateXtextProcessService(org.talend.core.services.ICreateXtextProcessService) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IProject(org.eclipse.core.resources.IProject) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) IExtension(org.eclipse.core.runtime.IExtension) FileEditorInput(org.eclipse.ui.part.FileEditorInput) PersistenceException(org.talend.commons.exception.PersistenceException) PartInitException(org.eclipse.ui.PartInitException) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IEditorInput(org.eclipse.ui.IEditorInput)

Example 14 with RepositoryEditorInput

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

the class AbstractMultiPageTalendEditor method foundExistEditor.

private boolean foundExistEditor(final IEditorInput editorInput) {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow != null) {
        // WorkbenchPage page = (WorkbenchPage) activeWorkbenchWindow.getActivePage();
        IWorkbenchPage page = activeWorkbenchWindow.getActivePage();
        if (page != null) {
            if (editorInput instanceof RepositoryEditorInput) {
                RepositoryEditorInput curEditorInput = (RepositoryEditorInput) editorInput;
                IEditorReference[] ref = page.findEditors(curEditorInput, getEditorId(), IWorkbenchPage.MATCH_INPUT);
                return ref.length > 1;
            }
        }
    }
    return false;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IEditorReference(org.eclipse.ui.IEditorReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 15 with RepositoryEditorInput

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

the class JobletUtil method isRed.

public boolean isRed(AbstractJobletContainer jobletContainer) {
    IProcess2 jobletProcess = (IProcess2) jobletContainer.getNode().getComponent().getProcess();
    if (jobletProcess == null) {
        return false;
    }
    ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(jobletProcess.getProperty().getItem());
    if (status == ERepositoryStatus.LOCK_BY_OTHER) {
        return true;
    }
    IEditorPart[] editors = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getDirtyEditors();
    if (editors.length <= 0) {
        return false;
    }
    for (IEditorPart editor : editors) {
        if (editor.getEditorInput() instanceof RepositoryEditorInput) {
            RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
            String jobletId = editorInput.getId();
            if (jobletId.equals(jobletProcess.getId())) {
                return true;
            }
        }
    }
    return false;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IProcess2(org.talend.core.model.process.IProcess2) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

RepositoryEditorInput (org.talend.core.repository.ui.editor.RepositoryEditorInput)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)9 IFile (org.eclipse.core.resources.IFile)7 IEditorPart (org.eclipse.ui.IEditorPart)7 Item (org.talend.core.model.properties.Item)7 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)7 IEditorInput (org.eclipse.ui.IEditorInput)6 IEditorReference (org.eclipse.ui.IEditorReference)6 PartInitException (org.eclipse.ui.PartInitException)5 ICodeGeneratorService (org.talend.designer.codegen.ICodeGeneratorService)5 ECodeLanguage (org.talend.core.language.ECodeLanguage)4 CoreException (org.eclipse.core.runtime.CoreException)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)3 ProcessItem (org.talend.core.model.properties.ProcessItem)3 ISQLPatternSynchronizer (org.talend.designer.codegen.ISQLPatternSynchronizer)3 ITalendSynchronizer (org.talend.designer.codegen.ITalendSynchronizer)3 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)3 IProject (org.eclipse.core.resources.IProject)2 WizardDialog (org.eclipse.jface.wizard.WizardDialog)2