private IEditorPart getActiveEditor() { final IWorkbenchPage activePage = ErlideUIPlugin.getActivePage(); if (activePage != null) { return activePage.getActiveEditor(); } return null; }
/** * Returns the string from the plugin's resource bundle, or 'key' if not found. * * @param key The resource * @return The identified string */ public static String getResourceString(final String key) { final ResourceBundle bundle = ErlideUIPlugin.getDefault().getResourceBundle(); try { final String returnString = bundle != null ? bundle.getString(key) : key; return returnString; } catch (final MissingResourceException e) { return key; } }
private static IEditorPart openInEditor(final IFile file, final boolean activate) throws PartInitException { if (file != null) { final IWorkbenchPage p = ErlideUIPlugin.getActivePage(); if (p != null) { final IEditorPart editorPart = IDE.openEditor(p, file, activate); return editorPart; } } return null; }
/** @return */ public static int getTabWidthFromPreferences() { int tabw = ErlideUIPlugin.getDefault() .getPreferenceStore() .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); if (tabw == 0) { tabw = EditorsUI.getPreferenceStore() .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); } return tabw; }
private static IEditorPart openInEditor( final IEditorInput input, final String editorID, final boolean activate) throws PartInitException { if (input != null) { final IWorkbenchPage p = ErlideUIPlugin.getActivePage(); if (p != null) { final IEditorPart editorPart = p.openEditor(input, editorID, activate); return editorPart; } } return null; }
/* * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { final BrowserInformationControlInput input = fInfoControl.getInput(); fInfoControl.notifyDelayedInputChange(null); fInfoControl.dispose(); try { final EdocView view = (EdocView) ErlideUIPlugin.getActivePage().showView(EdocView.ID); // TODO view.setInput(infoInput); view.setText(input.getHtml()); } catch (final PartInitException e) { ErlLogger.error(e); } }
/** If the current active editor edits a erlang element return it, else return null */ public static IErlElement getActiveEditorErlangInput() { final IWorkbenchPage page = ErlideUIPlugin.getActivePage(); if (page != null) { final IEditorPart part = page.getActiveEditor(); if (part != null) { final IEditorInput editorInput = part.getEditorInput(); if (editorInput != null) { return (IErlElement) editorInput.getAdapter(IErlElement.class); // return JavaUI.getEditorInputJavaElement(editorInput); } } } return null; }
public static Collection<IEditorPart> getAllErlangEditors() { final List<IEditorPart> result = Lists.newArrayList(); final IWorkbench workbench = ErlideUIPlugin.getDefault().getWorkbench(); for (final IWorkbenchWindow i : workbench.getWorkbenchWindows()) { for (final IWorkbenchPage j : i.getPages()) { for (final IEditorReference editorReference : j.getEditorReferences()) { final IEditorPart editorPart = editorReference.getEditor(false); if (editorPart instanceof ErlangEditor) { result.add(editorPart); } } } } return result; }
/** @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ @Override public void init(final IWorkbench workbench) { fColorManager = new ColorManager(); fOverlayStore = new OverlayPreferenceStore( ErlideUIPlugin.getDefault().getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {}); fOverlayStore.addKeys(createOverlayStoreKeys()); fOverlayStore.load(); fOverlayStore.start(); for (final TokenHighlight th : TokenHighlight.values()) { fColors.put(th, null); } }
private void abortContinueDialog(final IDebugTarget target) { // do not report errors for snippet editor targets // that do not support HCR. HCR is simulated by using // a new class loader for each evaluation // final ILaunch launch = target.getLaunch(); // if (launch.getAttribute(ScrapbookLauncher.SCRAPBOOK_LAUNCH) != null) // { // if (!target.supportsHotCodeReplace()) { // return; // } // } final Display display = ErlideUIPlugin.getStandardDisplay(); if (display.isDisposed()) { return; } String name = null; try { name = target.getName(); } catch (final DebugException e) { name = ""; // never happens, ErlangDebugTarget doesn't throw this... } final String vmName = name; final ILaunchConfiguration config = target.getLaunch().getLaunchConfiguration(); final String launchName = config != null ? config.getName() : "<unknown>"; final IStatus status = new Status(IStatus.ERROR, ErlangCore.PLUGIN_ID, IStatus.ERROR, "Can't replace code", null); final String title = "Code Replace Failed"; final String message = MessageFormat.format( "Some code changes cannot be replaced when being debugged.", new Object[] {vmName, launchName}); display.asyncExec( new Runnable() { @Override public void run() { if (display.isDisposed()) { return; } final Shell shell = ErlideUIPlugin.getActiveWorkbenchShell(); final HotCodeReplaceErrorDialog dialog = new HotCodeReplaceErrorDialog(shell, title, message, status, target); dialog.setBlockOnOpen(false); dialog.open(); } }); }
public static SourceViewer createErlangPreviewer( final Composite parent, IColorManager colorManager, Map<TokenHighlight, HighlightStyle> colors, final String content) { // TODO we should move this method, to a utility class (or maybe create // an ErlangPreviewSourceViewer class) if (colorManager == null) { colorManager = new ColorManager(); } if (colors == null) { colors = new HashMap<TokenHighlight, HighlightStyle>(); for (final TokenHighlight th : TokenHighlight.values()) { colors.put(th, th.getDefaultData()); } } final IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); final IPreferenceStore store = new ChainedPreferenceStore( new IPreferenceStore[] { ErlideUIPlugin.getDefault().getPreferenceStore(), generalTextStore }); final SourceViewer viewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); final IDocument document = new Document(content); viewer.setDocument(document); final ErlangDocumentSetupParticipant setupParticipant = new ErlangDocumentSetupParticipant(); setupParticipant.setup(document); final TextSourceViewerConfiguration configuration = new SyntaxColorPreviewEditorConfiguration(store, colorManager, colors); viewer.configure(configuration); final Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new ErlangSourceViewerUpdater(viewer, configuration, store); viewer.setEditable(false); final Cursor arrowCursor = viewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); viewer.getTextWidget().setCursor(arrowCursor); return viewer; }
protected boolean isMarkingOccurrences() { final IEclipsePreferences prefsNode = ErlideUIPlugin.getPrefsNode(); return prefsNode.getBoolean("markingOccurences", false); }
/** * Returns the page settings for this Erlang search page. * * @return the page settings to be used */ private IDialogSettings getDialogSettings() { if (fDialogSettings == null) { fDialogSettings = ErlideUIPlugin.getDefault().getDialogSettingsSection(PAGE_NAME); } return fDialogSettings; }
public static boolean isFoldingEnabled() { return ErlideUIPlugin.getDefault() .getPreferenceStore() .getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED); }
@Override public boolean performOk() { fOverlayStore.propagate(); ErlideUIPlugin.flushInstanceScope(); return super.performOk(); }