jdk/src/share/classes/javax/swing/ClientPropertyKey.java
author malenkov
Wed, 30 Apr 2014 19:28:05 +0400
changeset 24544 c0133e7c7162
parent 23010 6dadb192ad81
permissions -rw-r--r--
8041917: unexcepted behavior of LineBorder while using Boolean variable true Reviewed-by: alexsch, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 13604
diff changeset
     2
 * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    28
import sun.awt.AWTAccessor;
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * An enumeration for keys used as client properties within the Swing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * This enum holds only a small subset of the keys currently used within Swing,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * but we may move more of them here in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Adding an item to, and using, this class instead of {@code String} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * client properties protects against conflicts with developer-set client
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * properties. Using this class also avoids a problem with {@code StringBuilder}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * and {@code StringBuffer} keys, whereby the keys are not recognized upon
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * deserialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * When a client property value associated with one of these keys does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * implement {@code Serializable}, the result during serialization depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * on how the key is defined here. Historically, client properties with values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * not implementing {@code Serializable} have simply been dropped and left out
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * of the serialized representation. To define keys with such behavior in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * enum, provide a value of {@code false} for the {@code reportValueNotSerializable}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * property. When migrating existing properties to this enum, one may wish to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * consider using this by default, to preserve backward compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * To instead have a {@code NotSerializableException} thrown when a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * {@code non-Serializable} property is encountered, provide the value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * {@code true} for the {@code reportValueNotSerializable} property. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * is useful when the property represents something that the developer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * needs to know about when it cannot be serialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @author  Shannon Hickey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
enum ClientPropertyKey {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Key used by JComponent for storing InputVerifier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    JComponent_INPUT_VERIFIER(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Key used by JComponent for storing TransferHandler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    JComponent_TRANSFER_HANDLER(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Key used by JComponent for storing AncestorNotifier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    JComponent_ANCESTOR_NOTIFIER(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Key used by PopupFactory to force heavy weight popups for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    PopupFactory_FORCE_HEAVYWEIGHT_POPUP(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * Whether or not a {@code NotSerializableException} should be thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * during serialization, when the value associated with this key does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * not implement {@code Serializable}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    private final boolean reportValueNotSerializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    91
    static {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    92
        AWTAccessor.setClientPropertyKeyAccessor(
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    93
            new AWTAccessor.ClientPropertyKeyAccessor() {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    94
                public Object getJComponent_TRANSFER_HANDLER() {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    95
                    return JComponent_TRANSFER_HANDLER;
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    96
                }
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    97
            });
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    98
    }
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 5506
diff changeset
    99
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * Constructs a key with the {@code reportValueNotSerializable} property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * set to {@code false}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    private ClientPropertyKey() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        this(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Constructs a key with the {@code reportValueNotSerializable} property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * set to the given value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private ClientPropertyKey(boolean reportValueNotSerializable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        this.reportValueNotSerializable = reportValueNotSerializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Returns whether or not a {@code NotSerializableException} should be thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * during serialization, when the value associated with this key does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * not implement {@code Serializable}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public boolean getReportValueNotSerializable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        return reportValueNotSerializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
}