/**
   * Initialize the common user interface components.
   *
   * <p>
   */
  protected JButton[] initUI(
      String title, JComponent extraComps, String confirm, String[][] extra, String cancel) {
    JButton[] extraBtns = null;

    /* create dialog body components */
    {
      JPanel body = new JPanel();
      body.setName("MainDialogPanel");

      body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));

      body.add(UIFactory.createPanelLabel("Existing Layouts:"));

      body.add(Box.createRigidArea(new Dimension(0, 4)));

      {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode(new TreeData(), true);
        DefaultTreeModel model = new DefaultTreeModel(root, true);

        JTree tree = new JFancyTree(model);
        pTree = tree;
        tree.setName("DarkTree");

        tree.setCellRenderer(new JLayoutTreeCellRenderer());
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

        {
          JScrollPane scroll =
              UIFactory.createScrollPane(
                  pTree,
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(230, 120),
                  new Dimension(230, 150),
                  null);

          body.add(scroll);
        }
      }

      if (extraComps != null) body.add(extraComps);

      extraBtns = super.initUI(title, body, confirm, null, extra, cancel);
    }

    return extraBtns;
  }
 /**
  * Creates and returns a Container containing the buttons. The buttons are created by calling
  * <code>getButtons</code>.
  */
 protected Container createButtonArea() {
   JPanel bottom = new JPanel();
   Border border = (Border) DefaultLookup.get(optionPane, this, "OptionPane.buttonAreaBorder");
   bottom.setName("OptionPane.buttonArea");
   if (border != null) {
     bottom.setBorder(border);
   }
   bottom.setLayout(
       new ButtonAreaLayout(
           DefaultLookup.getBoolean(optionPane, this, "OptionPane.sameSizeButtons", true),
           DefaultLookup.getInt(optionPane, this, "OptionPane.buttonPadding", 6),
           DefaultLookup.getInt(
               optionPane, this, "OptionPane.buttonOrientation", SwingConstants.CENTER),
           DefaultLookup.getBoolean(optionPane, this, "OptionPane.isYesLast", false)));
   addButtonComponents(bottom, getButtons(), getInitialValueIndex());
   return bottom;
 }
  /**
   * Messaged from installComponents to create a Container containing the body of the message. The
   * icon is the created by calling <code>addIcon</code>.
   */
  protected Container createMessageArea() {
    JPanel top = new JPanel();
    Border topBorder = (Border) DefaultLookup.get(optionPane, this, "OptionPane.messageAreaBorder");
    if (topBorder != null) {
      top.setBorder(topBorder);
    }
    top.setLayout(new BorderLayout());

    /* Fill the body. */
    Container body = new JPanel(new GridBagLayout());
    Container realBody = new JPanel(new BorderLayout());

    body.setName("OptionPane.body");
    realBody.setName("OptionPane.realBody");

    if (getIcon() != null) {
      JPanel sep = new JPanel();
      sep.setName("OptionPane.separator");
      sep.setPreferredSize(new Dimension(15, 1));
      realBody.add(sep, BorderLayout.BEFORE_LINE_BEGINS);
    }
    realBody.add(body, BorderLayout.CENTER);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cons.gridheight = 1;
    cons.anchor =
        DefaultLookup.getInt(
            optionPane, this, "OptionPane.messageAnchor", GridBagConstraints.CENTER);
    cons.insets = new Insets(0, 0, 3, 0);

    addMessageComponents(body, cons, getMessage(), getMaxCharactersPerLineCount(), false);
    top.add(realBody, BorderLayout.CENTER);

    addIcon(top);
    return top;
  }
示例#4
0
  /** Construct a new dialog. */
  public JArchiveDialog() {
    super("Archive Tool");

    pPrivilegeDetails = new PrivilegeDetails();

    /* create dialog body components */
    {
      JPanel cpanel = new JPanel();
      {
        cpanel.setName("ButtonDialogPanel");
        cpanel.setLayout(new BoxLayout(cpanel, BoxLayout.Y_AXIS));

        cpanel.add(UIFactory.createPanelLabel("Candidate Versions:"));

        cpanel.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          ArchiveCandidateTableModel model = new ArchiveCandidateTableModel();
          pCandidateTableModel = model;

          JTablePanel tpanel = new JTablePanel(model);
          pCandidateTablePanel = tpanel;

          cpanel.add(tpanel);
        }

        cpanel.add(Box.createRigidArea(new Dimension(0, 5)));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createHorizontalGlue());
          hbox.add(Box.createRigidArea(new Dimension(10, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Search...",
                    "candidate-search",
                    this,
                    "Search for new candidate checked-in versions to archive.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(20, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Clear",
                    "clear-candidate",
                    this,
                    "Clear the displayed candidate checked-in versions.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(10, 0)));
          hbox.add(Box.createHorizontalGlue());

          cpanel.add(hbox);
        }
      }

      JPanel apanel = new JPanel();
      {
        apanel.setName("ButtonDialogPanel");
        apanel.setLayout(new BoxLayout(apanel, BoxLayout.Y_AXIS));

        {
          Box box = new Box(BoxLayout.X_AXIS);

          box.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("Versions to Archive:");
            label.setName("PanelLabel");
            box.add(label);
          }

          box.add(Box.createHorizontalGlue());

          {
            JLabel label = new JLabel("Total Size: ???");
            pArchiveSizeLabel = label;
            label.setName("PanelLabel");
            box.add(label);
          }

          box.add(Box.createRigidArea(new Dimension(23, 0)));

          apanel.add(box);
        }

        apanel.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          NodeVersionSizeTableModel model = new NodeVersionSizeTableModel(880);
          pArchiveTableModel = model;

          JTablePanel tpanel = new JTablePanel(model);
          pArchiveTablePanel = tpanel;

          apanel.add(tpanel);
        }

        apanel.add(Box.createRigidArea(new Dimension(0, 5)));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createHorizontalGlue());
          hbox.add(Box.createRigidArea(new Dimension(10, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Add",
                    "add-archive",
                    this,
                    "Add the selected candidate versions to the list of versions to be "
                        + "archived.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(10, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Add All",
                    "add-all-archive",
                    this,
                    "Add all candidate versions to the list of versions to be archived.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(20, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Remove",
                    "remove-archive",
                    this,
                    "Remove the selected versions from the list of versions to be archived.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(10, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Clear",
                    "remove-all-archive",
                    this,
                    "Clear the list of versions to be archived.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(20, 0)));

          {
            JButton btn =
                UIFactory.createDialogButton(
                    "Calc Sizes",
                    "calc-archive",
                    this,
                    "Calculate the amount of disk space needed to archive the files "
                        + "associated with the checked-in versions.");

            hbox.add(btn);
          }

          hbox.add(Box.createRigidArea(new Dimension(10, 0)));
          hbox.add(Box.createHorizontalGlue());

          apanel.add(hbox);
        }
      }

      JSplitPane body = new JVertSplitPanel(cpanel, apanel);
      body.setAlignmentX(0.5f);

      String extra[][] = {{"Archive...", "archive"}};

      JButton btns[] = super.initUI("Archive Tool:", body, null, null, extra, "Close", null);

      pArchiveButton = btns[0];
      pArchiveButton.setEnabled(false);

      updatePanel();
      pack();
    }

    pQueryDialog = new JArchiveQueryDialog(this);
    pArchiveParamsDialog = new JArchiveParamsDialog(this);
  }
  /**
   * Creates the appropriate object to represent <code>msg</code> and places it into <code>container
   * </code>. If <code>msg</code> is an instance of Component, it is added directly, if it is an
   * Icon, a JLabel is created to represent it, otherwise a JLabel is created for the string, if
   * <code>d</code> is an Object[], this method will be recursively invoked for the children. <code>
   * internallyCreated</code> is true if Objc is an instance of Component and was created internally
   * by this method (this is used to correctly set hasCustomComponents only if !internallyCreated).
   */
  protected void addMessageComponents(
      Container container,
      GridBagConstraints cons,
      Object msg,
      int maxll,
      boolean internallyCreated) {
    if (msg == null) {
      return;
    }
    if (msg instanceof Component) {
      // To workaround problem where Gridbad will set child
      // to its minimum size if its preferred size will not fit
      // within allocated cells
      if (msg instanceof JScrollPane || msg instanceof JPanel) {
        cons.fill = GridBagConstraints.BOTH;
        cons.weighty = 1;
      } else {
        cons.fill = GridBagConstraints.HORIZONTAL;
      }
      cons.weightx = 1;

      container.add((Component) msg, cons);
      cons.weightx = 0;
      cons.weighty = 0;
      cons.fill = GridBagConstraints.NONE;
      cons.gridy++;
      if (!internallyCreated) {
        hasCustomComponents = true;
      }

    } else if (msg instanceof Object[]) {
      Object[] msgs = (Object[]) msg;
      for (Object o : msgs) {
        addMessageComponents(container, cons, o, maxll, false);
      }

    } else if (msg instanceof Icon) {
      JLabel label = new JLabel((Icon) msg, SwingConstants.CENTER);
      configureMessageLabel(label);
      addMessageComponents(container, cons, label, maxll, true);

    } else {
      String s = msg.toString();
      int len = s.length();
      if (len <= 0) {
        return;
      }
      int nl;
      int nll = 0;

      if ((nl = s.indexOf(newline)) >= 0) {
        nll = newline.length();
      } else if ((nl = s.indexOf("\r\n")) >= 0) {
        nll = 2;
      } else if ((nl = s.indexOf('\n')) >= 0) {
        nll = 1;
      }
      if (nl >= 0) {
        // break up newlines
        if (nl == 0) {
          JPanel breakPanel =
              new JPanel() {
                public Dimension getPreferredSize() {
                  Font f = getFont();

                  if (f != null) {
                    return new Dimension(1, f.getSize() + 2);
                  }
                  return new Dimension(0, 0);
                }
              };
          breakPanel.setName("OptionPane.break");
          addMessageComponents(container, cons, breakPanel, maxll, true);
        } else {
          addMessageComponents(container, cons, s.substring(0, nl), maxll, false);
        }
        addMessageComponents(container, cons, s.substring(nl + nll), maxll, false);

      } else if (len > maxll) {
        Container c = Box.createVerticalBox();
        c.setName("OptionPane.verticalBox");
        burstStringInto(c, s, maxll);
        addMessageComponents(container, cons, c, maxll, true);

      } else {
        JLabel label;
        label = new JLabel(s, JLabel.LEADING);
        label.setName("OptionPane.label");
        configureMessageLabel(label);
        addMessageComponents(container, cons, label, maxll, true);
      }
    }
  }
  /** Construct a new dialog. */
  public JExecDetailsDialog() {
    super("Execution Details");

    /* create dialog body components */
    {
      JPanel body = new JPanel();
      body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS));

      {
        JPanel panel = new JPanel();
        panel.setName("MainDialogPanel");
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

        /* working directory */
        {
          panel.add(UIFactory.createPanelLabel("Working Directory:"));

          panel.add(Box.createRigidArea(new Dimension(0, 4)));

          JTextField field = UIFactory.createTextField(null, 100, JLabel.LEFT);
          pWorkingDirField = field;

          panel.add(field);
        }

        body.add(panel);
      }

      {
        JPanel panel = new JPanel();
        panel.setName("HorizontalBar");

        Dimension size = new Dimension(100, 7);
        panel.setPreferredSize(size);
        panel.setMinimumSize(size);
        panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 7));

        body.add(panel);
      }

      /* command line */
      JPanel above = new JPanel();
      {
        above.setName("MainDialogPanel");
        above.setLayout(new BoxLayout(above, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pCommandLineLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          above.add(hbox);
        }

        above.add(Box.createRigidArea(new Dimension(0, 4)));

        {
          JTextArea area = new JTextArea(null, 5, 70);
          pCommandLineArea = area;

          area.setName("CodeTextArea");
          area.setLineWrap(true);
          area.setWrapStyleWord(true);
          area.setEditable(false);
        }

        {
          JScrollPane scroll =
              UIFactory.createScrollPane(
                  pCommandLineArea,
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 27),
                  null,
                  null);

          above.add(scroll);
        }
      }

      /* environment */
      JPanel below = new JPanel();
      {
        below.setName("MainDialogPanel");
        below.setLayout(new BoxLayout(below, BoxLayout.Y_AXIS));

        {
          Box hbox = new Box(BoxLayout.X_AXIS);

          hbox.add(Box.createRigidArea(new Dimension(4, 0)));

          {
            JLabel label = new JLabel("X");
            pEnvLabel = label;

            label.setName("PanelLabel");

            hbox.add(label);
          }

          hbox.add(Box.createHorizontalGlue());

          below.add(hbox);
        }

        below.add(Box.createRigidArea(new Dimension(0, 4)));

        Component comps[] = UIFactory.createTitledPanels();
        {
          JPanel tpanel = (JPanel) comps[0];
          JPanel vpanel = (JPanel) comps[1];

          tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0)));
          vpanel.add(Box.createHorizontalGlue());
        }

        {
          pEnvScroll =
              UIFactory.createScrollPane(
                  comps[2],
                  ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
                  ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                  new Dimension(100, 50),
                  new Dimension(100, 300),
                  null);

          below.add(pEnvScroll);
        }
      }

      {
        JVertSplitPanel split = new JVertSplitPanel(above, below);
        split.setResizeWeight(0.0);
        split.setAlignmentX(0.5f);

        body.add(split);
      }

      super.initUI("X", body, null, null, null, "Close", null);
    }
  }
  /**
   * Returns the main control panel.
   *
   * @param mainFrame The main test frame.
   * @param mainTabbedPane The main tabbed pane.
   * @param mainTabPreviewPainter The preview painter of the main tabbed pane.
   * @param toolbar The toolbar of the main test frame.
   * @return The main control panel.
   */
  public static JPanel getMainControlPanel(
      final JFrame mainFrame,
      final JTabbedPane mainTabbedPane,
      final MyMainTabPreviewPainter mainTabPreviewPainter,
      final JToolBar toolbar) {
    FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(lm);
    // builder.setDefaultDialogBorder();

    builder.appendSeparator("Title pane settings");
    final JCheckBox markAsModified = new JCheckBox("Marked modified");
    markAsModified.setOpaque(false);
    markAsModified.setSelected(false);
    markAsModified.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            mainFrame
                .getRootPane()
                .putClientProperty(
                    SubstanceLookAndFeel.WINDOW_MODIFIED,
                    (markAsModified.isSelected() ? Boolean.TRUE : false));
          }
        });
    builder.append("Modified", markAsModified);

    final JCheckBox heapPanel = new JCheckBox("Has heap panel");
    heapPanel.setOpaque(false);
    heapPanel.setSelected(false);
    heapPanel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SubstanceLookAndFeel.setWidgetVisible(
                mainFrame.getRootPane(),
                heapPanel.isSelected(),
                SubstanceWidgetType.TITLE_PANE_HEAP_STATUS);
          }
        });
    builder.append("Heap panel", heapPanel);

    JButton changeTitleButton = new JButton("Change");
    changeTitleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String random = "abcdefghijklmnopqrstuvwxyz ";
            int length = 60 + (int) (150 * Math.random());
            String title = "";
            while (length > 0) {
              title += random.charAt((int) (random.length() * Math.random()));
              length--;
            }
            mainFrame.setTitle(title);
          }
        });
    builder.append("Title string", changeTitleButton);

    builder.appendSeparator("Miscellaneous");

    final JCheckBox defaultRoundedCorners = new JCheckBox("by default");
    defaultRoundedCorners.setOpaque(false);
    boolean roundable =
        Boolean.valueOf(
            System.getProperty(SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS_PROPERTY, "True"));
    defaultRoundedCorners.setSelected(roundable);
    defaultRoundedCorners.setEnabled(roundable);
    defaultRoundedCorners.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(
                SubstanceLookAndFeel.WINDOW_ROUNDED_CORNERS, defaultRoundedCorners.isSelected());
          }
        });
    builder.append("Rounded Windows", defaultRoundedCorners);

    final JCheckBox useThemedDefaultIconsCheckBox = new JCheckBox("use themed icons");
    useThemedDefaultIconsCheckBox.setOpaque(false);
    useThemedDefaultIconsCheckBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    UIManager.put(
                        SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS,
                        useThemedDefaultIconsCheckBox.isSelected() ? Boolean.TRUE : null);
                    mainFrame.repaint();
                  }
                });
          }
        });
    builder.append("Themed icons", useThemedDefaultIconsCheckBox);

    final JCheckBox useConstantThemesOnDialogs = new JCheckBox("use constant themes");
    useConstantThemesOnDialogs.setOpaque(false);
    useConstantThemesOnDialogs.setSelected(SubstanceLookAndFeel.isToUseConstantThemesOnDialogs());
    useConstantThemesOnDialogs.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    SubstanceLookAndFeel.setToUseConstantThemesOnDialogs(
                        useConstantThemesOnDialogs.isSelected());
                    SubstanceLookAndFeel.setSkin(
                        SubstanceLookAndFeel.getCurrentSkin(mainFrame.getRootPane()));
                  }
                });
          }
        });
    builder.append("Option pane icons", useConstantThemesOnDialogs);

    final JComboBox placementCombo = new JComboBox(new Object[] {"top", "bottom", "left", "right"});
    placementCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            String selected = (String) placementCombo.getSelectedItem();
            if ("top".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.TOP);
            if ("bottom".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
            if ("left".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.LEFT);
            if ("right".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.RIGHT);
          }
        });
    builder.append("Placement", placementCombo);

    try {
      final JComboBox overviewKindCombo =
          new FlexiComboBox<TabOverviewKind>(
              TabOverviewKind.GRID, TabOverviewKind.MENU_CAROUSEL, TabOverviewKind.ROUND_CAROUSEL) {
            @Override
            public String getCaption(TabOverviewKind item) {
              return item.getName();
            }
          };
      overviewKindCombo.setSelectedItem(
          LafWidgetUtilities2.getTabPreviewPainter(mainTabbedPane).getOverviewKind(mainTabbedPane));
      overviewKindCombo.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              mainTabPreviewPainter.setTabOverviewKind(
                  (TabOverviewKind) overviewKindCombo.getSelectedItem());
            }
          });

      builder.append("Overview kind", overviewKindCombo);
    } catch (NoClassDefFoundError ignored) {
    }

    final JComboBox menuGutterFillCombo =
        new FlexiComboBox<MenuGutterFillKind>(
            MenuGutterFillKind.NONE,
            MenuGutterFillKind.SOFT,
            MenuGutterFillKind.HARD,
            MenuGutterFillKind.SOFT_FILL,
            MenuGutterFillKind.HARD_FILL) {
          @Override
          public String getCaption(MenuGutterFillKind item) {
            return item.name();
          }
        };
    menuGutterFillCombo.setSelectedItem(MenuGutterFillKind.HARD);
    menuGutterFillCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(
                SubstanceLookAndFeel.MENU_GUTTER_FILL_KIND, menuGutterFillCombo.getSelectedItem());
          }
        });
    builder.append("Menu fill", menuGutterFillCombo);

    final JComboBox focusKindCombo =
        new FlexiComboBox<FocusKind>(FocusKind.values()) {
          @Override
          public String getCaption(FocusKind item) {
            return item.name();
          }
        };
    focusKindCombo.setSelectedItem(FocusKind.ALL_INNER);
    focusKindCombo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, focusKindCombo.getSelectedItem());
          }
        });
    builder.append("Focus kind", focusKindCombo);

    JButton buttonGlassPane = new JButton("Show");
    buttonGlassPane.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            final JPanel glassPane =
                new JPanel() {
                  @Override
                  public void paintComponent(Graphics g) {
                    super.paintComponent(g);
                    Graphics2D graphics = (Graphics2D) g;
                    int height = getHeight();
                    int width = getWidth();
                    Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 0.4);
                    graphics.setComposite(c);
                    for (int i = 0; i < height; i++) {
                      Color color =
                          (i % 2 == 0) ? new Color(200, 200, 255) : new Color(230, 230, 255);
                      graphics.setColor(color);
                      graphics.drawLine(0, i, width, i);
                    }
                    Composite c2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) 1.0);
                    graphics.setComposite(c2);
                  }
                };
            glassPane.setOpaque(false);
            glassPane.addMouseListener(new MouseAdapter() {});
            glassPane.addKeyListener(new KeyAdapter() {});
            mainFrame.setGlassPane(glassPane);
            new Thread() {
              @Override
              public void run() {
                glassPane.setVisible(true);
                try {
                  Thread.sleep(5000);
                } catch (InterruptedException ie) {
                  ie.printStackTrace();
                }
                glassPane.setVisible(false);
              }
            }.start();
          }
        });
    builder.append("Glass pane", buttonGlassPane);

    builder.appendSeparator("Custom animations");
    final JCheckBox allowFocusLoopAnimations = new JCheckBox("Allow animation");
    allowFocusLoopAnimations.setOpaque(false);
    allowFocusLoopAnimations.setSelected(
        AnimationConfigurationManager.getInstance()
            .isAnimationAllowed(AnimationFacet.FOCUS_LOOP_ANIMATION, null));
    allowFocusLoopAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowFocusLoopAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION);
            }
          }
        });
    builder.append("Focus loop", allowFocusLoopAnimations);

    final JCheckBox allowGlowIconAnimations = new JCheckBox("Allow animation");
    allowGlowIconAnimations.setOpaque(false);
    allowGlowIconAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGlowIconAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance().allowAnimations(AnimationFacet.ICON_GLOW);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.ICON_GLOW);
            }
          }
        });
    builder.append("Icon glow", allowGlowIconAnimations);

    final JCheckBox allowGhostIconAnimations = new JCheckBox("Allow animation");
    allowGhostIconAnimations.setOpaque(false);
    allowGhostIconAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGhostIconAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.GHOSTING_ICON_ROLLOVER);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.GHOSTING_ICON_ROLLOVER);
            }
          }
        });
    builder.append("Icon rollover", allowGhostIconAnimations);

    final JCheckBox allowGhostPressAnimations = new JCheckBox("Allow animation");
    allowGhostPressAnimations.setOpaque(false);
    allowGhostPressAnimations.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (allowGhostPressAnimations.isSelected()) {
              AnimationConfigurationManager.getInstance()
                  .allowAnimations(AnimationFacet.GHOSTING_BUTTON_PRESS);
            } else {
              AnimationConfigurationManager.getInstance()
                  .disallowAnimations(AnimationFacet.GHOSTING_BUTTON_PRESS);
            }
          }
        });
    builder.append("Button press", allowGhostPressAnimations);

    builder.appendSeparator("Toolbar");
    final JCheckBox isToolbarFlat = new JCheckBox("Is flat");
    isToolbarFlat.setOpaque(false);
    isToolbarFlat.setSelected(true);
    isToolbarFlat.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            toolbar.putClientProperty(
                SubstanceLookAndFeel.FLAT_PROPERTY, isToolbarFlat.isSelected());
            toolbar.repaint();
          }
        });
    builder.append("Flat", isToolbarFlat);

    builder.appendSeparator("Menu bar");
    final JCheckBox menuSearch = new JCheckBox("Has menu search");
    menuSearch.setOpaque(false);
    menuSearch.setSelected(false);
    menuSearch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SubstanceLookAndFeel.setWidgetVisible(
                mainFrame.getRootPane(), menuSearch.isSelected(), SubstanceWidgetType.MENU_SEARCH);
          }
        });
    builder.append("Menu search", menuSearch);

    final JCheckBox menuLocale = new JCheckBox("Has custom locale");
    menuLocale.setOpaque(false);
    menuLocale.setSelected(false);
    menuLocale.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (menuLocale.isSelected()) {
              mainFrame.getJMenuBar().setLocale(Locale.FRENCH);
              mainFrame
                  .getJMenuBar()
                  .putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, Boolean.TRUE);
            } else {
              mainFrame.getJMenuBar().putClientProperty(LafWidget.IGNORE_GLOBAL_LOCALE, null);
            }
          }
        });
    builder.append("Menu locale", menuLocale);

    JPanel result = builder.getPanel();
    result.setName("Main control panel");
    return result;
  }
示例#8
0
  ///////////////////////////////////
  // member functions
  //////////////////////////////////
  protected final void initForm() {
    thisPanel = new JPanel();
    thisPanel.setName("Import Range Data");
    thisPanel.setLayout(new java.awt.BorderLayout());

    _thePanel.add(thisPanel);

    _theWarning = new JTextArea();
    _theWarning.setEditable(false);
    String theMessage = "Warning, data imported through this panel has";
    theMessage += " speed and course calculated as over the ground.";
    theMessage += System.getProperties().getProperty("line.separator");
    theMessage += "Debrief recognises PC Argos (RAO) and PMRF (PRN) files.";
    theMessage += System.getProperties().getProperty("line.separator");
    theMessage += "See Debrief Help File for file format and details.";

    _theWarning.setText(theMessage);
    _theWarning.setLineWrap(true);
    _theWarning.setBorder(BorderFactory.createLoweredBevelBorder());
    _theWarning.setWrapStyleWord(true);
    thisPanel.add("North", _theWarning);
    ////////////////////////////////////////////
    // auto generated stuff
    ////////////////////////////////////////////

    ButtonPanel = new javax.swing.JPanel();
    importBtn = new javax.swing.JButton();
    closeBtn = new javax.swing.JButton();
    PropertiesList = new javax.swing.JPanel();
    FilenamePanel = new javax.swing.JPanel();
    jLabel3 = new javax.swing.JLabel();
    FilenameLabel = new javax.swing.JLabel();
    selectFileBtn = new javax.swing.JButton();
    FrequencyPanel = new javax.swing.JPanel();
    FrequencyLabel = new javax.swing.JLabel();
    FrequencyCombo = new TimeFrequencyCombo();
    OriginPanel = new javax.swing.JPanel();
    jLabel7 = new javax.swing.JLabel();
    OriginLabel = new javax.swing.JLabel();
    selectOriginBtn = new javax.swing.JButton();
    DTGPanel = new javax.swing.JPanel();
    jLabel9 = new javax.swing.JLabel();
    _theDate = new javax.swing.JTextField("2001/01/30");

    /////////////////////////////////////////////////
    // button panel first
    //////////////////////////////////////////////////

    importBtn.setText("Import");
    ButtonPanel.add(importBtn);
    closeBtn.setText("Close");
    ButtonPanel.add(closeBtn);
    thisPanel.add(ButtonPanel, java.awt.BorderLayout.SOUTH);
    closeBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doClose();
          }
        });
    importBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doImport();
          }
        });

    ///////////////////////////////////////////////////
    // now the properties panel
    ///////////////////////////////////////////////////

    PropertiesList.setLayout(new java.awt.GridLayout(0, 1));

    jLabel3.setText("Filename:");
    FilenamePanel.add(jLabel3);
    FilenameLabel.setText("    blank    ");
    FilenamePanel.add(FilenameLabel);
    selectFileBtn.setPreferredSize(new java.awt.Dimension(33, 27));
    selectFileBtn.setToolTipText("Select file");
    selectFileBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectFileBtn.setText("...");
    selectFileBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            doEditFilename();
          }
        });
    FilenamePanel.add(selectFileBtn);
    PropertiesList.add(FilenamePanel);

    FrequencyLabel.setText("Frequency:");
    FrequencyPanel.add(FrequencyLabel);
    FrequencyCombo.setPreferredSize(new java.awt.Dimension(100, 25));
    FrequencyPanel.add(FrequencyCombo);
    PropertiesList.add(FrequencyPanel);

    jLabel7.setText("Origin:");
    OriginPanel.add(jLabel7);
    OriginLabel.setText("    blank    ");
    OriginPanel.add(OriginLabel);
    selectOriginBtn.setPreferredSize(new java.awt.Dimension(33, 27));
    selectOriginBtn.setToolTipText("Select file");
    selectOriginBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectOriginBtn.setText("...");
    selectOriginBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            editOrigin();
          }
        });
    OriginPanel.add(selectOriginBtn);
    PropertiesList.add(OriginPanel);

    //////////////////////////////////////////////////////
    // DTG
    /////////////////////////////////////////////////////

    jLabel9.setText("DTG (yyyy/mm/dd):");
    _theDate.setText("2001/01/30");
    _theDate.addFocusListener(
        new FocusAdapter() {
          public void focusLost(final FocusEvent e) {
            checkDTG();
          }
        });
    DTGPanel.add(jLabel9);
    DTGPanel.add(_theDate);
    PropertiesList.add(DTGPanel);

    final JPanel jp = new JPanel();
    jp.setLayout(new FlowLayout());
    jp.add(PropertiesList);

    thisPanel.add(jp, java.awt.BorderLayout.CENTER);
  }