0001: /*
0002: * Copyright (C) 2004 NNL Technology AB
0003: * Visit www.infonode.net for information about InfoNode(R)
0004: * products and how to contact NNL Technology AB.
0005: *
0006: * This program is free software; you can redistribute it and/or
0007: * modify it under the terms of the GNU General Public License
0008: * as published by the Free Software Foundation; either version 2
0009: * of the License, or (at your option) any later version.
0010: *
0011: * This program is distributed in the hope that it will be useful,
0012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0014: * GNU General Public License for more details.
0015: *
0016: * You should have received a copy of the GNU General Public License
0017: * along with this program; if not, write to the Free Software
0018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
0019: * MA 02111-1307, USA.
0020: */
0021:
0022: // $Id: RootWindowProperties.java,v 1.96 2007/01/28 21:25:10 jesper Exp $
0023: package net.infonode.docking.properties;
0024:
0025: import net.infonode.docking.DefaultButtonFactories;
0026: import net.infonode.docking.action.*;
0027: import net.infonode.docking.drop.AcceptAllDropFilter;
0028: import net.infonode.docking.internalutil.InternalDockingUtil;
0029: import net.infonode.gui.DynamicUIManager;
0030: import net.infonode.gui.DynamicUIManagerListener;
0031: import net.infonode.gui.UIManagerUtil;
0032: import net.infonode.gui.colorprovider.FixedColorProvider;
0033: import net.infonode.gui.componentpainter.ComponentPainter;
0034: import net.infonode.gui.componentpainter.GradientComponentPainter;
0035: import net.infonode.gui.componentpainter.SolidColorComponentPainter;
0036: import net.infonode.properties.base.Property;
0037: import net.infonode.properties.gui.util.ComponentProperties;
0038: import net.infonode.properties.gui.util.ShapedPanelProperties;
0039: import net.infonode.properties.propertymap.*;
0040: import net.infonode.properties.types.BooleanProperty;
0041: import net.infonode.properties.types.IntegerProperty;
0042: import net.infonode.tabbedpanel.*;
0043: import net.infonode.tabbedpanel.border.TabAreaLineBorder;
0044: import net.infonode.tabbedpanel.titledtab.TitledTabProperties;
0045: import net.infonode.tabbedpanel.titledtab.TitledTabSizePolicy;
0046: import net.infonode.util.Direction;
0047:
0048: import javax.swing.*;
0049: import javax.swing.border.LineBorder;
0050: import java.awt.*;
0051: import java.util.Map;
0052:
0053: /**
0054: * Properties and property values for a root window.
0055: *
0056: * @author $Author: jesper $
0057: * @version $Revision: 1.96 $
0058: */
0059: public class RootWindowProperties extends PropertyMapContainer {
0060: /**
0061: * The size of the default window tab button icons.
0062: */
0063: public static final int DEFAULT_WINDOW_TAB_BUTTON_ICON_SIZE = InternalDockingUtil.DEFAULT_BUTTON_ICON_SIZE;
0064:
0065: /**
0066: * Property group containing all root window properties.
0067: */
0068: public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
0069: "Root Window Properties", "");
0070:
0071: /**
0072: * The root window component property values.
0073: */
0074: public static final PropertyMapProperty COMPONENT_PROPERTIES = new PropertyMapProperty(
0075: PROPERTIES, "Component Properties",
0076: "The root window component property values.",
0077: ComponentProperties.PROPERTIES);
0078:
0079: /**
0080: * The root window shaped panel property values.
0081: */
0082: public static final PropertyMapProperty SHAPED_PANEL_PROPERTIES = new PropertyMapProperty(
0083: PROPERTIES, "Shaped Panel Properties",
0084: "The root window shaped panel property values.",
0085: ShapedPanelProperties.PROPERTIES);
0086:
0087: /**
0088: * The window area component property values. The window area is the area inside the WindowBars.
0089: */
0090: public static final PropertyMapProperty WINDOW_AREA_PROPERTIES = new PropertyMapProperty(
0091: PROPERTIES,
0092: "Window Area Properties",
0093: "The window area component property values. The window area is the area inside the WindowBars.",
0094: ComponentProperties.PROPERTIES);
0095:
0096: /**
0097: * The window area shaped panel property values. The window area is the area inside the WindowBars.
0098: */
0099: public static final PropertyMapProperty WINDOW_AREA_SHAPED_PANEL_PROPERTIES = new PropertyMapProperty(
0100: PROPERTIES,
0101: "Window Area Shaped Panel Properties",
0102: "The window area shaped panel property values. The window area is the area inside the WindowBars.",
0103: ShapedPanelProperties.PROPERTIES);
0104:
0105: /**
0106: * Shaped panel properties for the drag rectangle. Setting a painter disables the default drag rectangle.
0107: *
0108: * @since IDW 1.2.0
0109: */
0110: public static final PropertyMapProperty DRAG_RECTANGLE_SHAPED_PANEL_PROPERTIES = new PropertyMapProperty(
0111: PROPERTIES,
0112: "Drag Rectangle Shaped Panel Properties",
0113: "Shaped panel properties for the drag rectangle. Setting a painter disables the default drag rectangle.",
0114: ShapedPanelProperties.PROPERTIES);
0115:
0116: /**
0117: * The width of the drag rectangle border.
0118: */
0119: public static final IntegerProperty DRAG_RECTANGLE_BORDER_WIDTH = IntegerProperty
0120: .createPositive(PROPERTIES, "Drag Rectangle Border Width",
0121: "The width of the drag rectangle border. The drag rectangle will only "
0122: + "be painted if the painter of the '"
0123: + DRAG_RECTANGLE_SHAPED_PANEL_PROPERTIES
0124: .getName()
0125: + "' property is not set.", 2,
0126: PropertyMapValueHandler.INSTANCE);
0127:
0128: /**
0129: * The window drag label property values.
0130: */
0131: public static final PropertyMapProperty DRAG_LABEL_PROPERTIES = new PropertyMapProperty(
0132: PROPERTIES, "Drag Label Properties",
0133: "The window drag label property values.",
0134: ComponentProperties.PROPERTIES);
0135:
0136: /**
0137: * Default property values for DockingWindows inside this root window.
0138: */
0139: public static final PropertyMapProperty DOCKING_WINDOW_PROPERTIES = new PropertyMapProperty(
0140: PROPERTIES,
0141: "Docking Window Properties",
0142: "Default property values for DockingWindows inside this RootWindow.",
0143: DockingWindowProperties.PROPERTIES);
0144:
0145: /**
0146: * Default property values for tab windows inside this root window.
0147: */
0148: public static final PropertyMapProperty TAB_WINDOW_PROPERTIES = new PropertyMapProperty(
0149: PROPERTIES,
0150: "Tab Window Properties",
0151: "Default property values for TabWindows inside this RootWindow.",
0152: TabWindowProperties.PROPERTIES);
0153:
0154: /**
0155: * Default property values for split windows inside this root window.
0156: */
0157: public static final PropertyMapProperty SPLIT_WINDOW_PROPERTIES = new PropertyMapProperty(
0158: PROPERTIES,
0159: "Split Window Properties",
0160: "Default property values for SplitWindows inside this RootWindow.",
0161: SplitWindowProperties.PROPERTIES);
0162:
0163: /**
0164: * Default property values for floating windows inside this root window.
0165: *
0166: * @since IDW 1.4.0
0167: */
0168: public static final PropertyMapProperty FLOATING_WINDOW_PROPERTIES = new PropertyMapProperty(
0169: PROPERTIES,
0170: "Floating Window Properties",
0171: "Default property values for FloatingWindows inside this RootWindow.",
0172: FloatingWindowProperties.PROPERTIES);
0173:
0174: /**
0175: * Default property values for views inside this root window.
0176: */
0177: public static final PropertyMapProperty VIEW_PROPERTIES = new PropertyMapProperty(
0178: PROPERTIES,
0179: "View Properties",
0180: "Default property values for Views inside this RootWindow.",
0181: ViewProperties.PROPERTIES);
0182:
0183: /**
0184: * Double clicking on a minimized window in a window bar restores it.
0185: */
0186: public static final BooleanProperty DOUBLE_CLICK_RESTORES_WINDOW = new BooleanProperty(
0187: PROPERTIES,
0188: "Double Click Restores Window",
0189: "Double clicking on a minimized window in a window bar restores it.",
0190: PropertyMapValueHandler.INSTANCE);
0191:
0192: /**
0193: * If true, makes it possible for the user to create tab windows inside other tab windows when dragging windows.
0194: * If false, only one level of tab windows is allowed.
0195: * Changing the value of this property does not alter the window tree.
0196: */
0197: public static final BooleanProperty RECURSIVE_TABS_ENABLED = new BooleanProperty(
0198: PROPERTIES,
0199: "Recursive Tabs Enabled",
0200: "If true, makes it possible for the user to create tab windows inside other tab windows by "
0201: + "dragging windows. If false, only one level of tab windows is allowed. Changing the value of "
0202: + "this property does not alter the window tree.",
0203: PropertyMapValueHandler.INSTANCE);
0204:
0205: /**
0206: * Inside this distance from the window edge a mouse drag will trigger a window split.
0207: */
0208: public static final IntegerProperty EDGE_SPLIT_DISTANCE = IntegerProperty
0209: .createPositive(
0210: PROPERTIES,
0211: "Edge Split Distance",
0212: "Inside this distance from the window edge a mouse drag will trigger a window split.",
0213: 3, PropertyMapValueHandler.INSTANCE);
0214:
0215: /**
0216: * Key code for the key that aborts a drag.
0217: */
0218: public static final IntegerProperty ABORT_DRAG_KEY = IntegerProperty
0219: .createPositive(PROPERTIES, "Abort Drag Key Code",
0220: "Key code for the key that aborts a drag.", 3,
0221: PropertyMapValueHandler.INSTANCE);
0222:
0223: /**
0224: * The default window bar property values.
0225: *
0226: * @since IDW 1.1.0
0227: */
0228: public static final PropertyMapProperty WINDOW_BAR_PROPERTIES = new PropertyMapProperty(
0229: PROPERTIES,
0230: "Window Bar Properties",
0231: "Default property values for WindowBars inside this RootWindow.",
0232: WindowBarProperties.PROPERTIES);
0233:
0234: private static RootWindowProperties DEFAULT_VALUES;
0235:
0236: private static void setTabProperties() {
0237: WindowTabProperties tabProperties = DEFAULT_VALUES
0238: .getTabWindowProperties().getTabProperties();
0239:
0240: PropertyMapProperty[] buttonProperties = {
0241: WindowTabStateProperties.CLOSE_BUTTON_PROPERTIES,
0242: WindowTabStateProperties.MINIMIZE_BUTTON_PROPERTIES,
0243: WindowTabStateProperties.RESTORE_BUTTON_PROPERTIES,
0244: WindowTabStateProperties.UNDOCK_BUTTON_PROPERTIES,
0245: WindowTabStateProperties.DOCK_BUTTON_PROPERTIES };
0246:
0247: for (int i = 0; i < buttonProperties.length; i++) {
0248: for (int j = 0; j < WindowTabButtonProperties.PROPERTIES
0249: .getPropertyCount(); j++) {
0250: Property property = WindowTabButtonProperties.PROPERTIES
0251: .getProperty(j);
0252:
0253: // Highlighted properties inherits from normal properties
0254: buttonProperties[i].get(
0255: tabProperties.getHighlightedButtonProperties()
0256: .getMap()).createRelativeRef(
0257: property,
0258: buttonProperties[i].get(tabProperties
0259: .getNormalButtonProperties().getMap()),
0260: property);
0261:
0262: // Focus properties inherits from highlight properties
0263: buttonProperties[i].get(
0264: tabProperties.getFocusedButtonProperties()
0265: .getMap()).createRelativeRef(
0266: property,
0267: buttonProperties[i].get(tabProperties
0268: .getHighlightedButtonProperties()
0269: .getMap()), property);
0270: }
0271: }
0272:
0273: tabProperties.getTitledTabProperties().getNormalProperties()
0274: .setToolTipEnabled(true).getComponentProperties()
0275: .setInsets(new Insets(0, 3, 0, 2));
0276:
0277: tabProperties.getTitledTabProperties().setSizePolicy(
0278: TitledTabSizePolicy.INDIVIDUAL_SIZE);
0279:
0280: tabProperties.getNormalButtonProperties()
0281: .getCloseButtonProperties().setFactory(
0282: DefaultButtonFactories.getCloseButtonFactory())
0283: .setTo(CloseWithAbortWindowAction.INSTANCE);
0284:
0285: tabProperties
0286: .getNormalButtonProperties()
0287: .getUndockButtonProperties()
0288: .setFactory(
0289: DefaultButtonFactories.getUndockButtonFactory())
0290: .setVisible(false).setTo(
0291: UndockWithAbortWindowAction.INSTANCE);
0292:
0293: tabProperties.getNormalButtonProperties()
0294: .getDockButtonProperties().setFactory(
0295: DefaultButtonFactories.getDockButtonFactory())
0296: .setVisible(false).setTo(
0297: DockWithAbortWindowAction.INSTANCE);
0298:
0299: tabProperties.getNormalButtonProperties()
0300: .getRestoreButtonProperties().setFactory(
0301: DefaultButtonFactories
0302: .getRestoreButtonFactory()).setVisible(
0303: false).setTo(
0304: RestoreWithAbortWindowAction.INSTANCE);
0305:
0306: tabProperties.getNormalButtonProperties()
0307: .getMinimizeButtonProperties().setFactory(
0308: DefaultButtonFactories
0309: .getMinimizeButtonFactory())
0310: .setVisible(false).setTo(
0311: MinimizeWithAbortWindowAction.INSTANCE);
0312:
0313: tabProperties.getTitledTabProperties().setFocusable(false);
0314: tabProperties.getHighlightedButtonProperties()
0315: .getCloseButtonProperties().setVisible(true);
0316: tabProperties.getHighlightedButtonProperties()
0317: .getMinimizeButtonProperties().setVisible(true);
0318: tabProperties.getHighlightedButtonProperties()
0319: .getRestoreButtonProperties().setVisible(true);
0320: tabProperties.getHighlightedButtonProperties()
0321: .getUndockButtonProperties().setVisible(true);
0322: tabProperties.getHighlightedButtonProperties()
0323: .getDockButtonProperties().setVisible(true);
0324: }
0325:
0326: private static void setTabbedPanelProperties() {
0327: TabWindowProperties tabWindowProperties = DEFAULT_VALUES
0328: .getTabWindowProperties();
0329:
0330: tabWindowProperties.getTabbedPanelProperties()
0331: .setTabDropDownListVisiblePolicy(
0332: TabDropDownListVisiblePolicy.TABS_NOT_VISIBLE)
0333: .setTabSelectTrigger(TabSelectTrigger.MOUSE_RELEASE)
0334: .setEnsureSelectedTabVisible(true)
0335: .setTabReorderEnabled(false).setHighlightPressedTab(
0336: false).setShadowEnabled(true);
0337:
0338: tabWindowProperties.getTabbedPanelProperties()
0339: .getTabAreaComponentsProperties()
0340: .getComponentProperties().setInsets(
0341: new Insets(1, 3, 1, 3));
0342:
0343: tabWindowProperties.getCloseButtonProperties().setFactory(
0344: DefaultButtonFactories.getCloseButtonFactory())
0345: .setVisible(true).setTo(
0346: CloseWithAbortWindowAction.INSTANCE);
0347:
0348: tabWindowProperties.getRestoreButtonProperties().setFactory(
0349: DefaultButtonFactories.getRestoreButtonFactory())
0350: .setVisible(true).setTo(
0351: RestoreWithAbortWindowAction.INSTANCE);
0352:
0353: tabWindowProperties.getMinimizeButtonProperties().setFactory(
0354: DefaultButtonFactories.getMinimizeButtonFactory())
0355: .setVisible(true).setTo(
0356: MinimizeWithAbortWindowAction.INSTANCE);
0357:
0358: tabWindowProperties.getMaximizeButtonProperties().setFactory(
0359: DefaultButtonFactories.getMaximizeButtonFactory())
0360: .setVisible(true).setTo(
0361: MaximizeWithAbortWindowAction.INSTANCE);
0362:
0363: tabWindowProperties.getUndockButtonProperties().setFactory(
0364: DefaultButtonFactories.getUndockButtonFactory())
0365: .setVisible(true).setTo(
0366: UndockWithAbortWindowAction.INSTANCE);
0367:
0368: tabWindowProperties.getDockButtonProperties().setFactory(
0369: DefaultButtonFactories.getDockButtonFactory())
0370: .setVisible(true).setTo(
0371: DockWithAbortWindowAction.INSTANCE);
0372:
0373: TabbedPanelButtonProperties buttonProps = tabWindowProperties
0374: .getTabbedPanelProperties().getButtonProperties();
0375: buttonProps.getTabDropDownListButtonProperties()
0376: .setToolTipText("Tab List");
0377: buttonProps.getScrollLeftButtonProperties().setToolTipText(
0378: "Scroll Left");
0379: buttonProps.getScrollRightButtonProperties().setToolTipText(
0380: "Scroll Right");
0381: buttonProps.getScrollUpButtonProperties().setToolTipText(
0382: "Scroll Up");
0383: buttonProps.getScrollDownButtonProperties().setToolTipText(
0384: "Scroll Down");
0385: }
0386:
0387: private static void setWindowBarProperties() {
0388: {
0389: WindowBarProperties p = DEFAULT_VALUES
0390: .getWindowBarProperties();
0391:
0392: p.setMinimumWidth(4);
0393: p.setContentPanelEdgeResizeEdgeDistance(6);
0394: p.setContinuousLayoutEnabled(true);
0395: p.setDragIndicatorColor(Color.DARK_GRAY);
0396:
0397: p.getTabWindowProperties().getTabbedPanelProperties()
0398: .setTabDeselectable(true).setAutoSelectTab(false)
0399:
0400: .getTabAreaComponentsProperties()
0401: .setStretchEnabled(true)
0402:
0403: .getComponentProperties().setBorder(
0404: new TabAreaLineBorder());
0405:
0406: p.getTabWindowProperties().getTabbedPanelProperties()
0407: .getContentPanelProperties()
0408: .getComponentProperties().setInsets(
0409: new Insets(4, 4, 4, 4));
0410:
0411: p.getTabWindowProperties().getTabbedPanelProperties()
0412: .getContentPanelProperties()
0413: .getShapedPanelProperties().setOpaque(true);
0414:
0415: p.getTabWindowProperties().getTabbedPanelProperties()
0416: .getTabAreaProperties().setTabAreaVisiblePolicy(
0417: TabAreaVisiblePolicy.ALWAYS);
0418: }
0419:
0420: {
0421: WindowTabProperties p = DEFAULT_VALUES
0422: .getWindowBarProperties().getTabWindowProperties()
0423: .getTabProperties();
0424:
0425: p.getTitledTabProperties().setSizePolicy(
0426: TitledTabSizePolicy.EQUAL_SIZE)
0427: // .addSuperObject(HighlightedTabSetup.createTabProperties())
0428: .setHighlightedRaised(0);
0429:
0430: /* p.getFocusedProperties()
0431: .setBackgroundColor(Color.YELLOW);
0432:
0433: */
0434: p.getTitledTabProperties().getNormalProperties()
0435: .getComponentProperties().setInsets(
0436: new Insets(1, 4, 1, 4));
0437:
0438: p.getNormalButtonProperties().getCloseButtonProperties()
0439: .setVisible(true);
0440: p.getNormalButtonProperties().getRestoreButtonProperties()
0441: .setVisible(true);
0442: p.getNormalButtonProperties().getUndockButtonProperties()
0443: .setVisible(true);
0444: p.getNormalButtonProperties().getDockButtonProperties()
0445: .setVisible(true);
0446: }
0447: }
0448:
0449: private static void setFloatingWindowProperties() {
0450: for (int i = 0; i < ComponentProperties.PROPERTIES
0451: .getPropertyCount(); i++) {
0452: Property property = ComponentProperties.PROPERTIES
0453: .getProperty(i);
0454:
0455: FloatingWindowProperties.COMPONENT_PROPERTIES.get(
0456: DEFAULT_VALUES.getFloatingWindowProperties()
0457: .getMap()).createRelativeRef(
0458: property,
0459: RootWindowProperties.WINDOW_AREA_PROPERTIES
0460: .get(DEFAULT_VALUES.getMap()), property);
0461: }
0462: for (int i = 0; i < ShapedPanelProperties.PROPERTIES
0463: .getPropertyCount(); i++) {
0464: Property property = ShapedPanelProperties.PROPERTIES
0465: .getProperty(i);
0466:
0467: FloatingWindowProperties.SHAPED_PANEL_PROPERTIES
0468: .get(
0469: DEFAULT_VALUES
0470: .getFloatingWindowProperties()
0471: .getMap())
0472: .createRelativeRef(
0473: property,
0474: RootWindowProperties.WINDOW_AREA_SHAPED_PANEL_PROPERTIES
0475: .get(DEFAULT_VALUES.getMap()),
0476: property);
0477: }
0478:
0479: DEFAULT_VALUES.getFloatingWindowProperties()
0480: .setAutoCloseEnabled(true);
0481: DEFAULT_VALUES.getFloatingWindowProperties().setUseFrame(false);
0482: }
0483:
0484: private static void setViewTitleBarProperties() {
0485: ViewTitleBarProperties props = DEFAULT_VALUES
0486: .getViewProperties().getViewTitleBarProperties();
0487:
0488: props.setOrientation(Direction.UP)
0489: .setDirection(Direction.RIGHT).getNormalProperties()
0490: .setTitleVisible(true).setIconVisible(true);
0491:
0492: ViewTitleBarStateProperties stateProps = props
0493: .getNormalProperties();
0494:
0495: stateProps.setButtonSpacing(0);
0496:
0497: stateProps.getUndockButtonProperties().setFactory(
0498: DefaultButtonFactories.getUndockButtonFactory())
0499: .setVisible(true).setTo(
0500: UndockWithAbortWindowAction.INSTANCE);
0501:
0502: stateProps.getDockButtonProperties().setFactory(
0503: DefaultButtonFactories.getDockButtonFactory())
0504: .setVisible(true).setTo(
0505: DockWithAbortWindowAction.INSTANCE);
0506:
0507: stateProps.getCloseButtonProperties().setFactory(
0508: DefaultButtonFactories.getCloseButtonFactory())
0509: .setVisible(true).setTo(
0510: CloseWithAbortWindowAction.INSTANCE);
0511:
0512: stateProps.getRestoreButtonProperties().setFactory(
0513: DefaultButtonFactories.getRestoreButtonFactory())
0514: .setVisible(true).setTo(
0515: RestoreViewWithAbortTitleBarAction.INSTANCE);
0516:
0517: stateProps.getMinimizeButtonProperties().setFactory(
0518: DefaultButtonFactories.getMinimizeButtonFactory())
0519: .setVisible(true).setTo(
0520: MinimizeWithAbortWindowAction.INSTANCE);
0521:
0522: stateProps.getMaximizeButtonProperties().setFactory(
0523: DefaultButtonFactories.getMaximizeButtonFactory())
0524: .setVisible(true).setTo(
0525: MaximizeWithAbortWindowAction.INSTANCE);
0526:
0527: stateProps.getMap().createRelativeRef(
0528: ViewTitleBarStateProperties.TITLE,
0529: DEFAULT_VALUES.getViewProperties().getMap(),
0530: ViewProperties.TITLE);
0531:
0532: stateProps.getMap().createRelativeRef(
0533: ViewTitleBarStateProperties.ICON,
0534: DEFAULT_VALUES.getViewProperties().getMap(),
0535: ViewProperties.ICON);
0536: }
0537:
0538: private static void updateVisualProperties() {
0539: DEFAULT_VALUES.getWindowBarProperties()
0540: .getTabWindowProperties().getTabProperties()
0541: .getTitledTabProperties().getNormalProperties()
0542: .getComponentProperties().setBackgroundColor(
0543: TabbedUIDefaults
0544: .getHighlightedStateBackground());
0545:
0546: Color shadowColor = UIManagerUtil.getColor("controlDkShadow",
0547: Color.BLACK);
0548:
0549: DEFAULT_VALUES.getWindowAreaProperties().setBorder(
0550: new LineBorder(shadowColor))
0551: .setBackgroundColor(
0552: UIManagerUtil.getColor("Desktop.background",
0553: "control"));
0554:
0555: DEFAULT_VALUES.getWindowAreaShapedPanelProperties().setOpaque(
0556: true);
0557:
0558: DEFAULT_VALUES.getDragLabelProperties().setBorder(
0559: new LineBorder(shadowColor)).setFont(
0560: UIManagerUtil.getFont("ToolTip.font"))
0561: .setForegroundColor(
0562: UIManagerUtil.getColor("ToolTip.foreground",
0563: "controlText")).setBackgroundColor(
0564: UIManagerUtil.getColor("ToolTip.background",
0565: "control"));
0566:
0567: DEFAULT_VALUES.setRecursiveTabsEnabled(true);
0568: }
0569:
0570: private static void updateFont() {
0571: Font font = TitledTabProperties.getDefaultProperties()
0572: .getHighlightedProperties().getComponentProperties()
0573: .getFont();
0574:
0575: if (font != null)
0576: font = font.deriveFont(Font.BOLD);
0577:
0578: DEFAULT_VALUES.getTabWindowProperties().getTabProperties()
0579: .getTitledTabProperties().getHighlightedProperties()
0580: .getComponentProperties().setFont(font);
0581: }
0582:
0583: private static void updateViewTitleBarProperties() {
0584: ViewTitleBarProperties props = DEFAULT_VALUES
0585: .getViewProperties().getViewTitleBarProperties();
0586: Font font = TabbedUIDefaults.getFont();
0587: if (font != null)
0588: font = font.deriveFont(Font.BOLD);
0589:
0590: props
0591: .getNormalProperties()
0592: .getComponentProperties()
0593: .setFont(font)
0594: .setForegroundColor(
0595: UIManager
0596: .getColor("InternalFrame.inactiveTitleForeground"))
0597: .setBackgroundColor(
0598: UIManager
0599: .getColor("InternalFrame.inactiveTitleBackground"))
0600: .setInsets(new Insets(2, 2, 2, 2));
0601: props
0602: .getFocusedProperties()
0603: .getComponentProperties()
0604: .setForegroundColor(
0605: UIManager
0606: .getColor("InternalFrame.activeTitleForeground"))
0607: .setBackgroundColor(
0608: UIManager
0609: .getColor("InternalFrame.activeTitleBackground"));
0610:
0611: Color c1 = UIManager
0612: .getColor("InternalFrame.inactiveTitleBackground");
0613: Color c2 = UIManager
0614: .getColor("InternalFrame.inactiveTitleGradient");
0615: ComponentPainter backgroundPainter;
0616:
0617: if (c1 == null)
0618: backgroundPainter = null;
0619: else if (c1.equals(c2) || c2 == null)
0620: backgroundPainter = new SolidColorComponentPainter(
0621: new FixedColorProvider(c1));
0622: else
0623: backgroundPainter = new GradientComponentPainter(c2, c2,
0624: c1, c1);
0625: props.getNormalProperties().getShapedPanelProperties()
0626: .setComponentPainter(backgroundPainter).setOpaque(true);
0627:
0628: Color focused1 = UIManager
0629: .getColor("InternalFrame.activeTitleBackground");
0630: Color focused2 = UIManager
0631: .getColor("InternalFrame.activeTitleGradient");
0632: ComponentPainter focusedPainter;
0633:
0634: if (focused1 == null)
0635: focusedPainter = null;
0636: else if (focused1.equals(focused2) || focused2 == null)
0637: focusedPainter = new SolidColorComponentPainter(
0638: new FixedColorProvider(focused1));
0639: else
0640: focusedPainter = new GradientComponentPainter(focused2,
0641: focused2, focused1, focused1);
0642: props.getFocusedProperties().getShapedPanelProperties()
0643: .setComponentPainter(focusedPainter);
0644: props
0645: .getFocusedProperties()
0646: .getComponentProperties()
0647: .setForegroundColor(
0648: UIManager
0649: .getColor("InternalFrame.activeTitleForeground"));
0650:
0651: props.setContentTitleBarGap(0).getNormalProperties()
0652: .setIconTextGap(TabbedUIDefaults.getIconTextGap());
0653: }
0654:
0655: static {
0656: DEFAULT_VALUES = new RootWindowProperties(PROPERTIES
0657: .getDefaultMap());
0658:
0659: DEFAULT_VALUES.setAbortDragKey(
0660: TabbedPanelProperties.getDefaultProperties()
0661: .getAbortDragKey()).setEdgeSplitDistance(6)
0662: .setDragRectangleBorderWidth(5);
0663:
0664: DEFAULT_VALUES.getShapedPanelProperties().setOpaque(true);
0665:
0666: DEFAULT_VALUES.getDockingWindowProperties().setMaximizeEnabled(
0667: true).setMinimizeEnabled(true).setCloseEnabled(true)
0668: .setRestoreEnabled(true).setDragEnabled(true)
0669: .setUndockEnabled(true).setUndockOnDropEnabled(true)
0670: .setDockEnabled(true);
0671:
0672: DEFAULT_VALUES.getDockingWindowProperties()
0673: .getDropFilterProperties().setChildDropFilter(
0674: AcceptAllDropFilter.INSTANCE)
0675: .setInsertTabDropFilter(AcceptAllDropFilter.INSTANCE)
0676: .setInteriorDropFilter(AcceptAllDropFilter.INSTANCE)
0677: .setSplitDropFilter(AcceptAllDropFilter.INSTANCE);
0678:
0679: DEFAULT_VALUES.getWindowAreaProperties().setInsets(
0680: new Insets(6, 6, 2, 2));
0681:
0682: DEFAULT_VALUES.getDragLabelProperties().setInsets(
0683: new Insets(4, 6, 4, 6));
0684:
0685: DEFAULT_VALUES.getDragRectangleShapedPanelProperties()
0686: .setOpaque(false);
0687:
0688: DEFAULT_VALUES.getSplitWindowProperties()
0689: .setContinuousLayoutEnabled(true).setDividerSize(4)
0690: .setDividerLocationDragEnabled(true)
0691: .setDragIndicatorColor(Color.DARK_GRAY);
0692:
0693: DEFAULT_VALUES.getViewProperties().setAlwaysShowTitle(true);
0694:
0695: setTabbedPanelProperties();
0696: setTabProperties();
0697: setWindowBarProperties();
0698: setViewTitleBarProperties();
0699: setFloatingWindowProperties();
0700:
0701: updateVisualProperties();
0702:
0703: updateViewTitleBarProperties();
0704:
0705: updateFont();
0706:
0707: TitledTabProperties.getDefaultProperties()
0708: .getHighlightedProperties().getComponentProperties()
0709: .getMap().addListener(new PropertyMapListener() {
0710: public void propertyValuesChanged(
0711: PropertyMap propertyObject, Map changes) {
0712: updateFont();
0713: }
0714: });
0715:
0716: DynamicUIManager.getInstance().addListener(
0717: new DynamicUIManagerListener() {
0718: public void lookAndFeelChanged() {
0719: PropertyMapManager.runBatch(new Runnable() {
0720: public void run() {
0721: updateVisualProperties();
0722: updateViewTitleBarProperties();
0723: }
0724: });
0725: }
0726:
0727: public void propertiesChanged() {
0728: PropertyMapManager.runBatch(new Runnable() {
0729: public void run() {
0730: updateVisualProperties();
0731: updateViewTitleBarProperties();
0732: }
0733: });
0734: }
0735:
0736: public void propertiesChanging() {
0737: }
0738:
0739: public void lookAndFeelChanging() {
0740: }
0741: });
0742: }
0743:
0744: /**
0745: * Creates a property object that inherits default property values.
0746: *
0747: * @return a new property object that inherits default property values
0748: */
0749: public static RootWindowProperties createDefault() {
0750: return new RootWindowProperties(DEFAULT_VALUES);
0751: }
0752:
0753: /**
0754: * Creates an empty property object.
0755: */
0756: public RootWindowProperties() {
0757: super (PropertyMapFactory.create(PROPERTIES));
0758: }
0759:
0760: /**
0761: * Creates a property object containing the map.
0762: *
0763: * @param map the property map
0764: */
0765: public RootWindowProperties(PropertyMap map) {
0766: super (map);
0767: }
0768:
0769: /**
0770: * Creates a property object which inherits property values from another object.
0771: *
0772: * @param inheritFrom the object which from to inherit property values
0773: */
0774: public RootWindowProperties(RootWindowProperties inheritFrom) {
0775: super (PropertyMapFactory.create(inheritFrom.getMap()));
0776: }
0777:
0778: /**
0779: * Adds a super object from which property values are inherited.
0780: *
0781: * @param properties the object from which to inherit property values
0782: * @return this
0783: */
0784: public RootWindowProperties addSuperObject(
0785: RootWindowProperties properties) {
0786: getMap().addSuperMap(properties.getMap());
0787: return this ;
0788: }
0789:
0790: /**
0791: * Removes the last added super object.
0792: *
0793: * @return this
0794: * @since IDW 1.1.0
0795: * @deprecated Use {@link #removeSuperObject(RootWindowProperties)} instead.
0796: */
0797: public RootWindowProperties removeSuperObject() {
0798: getMap().removeSuperMap();
0799: return this ;
0800: }
0801:
0802: /**
0803: * Removes a super object.
0804: *
0805: * @param superObject the super object to remove
0806: * @return this
0807: * @since IDW 1.3.0
0808: */
0809: public RootWindowProperties removeSuperObject(
0810: RootWindowProperties super Object) {
0811: getMap().removeSuperMap(super Object.getMap());
0812: return this ;
0813: }
0814:
0815: /**
0816: * Replaces a super object.
0817: *
0818: * @param oldSuperObject the super object to be replaced
0819: * @param newSuperObject the super object to replace it with
0820: * @return this
0821: * @since IDW 1.3.0
0822: */
0823: public RootWindowProperties replaceSuperObject(
0824: RootWindowProperties oldSuperObject,
0825: RootWindowProperties newSuperObject) {
0826: getMap().replaceSuperMap(oldSuperObject.getMap(),
0827: newSuperObject.getMap());
0828: return this ;
0829: }
0830:
0831: /**
0832: * Returns the default property values for tab windows.
0833: *
0834: * @return the default property values for tab windows
0835: */
0836: public TabWindowProperties getTabWindowProperties() {
0837: return new TabWindowProperties(TAB_WINDOW_PROPERTIES
0838: .get(getMap()));
0839: }
0840:
0841: /**
0842: * Returns the default property values for split windows.
0843: *
0844: * @return the default property values for split windows
0845: */
0846: public SplitWindowProperties getSplitWindowProperties() {
0847: return new SplitWindowProperties(SPLIT_WINDOW_PROPERTIES
0848: .get(getMap()));
0849: }
0850:
0851: /**
0852: * Returns the default property values for floating windows.
0853: *
0854: * @return the default property values for floating windows
0855: * @since IDW 1.4.0
0856: */
0857: public FloatingWindowProperties getFloatingWindowProperties() {
0858: return new FloatingWindowProperties(FLOATING_WINDOW_PROPERTIES
0859: .get(getMap()));
0860: }
0861:
0862: /**
0863: * Returns the default property values for views.
0864: *
0865: * @return the default property values for views
0866: */
0867: public ViewProperties getViewProperties() {
0868: return new ViewProperties(VIEW_PROPERTIES.get(getMap()));
0869: }
0870:
0871: /**
0872: * Returns the default property values for docking windows.
0873: *
0874: * @return the default property values for docking windows
0875: */
0876: public DockingWindowProperties getDockingWindowProperties() {
0877: return new DockingWindowProperties(DOCKING_WINDOW_PROPERTIES
0878: .get(getMap()));
0879: }
0880:
0881: /**
0882: * Sets the border width of the drag rectangle.
0883: *
0884: * @param width the border width
0885: * @return this
0886: */
0887: public RootWindowProperties setDragRectangleBorderWidth(int width) {
0888: DRAG_RECTANGLE_BORDER_WIDTH.set(getMap(), width);
0889: return this ;
0890: }
0891:
0892: /**
0893: * Returns the border width of the drag rectangle.
0894: *
0895: * @return the border width of the drag rectangle
0896: */
0897: public int getDragRectangleBorderWidth() {
0898: return DRAG_RECTANGLE_BORDER_WIDTH.get(getMap());
0899: }
0900:
0901: /**
0902: * Returns true if the user is allowed to place tab windows inside other tab windows.
0903: *
0904: * @return true if tab windows are allowed to be placed in other tab windows
0905: */
0906: public boolean getRecursiveTabsEnabled() {
0907: return RECURSIVE_TABS_ENABLED.get(getMap());
0908: }
0909:
0910: /**
0911: * Returns true if double clicking on a window tab in a window bar restores the window.
0912: *
0913: * @return true if double clicking on a window tab in a window bar restores the window
0914: */
0915: public boolean getDoubleClickRestoresWindow() {
0916: return DOUBLE_CLICK_RESTORES_WINDOW.get(getMap());
0917: }
0918:
0919: /**
0920: * If set to true, double clicking on a window tab in a window bar restores the window.
0921: *
0922: * @param enabled if true, double clicking on a window tab in a window bar restores the window
0923: * @return this
0924: */
0925: public RootWindowProperties setDoubleClickRestoresWindow(
0926: boolean enabled) {
0927: DOUBLE_CLICK_RESTORES_WINDOW.set(getMap(), enabled);
0928: return this ;
0929: }
0930:
0931: /**
0932: * If set to true, the user is allowed to place tab windows inside other tab windows.
0933: *
0934: * @param enabled if true, the user is allowed to place tab windows inside other tab windows
0935: * @return this
0936: */
0937: public RootWindowProperties setRecursiveTabsEnabled(boolean enabled) {
0938: RECURSIVE_TABS_ENABLED.set(getMap(), enabled);
0939: return this ;
0940: }
0941:
0942: /**
0943: * Returns the property values for the drag label.
0944: *
0945: * @return the property values for the drag label
0946: */
0947: public ComponentProperties getDragLabelProperties() {
0948: return new ComponentProperties(DRAG_LABEL_PROPERTIES
0949: .get(getMap()));
0950: }
0951:
0952: /**
0953: * Returns the property values for the root window component.
0954: *
0955: * @return the property values for the root window component
0956: */
0957: public ComponentProperties getComponentProperties() {
0958: return new ComponentProperties(COMPONENT_PROPERTIES
0959: .get(getMap()));
0960: }
0961:
0962: /**
0963: * Returns the property values for the root window shaped panel.
0964: *
0965: * @return the property values for the root window shaped panel
0966: * @since IDW 1.2.0
0967: */
0968: public ShapedPanelProperties getShapedPanelProperties() {
0969: return new ShapedPanelProperties(SHAPED_PANEL_PROPERTIES
0970: .get(getMap()));
0971: }
0972:
0973: /**
0974: * Returns the component property values for the window area component.
0975: *
0976: * @return the component property values for the window area component
0977: */
0978: public ComponentProperties getWindowAreaProperties() {
0979: return new ComponentProperties(WINDOW_AREA_PROPERTIES
0980: .get(getMap()));
0981: }
0982:
0983: /**
0984: * Returns the shaped panel property values for the window area component.
0985: *
0986: * @return the shaped panel property values for the window area component
0987: */
0988: public ShapedPanelProperties getWindowAreaShapedPanelProperties() {
0989: return new ShapedPanelProperties(
0990: WINDOW_AREA_SHAPED_PANEL_PROPERTIES.get(getMap()));
0991: }
0992:
0993: /**
0994: * Sets the distance from the window edge inside which a mouse drag will trigger a window split.
0995: *
0996: * @param size the distance from the window edge inside which a mouse drag will trigger a window split
0997: * @return this
0998: */
0999: public RootWindowProperties setEdgeSplitDistance(int size) {
1000: EDGE_SPLIT_DISTANCE.set(getMap(), size);
1001: return this ;
1002: }
1003:
1004: /**
1005: * Returns the distance from the window edge inside which a mouse drag will trigger a window split.
1006: *
1007: * @return the distance from the window edge inside which a mouse drag will trigger a window split
1008: */
1009: public int getEdgeSplitDistance() {
1010: return EDGE_SPLIT_DISTANCE.get(getMap());
1011: }
1012:
1013: /**
1014: * Returns the key code for the key that aborts a drag.
1015: *
1016: * @return the key code for the key that aborts a drag
1017: */
1018: public int getAbortDragKey() {
1019: return ABORT_DRAG_KEY.get(getMap());
1020: }
1021:
1022: /**
1023: * Sets the key code for the key that aborts a drag.
1024: *
1025: * @param key the key code for the key that aborts a drag
1026: * @return this
1027: */
1028: public RootWindowProperties setAbortDragKey(int key) {
1029: ABORT_DRAG_KEY.set(getMap(), key);
1030: return this ;
1031: }
1032:
1033: /**
1034: * Returns the default window bar property values.
1035: *
1036: * @return the default window bar property values
1037: * @since IDW 1.1.0
1038: */
1039: public WindowBarProperties getWindowBarProperties() {
1040: return new WindowBarProperties(WINDOW_BAR_PROPERTIES
1041: .get(getMap()));
1042: }
1043:
1044: /**
1045: * Shaped panel properties for the drag rectangle. Setting a painter disables the default drag rectangle.
1046: *
1047: * @return the drag rectangle shaped panel properties
1048: * @since IDW 1.2.0
1049: */
1050: public ShapedPanelProperties getDragRectangleShapedPanelProperties() {
1051: return new ShapedPanelProperties(
1052: DRAG_RECTANGLE_SHAPED_PANEL_PROPERTIES.get(getMap()));
1053: }
1054:
1055: }
|