changeset 2336:530967040620

Modena: Prepared Modena app to be used in test (partial fix for RT-27675)
author Alexander Kouznetsov <Alexander.Kouznetsov@oracle.com>
date Tue, 22 Jan 2013 00:35:12 +0400
parents b5fbd8b23e1c
children 53cf47ef85b9
files apps/experiments/Modena/src/modena/Modena.java apps/experiments/Modena/src/modena/SamplePage.java
diffstat 2 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/apps/experiments/Modena/src/modena/Modena.java	Sat Jan 19 21:57:29 2013 -0500
+++ b/apps/experiments/Modena/src/modena/Modena.java	Tue Jan 22 00:35:12 2013 +0400
@@ -43,6 +43,7 @@
 import java.net.URLStreamHandler;
 import java.net.URLStreamHandlerFactory;
 import java.util.Locale;
+import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javafx.application.Application;
@@ -110,6 +111,16 @@
     private ToggleButton modenaButton,retinaButton,rtlButton;
     private TabPane contentTabs;
     
+    private static Modena instance;
+
+    public static Modena getInstance() {
+        return instance;
+    }
+    
+    public Map<String, Node> getContent() {
+        return samplePage.getContent();
+    }
+    
     @Override public void start(Stage stage) throws Exception {
         mainStage = stage;
         // set user agent stylesheet
@@ -120,7 +131,9 @@
         Scene scene = new Scene(root, 1024, 768);
         scene.getStylesheets().add(testAppCssUrl);
         stage.setScene(scene);
-        stage.show();
+        stage.setTitle("Modena");
+        stage.show(); // see SamplePage.java:110 comment on how test fails without having stage shown
+        instance = this;
     }
     
     private void updateUserAgentStyleSheet() {
@@ -511,7 +524,7 @@
     {
         URL.setURLStreamHandlerFactory(new StringURLStreamHandlerFactory());
     }
-    
+
     /**
      * Simple URLConnection that always returns the content of the cssBuffer
      */
--- a/apps/experiments/Modena/src/modena/SamplePage.java	Sat Jan 19 21:57:29 2013 -0500
+++ b/apps/experiments/Modena/src/modena/SamplePage.java	Tue Jan 22 00:35:12 2013 +0400
@@ -31,6 +31,8 @@
  */
 package modena;
 
+import java.util.HashMap;
+import java.util.Map;
 import javafx.application.Platform;
 import javafx.geometry.Insets;
 import javafx.geometry.Orientation;
@@ -94,6 +96,8 @@
 public class SamplePage extends GridPane {
     private int rowIndex = 0;
     
+    private Map<String, Node> content = new HashMap<>();
+    
     private Node withState(Node node, String state) {
         node.getProperties().put("javafx.scene.Node.pseudoClassOverride", state);
         return node;
@@ -103,6 +107,7 @@
         if (state!=null) node.getProperties().put("javafx.scene.Node.pseudoClassOverride", state);
         Platform.runLater(new Runnable() {
             @Override public void run() {
+                // TODO: node.lookup(subNodeStyleClass) is null if stage is not shown
                 if (node != null) node.lookup(subNodeStyleClass).getProperties().put("javafx.scene.Node.pseudoClassOverride", subNodeState);
             }
         });
@@ -118,6 +123,7 @@
         setConstraints(sectionLabel, 0, rowIndex);
         setConstraints(box, 1, rowIndex++);
         getChildren().addAll(sectionLabel,box);
+        content.put(name, box);
     }
     
     private void newDetailedSection(String[] labels, Node ...children) {
@@ -137,6 +143,11 @@
         setConstraints(sectionLabel, 0, rowIndex);
         setConstraints(hbox, 1, rowIndex++);
         getChildren().addAll(sectionLabel,hbox);
+        content.put(labels[0], hbox);
+    }
+
+    public Map<String, Node> getContent() {
+        return content;
     }
     
     public SamplePage() {