⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rootwindowproperties.java

📁 修正了jdk1.6中对托盘事件产生异常的bug.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * Copyright (C) 2004 NNL Technology AB
 * Visit www.infonode.net for information about InfoNode(R) 
 * products and how to contact NNL Technology AB.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 
 * MA 02111-1307, USA.
 */

// $Id: RootWindowProperties.java,v 1.96 2007/01/28 21:25:10 jesper Exp $
package net.infonode.docking.properties;

import net.infonode.docking.DefaultButtonFactories;
import net.infonode.docking.action.*;
import net.infonode.docking.drop.AcceptAllDropFilter;
import net.infonode.docking.internalutil.InternalDockingUtil;
import net.infonode.gui.DynamicUIManager;
import net.infonode.gui.DynamicUIManagerListener;
import net.infonode.gui.UIManagerUtil;
import net.infonode.gui.colorprovider.FixedColorProvider;
import net.infonode.gui.componentpainter.ComponentPainter;
import net.infonode.gui.componentpainter.GradientComponentPainter;
import net.infonode.gui.componentpainter.SolidColorComponentPainter;
import net.infonode.properties.base.Property;
import net.infonode.properties.gui.util.ComponentProperties;
import net.infonode.properties.gui.util.ShapedPanelProperties;
import net.infonode.properties.propertymap.*;
import net.infonode.properties.types.BooleanProperty;
import net.infonode.properties.types.IntegerProperty;
import net.infonode.tabbedpanel.*;
import net.infonode.tabbedpanel.border.TabAreaLineBorder;
import net.infonode.tabbedpanel.titledtab.TitledTabProperties;
import net.infonode.tabbedpanel.titledtab.TitledTabSizePolicy;
import net.infonode.util.Direction;

import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.util.Map;

/**
 * Properties and property values for a root window.
 *
 * @author $Author: jesper $
 * @version $Revision: 1.96 $
 */
public class RootWindowProperties extends PropertyMapContainer {
  /**
   * The size of the default window tab button icons.
   */
  public static final int DEFAULT_WINDOW_TAB_BUTTON_ICON_SIZE = InternalDockingUtil.DEFAULT_BUTTON_ICON_SIZE;

  /**
   * Property group containing all root window properties.
   */
  public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup("Root Window Properties", "");

  /**
   * The root window component property values.
   */
  public static final PropertyMapProperty COMPONENT_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Component Properties",
                              "The root window component property values.",
                              ComponentProperties.PROPERTIES);

  /**
   * The root window shaped panel property values.
   */
  public static final PropertyMapProperty SHAPED_PANEL_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Shaped Panel Properties",
                              "The root window shaped panel property values.",
                              ShapedPanelProperties.PROPERTIES);

  /**
   * The window area component property values. The window area is the area inside the WindowBars.
   */
  public static final PropertyMapProperty WINDOW_AREA_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Window Area Properties",
                              "The window area component property values. The window area is the area inside the WindowBars.",
                              ComponentProperties.PROPERTIES);

  /**
   * The window area shaped panel property values. The window area is the area inside the WindowBars.
   */
  public static final PropertyMapProperty WINDOW_AREA_SHAPED_PANEL_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Window Area Shaped Panel Properties",
                              "The window area shaped panel property values. The window area is the area inside the WindowBars.",
                              ShapedPanelProperties.PROPERTIES);

  /**
   * Shaped panel properties for the drag rectangle. Setting a painter disables the default drag rectangle.
   *
   * @since IDW 1.2.0
   */
  public static final PropertyMapProperty DRAG_RECTANGLE_SHAPED_PANEL_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Drag Rectangle Shaped Panel Properties",
                              "Shaped panel properties for the drag rectangle. Setting a painter disables the default drag rectangle.",
                              ShapedPanelProperties.PROPERTIES);

  /**
   * The width of the drag rectangle border.
   */
  public static final IntegerProperty DRAG_RECTANGLE_BORDER_WIDTH =
      IntegerProperty.createPositive(PROPERTIES,
                                     "Drag Rectangle Border Width",
                                     "The width of the drag rectangle border. The drag rectangle will only " +
                                     "be painted if the painter of the '" +
                                     DRAG_RECTANGLE_SHAPED_PANEL_PROPERTIES.getName() +
                                     "' property is not set.",
                                     2,
                                     PropertyMapValueHandler.INSTANCE);

  /**
   * The window drag label property values.
   */
  public static final PropertyMapProperty DRAG_LABEL_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Drag Label Properties",
                              "The window drag label property values.",
                              ComponentProperties.PROPERTIES);

  /**
   * Default property values for DockingWindows inside this root window.
   */
  public static final PropertyMapProperty DOCKING_WINDOW_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Docking Window Properties",
                              "Default property values for DockingWindows inside this RootWindow.",
                              DockingWindowProperties.PROPERTIES);

  /**
   * Default property values for tab windows inside this root window.
   */
  public static final PropertyMapProperty TAB_WINDOW_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Tab Window Properties",
                              "Default property values for TabWindows inside this RootWindow.",
                              TabWindowProperties.PROPERTIES);

  /**
   * Default property values for split windows inside this root window.
   */
  public static final PropertyMapProperty SPLIT_WINDOW_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Split Window Properties",
                              "Default property values for SplitWindows inside this RootWindow.",
                              SplitWindowProperties.PROPERTIES);

  /**
   * Default property values for floating windows inside this root window.
   *
   * @since IDW 1.4.0
   */
  public static final PropertyMapProperty FLOATING_WINDOW_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Floating Window Properties",
                              "Default property values for FloatingWindows inside this RootWindow.",
                              FloatingWindowProperties.PROPERTIES);

  /**
   * Default property values for views inside this root window.
   */
  public static final PropertyMapProperty VIEW_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "View Properties",
                              "Default property values for Views inside this RootWindow.",
                              ViewProperties.PROPERTIES);

  /**
   * Double clicking on a minimized window in a window bar restores it.
   */
  public static final BooleanProperty DOUBLE_CLICK_RESTORES_WINDOW =
      new BooleanProperty(PROPERTIES,
                          "Double Click Restores Window",
                          "Double clicking on a minimized window in a window bar restores it.",
                          PropertyMapValueHandler.INSTANCE);

  /**
   * If true, makes it possible for the user to create tab windows inside other tab windows when dragging windows.
   * If false, only one level of tab windows is allowed.
   * Changing the value of this property does not alter the window tree.
   */
  public static final BooleanProperty RECURSIVE_TABS_ENABLED =
      new BooleanProperty(PROPERTIES,
                          "Recursive Tabs Enabled",
                          "If true, makes it possible for the user to create tab windows inside other tab windows by " +
                          "dragging windows. If false, only one level of tab windows is allowed. Changing the value of " +
                          "this property does not alter the window tree.",
                          PropertyMapValueHandler.INSTANCE);

  /**
   * Inside this distance from the window edge a mouse drag will trigger a window split.
   */
  public static final IntegerProperty EDGE_SPLIT_DISTANCE =
      IntegerProperty.createPositive(PROPERTIES,
                                     "Edge Split Distance",
                                     "Inside this distance from the window edge a mouse drag will trigger a window split.",
                                     3,
                                     PropertyMapValueHandler.INSTANCE);

  /**
   * Key code for the key that aborts a drag.
   */
  public static final IntegerProperty ABORT_DRAG_KEY =
      IntegerProperty.createPositive(PROPERTIES,
                                     "Abort Drag Key Code",
                                     "Key code for the key that aborts a drag.",
                                     3,
                                     PropertyMapValueHandler.INSTANCE);

  /**
   * The default window bar property values.
   *
   * @since IDW 1.1.0
   */
  public static final PropertyMapProperty WINDOW_BAR_PROPERTIES =
      new PropertyMapProperty(PROPERTIES,
                              "Window Bar Properties",
                              "Default property values for WindowBars inside this RootWindow.",
                              WindowBarProperties.PROPERTIES);

  private static RootWindowProperties DEFAULT_VALUES;

  private static void setTabProperties() {
    WindowTabProperties tabProperties = DEFAULT_VALUES.getTabWindowProperties().getTabProperties();

    PropertyMapProperty[] buttonProperties = {WindowTabStateProperties.CLOSE_BUTTON_PROPERTIES,
                                              WindowTabStateProperties.MINIMIZE_BUTTON_PROPERTIES,
                                              WindowTabStateProperties.RESTORE_BUTTON_PROPERTIES,
                                              WindowTabStateProperties.UNDOCK_BUTTON_PROPERTIES,
                                              WindowTabStateProperties.DOCK_BUTTON_PROPERTIES};

    for (int i = 0; i < buttonProperties.length; i++) {
      for (int j = 0; j < WindowTabButtonProperties.PROPERTIES.getPropertyCount(); j++) {
        Property property = WindowTabButtonProperties.PROPERTIES.getProperty(j);

        // Highlighted properties inherits from normal properties
        buttonProperties[i].get(tabProperties.getHighlightedButtonProperties().getMap()).
            createRelativeRef(property,
                              buttonProperties[i].get(tabProperties.getNormalButtonProperties().getMap()),
                              property);

        // Focus properties inherits from highlight properties
        buttonProperties[i].get(tabProperties.getFocusedButtonProperties().getMap()).
            createRelativeRef(property,
                              buttonProperties[i].get(tabProperties.getHighlightedButtonProperties().getMap()),
                              property);
      }
    }

    tabProperties.getTitledTabProperties().getNormalProperties()
        .setToolTipEnabled(true)
        .getComponentProperties().setInsets(new Insets(0, 3, 0, 2));

    tabProperties.getTitledTabProperties().setSizePolicy(TitledTabSizePolicy.INDIVIDUAL_SIZE);

    tabProperties.getNormalButtonProperties().getCloseButtonProperties()
        .setFactory(DefaultButtonFactories.getCloseButtonFactory())
        .setTo(CloseWithAbortWindowAction.INSTANCE);

    tabProperties.getNormalButtonProperties().getUndockButtonProperties()
        .setFactory(DefaultButtonFactories.getUndockButtonFactory())
        .setVisible(false)
        .setTo(UndockWithAbortWindowAction.INSTANCE);

    tabProperties.getNormalButtonProperties().getDockButtonProperties()
        .setFactory(DefaultButtonFactories.getDockButtonFactory())
        .setVisible(false)
        .setTo(DockWithAbortWindowAction.INSTANCE);

    tabProperties.getNormalButtonProperties().getRestoreButtonProperties()
        .setFactory(DefaultButtonFactories.getRestoreButtonFactory())
        .setVisible(false)
        .setTo(RestoreWithAbortWindowAction.INSTANCE);

    tabProperties.getNormalButtonProperties().getMinimizeButtonProperties()
        .setFactory(DefaultButtonFactories.getMinimizeButtonFactory())
        .setVisible(false)
        .setTo(MinimizeWithAbortWindowAction.INSTANCE);

    tabProperties.getTitledTabProperties().setFocusable(false);
    tabProperties.getHighlightedButtonProperties().getCloseButtonProperties().setVisible(true);
    tabProperties.getHighlightedButtonProperties().getMinimizeButtonProperties().setVisible(true);
    tabProperties.getHighlightedButtonProperties().getRestoreButtonProperties().setVisible(true);
    tabProperties.getHighlightedButtonProperties().getUndockButtonProperties().setVisible(true);
    tabProperties.getHighlightedButtonProperties().getDockButtonProperties().setVisible(true);
  }

  private static void setTabbedPanelProperties() {
    TabWindowProperties tabWindowProperties = DEFAULT_VALUES.getTabWindowProperties();

    tabWindowProperties.getTabbedPanelProperties()
        .setTabDropDownListVisiblePolicy(TabDropDownListVisiblePolicy.TABS_NOT_VISIBLE)
        .setTabSelectTrigger(TabSelectTrigger.MOUSE_RELEASE)
        .setEnsureSelectedTabVisible(true)
        .setTabReorderEnabled(false)
        .setHighlightPressedTab(false)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -