]> source.dussan.org Git - vaadin-framework.git/commitdiff
Theme select for #2972, still needs theme-resource update
authorMarc Englund <marc.englund@itmill.com>
Tue, 19 May 2009 08:17:54 +0000 (08:17 +0000)
committerMarc Englund <marc.englund@itmill.com>
Tue, 19 May 2009 08:17:54 +0000 (08:17 +0000)
svn changeset:7873/svn branch:6.0

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

index ea35d986ac01ef00029d9483b8edd81683df021a..2b2464e1a3d2784c5e2fd5a5d563500ccf0b431c 100644 (file)
@@ -7,8 +7,10 @@ import java.util.HashMap;
 import java.util.Iterator;
 
 import com.vaadin.Application;
+import com.vaadin.data.Item;
 import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.HierarchicalContainer;
 import com.vaadin.data.util.ObjectProperty;
 import com.vaadin.demo.sampler.ActiveLink.LinkActivatedEvent;
@@ -51,7 +53,8 @@ public class SamplerApplication extends Application {
     private static final HierarchicalContainer allFeatures = FeatureSet.FEATURES
             .getContainer(true);
 
-    // init() inits
+    // this actually differs from getTheme() - this is the 'base', the active
+    // theme extends this
     private static final String THEME_NAME = "sampler";
 
     // used when trying to guess theme location
@@ -59,7 +62,7 @@ public class SamplerApplication extends Application {
 
     @Override
     public void init() {
-        setTheme("sampler");
+        setTheme("sampler-reindeer");
         setMainWindow(new SamplerWindow());
         APP_URL = getURL().toString();
     }
@@ -210,6 +213,33 @@ public class SamplerApplication extends Application {
                 }
             });
 
+            { // Theme select
+                final ComboBox themeSelect = new ComboBox();
+                themeSelect.setWidth("120px");
+                themeSelect.setStyleName("theme");
+                themeSelect.setImmediate(true);
+                themeSelect.setNullSelectionAllowed(false);
+                themeSelect.addContainerProperty("name", String.class, null);
+                themeSelect.setItemCaptionPropertyId("name");
+                Item item = themeSelect.addItem("sampler-reindeer");
+                item.getItemProperty("name").setValue("Reindeer theme");
+                item = themeSelect.addItem("sampler-runo");
+                item.getItemProperty("name").setValue("Runo theme");
+                themeSelect.setValue(SamplerApplication.this.getTheme());
+                themeSelect.addListener(new ValueChangeListener() {
+                    public void valueChange(ValueChangeEvent event) {
+                        Object theme = themeSelect.getValue();
+                        if (theme != null
+                                && !theme.equals(SamplerApplication.this
+                                        .getTheme())) {
+                            SamplerApplication.this.setTheme((String) theme);
+                        }
+                    }
+                });
+                nav.addComponent(themeSelect);
+                nav.setComponentAlignment(themeSelect, Alignment.MIDDLE_LEFT);
+            }
+
             // Main left/right split; hidden menu tree
             mainSplit = new SplitPanel(SplitPanel.ORIENTATION_HORIZONTAL);
             mainSplit.setSizeFull();