jdk/make/src/classes/build/tools/generatenimbus/UIRegion.java
author ihse
Thu, 14 Nov 2013 11:19:32 +0100
changeset 21805 c7d7946239de
parent 14342 jdk/make/tools/src/build/tools/generatenimbus/UIRegion.java@8435a30053c1
child 23010 6dadb192ad81
permissions -rw-r--r--
8027566: Remove the old build system Reviewed-by: erikj, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14330
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 14330
diff changeset
     2
 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
14330
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
     4
 *
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    10
 *
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    15
 * accompanied this code).
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    16
 *
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    20
 *
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    23
 * questions.
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    24
 */
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    25
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    26
package build.tools.generatenimbus;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    27
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    28
import java.util.ArrayList;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    29
import java.util.List;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    30
import java.util.Map;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    31
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    32
import javax.xml.bind.annotation.XmlAttribute;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    33
import javax.xml.bind.annotation.XmlElement;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    34
import javax.xml.bind.annotation.XmlElementWrapper;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    35
import javax.xml.bind.annotation.XmlElements;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    36
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    37
class UIRegion {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    38
    @XmlAttribute protected String name;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    39
    @XmlAttribute protected String key;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    40
    @XmlAttribute private boolean opaque = false;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    41
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    42
    @XmlElement private Insets contentMargins = new Insets(0, 0, 0, 0);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    43
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    44
    @XmlElement(name="state")
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    45
    @XmlElementWrapper(name="backgroundStates")
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    46
    protected List<UIState> backgroundStates = new ArrayList<UIState>();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    47
    public List<UIState> getBackgroundStates() { return backgroundStates; }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    48
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    49
    @XmlElement(name="state")
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    50
    @XmlElementWrapper(name="foregroundStates")
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    51
    protected List<UIState> foregroundStates = new ArrayList<UIState>();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    52
    public List<UIState> getForegroundStates() { return foregroundStates; }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    53
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    54
    @XmlElement(name="state")
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    55
    @XmlElementWrapper(name="borderStates")
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    56
    protected List<UIState> borderStates = new ArrayList<UIState>();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    57
    public List<UIState> getBorderStates() { return borderStates; }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    58
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    59
    @XmlElement private UIStyle style = new UIStyle();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    60
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    61
    @XmlElements({
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    62
        @XmlElement(name = "region", type = UIRegion.class),
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    63
        @XmlElement(name = "uiComponent", type = UIComponent.class),
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    64
        @XmlElement(name = "uiIconRegion", type = UIIconRegion.class)
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    65
    })
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    66
    @XmlElementWrapper(name="regions")
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    67
    private List<UIRegion> subRegions = new ArrayList<UIRegion>();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    68
    public List<UIRegion> getSubRegions() { return subRegions; }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    69
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    70
    protected void initStyles(UIStyle parentStyle) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    71
        style.setParentStyle(parentStyle);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    72
        for (UIState state: backgroundStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    73
            state.getStyle().setParentStyle(this.style);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    74
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    75
        for (UIState state: foregroundStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    76
            state.getStyle().setParentStyle(this.style);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    77
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    78
        for (UIState state: borderStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    79
            state.getStyle().setParentStyle(this.style);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    80
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    81
        for (UIRegion region: subRegions) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    82
            region.initStyles(this.style);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    83
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    84
    }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    85
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    86
    public String getKey() {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    87
        return key == null || "".equals(key) ? name : key;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    88
    }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    89
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    90
    private boolean hasCanvas() {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    91
        for (UIState s : backgroundStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    92
            if (s.hasCanvas()) return true;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    93
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    94
        for (UIState s : borderStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    95
            if (s.hasCanvas()) return true;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    96
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    97
        for (UIState s : foregroundStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    98
            if (s.hasCanvas()) return true;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
    99
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   100
        for (UIRegion r: subRegions) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   101
            if (r.hasCanvas()) return true;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   102
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   103
        return false;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   104
    }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   105
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   106
    public void write(StringBuilder sb, StringBuilder styleBuffer,
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   107
                      UIComponent comp, String prefix, String pkg) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   108
        // write content margins
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   109
        sb.append(String.format("        d.put(\"%s.contentMargins\", %s);\n",
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   110
                                prefix, contentMargins.write(true)));
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   111
        // write opaque if true
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   112
        if (opaque) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   113
            sb.append(String.format("        d.put(\"%s.opaque\", Boolean.TRUE);\n", prefix));
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   114
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   115
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   116
        // register component with LAF
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   117
        String regionCode = "Region." + Utils.regionNameToCaps(name);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   118
        styleBuffer.append(String.format("        register(%s, \"%s\");\n",
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   119
                                         regionCode, prefix));
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   120
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   121
        //write the State, if necessary
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   122
        StringBuffer regString = new StringBuffer();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   123
        List<UIStateType> types = comp.getStateTypes();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   124
        if (types != null && types.size() > 0) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   125
            for (UIStateType type : types) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   126
                regString.append(type.getKey());
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   127
                regString.append(",");
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   128
            }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   129
            //remove the last ","
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   130
            regString.deleteCharAt(regString.length() - 1);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   131
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   132
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   133
        if (! regString.equals("Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Default") && types.size() > 0) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   134
            //there were either custom states, or the normal states were in a custom order
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   135
            //so go ahead and write out prefix.State
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   136
            sb.append(String.format("        d.put(\"%s.States\", \"%s\");\n",
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   137
                                    prefix, regString));
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   138
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   139
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   140
        // write out any custom states, if necessary
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   141
        for (UIStateType type : types) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   142
            String synthState = type.getKey();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   143
            if (! "Enabled".equals(synthState) &&
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   144
                ! "MouseOver".equals(synthState) &&
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   145
                ! "Pressed".equals(synthState) &&
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   146
                ! "Disabled".equals(synthState) &&
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   147
                ! "Focused".equals(synthState) &&
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   148
                ! "Selected".equals(synthState) &&
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   149
                ! "Default".equals(synthState)) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   150
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   151
                //what we have here, gentlemen, is a bona-fide custom state.
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   152
                //if the type is not one of the standard types, then construct a name for
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   153
                //the new type, and write out a new subclass of State.
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   154
                String className = Utils.normalize(prefix) + synthState + "State";
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   155
                sb.append(String.format("        d.put(\"%s.%s\", new %s());\n",
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   156
                                        prefix, synthState, className));
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   157
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   158
                String body = type.getCodeSnippet();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   159
                Map<String, String> variables = Generator.getVariables();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   160
                variables.put("STATE_NAME", className);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   161
                variables.put("STATE_KEY", synthState);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   162
                variables.put("BODY", body);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   163
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   164
                Generator.writeSrcFile("StateImpl", variables, className);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   165
            }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   166
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   167
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   168
        // write style
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   169
        sb.append(style.write(prefix + '.'));
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   170
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   171
        String fileName = Utils.normalize(prefix) + "Painter";
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   172
        boolean hasCanvas = hasCanvas();
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   173
        if (hasCanvas) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   174
            PainterGenerator.writePainter(this, fileName);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   175
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   176
        // write states ui defaults
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   177
        for (UIState state : backgroundStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   178
            state.write(sb, prefix, pkg, fileName, "background");
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   179
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   180
        for (UIState state : foregroundStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   181
            state.write(sb, prefix, pkg, fileName, "foreground");
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   182
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   183
        for (UIState state : borderStates) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   184
            state.write(sb, prefix, pkg, fileName, "border");
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   185
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   186
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   187
        // handle sub regions
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   188
        for (UIRegion subreg : subRegions) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   189
            String p = prefix;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   190
            if (! (subreg instanceof UIIconRegion)) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   191
                p = prefix + ":" + Utils.escape(subreg.getKey());
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   192
            }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   193
            UIComponent c = comp;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   194
            if (subreg instanceof UIComponent) {
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   195
                c = (UIComponent) subreg;
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   196
            }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   197
            subreg.write(sb, styleBuffer, c, p, pkg);
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   198
        }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   199
    }
e4cb78065603 8000970: break out auxiliary classes that will prevent multi-core compilation of the JDK
ohrstrom
parents:
diff changeset
   200
}