org.eclipse.ui.themes.ITheme Java Examples

The following examples show how to use org.eclipse.ui.themes.ITheme. 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: FindBugsConsole.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static FindBugsConsole showConsole() {
    IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
    boolean exists = false;
    if (console != null) {
        IConsole[] existing = manager.getConsoles();
        for (int i = 0; i < existing.length; i++) {
            if (console == existing[i]) {
                exists = true;
            }
        }
    } else {
        console = new FindBugsConsole("SpotBugs",
                FindbugsPlugin.getDefault().getImageDescriptor(AbstractFindbugsView.PERSPECTIVE_IMG), true);
    }
    if (!exists) {
        manager.addConsoles(new IConsole[] { console });
    }
    ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
    theme.addPropertyChangeListener(console);
    console.setConsoleFont();
    manager.showConsoleView(console);
    return console;
}
 
Example #2
Source File: ThemePreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void setFont(String fontId, FontData[] data)
{
	String fdString = PreferenceConverter.getStoredRepresentation(data);
	// Only set new values if they're different from existing!
	Font existing = JFaceResources.getFont(fontId);
	String existingString = ""; //$NON-NLS-1$
	if (!existing.isDisposed())
	{
		existingString = PreferenceConverter.getStoredRepresentation(existing.getFontData());
	}
	if (!existingString.equals(fdString))
	{
		// put in registry...
		JFaceResources.getFontRegistry().put(fontId, data);
		// Save to prefs...
		ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
		String key = ThemeElementHelper.createPreferenceKey(currentTheme, fontId);
		IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
		store.setValue(key, fdString);
	}
}
 
Example #3
Source File: ThemeUIComposite.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void setFont(String fontId, FontData[] data) {
	String fdString = PreferenceConverter.getStoredRepresentation(data);

	Font existing = JFaceResources.getFont(fontId);
	String existingString = "";
	if (!(existing.isDisposed())) {
		existingString = PreferenceConverter
				.getStoredRepresentation(existing.getFontData());
	}
	if (existingString.equals(fdString)) {
		return;
	}
	JFaceResources.getFontRegistry().put(fontId, data);

	ITheme currentTheme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	String key = ThemeElementHelper.createPreferenceKey(currentTheme,fontId);
	IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore();
	store.setValue(key, fdString);
}
 
Example #4
Source File: FindBugsConsole.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
protected void dispose() {
    if (!disposed) {
        disposed = true;
        ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
        theme.removePropertyChangeListener(this);
        super.dispose();
    }
}
 
Example #5
Source File: FindBugsConsole.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void setConsoleFont() {
    if (Display.getCurrent() == null) {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
            @Override
            public void run() {
                setConsoleFont();
            }
        });
    } else {
        ITheme theme = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
        Font font = theme.getFontRegistry().get(CONSOLE_FONT);
        console.setFont(font);
    }
}
 
Example #6
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Color getBackground(Object element) {
	ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	if (((PreviewFile)element).ignored) {
		return current.getColorRegistry().get(SVNDecoratorConfiguration.IGNORED_BACKGROUND_COLOR);
	} else if (((PreviewFile)element).dirty) {
		return current.getColorRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR);
	}
	return null;
}
 
Example #7
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Color getForeground(Object element) {
	ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	if (((PreviewFile)element).ignored) {
		return current.getColorRegistry().get(SVNDecoratorConfiguration.IGNORED_FOREGROUND_COLOR);
	} else if (((PreviewFile)element).dirty) {
		return current.getColorRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR);
	}
	return null;			
}
 
Example #8
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Font getFont(Object element) {
	ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	if (((PreviewFile)element).ignored) {
		return current.getFontRegistry().get(SVNDecoratorConfiguration.IGNORED_FONT);
	} else if (((PreviewFile)element).dirty) {
		return current.getFontRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_FONT);
	}
	return null;			
}
 
Example #9
Source File: SVNLightweightDecorator.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method will ensure that the fonts and colors used by the decorator
 * are cached in the registries. This avoids having to syncExec when
 * decorating since we ensure that the fonts and colors are pre-created.
 * 
 * @param fonts fonts ids to cache
 * @param colors color ids to cache
 */
private void ensureFontAndColorsCreated(final String[] fonts, final String[] colors) {
	SVNUIPlugin.getStandardDisplay().syncExec(new Runnable() {
		public void run() {
			ITheme theme  = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
			for (int i = 0; i < colors.length; i++) {
				theme.getColorRegistry().get(colors[i]);
			}
			for (int i = 0; i < fonts.length; i++) {
				theme.getFontRegistry().get(fonts[i]);
			}
		}
	});
}
 
Example #10
Source File: SVNLightweightDecorator.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void computeColorsAndFonts(boolean isIgnored, boolean isDirty, IDecoration decoration) {
	if (!SVNUIPlugin.getPlugin().getPreferenceStore().getBoolean(ISVNUIConstants.PREF_USE_FONT_DECORATORS)) return;
	ITheme current = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme();
	if(isIgnored) {
		decoration.setBackgroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.IGNORED_BACKGROUND_COLOR));
		decoration.setForegroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.IGNORED_FOREGROUND_COLOR));
		decoration.setFont(current.getFontRegistry().get(SVNDecoratorConfiguration.IGNORED_FONT));
	} else if(isDirty) {
		decoration.setBackgroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_BACKGROUND_COLOR));
		decoration.setForegroundColor(current.getColorRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_FOREGROUND_COLOR));
		decoration.setFont(current.getFontRegistry().get(SVNDecoratorConfiguration.OUTGOING_CHANGE_FONT));
	}
}
 
Example #11
Source File: EditorContentExtractor.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private Font getTextFont() {
	final ITheme theme = getWorkbench().getThemeManager().getCurrentTheme();
	return theme.getFontRegistry().get(TEXT_FONT_ID);
}