示例#1
0
 /**
  * Adds the connection speed options to the display.
  *
  * @param index The default index.
  * @param comp The component to add to the display.
  * @return See above.
  */
 private JPanel buildConnectionSpeed(int index, JComponent comp) {
   JPanel p = new JPanel();
   p.setBorder(BorderFactory.createTitledBorder("Connection Speed"));
   buttonsGroup = new ButtonGroup();
   JRadioButton button = new JRadioButton();
   button.setText("LAN");
   button.setActionCommand("" + HIGH_SPEED);
   button.addActionListener(this);
   button.setSelected(index == LoginCredentials.HIGH);
   buttonsGroup.add(button);
   p.add(button);
   button = new JRadioButton();
   button.setText("High (Broadband)");
   button.setActionCommand("" + MEDIUM_SPEED);
   button.setSelected(index == LoginCredentials.MEDIUM);
   button.addActionListener(this);
   buttonsGroup.add(button);
   p.add(button);
   button = new JRadioButton();
   button.setText("Low (Dial-up)");
   button.setActionCommand("" + LOW_SPEED);
   button.setSelected(index == LoginCredentials.LOW);
   button.addActionListener(this);
   buttonsGroup.add(button);
   p.add(button);
   if (comp == null) return p;
   JPanel content = new JPanel();
   content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
   content.add(comp);
   p = UIUtilities.buildComponentPanel(p);
   content.add(p);
   return content;
 }
 /**
  * Create the button panel to the right of the summary table.
  *
  * @return see above.
  */
 private JPanel createButtonPanel() {
   JPanel panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(Box.createRigidArea(new Dimension(0, 10)));
   JPanel channelPanel = UIUtilities.buildComponentPanel(channelSelection);
   // UIUtilities.setDefaultSize(channelPanel, new Dimension(175, 32));
   panel.add(channelPanel);
   panel.add(Box.createRigidArea(new Dimension(0, 10)));
   JPanel intensityPanel = UIUtilities.buildComponentPanel(showIntensityTable);
   UIUtilities.setDefaultSize(intensityPanel, new Dimension(175, 32));
   panel.add(intensityPanel);
   panel.add(Box.createRigidArea(new Dimension(0, 10)));
   JPanel savePanel = UIUtilities.buildComponentPanel(saveButton);
   UIUtilities.setDefaultSize(savePanel, new Dimension(175, 32));
   panel.add(savePanel);
   panel.add(Box.createVerticalGlue());
   return panel;
 }
示例#3
0
  /**
   * Builds the UI component hosting the UI component used to modify the password.
   *
   * @return See above.
   */
  private JPanel buildPasswordPanel() {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    Registry reg = MetadataViewerAgent.getRegistry();
    String ldap = (String) reg.lookup(LookupNames.USER_AUTHENTICATION);
    if (ldap != null && ldap.length() > 0) {
      content.setBorder(BorderFactory.createTitledBorder("LDAP Authentication"));
      content.setLayout(new FlowLayout(FlowLayout.LEFT));
      content.add(new JLabel(ldap));
      return content;
    }
    content.setBorder(BorderFactory.createTitledBorder("Change Password"));

    content.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(0, 2, 2, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
    c.fill = GridBagConstraints.NONE; // reset to default
    c.weightx = 0.0;
    if (MetadataViewerAgent.isAdministrator()) {
      content.add(UIUtilities.setTextFont(PASSWORD_NEW), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordNew, c);
    } else {
      content.add(UIUtilities.setTextFont(PASSWORD_OLD), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(oldPassword, c);
      c.gridy++;
      c.gridx = 0;
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(UIUtilities.setTextFont(PASSWORD_NEW), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordNew, c);
      c.gridy++;
      c.gridx = 0;
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.weightx = 0.0;
      content.add(UIUtilities.setTextFont(PASSWORD_CONFIRMATION), c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER; // end row
      c.fill = GridBagConstraints.HORIZONTAL;
      c.weightx = 1.0;
      content.add(passwordConfirm, c);
      c.gridy++;
      c.gridx = 0;
    }

    JPanel p = new JPanel();
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(content);
    JPanel buttonPanel = UIUtilities.buildComponentPanel(passwordButton);
    buttonPanel.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(buttonPanel);
    return p;
  }
  /** Builds and lays out the UI. */
  private void buildGUI() {
    removeAll();
    JLabel l = new JLabel();
    Font f = l.getFont();
    int size = f.getSize() - 1;
    content.removeAll();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));

    // layout button.
    // filters
    JPanel p = UIUtilities.buildComponentPanel(createBar(filterButton, null), 0, 0);
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.add(p);
    // rating
    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("rate", Font.BOLD, size));
    p.add(createBar(unrateButton, null));
    p.add(Box.createHorizontalStrut(2));
    p.add(rating);
    // p.add(Box.createHorizontalStrut(2));
    // p.add(otherRating);
    content.add(p);

    // tags and attachments.
    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);
    p.add(UIUtilities.setTextFont("tag", Font.BOLD, size));
    p.add(createBar(addTagsButton, removeTagsButton));

    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(null);
    panel.setBackground(UIUtilities.BACKGROUND_COLOR);
    GridBagConstraints c = new GridBagConstraints();
    // c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
    c.fill = GridBagConstraints.NONE; // reset to default
    c.insets = new Insets(0, 2, 2, 0);
    c.gridy = 0;
    c.gridx = 0;
    panel.add(p, c);

    p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    p.setBackground(UIUtilities.BACKGROUND_COLOR);

    p.add(UIUtilities.setTextFont("attachment", Font.BOLD, size));
    p.add(createBar(addDocsButton, removeDocsButton));
    c.gridy = 3;
    panel.add(p, c);
    c.gridy = 0;
    c.gridx++;
    // c.ipady = 2;
    c.gridheight = 2;
    panel.add(tagsPane, c);
    c.gridy = 3;
    panel.add(docRef, c);
    content.add(panel);

    // analysis results
    List results = model.getAnalysisResults();
    if (results != null && results.size() > 0) {
      // panel = new JPanel(new GridBagLayout());
      // panel.setBorder(null);
      // panel.setBackground(UIUtilities.BACKGROUND_COLOR);
      // c = new GridBagConstraints();
      // c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.WEST;
      c.gridwidth = GridBagConstraints.RELATIVE; // next-to-last
      c.fill = GridBagConstraints.NONE; // reset to default
      c.insets = new Insets(0, 2, 2, 0);
      c.gridy = 4;
      c.gridx = 0;

      p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
      p.setBackground(UIUtilities.BACKGROUND_COLOR);
      p.setBorder(null);
      l = UIUtilities.setTextFont("analysis", Font.BOLD, size);
      l.setToolTipText("Displays the results of analysis run.");
      p.add(l);
      panel.add(p, c);
      Iterator i = results.iterator();
      AnalysisResultsItem item;
      JPanel list = new JPanel();
      list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS));
      list.setBackground(UIUtilities.BACKGROUND_COLOR);
      int n = 0;
      JPanel row = null;
      while (i.hasNext()) {
        item = (AnalysisResultsItem) i.next();
        item.addPropertyChangeListener(controller);
        if (n == 0) {
          row = initRow();
          row.add(item);
          n++;
        } else if (n == 1) {
          row.add(item);
          list.add(row);
          n = 0;
        }
      }
      if (row != null) list.add(row);
      c.gridx++;
      c.gridheight = 2;
      panel.add(UIUtilities.buildComponentPanel(list, 0, 0), c);
    }
    setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    setBackground(UIUtilities.BACKGROUND);
    setBorder(new SeparatorOneLineBorder());
    add(content);
  }