@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbench workbench = PlatformUI.getWorkbench(); if (workbench==null){ return null; } IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); if (activeWorkbenchWindow==null){ return null; } IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); if (activePage==null){ return null; } IEditorPart editor = activePage.getActiveEditor(); if (editor instanceof BashEditor){ executeOnBashEditor((BashEditor) editor); } return null; }
/** * Obtains or opens {@link XtextEditor} for provided {@link Resource} and editor id. Upon activation or opening of * the editor waits a moment for editor to become active. * * @param uri * URI to be opened * @param editorExtensionID * {String} defining the id of the editor extension to use * @return {@link Optional} instance of {@link XtextEditor} for given {@link Resource}. */ public static final Optional<XtextEditor> openXtextEditor(URI uri, String editorExtensionID) { String platformStr = uri.toString().replace("platform:/resource/", ""); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformStr)); Optional<IWorkbenchPage> page = getActivePage(); Optional<IEditorPart> internalFileEditor = getFileEditor(file, page.get(), editorExtensionID); if ((page.isPresent() && internalFileEditor.isPresent()) == false) { logger.warn("Cannot obtain editor components for " + file.getRawLocationURI()); return Optional.empty(); } IEditorPart ieditorPart = internalFileEditor.get(); if (ieditorPart instanceof XtextEditor == false) { logger.warn("cannot obtain Xtext editor for file " + file.getRawLocation()); return Optional.empty(); } waitForEditorToBeActive(ieditorPart, page.get()); return Optional.ofNullable((XtextEditor) ieditorPart); }
@Override public void resourceChanged(IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.PRE_CLOSE) { Display.getDefault().asyncExec(new Runnable() { public void run() { IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages(); for (int i = 0; i < pages.length; i++) { if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) { IEditorPart editorPart = pages[i].findEditor(getEditorInput()); pages[i].closeEditor(editorPart, true); } } } }); } }
/** * * Called by web socket server, message contain execution tracking status that updated on job canvas. * * @param message the message * @param session the session */ @OnMessage public void updateJobTrackingStatus(String message, Session session) { final String status = message; Display.getDefault().asyncExec(new Runnable() { public void run() { Gson gson = new Gson(); ExecutionStatus executionStatus=gson.fromJson(status, ExecutionStatus.class); IWorkbenchPage page = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage(); IEditorReference[] refs = page.getEditorReferences(); for (IEditorReference ref : refs){ IEditorPart editor = ref.getEditor(false); if(editor instanceof ELTGraphicalEditor){ ELTGraphicalEditor editPart=(ELTGraphicalEditor)editor; if(editPart.getJobId().equals(executionStatus.getJobId()) || (((editPart.getContainer()!=null) && (editPart.getContainer().getUniqueJobId().equals(executionStatus.getJobId()))) && editPart.getContainer().isOpenedForTracking() )){ TrackingStatusUpdateUtils.INSTANCE.updateEditorWithCompStatus(executionStatus, (ELTGraphicalEditor)editor,false); } } } } }); }
private void tryValidateManifestInEditor(final IResourceDelta delta) { if (isWorkbenchRunning()) { Display.getDefault().asyncExec(() -> { final IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow(); if (null != window) { final IWorkbenchPage page = window.getActivePage(); for (final IEditorReference editorRef : page.getEditorReferences()) { if (isEditorForResource(editorRef, delta.getResource())) { final IWorkbenchPart part = editorRef.getPart(true); if (part instanceof XtextEditor) { editorCallback.afterSave((XtextEditor) part); return; } } } } }); } }
public static void notifyDbChanged(DbInfo dbinfo) { String action = Activator.getDefault().getPreferenceStore().getString(PG_EDIT_PREF.EDITOR_UPDATE_ACTION); if (action.equals(PG_EDIT_PREF.NO_ACTION)) { return; } for (IWorkbenchWindow wnd : PlatformUI.getWorkbench().getWorkbenchWindows()) { for (IWorkbenchPage page : wnd.getPages()) { for (IEditorReference ref : page.getEditorReferences()) { IEditorPart ed = ref.getEditor(false); if (ed instanceof ProjectEditorDiffer) { notifyDbChanged(dbinfo, (ProjectEditorDiffer) ed, action.equals(PG_EDIT_PREF.UPDATE)); } } } } }
/** * Obtains all editors that are currently opened. * @return the collection of the opened editors */ public static List<IEditorPart> getEditors() { List<IEditorPart> editors = new ArrayList<IEditorPart>(); IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); for (IWorkbenchWindow window : windows) { IWorkbenchPage[] pages = window.getPages(); for (IWorkbenchPage page : pages) { IEditorReference[] refs = page.getEditorReferences(); for (IEditorReference ref : refs) { IEditorPart part = ref.getEditor(false); if (part != null) { editors.add(part); } } } } return editors; }
/** * Closes all project files on project close. */ public void resourceChanged(final IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.PRE_CLOSE) { Display.getDefault().asyncExec(new Runnable() { public void run() { IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages(); for (int i = 0; i < pages.length; i++) { if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) { IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput()); pages[i].closeEditor(editorPart, true); } } } }); } }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); if (site == null) { return; } IWorkbenchPage page = site.getPage(); if (page == null) { return; } // workaround to show action set for block mode etc. // https://www.eclipse.org/forums/index.php/t/366630/ page.showActionSet("org.eclipse.ui.edit.text.actionSet.presentation"); }
/** * Closes all project files on project close. */ public void resourceChanged(final IResourceChangeEvent event) { if (event.getType() == IResourceChangeEvent.PRE_CLOSE) { Display.getDefault().asyncExec(new Runnable() { public void run() { IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages(); for (int i = 0; i < pages.length; i++) { if (((FileEditorInput) editor.getEditorInput()).getFile().getProject() .equals(event.getResource())) { IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput()); pages[i].closeEditor(editorPart, true); } } } }); } }
protected AvroSchemaEditor getEditor() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage workbenchPage = window.getActivePage(); if (workbenchPage != null) { IWorkbenchPart activePart = workbenchPage.getActivePart(); if (activePart instanceof IWithAvroSchemaEditor) { return ((IWithAvroSchemaEditor) activePart).getEditor(); } } } return null; }
public static IEditorPart editFile(File file, boolean preferIdeEditor) throws IOException, PartInitException { if (file == null || !file.exists() || !file.isFile() || !file.canRead()) { throw new IOException("Invalid file: '" + file + "'"); } IWorkbench workBench = PlatformUI.getWorkbench(); IWorkbenchPage page = workBench.getActiveWorkbenchWindow().getActivePage(); IPath location = Path.fromOSString(file.getAbsolutePath()); IFileStore fileStore = EFS.getLocalFileSystem().getStore(location); FileStoreEditorInput fileStoreEditorInput = new FileStoreEditorInput(fileStore); String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID; if (preferIdeEditor) { IEditorDescriptor editorDescriptor = workBench.getEditorRegistry().getDefaultEditor(file.getName()); if (editorDescriptor != null) { editorId = editorDescriptor.getId(); } } return page.openEditor(fileStoreEditorInput, editorId); }
/** * Opens the view with the given identifier. * * @param viewId * The view to open; must not be <code>null</code> * @throws PartInitException * If the part could not be initialized. */ private final void openView ( final String viewId, final String secondaryId, final IWorkbenchWindow activeWorkbenchWindow ) throws PartInitException { final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage (); if ( activePage == null ) { return; } if ( secondaryId != null ) { activePage.showView ( viewId, secondaryId, IWorkbenchPage.VIEW_ACTIVATE ); } else { activePage.showView ( viewId ); } }
public Object execute ( final ExecutionEvent event ) throws ExecutionException { for ( final Item item : getItems () ) { GeneratorView view; try { view = (GeneratorView)getActivePage ().showView ( GeneratorView.VIEW_ID, asSecondardId ( item ), IWorkbenchPage.VIEW_ACTIVATE ); } catch ( final PartInitException e ) { throw new ExecutionException ( "Failed to open view", e ); } view.setDataItem ( item ); } return null; }
/** * * loading the properties files */ public void loadProperties() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (page.getActiveEditor().getEditorInput() instanceof IFileEditorInput) { IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput(); List<File> paramNameList = null; IFile file = input.getFile(); IProject activeProject = file.getProject(); final File globalparamFilesPath = new File(activeProject.getLocation().toString() + "/" + "globalparam"); final File localParamFilePath = new File(activeProject.getLocation().toString() + "/" + Constants.PARAM_FOLDER); File[] files = (File[]) ArrayUtils.addAll(listFilesForFolder(globalparamFilesPath), getJobsPropertyFile(localParamFilePath,file)); if (files != null) { paramNameList = Arrays.asList(files); getParamMap(paramNameList, null); } } }
public static void handleOpen ( final IWorkbenchPage page, final ISelection selection ) { final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, "Open editor", null ); final IEditorInput[] inputs = EditorHelper.createInput ( selection ); for ( final IEditorInput input : inputs ) { try { if ( input instanceof ConfigurationEditorInput ) { page.openEditor ( input, MultiConfigurationEditor.EDITOR_ID, true ); } else if ( input instanceof FactoryEditorInput ) { page.openEditor ( input, FactoryEditor.EDITOR_ID, true ); } } catch ( final PartInitException e ) { status.add ( e.getStatus () ); } } }
@Override public Object execute ( final ExecutionEvent event ) throws ExecutionException { try { // the following cast might look a bit weird. But first an adapter is requested and it only adapts to "core" connection services. final ConnectionService connectionService = (ConnectionService)SelectionHelper.first ( getSelection (), org.eclipse.scada.core.connection.provider.ConnectionService.class ); final IViewPart view = getActivePage ().showView ( SummaryExplorerViewPart.VIEW_ID, "" + this.counter++, IWorkbenchPage.VIEW_ACTIVATE ); ( (SummaryExplorerViewPart)view ).setConnectionService ( connectionService ); } catch ( final PartInitException e ) { throw new ExecutionException ( "Failed to open view", e ); } return null; }
private void openJscriptStepEditor(IProject project) { Step step = (Step) this.getObject(); IFile file = project.getFile("/_private/" + Base64.encodeBase64URLSafeString(DigestUtils.sha1(step.getQName())) + " " + step.getName()); IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { try { activePage.openEditor(new JscriptStepEditorInput(file,step), "com.twinsoft.convertigo.eclipse.editors.jscript.JscriptStepEditor"); } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while loading the step editor '" + step.getName() + "'"); } } }
public void openXMLTransactionStepEditor(IProject project) { TransactionStep transactionStep = (TransactionStep)this.getObject(); IFile file = project.getFile("_private/"+transactionStep.getName()+".xml"); IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { try { activePage.openEditor(new XMLTransactionStepEditorInput(file,transactionStep), "com.twinsoft.convertigo.eclipse.editors.xml.XMLTransactionStepEditor"); } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while loading the step editor '" + transactionStep.getName() + "'"); } } }
public void openXMLSequenceStepEditor(IProject project) { SequenceStep sequenceStep = (SequenceStep)this.getObject(); IFile file = project.getFile("_private/"+sequenceStep.getName()+".xml"); IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { try { activePage.openEditor(new XMLSequenceStepEditorInput(file,sequenceStep), "com.twinsoft.convertigo.eclipse.editors.xml.XMLSequenceStepEditor"); } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while loading the step editor '" + sequenceStep.getName() + "'"); } } }
@SuppressWarnings({ "unchecked", "deprecation", "rawtypes" }) public static void openInEditor(IFile file, int startpos, int length) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); HashMap map = new HashMap(); map.put(IMarker.CHAR_START, new Integer(startpos)); map.put(IMarker.CHAR_END, new Integer(startpos+length)); map.put(IWorkbenchPage.EDITOR_ID_ATTR, "org.eclipse.ui.DefaultTextEditor"); try { IMarker marker = file.createMarker(IMarker.TEXT); marker.setAttributes(map); IDE.openEditor(page, marker); } catch (Exception e) { e.printStackTrace(); } }
public void closeConnectorEditors() { IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { IEditorReference[] editorRefs = activePage.getEditorReferences(); for (int i=0;i<editorRefs.length;i++) { IEditorReference editorRef = (IEditorReference)editorRefs[i]; try { IEditorInput editorInput = editorRef.getEditorInput(); if ((editorInput != null) && (editorInput instanceof ConnectorEditorInput)) { if (((ConnectorEditorInput)editorInput).is(getObject())) activePage.closeEditor(editorRef.getEditor(false),true); } } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'"); } } } }
public void closeSequenceEditors(Sequence sequence) { IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { if (sequence != null) { IEditorReference[] editorRefs = activePage.getEditorReferences(); for (int i=0;i<editorRefs.length;i++) { IEditorReference editorRef = (IEditorReference)editorRefs[i]; try { IEditorInput editorInput = editorRef.getEditorInput(); if ((editorInput != null) && (editorInput instanceof SequenceEditorInput)) { if (((SequenceEditorInput)editorInput).is(sequence)) { activePage.closeEditor(editorRef.getEditor(false),true); break; } } } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while retrieving the sequence editor '" + editorRef.getName() + "'"); } } } } }
private IEditorPart getConnectorEditor(IWorkbenchPage activePage, Connector connector) { IEditorPart editorPart = null; if (activePage != null) { if (connector != null) { IEditorReference[] editorRefs = activePage.getEditorReferences(); for (int i=0;i<editorRefs.length;i++) { IEditorReference editorRef = (IEditorReference)editorRefs[i]; try { IEditorInput editorInput = editorRef.getEditorInput(); if ((editorInput != null) && (editorInput instanceof ConnectorEditorInput)) { if (((ConnectorEditorInput)editorInput).is(connector)) { editorPart = editorRef.getEditor(false); break; } } } catch(PartInitException e) { //ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'"); } } } } return editorPart; }
public void openXslEditor(IProject project) { Sheet sheet = getObject(); String projectName = sheet.getProject().getName(); String parentStyleSheet = sheet.getUrl(); Path filePath = new Path(sheet.getUrl()); IFile file = project.getFile(filePath); IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { try { activePage.openEditor(new XslFileEditorInput(file, projectName, sheet), "com.twinsoft.convertigo.eclipse.editors.xsl.XslRuleEditor"); } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while loading the xsl editor '" + parentStyleSheet + "'"); } } }
public static File getEditedFileFolder() { IWorkbenchPage page = null; IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); for (int i = 0; i < windows.length; i++) { if (windows[i] != null) { IWorkbenchWindow window = windows[i]; page = windows[i].getActivePage(); if (page != null) break; } } IEditorPart part = page.getActiveEditor(); FileEditorInput editor = (FileEditorInput) part.getEditorInput(); IFile file = editor.getFile(); IFolder folder = (IFolder) file.getParent(); File f = null; try { f = ResourceManager.toFile(folder.getFullPath()); } catch (FileNotFoundException e) { ResourceManager.logException(e); } return f; }
public IEditorPart getConnectorEditor(Connector connector) { IEditorPart editorPart = null; IWorkbenchPage activePage = getActivePage(); if (activePage != null) { if (connector != null) { IEditorReference[] editorRefs = activePage.getEditorReferences(); for (int i=0;i<editorRefs.length;i++) { IEditorReference editorRef = (IEditorReference)editorRefs[i]; try { IEditorInput editorInput = editorRef.getEditorInput(); if ((editorInput != null) && (editorInput instanceof ConnectorEditorInput)) { if (((ConnectorEditorInput)editorInput).is(connector)) { editorPart = editorRef.getEditor(false); break; } } } catch(PartInitException e) { //ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'"); } } } } return editorPart; }
/** * Note: it compares marker's resource file name and open editors' file name. * * @param marker * @return if marker's editor is open, return editor, else return null */ public static IEditorPart getOpenEditorOfMarker(final IMarker marker) { final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); for (final IWorkbenchWindow iWorkbenchWindow : windows) { final IWorkbenchPage[] pages = iWorkbenchWindow.getPages(); for (final IWorkbenchPage iWorkbenchPage : pages) { final IEditorReference[] editors = iWorkbenchPage.getEditorReferences(); for (final IEditorReference iEditorReference : editors) { try { if (iEditorReference instanceof IFileEditorInput) { final IFileEditorInput input = (IFileEditorInput) iEditorReference.getEditorInput(); final IFile file = input.getFile(); // TODO Caused by: java.lang.NullPointerException when delete marker on ecore editor. if (file.getFullPath().equals(marker.getResource().getFullPath())) { return iEditorReference.getEditor(false); } } } catch (final PartInitException e) { e.printStackTrace(); } } } } return null; }
@Override public void closeAllEditors(boolean save) { super.closeAllEditors(save);// will close any child component editor ApplicationComponent application = (ApplicationComponent) getObject(); synchronized (application) { IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (activePage != null) { IEditorReference[] editorRefs = activePage.getEditorReferences(); for (int i = 0; i < editorRefs.length; i++) { IEditorReference editorRef = (IEditorReference) editorRefs[i]; try { IEditorInput editorInput = editorRef.getEditorInput(); if (editorInput != null && editorInput instanceof ApplicationComponentEditorInput) { if (((ApplicationComponentEditorInput) editorInput).is(application)) { activePage.closeEditor(editorRef.getEditor(false),false); } } } catch(Exception e) { } } } } }
public static void openManifestForProject(IProject project) { File fileToOpen = new File(project.getFile("META-INF/MANIFEST.MF") .getLocation().toOSString()); if (fileToOpen.exists() && fileToOpen.isFile()) { IFileStore fileStore = EFS.getLocalFileSystem().getStore( fileToOpen.toURI()); IWorkbenchPage page = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(); try { IDE.openEditorOnFileStore(page, fileStore); } catch (PartInitException e) { // Put your exception handler here if you wish to } } else { // Do something if the file does not exist } }
private IEditorPart getSequenceEditor(IWorkbenchPage activePage, Sequence sequence) { IEditorPart editorPart = null; if (activePage != null) { if (sequence != null) { IEditorReference[] editorRefs = activePage.getEditorReferences(); for (int i=0;i<editorRefs.length;i++) { IEditorReference editorRef = (IEditorReference)editorRefs[i]; try { IEditorInput editorInput = editorRef.getEditorInput(); if ((editorInput != null) && (editorInput instanceof SequenceEditorInput)) { if (((SequenceEditorInput)editorInput).is(sequence)) { editorPart = editorRef.getEditor(false); break; } } } catch(PartInitException e) { //ConvertigoPlugin.logException(e, "Error while retrieving the sequence editor '" + editorRef.getName() + "'"); } } } } return editorPart; }
public void openJscriptHandlerEditor(IProject project) { String tempFileName = getTempFileName(project); IFile file = project.getFile(tempFileName); IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { try { activePage.openEditor(new JscriptTreeFunctionEditorInput(file,this), "com.twinsoft.convertigo.eclipse.editors.jscript.JscriptTreeFunctionEditor"); } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while loading the document editor '" + tempFileName + "'"); } } }
public void openJscriptTransactionEditor(IProject project) { Transaction transaction = (Transaction)this.getObject(); String tempFileName = "_private/"+project.getName()+ "__"+transaction.getConnector().getName()+ "__"+transaction.getName(); IFile file = project.getFile(tempFileName); IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { try { activePage.openEditor(new JscriptTransactionEditorInput(file,transaction), "com.twinsoft.convertigo.eclipse.editors.jscript.JscriptTransactionEditor"); } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while loading the transaction editor '" + transaction.getName() + "'"); } } }
public void openXMLTransactionEditor(IProject project) { Transaction transaction = (Transaction)this.getObject(); IFile file = project.getFile("_private/"+transaction.getName()+".xml"); IWorkbenchPage activePage = PlatformUI .getWorkbench() .getActiveWorkbenchWindow() .getActivePage(); if (activePage != null) { try { activePage.openEditor(new XMLTransactionEditorInput(file,transaction), "com.twinsoft.convertigo.eclipse.editors.xml.XMLTransactionEditor"); } catch(PartInitException e) { ConvertigoPlugin.logException(e, "Error while loading the transaction editor '" + transaction.getName() + "'"); } } }
public IEditorPart getJscriptTransactionEditor(Transaction transaction) { IEditorPart editorPart = null; IWorkbenchPage activePage = getActivePage(); if (activePage != null) { if (transaction != null) { IEditorReference[] editorRefs = activePage.getEditorReferences(); for (int i=0;i<editorRefs.length;i++) { IEditorReference editorRef = (IEditorReference)editorRefs[i]; try { IEditorInput editorInput = editorRef.getEditorInput(); if ((editorInput != null) && (editorInput instanceof JscriptTransactionEditorInput)) { if (((JscriptTransactionEditorInput)editorInput).transaction.equals(transaction)) { editorPart = editorRef.getEditor(false); break; } } } catch(PartInitException e) { //ConvertigoPlugin.logException(e, "Error while retrieving the jscript transaction editor '" + editorRef.getName() + "'"); } } } } return editorPart; }
/** * Gets the projects explorer view. * !!MUST BE CALLED IN A UI-THREAD!! * @return ProjectExplorerView : the explorer view of Convertigo Plugin */ public ProjectExplorerView getProjectExplorerView() { ProjectExplorerView projectExplorerView = null; IWorkbenchPage activePage = getActivePage(); if (activePage != null) { IViewPart viewPart = activePage.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView"); if (viewPart != null) projectExplorerView = (ProjectExplorerView)viewPart; else { IWorkbench workbench = PlatformUI.getWorkbench(); try { IWorkbenchPage page = workbench.showPerspective(ConvertigoPlugin.PLUGIN_PERSPECTIVE_ID, workbench.getActiveWorkbenchWindow()); viewPart = page.findView("com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView"); if (viewPart != null) { projectExplorerView = (ProjectExplorerView)viewPart; } } catch (WorkbenchException e) {} } } return projectExplorerView; }
private boolean closeEditorIfAlreadyOpen(IPath jobFilePath, String fileName) { String jobPathRelative = StringUtils.removeStart(jobFilePath.toString(), ".."); jobPathRelative = StringUtils.removeStart(jobPathRelative, "/"); String jobPathAbsolute = StringUtils.replace(jobPathRelative, "/", "\\"); IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (activeWorkbenchWindow != null) { IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); for (IEditorReference editorRefrence : activePage.getEditorReferences()) { if (StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathRelative) || StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathAbsolute) || fileName.equals(editorRefrence.getTitleToolTip())) { IEditorPart editor = editorRefrence.getEditor(true); if (!activePage.closeEditor(editor, true)) { LOGGER.debug("Editor not closed"); } LOGGER.debug("Editor closed"); return true; } } } return false; }
private void openQueueMonitor() throws UnsupportedEncodingException { final IPreferenceStore store = Activator.getDefault().getPreferenceStore(); String bundle = store.getString(BUNDLE); String bean = store.getString(BEAN); String sqn = store.getString(STATUS_QUEUE); String stn = store.getString(STATUS_TOPIC); String submit = store.getString(SUBMIT_QUEUE); String part = store.getString(PART_NAME); String queueViewId = QueueViews.createSecondaryId(bundle,bean, sqn, stn, submit); queueViewId = queueViewId+"partName="+part; try { Util.getPage().showView(StatusQueueView.ID, queueViewId, IWorkbenchPage.VIEW_VISIBLE); } catch (PartInitException e) { ErrorDialog.openError(Display.getDefault().getActiveShell(), "Cannot open view", "Cannot open view "+queueViewId, new Status(Status.ERROR, "org.eclipse.scanning.event.ui", e.getMessage())); logger.error("Cannot open view", e); } }