use of org.eclipse.ui.internal.themes.ColorDefinition in project archi by archimatetool.
the class PaletteColorUtil method getThemeColor.
/**
* Added by Phillipus - get a theme color from the theme registry
*/
private static Color getThemeColor(final String id, RGB defaultColor) {
IThemeRegistry reg = WorkbenchPlugin.getDefault().getThemeRegistry();
ColorDefinition colorDef = reg.findColor(id);
if (colorDef != null && colorDef.getValue() != null) {
defaultColor = colorDef.getValue();
}
return new Color(defaultColor);
}
use of org.eclipse.ui.internal.themes.ColorDefinition in project eclipse.platform.ui by eclipse-platform.
the class ColorDefinitionTest method testColorDefinitionWhenNameCategoryIdAndDescriptionOverridden.
@Test
public void testColorDefinitionWhenNameCategoryIdAndDescriptionOverridden() {
// given
CSSEngine engine = createEngine("ColorDefinition#ACTIVE_HYPERLINK_COLOR{color: green;" + "label:'nameOverridden'; category:'#categoryIdOverridden'; description: 'descriptionOverridden'}", display);
ColorDefinition definition = colorDefinition("ACTIVE_HYPERLINK_COLOR", "name", "categoryId", "description");
assertEquals(new RGB(0, 0, 0), definition.getValue());
assertFalse(definition.isOverridden());
// when
engine.applyStyles(definition, true);
// then
assertEquals(new RGB(0, 128, 0), definition.getValue());
assertEquals("nameOverridden", definition.getName());
assertEquals("categoryIdOverridden", definition.getCategoryId());
assertTrue(definition.getDescription().startsWith("descriptionOverridden"));
assertTrue(definition.isOverridden());
engine.dispose();
}
use of org.eclipse.ui.internal.themes.ColorDefinition in project eclipse.platform.ui by eclipse-platform.
the class PluginContributionAdapterFactory method getAdapter.
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adapterType != ContributionInfo.class) {
return null;
}
if (adaptableObject instanceof IPluginContribution) {
IPluginContribution contribution = (IPluginContribution) adaptableObject;
String elementType;
if (contribution instanceof EditorDescriptor) {
elementType = ContributionInfoMessages.ContributionInfo_Editor;
} else if (contribution instanceof ViewDescriptor) {
elementType = ContributionInfoMessages.ContributionInfo_View;
} else if (contribution instanceof ActionSetDescriptor) {
elementType = ContributionInfoMessages.ContributionInfo_ActionSet;
} else if (contribution instanceof Category) {
elementType = ContributionInfoMessages.ContributionInfo_Category;
} else if (contribution instanceof IViewCategory) {
elementType = ContributionInfoMessages.ContributionInfo_Category;
} else if (contribution instanceof ThemeElementCategory) {
elementType = ContributionInfoMessages.ContributionInfo_Category;
} else if (contribution instanceof WizardCollectionElement) {
elementType = ContributionInfoMessages.ContributionInfo_Category;
} else if (contribution instanceof ColorDefinition) {
elementType = ContributionInfoMessages.ContributionInfo_ColorDefinition;
} else if (contribution instanceof WorkbenchWizardElement) {
elementType = ContributionInfoMessages.ContributionInfo_Wizard;
} else if (contribution instanceof PerspectiveDescriptor) {
elementType = ContributionInfoMessages.ContributionInfo_Perspective;
} else if (contribution instanceof WorkbenchPreferenceExpressionNode) {
elementType = ContributionInfoMessages.ContributionInfo_Page;
} else if (contribution instanceof DecoratorDefinition) {
elementType = ContributionInfoMessages.ContributionInfo_LabelDecoration;
} else {
elementType = ContributionInfoMessages.ContributionInfo_Unknown;
}
return adapterType.cast(new ContributionInfo(contribution.getPluginId(), elementType, null));
}
if (adaptableObject instanceof JobInfo) {
JobInfo jobInfo = (JobInfo) adaptableObject;
Job job = jobInfo.getJob();
if (job != null) {
Bundle bundle = FrameworkUtil.getBundle(job.getClass());
if (bundle != null) {
return adapterType.cast(new ContributionInfo(bundle.getSymbolicName(), ContributionInfoMessages.ContributionInfo_Job, null));
}
}
}
return null;
}
use of org.eclipse.ui.internal.themes.ColorDefinition in project eclipse.platform.ui by eclipse-platform.
the class ExtensionEventHandler method loadThemes.
// TODO: confirm
private void loadThemes(IExtension ext) {
ThemeRegistryReader reader = new ThemeRegistryReader();
ThemeRegistry registry = (ThemeRegistry) WorkbenchPlugin.getDefault().getThemeRegistry();
reader.setRegistry(registry);
for (IConfigurationElement configElement : ext.getConfigurationElements()) {
reader.readElement(configElement);
}
Collection<ColorDefinition> colors = reader.getColorDefinitions();
ColorDefinition[] colorDefs = colors.toArray(new ColorDefinition[colors.size()]);
ITheme theme = workbench.getThemeManager().getTheme(IThemeManager.DEFAULT_THEME);
ThemeElementHelper.populateRegistry(theme, colorDefs, PrefUtil.getInternalPreferenceStore());
Collection<FontDefinition> fonts = reader.getFontDefinitions();
FontDefinition[] fontDefs = fonts.toArray(new FontDefinition[fonts.size()]);
ThemeElementHelper.populateRegistry(theme, fontDefs, PrefUtil.getInternalPreferenceStore());
Map<String, String> data = reader.getData();
registry.addData(data);
}
use of org.eclipse.ui.internal.themes.ColorDefinition in project eclipse.platform.ui by eclipse-platform.
the class ThemesExtensionTest method testThemesExtension.
@Test
public void testThemesExtension() {
// given
engine = createEngine("ThemesExtension {font-definition: '#org-eclipse-ui-workbench-FONT_DEF_1'," + "'#org-eclipse-ui-workbench-FONT_DEF_2'; color-definition: '#org-eclipse-ui-workbench-COLOR_DEF_1';}", display);
ThemesExtension themesExtention = new ThemesExtension();
// when
engine.applyStyles(themesExtention, true);
// then
assertEquals(3, themesExtention.getDefinitions().size());
assertTrue(themesExtention.getDefinitions().get(0) instanceof FontDefinition);
FontDefinition fontDefinition1 = (FontDefinition) themesExtention.getDefinitions().get(0);
assertTrue(fontDefinition1.isAddedByCss());
assertFalse(fontDefinition1.isOverridden());
assertEquals("org.eclipse.ui.workbench.FONT_DEF_1", fontDefinition1.getId());
assertEquals(ThemesExtension.DEFAULT_CATEGORY_ID, fontDefinition1.getCategoryId());
assertTrue(fontDefinition1.getName().startsWith(FontDefinition.class.getSimpleName()));
assertTrue(fontDefinition1.getName().endsWith(fontDefinition1.getId()));
assertNotNull(fontDefinition1.getDescription());
assertTrue(themesExtention.getDefinitions().get(1) instanceof FontDefinition);
FontDefinition fontDefinition2 = (FontDefinition) themesExtention.getDefinitions().get(1);
assertTrue(fontDefinition2.isAddedByCss());
assertFalse(fontDefinition2.isOverridden());
assertEquals("org.eclipse.ui.workbench.FONT_DEF_2", fontDefinition2.getId());
assertEquals(ThemesExtension.DEFAULT_CATEGORY_ID, fontDefinition1.getCategoryId());
assertTrue(fontDefinition2.getName().startsWith(FontDefinition.class.getSimpleName()));
assertTrue(fontDefinition2.getName().endsWith(fontDefinition2.getId()));
assertNotNull(fontDefinition2.getDescription());
assertTrue(themesExtention.getDefinitions().get(2) instanceof ColorDefinition);
ColorDefinition colorDefinition1 = (ColorDefinition) themesExtention.getDefinitions().get(2);
assertTrue(colorDefinition1.isAddedByCss());
assertFalse(colorDefinition1.isOverridden());
assertEquals("org.eclipse.ui.workbench.COLOR_DEF_1", colorDefinition1.getId());
assertNotNull(colorDefinition1.getDescription());
assertEquals(ThemesExtension.DEFAULT_CATEGORY_ID, colorDefinition1.getCategoryId());
assertTrue(colorDefinition1.getName().startsWith(ColorDefinition.class.getSimpleName()));
assertTrue(colorDefinition1.getName().endsWith(colorDefinition1.getId()));
assertNotNull(colorDefinition1.getDescription());
}
Aggregations