1 package com.sun.javafx.css;
   2 
   3 import java.util.List;
   4 import java.util.Map;
   5 import java.util.Set;
   6 import javafx.css.PseudoClass;
   7 import javafx.css.Styleable;
   8 import javafx.css.Stylesheet;
   9 import javafx.scene.Node;
  10 import javafx.scene.Parent;
  11 import javafx.scene.Scene;
  12 import javafx.scene.SubScene;
  13 
  14 
  15 
  16 /*
  17  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  18  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  19  * 
  20  * This code is free software; you can redistribute it and/or modify it
  21  * under the terms of the GNU General Public License version 2 only, as
  22  * published by the Free Software Foundation.  Oracle designates this
  23  * particular file as subject to the "Classpath" exception as provided
  24  * by Oracle in the LICENSE file that accompanied this code.
  25  * 
  26  * This code is distributed in the hope that it will be useful, but WITHOUT
  27  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  28  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  29  * version 2 for more details (a copy is included in the LICENSE file that
  30  * accompanied this code).
  31  * 
  32  * You should have received a copy of the GNU General Public License version
  33  * 2 along with this work; if not, write to the Free Software Foundation,
  34  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  35  * 
  36  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  37  * or visit www.oracle.com if you need additional information or have any
  38  * questions.
  39  */
  40 
  41 
  42 public class StyleManagerShim {
  43 
  44     private final StyleManager sm;
  45 
  46     private StyleManagerShim(StyleManager sm) {
  47         this.sm = sm;
  48     }
  49 
  50     public static StyleManagerShim getInstance() {
  51         return new StyleManagerShim(StyleManager.getInstance());
  52 
  53     } 
  54     
  55     public boolean isCacheContainerNull(
  56             Styleable styleable, SubScene subScene) {
  57         StyleManager.CacheContainer cc = sm.getCacheContainer(styleable, subScene); 
  58         return cc == null;
  59     }
  60 
  61     public void cacheContainerMap_clear() {
  62         sm.cacheContainerMap.clear();
  63     }
  64 
  65     public int platformUserAgentStylesheetContainers_indexOf(String fname) {
  66         return indexOf(sm.platformUserAgentStylesheetContainers, fname);
  67     }
  68 
  69     public int userAgentStylesheetContainers_indexOf(String fname) {
  70         return indexOf(sm.userAgentStylesheetContainers, fname);
  71     }
  72 
  73     private int indexOf(List<StyleManager.StylesheetContainer> list, String fname) {
  74         for (int n = 0, nMax = list.size(); n < nMax; n++) {
  75             StyleManager.StylesheetContainer container = list.get(n);
  76             if (fname.equals(container.fname)) {
  77                 return n;
  78             }
  79         }
  80 
  81         return -1;
  82     }
  83 
  84     public int userAgentStylesheetContainers_size() {
  85         return sm.userAgentStylesheetContainers.size();
  86     }
  87 
  88     public void userAgentStylesheetContainers_clear() {
  89         sm.userAgentStylesheetContainers.clear();
  90     }
  91 
  92     public boolean userAgentStylesheetContainers_isEmpty() {
  93         return sm.userAgentStylesheetContainers.isEmpty();
  94     }
  95 
  96     public void platformUserAgentStylesheetContainers_clear() {
  97         sm.platformUserAgentStylesheetContainers.clear();
  98     }
  99 
 100     public int platformUserAgentStylesheetContainers_size() {
 101         return sm.platformUserAgentStylesheetContainers.size();
 102     }
 103 
 104     public String platformUserAgentStylesheetContainers_getfname(int dex) {
 105         return sm.platformUserAgentStylesheetContainers.get(dex).fname;
 106     }
 107 
 108     public void stylesheetContainerMap_clear() {
 109         sm.stylesheetContainerMap.clear();
 110     }
 111 
 112     public boolean get_hasDefaultUserAgentStylesheet() {
 113         return sm.hasDefaultUserAgentStylesheet;
 114     }
 115 
 116     public void set_hasDefaultUserAgentStylesheet(boolean value) {
 117         sm.hasDefaultUserAgentStylesheet = value;
 118     }
 119 
 120     public void setDefaultUserAgentStylesheet(String fname) {
 121         sm.setDefaultUserAgentStylesheet(fname);
 122     }
 123 
 124     public void setDefaultUserAgentStylesheet(Scene scene, String url) {
 125         sm.setDefaultUserAgentStylesheet(scene, url);
 126     }
 127 
 128     public void setDefaultUserAgentStylesheet(Stylesheet ua_stylesheet) {
 129         sm.setDefaultUserAgentStylesheet(ua_stylesheet);
 130     }
 131 
 132     public void setUserAgentStylesheets(List<String> urls) {
 133         sm.setUserAgentStylesheets(urls);
 134     }
 135 
 136     public void addUserAgentStylesheet(String fname) {
 137         sm.addUserAgentStylesheet(fname);
 138     }
 139 
 140     public void addUserAgentStylesheet(Scene scene, String url) {
 141         sm.addUserAgentStylesheet(scene, url);
 142     }
 143 
 144     public void addUserAgentStylesheet(Scene scene, Stylesheet ua_stylesheet) {
 145         sm.addUserAgentStylesheet(scene, ua_stylesheet);
 146     }
 147 
 148     public void forget(final Scene scene) {
 149         sm.forget(scene);
 150     }
 151 
 152     public void forget(final Parent parent) {
 153         sm.forget(parent);
 154     }
 155 
 156     public void forget(final SubScene subScene) {
 157         sm.forget(subScene);
 158     }
 159 
 160     public StyleMap findMatchingStyles(Node node, SubScene subScene, Set<PseudoClass>[] triggerStates) {
 161         return sm.findMatchingStyles(node, subScene, triggerStates);
 162     }
 163 
 164     public boolean stylesheetContainerMap_containsKey(String k) {
 165         return sm.stylesheetContainerMap.containsKey(k);
 166     }
 167 
 168     public StylesheetContainer stylesheetContainerMap_get(String k) {
 169         return new StylesheetContainer(
 170                 sm.stylesheetContainerMap.get(k));
 171     }
 172 
 173     public static class StylesheetContainer {
 174 
 175          private final StyleManager.StylesheetContainer sc;
 176 
 177          StylesheetContainer(StyleManager.StylesheetContainer sc) {
 178              this.sc = sc;
 179          }
 180 
 181         public String get_fname() {
 182             return sc.fname;
 183         }
 184 
 185         public int parentUsers_list_size() {
 186             return sc.parentUsers.list.size();
 187         }
 188 
 189         public boolean parentUsers_contains(Parent k) {
 190             return sc.parentUsers.contains(k);
 191         }
 192 
 193         public StyleManagerShim.RefList<Parent> get_parentUsers() {
 194             return new RefList<Parent>(sc.parentUsers);
 195         }
 196     }
 197 
 198     static class RefList<T> {
 199          private StyleManager.RefList ref;
 200 
 201          RefList(StyleManager.RefList ref) {
 202              this.ref = ref;
 203          }
 204     }
 205     
 206 }