aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2014-03-27 18:40:00 (EDT)
committerSopot Cela2014-03-27 18:40:00 (EDT)
commit478fb6533dd6fe68c91b8a98fe978114f0c30581 (patch)
tree667d91b795054f279c4ba06b78c581645d4911d7
parent89be22cf7469ecde426e4b75493d7c29ec9733f7 (diff)
downloadeclipse.platform.ui-478fb6533dd6fe68c91b8a98fe978114f0c30581.zip
eclipse.platform.ui-478fb6533dd6fe68c91b8a98fe978114f0c30581.tar.gz
eclipse.platform.ui-478fb6533dd6fe68c91b8a98fe978114f0c30581.tar.bz2
Bug 426777 - [CSS] Remove "A restart is required for the theme to startrefs/changes/25/23825/8
full effect" popup Change-Id: I46c09730b6fa60dbd5396f1812afa8f5597e5b1f Signed-off-by: Sopot Cela <sopotcela@gmail.com>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java2
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java70
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties3
3 files changed, 60 insertions, 15 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
index 50fc1ae..b570566 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java
@@ -28,8 +28,6 @@ public class WorkbenchMessages extends NLS {
public static String ThemeChangeWarningText;
- public static String ThemeChangeWarningTitle;
-
public static String BundleSigningTray_Cant_Find_Service;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java
index 37c4f4c..b3c2e31 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java
@@ -32,7 +32,8 @@ import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
import org.eclipse.e4.ui.internal.workbench.swt.E4Application;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.viewers.ArrayContentProvider;
@@ -47,6 +48,7 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -77,6 +79,7 @@ public class ViewsPreferencePage extends PreferencePage implements
private IThemeEngine engine;
private ComboViewer themeIdCombo;
+ private ControlDecoration themeComboDecorator;
private ITheme currentTheme;
private String defaultTheme;
private Button enableAnimations;
@@ -84,6 +87,7 @@ public class ViewsPreferencePage extends PreferencePage implements
private Text colorsAndFontsThemeDescriptionText;
private ComboViewer colorsAndFontsThemeCombo;
+ private ControlDecoration colorFontsDecorator;
private ColorsAndFontsTheme currentColorsAndFontsTheme;
private Map<String, String> themeAssociations;
@@ -92,7 +96,9 @@ public class ViewsPreferencePage extends PreferencePage implements
initializeDialogUnits(parent);
Composite comp = new Composite(parent, SWT.NONE);
- comp.setLayout(new GridLayout(2, false));
+ GridLayout layout = new GridLayout(2, false);
+ layout.horizontalSpacing = 10;
+ comp.setLayout(layout);
new Label(comp, SWT.NONE).setText(WorkbenchMessages.ViewsPreferencePage_Theme);
themeIdCombo = new ComboViewer(comp, SWT.READ_ONLY);
@@ -109,10 +115,21 @@ public class ViewsPreferencePage extends PreferencePage implements
if (this.currentTheme != null) {
themeIdCombo.setSelection(new StructuredSelection(currentTheme));
}
+ themeComboDecorator = new ControlDecoration(themeIdCombo.getCombo(), SWT.TOP | SWT.LEFT);
themeIdCombo.addSelectionChangedListener(new ISelectionChangedListener() {
+
@Override
public void selectionChanged(SelectionChangedEvent event) {
ITheme selection = getSelectedTheme();
+ if (!selection.equals(currentTheme)) {
+ themeComboDecorator.setDescriptionText(WorkbenchMessages.ThemeChangeWarningText);
+ Image decorationImage = FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage();
+ themeComboDecorator.setImage(decorationImage);
+ themeComboDecorator.show();
+ } else {
+ themeComboDecorator.hide();
+ }
engine.setTheme(selection, false);
try {
((PreferencePageEnhancer) Tweaklets.get(PreferencePageEnhancer.KEY))
@@ -192,15 +209,6 @@ public class ViewsPreferencePage extends PreferencePage implements
engine.setTheme(getSelectedTheme(), true);
}
- boolean themeChanged = theme != null && !theme.equals(currentTheme);
- boolean colorsAndFontsThemeChanged = !PlatformUI.getWorkbench().getThemeManager()
- .getCurrentTheme().getId().equals(currentColorsAndFontsTheme.getId());
-
- if (themeChanged || colorsAndFontsThemeChanged) {
- MessageDialog.openWarning(getShell(), WorkbenchMessages.ThemeChangeWarningTitle,
- WorkbenchMessages.ThemeChangeWarningText);
- }
-
IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
apiStore.setValue(IWorkbenchPreferenceConstants.ENABLE_ANIMATIONS,
enableAnimations.getSelection());
@@ -258,6 +266,9 @@ public class ViewsPreferencePage extends PreferencePage implements
if (colorsAndFontsTheme != null) {
currentColorsAndFontsTheme = colorsAndFontsTheme;
}
+
+ themeComboDecorator.hide();
+ colorFontsDecorator.hide();
}
private void createColorsAndFontsThemeCombo(Composite composite) {
@@ -271,6 +282,8 @@ public class ViewsPreferencePage extends PreferencePage implements
return ((ColorsAndFontsTheme) element).getLabel();
}
});
+ colorFontsDecorator = new ControlDecoration(colorsAndFontsThemeCombo.getCombo(), SWT.TOP
+ | SWT.LEFT);
colorsAndFontsThemeCombo.setContentProvider(new ArrayContentProvider());
colorsAndFontsThemeCombo.setInput(getColorsAndFontsThemes());
colorsAndFontsThemeCombo.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@@ -278,6 +291,15 @@ public class ViewsPreferencePage extends PreferencePage implements
@Override
public void selectionChanged(SelectionChangedEvent event) {
ColorsAndFontsTheme colorsAndFontsTheme = getSelectedColorsAndFontsTheme();
+ if (!colorsAndFontsTheme.equals(currentColorsAndFontsTheme)) {
+ Image decorationImage = FieldDecorationRegistry.getDefault()
+ .getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage();
+ colorFontsDecorator.setImage(decorationImage);
+ colorFontsDecorator
+ .setDescriptionText(WorkbenchMessages.ThemeChangeWarningText);
+ colorFontsDecorator.show();
+ } else
+ colorFontsDecorator.hide();
refreshColorsAndFontsThemeDescriptionText(colorsAndFontsTheme);
setColorsAndFontsTheme(colorsAndFontsTheme);
}
@@ -429,5 +451,31 @@ public class ViewsPreferencePage extends PreferencePage implements
public String getLabel() {
return label;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ColorsAndFontsTheme other = (ColorsAndFontsTheme) obj;
+ if (id == null) {
+ if (other.id != null)
+ return false;
+ } else if (!id.equals(other.id))
+ return false;
+ return true;
+ }
+
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
index 8cfeeeb..eda2fab 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties
@@ -495,8 +495,7 @@ OpenPerspectiveDialogAction_tooltip=Open Perspective
#---- General Preferences----
PreferencePage_noDescription = (No description available)
PreferencePageParameterValues_pageLabelSeparator = \ >\
-ThemeChangeWarningText = A restart is required for the theme change to take full effect.
-ThemeChangeWarningTitle = Theme change
+ThemeChangeWarningText = A restart may be required for the theme change to take full effect.
# --- Workbench -----
WorkbenchPreference_openMode=Open mode
WorkbenchPreference_doubleClick=D&ouble click