changeset 8028:99b538fc6dd3

[SCENEBUILDER] Fix for DTL-6798: Adapt CSS Analyzer to SubScene implementation
author Jerome Cambon
date Wed, 10 Sep 2014 16:51:32 +0200
parents a9f65720edc3
children c9450b73265d
files apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/css/CssPanelController.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/css/NodeCssState.java apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/util/CssInternal.java
diffstat 3 files changed, 9 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/css/CssPanelController.java	Wed Sep 10 15:46:12 2014 +0400
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/css/CssPanelController.java	Wed Sep 10 16:51:32 2014 +0200
@@ -1882,7 +1882,7 @@
             } catch (MalformedURLException ex) {
                 System.out.println("Invalid URL: " + ex);
             }
-            origin = CssInternal.getOrigin(rule);
+            origin = rule.getOrigin();
         }
         return getSource(url, origin);
     }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/css/NodeCssState.java	Wed Sep 10 15:46:12 2014 +0400
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/editor/panel/css/NodeCssState.java	Wed Sep 10 16:51:32 2014 +0200
@@ -429,7 +429,7 @@
         @Override
         public int compare(MatchingRule t, MatchingRule t1) {
             int originComparaison = compareOrigin(
-                    CssInternal.getOrigin(t.getRule()), CssInternal.getOrigin(t1.rule));
+                    t.getRule().getOrigin(), t1.rule.getOrigin());
             int tnotApplied = countNotApplied(t.declarations);
             int t1notApplied = countNotApplied(t1.declarations);
             int notAppliedComparaisons = tnotApplied - t1notApplied;
@@ -597,7 +597,7 @@
             for (Map.Entry<MatchingRule, List<MatchingDeclaration>> entry : matchingRules.entrySet()) {
                 MatchingRule rule = entry.getKey();
                 // Filterout the Inline
-                if (CssInternal.getOrigin(rule.getRule()) != StyleOrigin.INLINE) {
+                if (rule.getRule().getOrigin() != StyleOrigin.INLINE) {
                     rule.addDeclarations(entry.getValue());
                     sortedMatchingRules.add(rule);
                 }
--- a/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/util/CssInternal.java	Wed Sep 10 15:46:12 2014 +0400
+++ b/apps/scenebuilder/SceneBuilderKit/src/com/oracle/javafx/scenebuilder/kit/util/CssInternal.java	Wed Sep 10 16:51:32 2014 +0200
@@ -131,15 +131,11 @@
     }
 
     public static boolean isThemeRule(Rule rule) {
-        // With SB 2, we apply explicitly theme css (Modena, Caspian, ...)
-        // So although their rules appear with an AUTHOR origin, we have to consider them as USER_AGENT.
-        if (rule.getOrigin() == StyleOrigin.AUTHOR) {
-            String stylePath = rule.getStylesheet().getUrl();
-            assert stylePath != null;
-            for (String themeUrl : themeUrls) {
-                if (stylePath.endsWith(themeUrl)) {
-                    return true;
-                }
+        String stylePath = rule.getStylesheet().getUrl();
+        assert stylePath != null;
+        for (String themeUrl : themeUrls) {
+            if (stylePath.endsWith(themeUrl)) {
+                return true;
             }
         }
         return false;
@@ -496,24 +492,9 @@
         if (style == null || style.getDeclaration() == null) {
             return null;
         }
-        return getOrigin(style.getDeclaration().getRule());
+        return style.getDeclaration().getRule().getOrigin();
     }
 
-    // Wrapper method that force the origin to be USER_AGENT if this is an Fx theme style.
-    public static StyleOrigin getOrigin(Rule rule) {
-        if (rule == null) {
-            return null;
-        }
-        if (isThemeRule(rule)) {
-            // Force the origin to be USER_AGENT if this is an Fx theme style.
-            return StyleOrigin.USER_AGENT;
-        } else {
-            // Are the 2 lines below equivalent ?
-            // styleOrigin = style.getDeclaration().getRule().getStylesheet().getOrigin();
-            return rule.getOrigin();
-        }
-    }
-    
     // From an css url, returns the theme display name
     public static String getThemeDisplayName(String url) {
         String themeName = ""; //NOI18N