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);
}
}
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);
}
}
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);
}
}
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;
}
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;
}
Aggregations