use of org.talend.core.ui.services.IOpenJobScriptActionService in project tdi-studio-se by Talend.
the class OpenExistVersionProcessWizard method openXtextEditor.
private void openXtextEditor(RepositoryNode repositoryNode, IProject fsProject, boolean readonly) {
try {
if (ProjectManager.getInstance().isInCurrentMainProject(repositoryNode)) {
IFile linkedFile = null;
IOpenJobScriptActionService openJobScriptActionService = (IOpenJobScriptActionService) GlobalServiceRegister.getDefault().getService(IOpenJobScriptActionService.class);
if (openJobScriptActionService != null) {
linkedFile = openJobScriptActionService.createWorkspaceLink(fsProject, repositoryNode.getObject().getProperty().getItem());
} else {
linkedFile = createWorkspaceLink(fsProject, fsProject.getFolder(ERepositoryObjectType.getFolderName(ERepositoryObjectType.JOB_SCRIPT)).getFolder(repositoryNode.getParent().getRepositoryPath()).getFile(repositoryNode.getObject().getProperty().getLabel()).getLocation(), repositoryNode.getObject().getProperty().getVersion());
}
IWorkbenchPage page = getActivePage();
IEditorPart editor = IDE.openEditor(page, linkedFile);
if (readonly) {
IDocumentProvider provider = ((AbstractDecoratedTextEditor) editor).getDocumentProvider();
Class p = provider.getClass();
Class[] type = new Class[1];
type[0] = Boolean.TYPE;
Object[] para = new Object[1];
para[0] = Boolean.TRUE;
Method method = p.getMethod("setReadOnly", type);
method.invoke(provider, para);
}
} else {
JobScriptItem jobScriptItem = (JobScriptItem) repositoryNode.getObject().getProperty().getItem();
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(jobScriptItem.eResource().getURI().path()).removeFirstSegments(1).removeFileExtension());
IFile linkedFile = createWorkspaceLink(fsProject, file.getLocation(), "");
IWorkbenchPage page = getActivePage();
IEditorPart editor = IDE.openEditor(page, linkedFile);
if (readonly) {
IDocumentProvider provider = ((AbstractDecoratedTextEditor) editor).getDocumentProvider();
Class p = provider.getClass();
Class[] type = new Class[1];
type[0] = Boolean.TYPE;
Object[] para = new Object[1];
para[0] = Boolean.TRUE;
Method method = p.getMethod("setReadOnly", type);
method.invoke(provider, para);
}
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (SecurityException e) {
ExceptionHandler.process(e);
} catch (NoSuchMethodException e) {
ExceptionHandler.process(e);
} catch (IllegalArgumentException e) {
ExceptionHandler.process(e);
} catch (IllegalAccessException e) {
ExceptionHandler.process(e);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
}
}
Aggregations