]> source.dussan.org Git - vaadin-framework.git/commitdiff
Forgot to commit, part of fix for #3352.
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Wed, 16 Sep 2009 19:09:38 +0000 (19:09 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Wed, 16 Sep 2009 19:09:38 +0000 (19:09 +0000)
Also, trying to fix #3351, but this doesn't completely fix the issue.

svn changeset:8822/svn branch:6.1

src/com/vaadin/demo/sampler/SamplerApplication.java

index d3a85287fc2ca2ca07650b2c12e0a35788c3dd69..7122acf506593c732fada811911cf235125dac8a 100644 (file)
@@ -56,8 +56,6 @@ public class SamplerApplication extends Application {
     private static final String[] THEMES = { "reindeer", "runo" };
     private static final String SAMPLER_THEME_NAME = "sampler";
 
-    private static String currentTheme = SAMPLER_THEME_NAME + "-" + THEMES[0];
-
     // used when trying to guess theme location
     private static String APP_URL = null;
 
@@ -147,17 +145,26 @@ public class SamplerApplication extends Application {
      * 
      */
     class SamplerWindow extends Window {
+
+        private final ThemeResource EMPTY_THEME_ICON = new ThemeResource(
+                "../sampler/sampler/icon-empty.png");
+
+        private final ThemeResource SELECTED_THEME_ICON = new ThemeResource(
+                "../sampler/sampler/select-bullet.png");
+
+        private String currentTheme = SAMPLER_THEME_NAME + "-" + THEMES[0];
+
         private FeatureList currentList = new FeatureGrid();
-        private FeatureView featureView = new FeatureView();
-        private ObjectProperty currentFeature = new ObjectProperty(null,
+        private final FeatureView featureView = new FeatureView();
+        private final ObjectProperty currentFeature = new ObjectProperty(null,
                 Feature.class);
 
-        private ModeSwitch mode;
+        private final ModeSwitch mode;
 
-        private SplitPanel mainSplit;
-        private Tree navigationTree;
+        private final SplitPanel mainSplit;
+        private final Tree navigationTree;
         // itmill: UA-658457-6
-        private GoogleAnalytics webAnalytics = new GoogleAnalytics(
+        private final GoogleAnalytics webAnalytics = new GoogleAnalytics(
                 "UA-658457-6", "none");
         // "backbutton"
         UriFragmentUtility uriFragmentUtility = new UriFragmentUtility();
@@ -376,18 +383,24 @@ public class SamplerApplication extends Application {
             theme.setImmediate(true);
             theme.setNullSelectionAllowed(false);
             for (String themeName : THEMES) {
-                theme.addItem(SAMPLER_THEME_NAME + "-" + themeName);
-                theme.setItemCaption(SAMPLER_THEME_NAME + "-" + themeName,
-                        themeName.substring(0, 1).toUpperCase()
-                                + themeName.substring(1) + " theme");
+                String id = SAMPLER_THEME_NAME + "-" + themeName;
+                theme.addItem(id);
+                theme.setItemCaption(id, themeName.substring(0, 1)
+                        .toUpperCase()
+                        + themeName.substring(1) + " theme");
+                theme.setItemIcon(id, EMPTY_THEME_ICON);
             }
             theme.setValue(currentTheme);
+            theme.setItemIcon(currentTheme, SELECTED_THEME_ICON);
 
             theme.addListener(new ComboBox.ValueChangeListener() {
                 public void valueChange(ValueChangeEvent event) {
+
                     final String newTheme = event.getProperty().getValue()
                             .toString();
                     setTheme(newTheme);
+                    theme.setItemIcon(currentTheme, EMPTY_THEME_ICON);
+                    theme.setItemIcon(newTheme, SELECTED_THEME_ICON);
                     currentTheme = newTheme;
                 }
             });
@@ -617,7 +630,7 @@ public class SamplerApplication extends Application {
      * Table -mode FeatureList. Displays the features in a Table.
      */
     private class FeatureTable extends Table implements FeatureList {
-        private HashMap<Object, Resource> iconCache = new HashMap<Object, Resource>();
+        private final HashMap<Object, Resource> iconCache = new HashMap<Object, Resource>();
 
         FeatureTable() {
             setStyleName("featuretable");
@@ -717,7 +730,7 @@ public class SamplerApplication extends Application {
     private class FeatureGrid extends Panel implements FeatureList {
 
         GridLayout grid = new GridLayout(11, 1);
-        private HashMap<Object, Resource> iconCache = new HashMap<Object, Resource>();
+        private final HashMap<Object, Resource> iconCache = new HashMap<Object, Resource>();
 
         FeatureGrid() {
             setSizeFull();