1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
3715 * on.
3716 * @param defaultsKey Key to use to defaults table to check for
3717 * existing map and what resulting Map will be registered on.
3718 */
3719 static void installLazyActionMap(final JComponent c, final Class<AquaTabbedPaneCopyFromBasicUI> loaderClass, final String defaultsKey) {
3720 ActionMap map = (ActionMap)UIManager.get(defaultsKey);
3721 if (map == null) {
3722 map = new LazyActionMap(loaderClass);
3723 UIManager.getLookAndFeelDefaults().put(defaultsKey, map);
3724 }
3725 SwingUtilities.replaceUIActionMap(c, map);
3726 }
3727
3728 /**
3729 * Returns an ActionMap that will be populated by invoking the
3730 * {@code loadActionMap} method on the specified Class
3731 * when necessary.
3732 * <p>
3733 * This should be used if the ActionMap can be shared.
3734 *
3735 * @param c JComponent to install the ActionMap on.
3736 * @param loaderClass Class object that gets loadActionMap invoked
3737 * on.
3738 * @param defaultsKey Key to use to defaults table to check for
3739 * existing map and what resulting Map will be registered on.
3740 */
3741 static ActionMap getActionMap(final Class<AquaTabbedPaneCopyFromBasicUI> loaderClass, final String defaultsKey) {
3742 ActionMap map = (ActionMap)UIManager.get(defaultsKey);
3743 if (map == null) {
3744 map = new LazyActionMap(loaderClass);
3745 UIManager.getLookAndFeelDefaults().put(defaultsKey, map);
3746 }
3747 return map;
3748 }
3749
3750 private LazyActionMap(final Class<AquaTabbedPaneCopyFromBasicUI> loader) {
3751 _loader = loader;
3752 }
3753
3754 public void put(final Action action) {
3755 put(action.getValue(Action.NAME), action);
|
1 /*
2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
3715 * on.
3716 * @param defaultsKey Key to use to defaults table to check for
3717 * existing map and what resulting Map will be registered on.
3718 */
3719 static void installLazyActionMap(final JComponent c, final Class<AquaTabbedPaneCopyFromBasicUI> loaderClass, final String defaultsKey) {
3720 ActionMap map = (ActionMap)UIManager.get(defaultsKey);
3721 if (map == null) {
3722 map = new LazyActionMap(loaderClass);
3723 UIManager.getLookAndFeelDefaults().put(defaultsKey, map);
3724 }
3725 SwingUtilities.replaceUIActionMap(c, map);
3726 }
3727
3728 /**
3729 * Returns an ActionMap that will be populated by invoking the
3730 * {@code loadActionMap} method on the specified Class
3731 * when necessary.
3732 * <p>
3733 * This should be used if the ActionMap can be shared.
3734 *
3735 * @param loaderClass Class object that gets loadActionMap invoked
3736 * on.
3737 * @param defaultsKey Key to use to defaults table to check for
3738 * existing map and what resulting Map will be registered on.
3739 */
3740 static ActionMap getActionMap(final Class<AquaTabbedPaneCopyFromBasicUI> loaderClass, final String defaultsKey) {
3741 ActionMap map = (ActionMap)UIManager.get(defaultsKey);
3742 if (map == null) {
3743 map = new LazyActionMap(loaderClass);
3744 UIManager.getLookAndFeelDefaults().put(defaultsKey, map);
3745 }
3746 return map;
3747 }
3748
3749 private LazyActionMap(final Class<AquaTabbedPaneCopyFromBasicUI> loader) {
3750 _loader = loader;
3751 }
3752
3753 public void put(final Action action) {
3754 put(action.getValue(Action.NAME), action);
|