org.eclipse.ui.texteditor.AbstractTextEditor Java Examples
The following examples show how to use
org.eclipse.ui.texteditor.AbstractTextEditor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoStartup.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public void earlyStartup() { GamaPreferences.Modeling.EDITOR_BASE_FONT.init(() -> getDefaultFontData()).onChange(font -> { try { final FontData newValue = new FontData(font.getName(), font.getSize(), font.getStyle()); setValue(EditorsPlugin.getDefault().getPreferenceStore(), TEXT_FONT, newValue); } catch (final Exception e) {} }); GamaPreferences.Modeling.EDITOR_BACKGROUND_COLOR.init(() -> getDefaultBackground()).onChange(c -> { final RGB rgb = new RGB(c.getRed(), c.getGreen(), c.getBlue()); PreferenceConverter.setValue(EditorsPlugin.getDefault().getPreferenceStore(), AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, rgb); GamaPreferences.Modeling.OPERATORS_MENU_SORT .onChange(newValue -> OperatorsReferenceMenu.byName = newValue.equals("Name")); }); GamlRuntimeModule.staticInitialize(); GamlEditorBindings.install(); GamlReferenceSearch.install(); }
Example #2
Source File: ViewerColorUpdater.java From goclipse with Eclipse Public License 1.0 | 6 votes |
@Override protected void doConfigureViewer() { // ----------- foreground color -------------------- fForegroundColor = updateColorFromSetting(fForegroundColor, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND); styledText.setForeground(fForegroundColor); // ---------- background color ---------------------- fBackgroundColor = updateColorFromSetting(fBackgroundColor, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); styledText.setBackground(fBackgroundColor); // ----------- selection foreground color -------------------- fSelectionForegroundColor = updateColorFromSetting(fSelectionForegroundColor, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR); styledText.setSelectionForeground(fSelectionForegroundColor); // ---------- selection background color ---------------------- fSelectionBackgroundColor = updateColorFromSetting(fSelectionBackgroundColor, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR); styledText.setSelectionBackground(fSelectionBackgroundColor); }
Example #3
Source File: SourceViewerInformationControl.java From goclipse with Eclipse Public License 1.0 | 6 votes |
/** * Returns <code>null</code> if {@link SWT#COLOR_INFO_BACKGROUND} is visibly distinct from the * default Java source text color. Otherwise, returns the editor background color. * * @param display the display * @return an RGB or <code>null</code> * @since 3.6.1 */ public static RGB getVisibleBackgroundColor(Display display) { float[] infoBgHSB= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB().getHSB(); RGB javaDefaultRGB = EditorSettings_Actual.CODE_DEFAULT_COLOR.getFieldValue().rgb; float[] javaDefaultHSB= javaDefaultRGB.getHSB(); if (Math.abs(infoBgHSB[2] - javaDefaultHSB[2]) < 0.5f) { // workaround for dark tooltip background color, see https://bugs.eclipse.org/309334 IPreferenceStore preferenceStore= LangUIPlugin.getInstance().getCombinedPreferenceStore(); boolean useDefault= preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT); if (useDefault) return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); return PreferenceConverter.getColor(preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); } return null; }
Example #4
Source File: ISourceViewerFinder.java From eclipse-multicursor with Eclipse Public License 1.0 | 6 votes |
/** * Relies on protected final method {@link AbstractTextEditor#getSourceViewer()}. */ private static ISourceViewer fromAbstractTextEditor(AbstractTextEditor editor) { try { Method getSourceViewerMethod = null; Class<?> clazz = editor.getClass(); while (clazz != null && getSourceViewerMethod == null) { if (clazz.equals(AbstractTextEditor.class)) { getSourceViewerMethod = clazz.getDeclaredMethod("getSourceViewer"); } else { clazz = clazz.getSuperclass(); } } if (getSourceViewerMethod == null) { throw new RuntimeException(); } getSourceViewerMethod.setAccessible(true); ISourceViewer result = (ISourceViewer) getSourceViewerMethod.invoke(editor); return result; } catch (Exception e) { logger.error("Failed to acquire ISourceViewer via reflection", e); return null; } }
Example #5
Source File: PythonSourceViewer.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * Updates the given viewer's colors to match the preferences. */ public void updateViewerColors() { IPreferenceStore store = getPreferenceStore(); if (store != null) { StyledText styledText = getTextWidget(); if (styledText == null || styledText.isDisposed()) { return; } Color color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) ? null : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay()); styledText.setForeground(color); if (getForegroundColor() != null) { getForegroundColor().dispose(); } setForegroundColor(color); color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay()); styledText.setBackground(color); if (getBackgroundColor() != null) { getBackgroundColor().dispose(); } setBackgroundColor(color); } }
Example #6
Source File: PythonSourceViewer.java From Pydev with Eclipse Public License 1.0 | 6 votes |
/** * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (JFaceResources.TEXT_FONT.equals(property)) { updateViewerFont(); } if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)) { updateViewerColors(); } if (affectsTextPresentation(event)) { invalidateTextPresentation(); } }
Example #7
Source File: PyMoveLineAction.java From Pydev with Eclipse Public License 1.0 | 6 votes |
private IRegion getRegion(IDocument document, ILineRange lineRange) throws BadLocationException { final int startLine = lineRange.getStartLine(); int offset = document.getLineOffset(startLine); final int numberOfLines = lineRange.getNumberOfLines(); if (numberOfLines < 1) { return new Region(offset, 0); } int endLine = startLine + numberOfLines - 1; int endOffset; boolean blockSelectionModeEnabled = false; try { blockSelectionModeEnabled = ((AbstractTextEditor) getTextEditor()).isBlockSelectionModeEnabled(); } catch (Throwable e) { //Ignore (not available before 3.5) } if (blockSelectionModeEnabled) { // in block selection mode, don't select the last delimiter as we count an empty selected line IRegion endLineInfo = document.getLineInformation(endLine); endOffset = endLineInfo.getOffset() + endLineInfo.getLength(); } else { endOffset = document.getLineOffset(endLine) + document.getLineLength(endLine); } return new Region(offset, endOffset - offset); }
Example #8
Source File: UIUtil.java From birt with Eclipse Public License 1.0 | 6 votes |
public static Color getEclipseEditorBackground( ) { ScopedPreferenceStore preferenceStore = new ScopedPreferenceStore( InstanceScope.INSTANCE, "org.eclipse.ui.editors" );//$NON-NLS-1$ Color color = null; if ( preferenceStore != null ) { color = preferenceStore.getBoolean( AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT ) ? null : createColor( preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, Display.getCurrent( ) ); } if ( color == null ) { color = Display.getDefault( ) .getSystemColor( SWT.COLOR_LIST_BACKGROUND ); } return color; }
Example #9
Source File: UIUtil.java From birt with Eclipse Public License 1.0 | 6 votes |
public static Color getEclipseEditorForeground( ) { ScopedPreferenceStore preferenceStore = new ScopedPreferenceStore( InstanceScope.INSTANCE, "org.eclipse.ui.editors" );//$NON-NLS-1$ Color color = null; if ( preferenceStore != null ) { color = preferenceStore.getBoolean( AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT ) ? null : createColor( preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, Display.getCurrent( ) ); } if ( color == null ) { color = Display.getDefault( ) .getSystemColor( SWT.COLOR_LIST_FOREGROUND ); } return color; }
Example #10
Source File: CustomEditorListener.java From eclipse-wakatime with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void partActivated(IWorkbenchPartReference partRef) { IEditorPart part = partRef.getPage().getActiveEditor(); if (!(part instanceof AbstractTextEditor)) return; // log new active file IEditorInput input = part.getEditorInput(); if (input instanceof IURIEditorInput) { URI uri = ((IURIEditorInput)input).getURI(); if (uri != null && uri.getPath() != null) { String currentFile = uri.getPath(); long currentTime = System.currentTimeMillis() / 1000; if (!currentFile.equals(WakaTime.getDefault().lastFile) || WakaTime.getDefault().lastTime + WakaTime.FREQUENCY * 60 < currentTime) { WakaTime.sendHeartbeat(currentFile, WakaTime.getActiveProject(), false); WakaTime.getDefault().lastFile = currentFile; WakaTime.getDefault().lastTime = currentTime; } } } }
Example #11
Source File: SourceViewerInformationControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns <code>null</code> if {@link SWT#COLOR_INFO_BACKGROUND} is visibly distinct from the * default Java source text color. Otherwise, returns the editor background color. * * @param display the display * @return an RGB or <code>null</code> * @since 3.6.1 */ public static RGB getVisibleBackgroundColor(Display display) { float[] infoBgHSB= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB().getHSB(); Color javaDefaultColor= JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_DEFAULT); RGB javaDefaultRGB= javaDefaultColor != null ? javaDefaultColor.getRGB() : new RGB(255, 255, 255); float[] javaDefaultHSB= javaDefaultRGB.getHSB(); if (Math.abs(infoBgHSB[2] - javaDefaultHSB[2]) < 0.5f) { // workaround for dark tooltip background color, see https://bugs.eclipse.org/309334 IPreferenceStore preferenceStore= JavaPlugin.getDefault().getCombinedPreferenceStore(); boolean useDefault= preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT); if (useDefault) return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); return PreferenceConverter.getColor(preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); } return null; }
Example #12
Source File: ThemeableEditorExtension.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public void handlePreferenceStoreChanged(PropertyChangeEvent event) { if (event.getProperty().equals(IThemeManager.THEME_CHANGED)) { IThemeableEditor editor = this.fEditor.get(); overrideThemeColors(); if (editor != null) { editor.getISourceViewer().invalidateTextPresentation(); } } else if (event.getProperty().equals(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE)) { Object newValue = event.getNewValue(); if (newValue instanceof Boolean) { boolean on = (Boolean) newValue; fFullLineBackgroundPainter.setHighlightLineEnabled(on); } } else if (event.getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT)) { overrideRulerColors(); } }
Example #13
Source File: TextEditorUtils.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public static ISourceViewer getSourceViewer(ITextEditor textEditor) { if (textEditor instanceof IThemeableEditor) { IThemeableEditor editor = (IThemeableEditor) textEditor; return editor.getISourceViewer(); } if (textEditor instanceof AbstractTextEditor) { try { Method m = AbstractTextEditor.class.getDeclaredMethod("getSourceViewer"); //$NON-NLS-1$ m.setAccessible(true); return (ISourceViewer) m.invoke(textEditor); } catch (Exception e) { // ignore } } return null; }
Example #14
Source File: ThemeManager.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Set the FG, BG, selection and current line colors on our editors. * * @param theme */ private void setAptanaEditorColorsToMatchTheme(Theme theme) { IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode("com.aptana.editor.common"); //$NON-NLS-1$ prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, false); prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND, toString(theme.getForeground())); prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false); prefs.put(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, toString(theme.getBackground())); prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, false); prefs.put(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, toString(theme.getForeground())); prefs.put(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, toString(theme.getLineHighlightAgainstBG())); try { prefs.flush(); } catch (BackingStoreException e) { IdeLog.logError(ThemePlugin.getDefault(), e); } }
Example #15
Source File: TexlipseAnnotationUpdater.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * Creates a new TexlipseAnnotationUpdater and adds itself to the TexEditor via * <code>addPostSelectionChangedListener</code> * @param editor The TexEditor */ public TexlipseAnnotationUpdater (AbstractTextEditor editor) { //Add this listener to the current editors IPostSelectionListener (lazy update) ((IPostSelectionProvider) editor.getSelectionProvider()).addPostSelectionChangedListener(this); fEditor = editor; fEnabled = TexlipsePlugin.getDefault().getPreferenceStore().getBoolean( TexlipseProperties.TEX_EDITOR_ANNOTATATIONS); //Add a PropertyChangeListener TexlipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (TexlipseProperties.TEX_EDITOR_ANNOTATATIONS.equals(property)) { boolean enabled = TexlipsePlugin.getDefault().getPreferenceStore().getBoolean( TexlipseProperties.TEX_EDITOR_ANNOTATATIONS); fEnabled = enabled; } } }); }
Example #16
Source File: SootAttributeJimpleSelectAction.java From JAADAS with GNU General Public License v3.0 | 6 votes |
public void findClass(String className){ setLinkToEditor(getEditor()); String resource = removeExt(getResource(getEditor()).getName()); String ext = getResource(getEditor()).getFileExtension(); String classNameToFind = (ext == null) ? className : className+"."+ext; if (!resource.equals(className)){ IContainer parent = getResource(getEditor()).getParent(); IResource file = parent.findMember(classNameToFind); try { setLinkToEditor((AbstractTextEditor)SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new FileEditorInput((IFile)file), file.getName())); } catch (PartInitException e){ } } }
Example #17
Source File: TestXML.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Test public void testComplexXML() throws Exception { final IFile file = project.getFile("blah.xml"); String content = "<layout:BlockLayoutCell\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n" + " xsi:schemaLocation=\"sap.ui.layout https://openui5.hana.ondemand.com/downloads/schemas/sap.ui.layout.xsd\"\n" + " xmlns:layout=\"sap.ui.layout\">\n" + " |\n" + "</layout:BlockLayoutCell>"; int offset = content.indexOf('|'); content = content.replace("|", ""); file.create(new ByteArrayInputStream(content.getBytes()), true, null); AbstractTextEditor editor = (AbstractTextEditor) IDE .openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, "org.eclipse.ui.genericeditor.GenericEditor"); editor.getSelectionProvider().setSelection(new TextSelection(offset, 0)); LSContentAssistProcessor processor = new LSContentAssistProcessor(); proposals = processor.computeCompletionProposals(Utils.getViewer(editor), offset); DisplayHelper.sleep(editor.getSite().getShell().getDisplay(), 2000); assertTrue(proposals.length > 1); }
Example #18
Source File: AbstractAcuteTest.java From aCute with Eclipse Public License 2.0 | 6 votes |
protected static ITextViewer getTextViewer(IEditorPart part) throws InvocationTargetException { try { if (part instanceof ITextEditor) { ITextEditor textEditor = (ITextEditor) part; Method getSourceViewerMethod = AbstractTextEditor.class.getDeclaredMethod("getSourceViewer"); //$NON-NLS-1$ getSourceViewerMethod.setAccessible(true); return (ITextViewer) getSourceViewerMethod.invoke(textEditor); } else { fail("Unable to open editor"); return null; } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new InvocationTargetException(e); } }
Example #19
Source File: Implementations.java From corrosion with Eclipse Public License 2.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart part = HandlerUtil.getActiveEditor(event); if (part instanceof ITextEditor) { Collection<LSPDocumentInfo> infos = LanguageServiceAccessor.getLSPDocumentInfosFor( LSPEclipseUtils.getDocument((ITextEditor) part), capabilities -> Boolean.TRUE.equals(capabilities.getReferencesProvider())); if (!infos.isEmpty()) { LSPDocumentInfo info = infos.iterator().next(); ISelection sel = ((AbstractTextEditor) part).getSelectionProvider().getSelection(); if (sel instanceof TextSelection) { try { int offset = ((TextSelection) sel).getOffset(); ImplementationsSearchQuery query = new ImplementationsSearchQuery(offset, info); NewSearchUI.runQueryInBackground(query); } catch (BadLocationException e) { LanguageServerPlugin.logError(e); } } } } return null; }
Example #20
Source File: Theme.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@Override public Color getEditorBackground() { ITokenProvider provider = getTokenProvider(); Color themeColor = provider != null ? provider.getEditorBackground() : null; return ColorManager.getInstance() .getPriorityColor(themeColor, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); }
Example #21
Source File: Theme.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@Override public Color getEditorSelectionForeground() { ITokenProvider provider = getTokenProvider(); Color themeColor = provider != null ? provider.getEditorSelectionForeground() : null; return ColorManager.getInstance() .getPriorityColor(themeColor, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND); }
Example #22
Source File: ExpressionBuilder.java From birt with Eclipse Public License 1.0 | 5 votes |
private Color getBackgroundColor( IPreferenceStore preferenceStore ) { Color color = preferenceStore.getBoolean( AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT ) ? null : createColor( preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, Display.getCurrent( ) ); backgroundColor = color; return color; }
Example #23
Source File: ExpressionBuilder.java From birt with Eclipse Public License 1.0 | 5 votes |
private Color getForegroundColor( IPreferenceStore preferenceStore ) { Color color = preferenceStore.getBoolean( AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT ) ? null : createColor( preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, Display.getCurrent( ) ); foregroundColor = color; return color; }
Example #24
Source File: JSEditor.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Reset the selection forcely. * * @param list */ public void handleSelectionChange( List list ) { if ( scriptEditor instanceof AbstractTextEditor ) { SelectionChangedEvent event = new SelectionChangedEvent( ( (AbstractTextEditor) scriptEditor ).getSelectionProvider( ), new StructuredSelection( list ) ); handleSelectionChanged( event ); } }
Example #25
Source File: Theme.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@Override public Color getEditorSelectionBackground() { ITokenProvider provider = getTokenProvider(); Color themeColor = provider != null ? provider.getEditorSelectionBackground() : null; return ColorManager.getInstance() .getPriorityColor(themeColor, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND); }
Example #26
Source File: Theme.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@Override public Color getEditorCurrentLineHighlight() { ITokenProvider provider = getTokenProvider(); Color themeColor = provider != null ? provider.getEditorCurrentLineHighlight() : null; ColorManager manager = ColorManager.getInstance(); return manager.isColorUserDefined(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND) ? manager.getPreferenceEditorColor(PreferenceConstants.EDITOR_CURRENTLINE_HIGHLIGHT) : themeColor; }
Example #27
Source File: JavaSourceViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property) || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR.equals(property) || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR.equals(property) || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR.equals(property) || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR.equals(property)) { initializeViewerColors(); } }
Example #28
Source File: WithMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Installs this target. I.e. adds all required listeners. */ private boolean install() { if (editor instanceof AbstractTextEditor && !isInstalled()) { bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class); viewer = findSourceViewer(editor); if (viewer != null) { widget = viewer.getTextWidget(); if (widget == null || widget.isDisposed()) { viewer = null; widget = null; return false; } widget.addMouseListener(this); widget.addFocusListener(this); viewer.addTextListener(this); ISelectionProvider selectionProvider = viewer.getSelectionProvider(); if (selectionProvider != null) selectionProvider.addSelectionChangedListener(this); if (viewer instanceof ITextViewerExtension){ ((ITextViewerExtension) viewer).prependVerifyKeyListener(this); KbdMacroSupport.getInstance().continueKbdMacro(this,editor); } else { widget.addVerifyKeyListener(this); } addOtherListeners(page,viewer, widget); installed = true; } } addStatusContribution(editor); return installed; }
Example #29
Source File: TMEditorColorTest.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@Test public void userDefinedEditorColorTest() throws Exception { String testColorVal = "255,128,0"; Color testColor = new Color(Display.getCurrent(), 255, 128, 0); IPreferenceStore prefs = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.editors"); prefs.setValue(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, testColorVal); prefs.setValue(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false); prefs.setValue(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND, testColorVal); prefs.setValue(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, false); f = File.createTempFile("test" + System.currentTimeMillis(), ".ts"); editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), f.toURI(), editorDescriptor.getId(), true); StyledText styledText = (StyledText) editor.getAdapter(Control.class); String themeId = manager.getDefaultTheme().getId(); ITheme theme = manager.getThemeById(themeId); assertEquals("Default light theme isn't set", themeId, SolarizedLight); assertEquals("Background color should be user defined", styledText.getBackground(), testColor); assertEquals("Foreground colors should be ", theme.getEditorForeground(), styledText.getForeground()); assertEquals("Selection background color should be user defined", theme.getEditorSelectionBackground(), testColor); assertNull("Selection foreground should be System default (null)", theme.getEditorSelectionForeground()); Color lineHighlight = ColorManager.getInstance() .getPreferenceEditorColor(EDITOR_CURRENTLINE_HIGHLIGHT); assertNotNull("Highlight shouldn't be a null", lineHighlight); assertEquals("Line highlight should be from preferences (because of user defined background)", lineHighlight, theme.getEditorCurrentLineHighlight()); }
Example #30
Source File: Theme.java From tm4e with Eclipse Public License 1.0 | 5 votes |
@Override public Color getEditorForeground() { ITokenProvider provider = getTokenProvider(); Color themeColor = provider != null ? provider.getEditorForeground() : null; return ColorManager.getInstance() .getPriorityColor(themeColor, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND); }