Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java')
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java135
1 files changed, 34 insertions, 101 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java
index ec0eb281302..0d2ff3fd102 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/ColorsAndFontsPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2014 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -31,7 +31,6 @@ import org.eclipse.jface.resource.StringConverter;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ISelection;
@@ -62,7 +61,6 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Resource;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -125,8 +123,6 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
* Marks font tokens in EXPANDED_ELEMENTS_PREF and SELECTED_ELEMENT_PREF.
*/
private static final char MARKER_FONT = 'F';
-
- private static final int DEFINITION_NOT_AVAIL_COLOR = SWT.COLOR_WIDGET_LIGHT_SHADOW;
private class ThemeContentProvider implements ITreeContentProvider {
@@ -359,8 +355,7 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
}
private class PresentationLabelProvider extends LabelProvider implements
- IFontProvider,
- IColorProvider {
+ IFontProvider {
private HashMap fonts = new HashMap();
@@ -378,7 +373,8 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
} else {
// Some theme definition element has been modified and we
// need to refresh the viewer
- refreshAllLabels();
+ tree.getViewer().setContentProvider(new ThemeContentProvider());
+ tree.getViewer().collapseAll();
}
}
};
@@ -458,7 +454,8 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
fonts.put(baseFont, font);
}
return font;
- }
+ }
+
return JFaceResources.getDialogFont();
}
@@ -467,16 +464,11 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
*/
public Image getImage(Object element) {
if (element instanceof ColorDefinition) {
- Display display = tree.getDisplay();
Color c = colorRegistry
.get(((ColorDefinition) element).getId());
- Color foregroundColor = tree.getViewer().getControl().getForeground();
- if (c == null) {
- c = display.getSystemColor(SWT.COLOR_WHITE);
- foregroundColor = display.getSystemColor(DEFINITION_NOT_AVAIL_COLOR);
- }
Image image = (Image) images.get(c);
- if (image == null) {
+ if (image == null) {
+ Display display = tree.getDisplay();
ensureImageSize();
image = new Image(display, imageSize, imageSize);
@@ -487,7 +479,8 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
.getBackground());
gc.drawRectangle(0, 0, imageSize - 1, imageSize - 1);
- gc.setForeground(foregroundColor);
+ gc.setForeground(tree.getViewer().getControl()
+ .getForeground());
gc.setBackground(c);
int offset = (imageSize - usableImageSize) / 2;
@@ -567,34 +560,6 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
}
return false;
}
-
- /**
- * Returns the DEFINITION_NOT_AVAIL_COLOR color when definition is not
- * present in the current theme or null when it is available
- *
- * @param def
- * the definition
- * @return the DEFINITION_NOT_AVAIL_COLOR color or null
- */
- @Override
- public Color getForeground(Object element) {
- if (element instanceof ThemeElementDefinition && !isAvailableInCurrentTheme((ThemeElementDefinition) element)) {
- return tree.getDisplay().getSystemColor(DEFINITION_NOT_AVAIL_COLOR);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.
- * Object)
- */
- @Override
- public Color getBackground(Object element) {
- return null;
- }
}
/**
@@ -1004,19 +969,11 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
tree.getViewer().setExpandedState(element,
!tree.getViewer().getExpandedState(element));
- if (element instanceof ThemeElementDefinition) {
- ThemeElementDefinition definition = (ThemeElementDefinition) element;
- if (definition.isOverridden() || definition.isAddedByCss()
- || !isAvailableInCurrentTheme(definition)) {
- return;
- }
- if (element instanceof FontDefinition) {
- editFont(tree.getDisplay());
- } else if (element instanceof ColorDefinition) {
- editColor(tree.getDisplay());
- }
- updateControls();
- }
+ if (element instanceof FontDefinition)
+ editFont(tree.getDisplay());
+ else if (element instanceof ColorDefinition)
+ editColor(tree.getDisplay());
+ updateControls();
}
});
@@ -1294,7 +1251,7 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
IThemeManager.CHANGE_CURRENT_THEME)) {
updateThemeInfo(themeManager);
refreshCategory();
- refreshAllLabels();
+ tree.getViewer().refresh(); // refresh all the labels in the tree
}
}
};
@@ -1910,16 +1867,11 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
if (fontDefinition != null) {
boolean isDefault = isDefault(fontDefinition);
boolean hasDefault = fontDefinition.getDefaultsTo() != null;
- fontChangeButton.setEnabled(!fontDefinition.isOverridden()
- && isAvailableInCurrentTheme(fontDefinition));
- fontSystemButton.setEnabled(!fontDefinition.isOverridden()
- && isAvailableInCurrentTheme(fontDefinition));
- fontResetButton.setEnabled(!isDefault && !fontDefinition.isOverridden()
- && isAvailableInCurrentTheme(fontDefinition));
- editDefaultButton.setEnabled(hasDefault && isDefault && !fontDefinition.isOverridden()
- && isAvailableInCurrentTheme(fontDefinition));
- goToDefaultButton.setEnabled(hasDefault && !fontDefinition.isOverridden()
- && isAvailableInCurrentTheme(fontDefinition));
+ fontChangeButton.setEnabled(!fontDefinition.isOverridden());
+ fontSystemButton.setEnabled(!fontDefinition.isOverridden());
+ fontResetButton.setEnabled(!isDefault && !fontDefinition.isOverridden());
+ editDefaultButton.setEnabled(hasDefault && isDefault && !fontDefinition.isOverridden());
+ goToDefaultButton.setEnabled(hasDefault && !fontDefinition.isOverridden());
setCurrentFont(fontDefinition);
return;
}
@@ -1927,15 +1879,12 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
if (colorDefinition != null) {
boolean isDefault = isDefault(getSelectedColorDefinition());
boolean hasDefault = colorDefinition.getDefaultsTo() != null;
- fontChangeButton.setEnabled(!colorDefinition.isOverridden()
- && isAvailableInCurrentTheme(colorDefinition));
+ fontChangeButton.setEnabled(!colorDefinition.isOverridden());
fontSystemButton.setEnabled(false);
- fontResetButton.setEnabled(!isDefault && !colorDefinition.isOverridden()
- && isAvailableInCurrentTheme(colorDefinition));
- editDefaultButton.setEnabled(hasDefault && isDefault && !colorDefinition.isOverridden()
- && isAvailableInCurrentTheme(colorDefinition));
- goToDefaultButton.setEnabled(hasDefault && !colorDefinition.isOverridden()
- && isAvailableInCurrentTheme(colorDefinition));
+ fontResetButton.setEnabled(!isDefault && !colorDefinition.isOverridden());
+ editDefaultButton
+ .setEnabled(hasDefault && isDefault && !colorDefinition.isOverridden());
+ goToDefaultButton.setEnabled(hasDefault && !colorDefinition.isOverridden());
setCurrentColor(colorDefinition);
return;
}
@@ -1962,7 +1911,7 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
private void setCurrentFont(FontDefinition fontDefinition) {
currentFont = fontRegistry.get(fontDefinition.getId());
- FontData[] fontData = currentFont != null ? currentFont.getFontData() : new FontData[0];
+ FontData[] fontData = currentFont.getFontData();
// recalculate sample text
StringBuffer tmp = new StringBuffer();
@@ -1982,14 +1931,19 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
}
}
fontSampleText = tmp.toString();
- descriptionText.setText(fomatDescription(fontDefinition, currentFont));
+
+ String description = fontDefinition.getDescription();
+ descriptionText.setText(description == null ? "" : description); //$NON-NLS-1$
+
fontSampler.redraw();
}
public void setCurrentColor(ColorDefinition colorDefinition) {
currentColor = colorRegistry.get(colorDefinition.getId());
colorSampler.redraw();
- descriptionText.setText(fomatDescription(colorDefinition, currentColor));
+
+ String description = colorDefinition.getDescription();
+ descriptionText.setText(description == null ? "" : description); //$NON-NLS-1$
}
private Composite createFontPreviewControl() {
@@ -2155,25 +2109,4 @@ public final class ColorsAndFontsPreferencePage extends PreferencePage
workbench.getApplication());
}
}
-
- private void refreshAllLabels() {
- updateThemeInfo(PlatformUI.getWorkbench().getThemeManager());
- tree.getViewer().refresh(); // refresh all the labels in the tree
- }
-
- private boolean isAvailableInCurrentTheme(ThemeElementDefinition definition) {
- if (definition instanceof FontDefinition) {
- return fontRegistry.get(definition.getId()) != null;
- }
- return colorRegistry.get(definition.getId()) != null;
- }
-
- private String fomatDescription(ThemeElementDefinition definition, Resource resource) {
- String description = definition.getDescription() != null ? definition.getDescription() : ""; //$NON-NLS-1$
- if (resource != null) {
- return description;
- }
- return MessageFormat.format(RESOURCE_BUNDLE.getString("definitionNotAvailInTheme"), //$NON-NLS-1$
- new Object[] { description }).trim();
- }
}

Back to the top