类org.eclipse.ui.texteditor.AbstractTextEditor源码实例Demo

下面列出了怎么用org.eclipse.ui.texteditor.AbstractTextEditor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: wildwebdeveloper   文件: TestXML.java
@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);
}
 
源代码2 项目: aCute   文件: AbstractAcuteTest.java
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);
	}
}
 
源代码3 项目: corrosion   文件: Implementations.java
@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;
}
 
源代码4 项目: JAADAS   文件: SootAttributeJimpleSelectAction.java
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){
		}
		
	}
	
}
 
源代码5 项目: texlipse   文件: TexlipseAnnotationUpdater.java
/**
 * 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;
            }
        }
    });
}
 
源代码6 项目: gama   文件: AutoStartup.java
@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();
}
 
源代码7 项目: APICloud-Studio   文件: ThemeManager.java
/**
 * 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);
	}
}
 
源代码8 项目: APICloud-Studio   文件: TextEditorUtils.java
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;
}
 
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();
	}
}
 
/**
 * 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;
}
 
源代码11 项目: eclipse-wakatime   文件: CustomEditorListener.java
@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;
            }
        }
    }
}
 
源代码12 项目: birt   文件: UIUtil.java
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;
}
 
源代码13 项目: birt   文件: UIUtil.java
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;
}
 
源代码14 项目: Pydev   文件: PyMoveLineAction.java
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);
}
 
源代码15 项目: Pydev   文件: PythonSourceViewer.java
/**
 * @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();
    }
}
 
源代码16 项目: Pydev   文件: PythonSourceViewer.java
/**
 * 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);
    }
}
 
源代码17 项目: eclipse-multicursor   文件: ISourceViewerFinder.java
/**
 * 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;
	}
}
 
源代码18 项目: goclipse   文件: SourceViewerInformationControl.java
/**
 * 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;
}
 
源代码19 项目: goclipse   文件: ViewerColorUpdater.java
@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);
}
 
源代码20 项目: wildwebdeveloper   文件: TestTypeScript.java
@Test
public void testHTMLinTSXFile() throws Exception {
	IFile file = project.getFile("test.tsx");
	file.create(getClass().getResourceAsStream("/testProjects/htmlIn.tsx"), true, null);
	AbstractTextEditor editor = (AbstractTextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
	IDocument document = LSPEclipseUtils.getDocument(editor);
	DisplayHelper.sleep(2000); // Give time for LS to initialize enough before making edit and sending a didChange
	HoverParams params = new HoverParams(new TextDocumentIdentifier(LSPEclipseUtils.toUri(document).toString()), new Position(0, 18));
	Hover hover = LanguageServiceAccessor.getLanguageServers(document, null).get().get(0).getTextDocumentService().hover(params).get();
	Assert.assertTrue(hover.getContents().toString().contains("button"));
}
 
源代码21 项目: wildwebdeveloper   文件: Utils.java
public static ISourceViewer getViewer(AbstractTextEditor editor) {
	try {
		Method method = AbstractTextEditor.class.getDeclaredMethod("getSourceViewer");
		method.setAccessible(true);
		return (ISourceViewer)method.invoke(editor);
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
源代码22 项目: tm4e   文件: ColorManager.java
/**
 * Returns a token for the system default value of the given token.
 * 
 * @param tokenId
 *            name of the token
 * @return system default token or empty string if doesn't exist
 */
private String getSystemDefaultToken(String tokenId) {
	switch (tokenId) {
	case AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND:
		return AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT;
	case AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND:
		return AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT;
	case AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND:
		return AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT;
	case AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND:
		return AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT;
	default:
		return "";
	}
}
 
源代码23 项目: tm4e   文件: Theme.java
@Override
public Color getEditorForeground() {
	ITokenProvider provider = getTokenProvider();
	Color themeColor = provider != null ? provider.getEditorForeground() : null;
	return ColorManager.getInstance()
			.getPriorityColor(themeColor, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);
}
 
源代码24 项目: tm4e   文件: Theme.java
@Override
public Color getEditorBackground() {
	ITokenProvider provider = getTokenProvider();
	Color themeColor = provider != null ? provider.getEditorBackground() : null;
	return ColorManager.getInstance()
			.getPriorityColor(themeColor, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
}
 
源代码25 项目: tm4e   文件: Theme.java
@Override
public Color getEditorSelectionForeground() {
	ITokenProvider provider = getTokenProvider();
	Color themeColor = provider != null ? provider.getEditorSelectionForeground() : null;
	return ColorManager.getInstance()
			.getPriorityColor(themeColor, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND);
}
 
源代码26 项目: tm4e   文件: Theme.java
@Override
public Color getEditorSelectionBackground() {
	ITokenProvider provider = getTokenProvider();
	Color themeColor = provider != null ? provider.getEditorSelectionBackground() : null;
	return ColorManager.getInstance()
			.getPriorityColor(themeColor, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND);
}
 
源代码27 项目: tm4e   文件: Theme.java
@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;
}
 
源代码28 项目: tm4e   文件: TMEditorColorTest.java
@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());
}
 
源代码29 项目: xtext-eclipse   文件: DefaultMergeEditor.java
protected void setActionsActivated(boolean state) {
	Method method = null;
	try {
		method = AbstractTextEditor.class.getDeclaredMethod("setActionActivation", new Class[] { boolean.class }); //$NON-NLS-1$
		method.setAccessible(true);
		method.invoke(this, new Object[] { Boolean.valueOf(state) });
	} catch (Exception exception) {
		throw new WrappedException(exception);
	}
}
 
源代码30 项目: xtext-eclipse   文件: DefaultMergeEditor.java
private void setSourceViewer(ITextEditor editor, SourceViewer viewer) {
	Field field = null;
	try {
		field = AbstractTextEditor.class.getDeclaredField("fSourceViewer"); //$NON-NLS-1$
		field.setAccessible(true);
		field.set(editor, viewer);
	} catch (Exception exception) {
		throw new WrappedException(exception);
	}

}
 
 类所在包
 类方法
 同包方法