private void doJSPELHyperlinkTestForELInTagBodyTest( String pageName, String template, String editorName) throws BadLocationException { IEditorPart editor = WorkbenchUtils.openEditor(pageName); assertTrue(editor instanceof JSPMultiPageEditor); JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor; ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer(); assertNotNull("Viewer couldn't be found for " + pageName, viewer); IDocument document = viewer.getDocument(); IRegion reg = new FindReplaceDocumentAdapter(document).find(0, template, true, true, false, false); assertNotNull("Text: " + template + " not found", reg); IHyperlink[] links = elHyperlinkDetector.detectHyperlinks( viewer, new Region(reg.getOffset() + reg.getLength() - 1, 0), true); assertNotNull("Hyperlinks for EL:#{" + template + "} are not found", links); assertTrue("Hyperlinks for EL: #{" + template + "} are not found", links.length != 0); boolean found = false; for (IHyperlink link : links) { assertNotNull(link.toString()); link.open(); IEditorPart resultEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (editorName.equals(resultEditor.getTitle())) { found = true; return; } } assertTrue("OpenOn have not opened " + editorName + " editor", found); }
void createPage(IEditorPart editor, IEditorInput input) { try { int index = addPage(editor, input); setPageText(index, editor.getTitle()); } catch (PartInitException e) { ErrorDialog.openError( getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); } }
public void testEditorName() throws Exception { ILaunchConfiguration config = createConfiguration(proj.getProject()); doLaunch(config, "testEditorName"); // $NON-NLS-1$ ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView(); IAction chartAction = getChartAction(view); assertNotNull(chartAction); chartAction.run(); IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); assertTrue(part.getTitle().startsWith("Heap Chart - alloctest")); // $NON-NLS-1$ // assertEquals("Heap Chart - alloctest", part.getTitle()); //$NON-NLS-1$ }
@Override public void launch(IEditorPart editor, final String mode) { Activator.logInfo("launch shortcut: editor" + editor.getTitle() + " mode " + mode); IEditorInput ei = editor.getEditorInput(); if (ei != null && ei instanceof FileEditorInput) { FileEditorInput fei = (FileEditorInput) ei; IFile file = fei.getFile(); final String fName = file.getProjectRelativePath().toOSString(); final String pName = file.getProject().getName(); launch(pName, fName, mode); } }
public static void updateMainWindowTitle(IWorkbenchWindow window) { IProject activeProject = DBeaverCore.getInstance().getProjectRegistry().getActiveProject(); IProduct product = Platform.getProduct(); String title = product == null ? "Unknown" : product.getName(); // $NON-NLS-1$ if (activeProject != null) { title += " - " + activeProject.getName(); // $NON-NLS-1$ } IWorkbenchPage activePage = window.getActivePage(); if (activePage != null) { IEditorPart activeEditor = activePage.getActiveEditor(); if (activeEditor != null) { title += " - [ " + activeEditor.getTitle() + " ]"; } } window.getShell().setText(title); }
/** * Save the file in the active editor and close it. * * @param className */ public static void saveAndCloseEditor(String className) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart activeEditor = getActiveEditor(); if (activeEditor == null) { return; } String title = activeEditor.getTitle(); title = title.replace(".java", ""); // $NON-NLS-1$ //$NON-NLS-2$ className = className.replace(".java", ""); if (title.equals(className)) { activeEditor.doSave(null); page.closeEditor(activeEditor, false); } }
private static IEditorPart[] getDirtyEditors(String mask) { List<IEditorPart> result = new ArrayList<IEditorPart>(0); IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); for (int i = 0; i < windows.length; i++) { IWorkbenchPage[] pages = windows[i].getPages(); for (int x = 0; x < pages.length; x++) { IEditorPart[] editors = pages[x].getDirtyEditors(); for (int z = 0; z < editors.length; z++) { IEditorPart ep = editors[z]; if (ep.getTitle().indexOf(mask) > 0) { result.add(ep); } } } } return result.toArray(new IEditorPart[result.size()]); }
@Override public void launch(final IEditorPart editor, final String mode) { ErlLogger.debug("** Launch :: " + editor.getTitle()); if (editor instanceof ErlangEditor) { final ErlangEditor erlangEditor = (ErlangEditor) editor; final IErlModule module = erlangEditor.getModule(); if (module != null) { final IErlProject project = ModelUtils.getProject(module); if (project != null) { try { doLaunch(mode, Lists.newArrayList(project)); } catch (final CoreException e) { final IWorkbench workbench = PlatformUI.getWorkbench(); final Shell shell = workbench.getActiveWorkbenchWindow().getShell(); MessageDialog.openError(shell, "Error", e.getStatus().getMessage()); } } } } }
@Override public void selectionChanged(final IWorkbenchPart part, final ISelection selection) { if (selection instanceof ITreeSelection && part instanceof ResultList) { final Object first = ((ITreeSelection) selection).getFirstElement(); if (first instanceof CounterExampleResult) { final IEditorPart edPart = getSite().getPage().getActiveEditor(); actualAllowedInput = edPart.getTitle(); final CounterExampleResult<?, ?, ?> res = (CounterExampleResult<?, ?, ?>) first; if (res.getProgramExecution() != null) { // TODO: Implement this right with IProgramExecution and known values for generic // contProv.setValuation(res.getValuation()); } else { contProv.setValuation(new TestValuation()); } } viewer.getTree().removeAll(); } else if (selection instanceof ITreeSelection && part instanceof LocationTrace) { final Object first = ((ITreeSelection) selection).getFirstElement(); if (first != null) { viewer.setInput(((TraceNode) first).getOriginalIndex()); } } else if (selection instanceof ITextSelection && part instanceof EditorPart) { final String text = ((EditorPart) part).getTitle(); if (!text.equals(actualAllowedInput)) { viewer.getTree().removeAll(); } } else if (selection instanceof ITreeSelection && part instanceof CommonNavigator) { final CommonNavigator navi = (CommonNavigator) part; if (navi.isLinkingEnabled()) { if (((ITreeSelection) selection).getFirstElement() != null) { final String text = ((ITreeSelection) selection).getFirstElement().toString(); if (!text.equals(actualAllowedInput)) { viewer.getTree().removeAll(); } } else { viewer.getTree().removeAll(); } } } }
private void saveTestVariables() { int edCount = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .getEditorReferences() .length; // number of opened editors setProperty("editorCount", new Integer(edCount).toString()); setProperty("reCopy", reCopy); setProperty("mdlClassPath", oldFile.toString()); setProperty("compType", compType); if (compName == null) setProperty("compName", "null"); else setProperty("compName", compName); for (int i = 0; i < openEditors.length; i++) { if (openEditors[i] instanceof IEditorPart) { IEditorPart editor = (IEditorPart) openEditors[i]; setProperty("editroTitle" + String.valueOf(i), editor.getTitle()); } } setProperty("editorToTest", focusedEditor); if (focusedEditor == EditorTestUtilities.EDITOR_TYPE_NONE) removeProperty("focusEditorTitle"); else setProperty( "focusEditorTitle", PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .getActiveEditor() .getTitle()); if (baseEditor != null) setProperty("baseEditorTitle", baseEditor.getTitle()); else removeProperty("baseEditorTitle"); }
/** * Saves the multi-page vEditor's document as another file. Also updates the text for page 0's * tab, and updates this multi-page vEditor's input to correspond to the nested vEditor's. */ public void doSaveAs() { IEditorPart editor = getEditor(0); editor.doSaveAs(); setPageText(0, editor.getTitle()); setInput(editor.getEditorInput()); }