private static JMenu getMoveToMenuItems(final DockingWindow window) {
    JMenu moveToMenu = new JMenu("Move to Window Bar");

    if (window.isMinimizable()) {
      final RootWindow root = window.getRootWindow();
      final Direction[] directions = Direction.getDirections();

      for (int i = 0; i < 4; i++) {
        final Direction dir = directions[i];

        if (!DockingUtil.isAncestor(root.getWindowBar(dir), window)
            && root.getWindowBar(dir).isEnabled()) {
          moveToMenu
              .add(new JMenuItem(dir.getName(), ARROW_ICONS[i]))
              .addActionListener(
                  new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                      root.getWindowBar(dir).addTab(window);
                    }
                  });
        }
      }
    }

    return moveToMenu;
  }
  static {
    final Direction[] directions = Direction.getDirections();

    for (int i = 0; i < directions.length; i++)
      ARROW_ICONS[i] =
          new ArrowIcon(InternalDockingUtil.DEFAULT_BUTTON_ICON_SIZE + 1, directions[i]);
  }
  private static void addTabDirectionMenuItems(JPopupMenu menu, DockingWindow window) {
    final AbstractTabWindow tabWindow = getTabWindowFor(window);

    if (tabWindow == null) return;

    JMenu directionMenu = new JMenu("Tab Direction");
    TitledTabProperties properties = TitledTabProperties.getDefaultProperties();
    properties.addSuperObject(
        tabWindow.getTabWindowProperties().getTabProperties().getTitledTabProperties());
    final Direction[] directions = Direction.getDirections();

    for (int i = 0; i < directions.length; i++) {
      final Direction dir = directions[i];

      if (dir != Direction.LEFT) {
        JMenuItem item = directionMenu.add(new JMenuItem(dir.getName(), ARROW_ICONS[i]));
        item.setEnabled(dir != properties.getNormalProperties().getDirection());
        item.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                tabWindow
                    .getTabWindowProperties()
                    .getTabProperties()
                    .getTitledTabProperties()
                    .getNormalProperties()
                    .setDirection(dir);
              }
            });
      }
    }

    menu.add(directionMenu);
  }
  private static void addTabOrientationMenuItems(JPopupMenu menu, DockingWindow window) {
    final AbstractTabWindow tabWindow = getTabWindowFor(window);

    if (tabWindow == null || tabWindow instanceof WindowBar) return;

    JMenu orientationMenu = new JMenu("Tab Orientation");
    TabbedPanelProperties properties =
        tabWindow.getTabWindowProperties().getTabbedPanelProperties();
    final Direction[] directions = Direction.getDirections();

    for (int i = 0; i < directions.length; i++) {
      final Direction dir = directions[i];
      JMenuItem item = orientationMenu.add(new JMenuItem(dir.getName(), ARROW_ICONS[i]));
      item.setEnabled(dir != properties.getTabAreaOrientation());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              tabWindow
                  .getTabWindowProperties()
                  .getTabbedPanelProperties()
                  .setTabAreaOrientation(dir);
            }
          });
    }

    menu.add(orientationMenu);
  }
  /**
   * Creates the Titled Tab menu
   *
   * @return the titled tab menu
   */
  private JMenu createTitledTabMenu() {
    JMenu titledTabMenu = new JMenu("Titled Tab");

    // Get all avaliable directions
    Direction[] directions = Direction.getDirections();
    for (int i = 0; i < directions.length; i++) {
      final Direction direction = directions[i];
      titledTabMenu.add(
          createMenuItem(
              "Direction: " + direction.getName(),
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  // Sets in what direction the icon, text and title
                  // components are laid out (as a line).
                  // If no direction have been set for the highlighted and/or
                  // disabled state then those
                  // states will use the direction for the normal state and
                  // therefore we only need to
                  // set the direction for the normal state because we want
                  // the same direction for all
                  // states in this example. The titled tab is automatically
                  // updated.
                  titledTabProperties.getNormalProperties().setDirection(direction);
                }
              }));
    }

    titledTabMenu.add(new JSeparator());

    // Get all size policies
    TitledTabSizePolicy[] titledTabSizePolicies = TitledTabSizePolicy.getSizePolicies();
    for (int i = 0; i < titledTabSizePolicies.length; i++) {
      final TitledTabSizePolicy titledTabSizePolicy = titledTabSizePolicies[i];
      titledTabMenu.add(
          createMenuItem(
              "Size Policy: " + titledTabSizePolicy.getName(),
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  // Sets the size policy for the entire titled tab. This
                  // means that if equal size is
                  // set then titled tab will calculate its maximum size for
                  // all its state and use that
                  // size regardless of the current state for the tab. If
                  // individual size is used then
                  // titled tab will only use the size for the active state
                  // even i.e. if the states have
                  // different sizes i.e. titled tab will change size
                  // depending on what state it is in.
                  // The titled tab is automatically updated.
                  titledTabProperties.setSizePolicy(titledTabSizePolicy);
                }
              }));
    }

    return titledTabMenu;
  }
 /**
  * Constructor.
  *
  * @param group the property group
  * @param name the property name
  * @param description the property description
  * @param valueHandler handles values for this property
  */
 public DirectionProperty(
     PropertyGroup group, String name, String description, PropertyValueHandler valueHandler) {
   super(group, name, Direction.class, description, valueHandler, Direction.getDirections());
 }
  /**
   * Creates the Tabbed Panel menu
   *
   * @return the tabbed panel menu
   */
  private JMenu createTabbedPanelMenu() {
    JMenu tabbedPanelMenu = new JMenu("Tabbed Panel");

    tabbedPanelMenu.add(
        createMenuItem(
            "Add a Titled Tab",
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                tabbedPanel.addTab(createTab());
              }
            }));

    tabbedPanelMenu.add(new JSeparator());

    // Get all avaliable directions
    Direction[] directions = Direction.getDirections();
    for (int i = 0; i < directions.length; i++) {
      final Direction direction = directions[i];
      tabbedPanelMenu.add(
          createMenuItem(
              "Tab Area Orientation: " + direction.getName(),
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  // Sets the orientation (direction) for the tab area in the
                  // TabbedPanelProperties
                  // for the tabbed panel. The tabbed panel is automatically
                  // updated.
                  tabbedPanel.getProperties().setTabAreaOrientation(direction);
                }
              }));
    }

    tabbedPanelMenu.add(new JSeparator());

    // Get all available tab layout policies i.e. how the tabs can be laid
    // out in the tab area
    TabLayoutPolicy[] tabLayoutPolicies = TabLayoutPolicy.getLayoutPolicies();
    for (int i = 0; i < tabLayoutPolicies.length; i++) {
      final TabLayoutPolicy tabLayoutPolicy = tabLayoutPolicies[i];
      tabbedPanelMenu.add(
          createMenuItem(
              "Tab Layout: " + tabLayoutPolicy.getName(),
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  // Sets the layout for the tab area in the
                  // TabbedPanelProperties
                  // for the tabbed panel. The tabbed panel is automatically
                  // updated.
                  tabbedPanel.getProperties().setTabLayoutPolicy(tabLayoutPolicy);
                }
              }));
    }

    tabbedPanelMenu.add(new JSeparator());

    // Get all available tab drop down list visible policies i.e. when to
    // show a button (as
    // a tab area component) that shows a drop down list of all the tabs in
    // the tabbed panel
    // where a tab can be selected.
    TabDropDownListVisiblePolicy[] tabDropDownListVisiblePolicies =
        TabDropDownListVisiblePolicy.getDropDownListVisiblePolicies();
    for (int i = 0; i < tabDropDownListVisiblePolicies.length; i++) {
      final TabDropDownListVisiblePolicy tabDropDownListVisiblePolicy =
          tabDropDownListVisiblePolicies[i];
      tabbedPanelMenu.add(
          createMenuItem(
              "Tab Drop Down List: " + tabDropDownListVisiblePolicy.getName(),
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  // Sets the tab drop down list visible policy for the tabbed
                  // panel. The
                  // tabbed panel is automatically updated.
                  tabbedPanel
                      .getProperties()
                      .setTabDropDownListVisiblePolicy(tabDropDownListVisiblePolicy);
                }
              }));
    }

    tabbedPanelMenu.add(new JSeparator());

    tabbedPanelMenu.add(
        createMenuItem(
            "Shadow: Enable",
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                tabbedPanel
                    .getProperties()
                    .setShadowEnabled(!tabbedPanel.getProperties().getShadowEnabled());
                // Enable or disable (toggle) the shadow for the tabbed panel.
                // The tabbed panel is
                // automatically updated.
                ((JMenuItem) e.getSource())
                    .setText(
                        "Shadow: "
                            + (tabbedPanel.getProperties().getShadowEnabled()
                                ? "Disable"
                                : "Enable"));
              }
            }));

    return tabbedPanelMenu;
  }