@Override
 public void testInstallDefaults() {
   JCheckBox button = new JCheckBox();
   UIManager.put("CheckBox.disabledText", new ColorUIResource(Color.red));
   UIManager.put("CheckBox.focus", new ColorUIResource(Color.yellow));
   UIManager.put("CheckBox.select", new ColorUIResource(Color.green));
   UIManager.put("CheckBox.foreground", new ColorUIResource(Color.cyan));
   UIManager.put("CheckBox.background", new ColorUIResource(Color.blue));
   Font font = new FontUIResource(button.getFont().deriveFont(100f));
   UIManager.put("CheckBox.font", font);
   Border border = new BorderUIResource(BorderFactory.createEmptyBorder(0, 0, 0, 0));
   UIManager.put("CheckBox.border", border);
   Icon icon =
       new IconUIResource(new ImageIcon(new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB)));
   UIManager.put("CheckBox.icon", icon);
   button.setUI(publicUI);
   publicUI.installDefaults(button);
   assertEquals(Color.blue, button.getBackground());
   assertEquals(Color.cyan, button.getForeground());
   assertEquals("SelectedColor ", Color.green, publicUI.getSelectColor());
   assertEquals("focusColor ", Color.yellow, publicUI.getFocusColor());
   assertEquals("disabledTextColor ", Color.red, publicUI.getDisabledTextColor());
   assertEquals("font", font, button.getFont());
   assertEquals("border", border, button.getBorder());
   assertEquals("icon", icon, publicUI.getDefaultIcon());
 }
 @Override
 public Component getComponent(
     JTree tree,
     Object nodeRenderer,
     boolean selected,
     boolean expanded,
     boolean leaf,
     int row,
     boolean hasFocus) {
   JCheckBox checkbox = new JCheckBox(this.toString(), this.isChecked);
   checkbox.setFont(
       checkbox.getFont().deriveFont(Font.PLAIN | Font.ITALIC, checkbox.getFont().getSize()));
   checkbox.setBackground(Color.WHITE);
   return checkbox;
 }
  /**
   * Set up the expander button to display qualifier values.
   *
   * @param butt - expander button
   * @param qualifier - the qualifer that is being displayed
   * @param qualifierValueBox - Box containing the values
   * @param qualifierNameCheckBox - JCheckBox for the given qualifier
   * @param pane
   * @return
   */
  private Vector<JCheckBox> setExpanderButton(
      final JButton butt,
      final Qualifier qualifier,
      final Box qualifierValueBox,
      final JCheckBox qualifierNameCheckBox) {
    butt.setMargin(new Insets(0, 0, 0, 0));
    butt.setHorizontalAlignment(SwingConstants.RIGHT);
    butt.setHorizontalTextPosition(SwingConstants.RIGHT);
    butt.setBorderPainted(false);
    butt.setFont(butt.getFont().deriveFont(Font.BOLD));
    butt.setForeground(TransferAnnotationTool.STEEL_BLUE);

    butt.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (butt.getText().equals("+")) butt.setText("-");
            else butt.setText("+");

            qualifierValueBox.setVisible(butt.getText().equals("-"));
            revalidate();
          }
        });

    // set-up qualifier values list
    qualifierValueBox.setVisible(false);
    final Vector<JCheckBox> qualifierValuesCheckBox = new Vector<JCheckBox>();
    final StringVector values = qualifier.getValues();
    if (values != null) {
      for (int i = 0; i < values.size(); i++) {
        final JCheckBox cb = new JCheckBox(values.get(i), qualifierNameCheckBox.isSelected());
        cb.setFont(cb.getFont().deriveFont(Font.ITALIC));
        qualifierValueBox.add(cb);
        qualifierValuesCheckBox.add(cb);
      }
    }
    return qualifierValuesCheckBox;
  }
Пример #4
0
    @Override
    public Void doInBackground() throws Exception {
      StringBuilder message = new StringBuilder();
      try {
        getManager().deleteBean(t, "CanDelete"); // IN18N
      } catch (PropertyVetoException e) {
        if (e.getPropertyChangeEvent().getPropertyName().equals("DoNotDelete")) { // IN18N
          log.warn(e.getMessage());
          message.append(
              Bundle.getMessage(
                  "VetoDeleteBean",
                  t.getBeanType(),
                  t.getFullyFormattedDisplayName(),
                  e.getMessage()));
          JOptionPane.showMessageDialog(
              null,
              message.toString(),
              Bundle.getMessage("WarningTitle"),
              JOptionPane.ERROR_MESSAGE);
          return null;
        }
        message.append(e.getMessage());
      }
      int count = t.getNumPropertyChangeListeners();
      if (log.isDebugEnabled()) {
        log.debug("Delete with " + count);
      }
      if (getDisplayDeleteMsg() == 0x02 && message.toString().equals("")) {
        doDelete(t);
      } else {
        final JDialog dialog = new JDialog();
        dialog.setTitle(Bundle.getMessage("WarningTitle"));
        dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        JPanel container = new JPanel();
        container.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
        if (count > 0) { // warn of listeners attached before delete

          JLabel question =
              new JLabel(Bundle.getMessage("DeletePrompt", t.getFullyFormattedDisplayName()));
          question.setAlignmentX(Component.CENTER_ALIGNMENT);
          container.add(question);

          ArrayList<String> listenerRefs = t.getListenerRefs();
          if (listenerRefs.size() > 0) {
            ArrayList<String> listeners = new ArrayList<>();
            for (int i = 0; i < listenerRefs.size(); i++) {
              if (!listeners.contains(listenerRefs.get(i))) {
                listeners.add(listenerRefs.get(i));
              }
            }

            message.append("<br>");
            message.append(Bundle.getMessage("ReminderInUse", count));
            message.append("<ul>");
            for (int i = 0; i < listeners.size(); i++) {
              message.append("<li>");
              message.append(listeners.get(i));
              message.append("</li>");
            }
            message.append("</ul>");

            JEditorPane pane = new JEditorPane();
            pane.setContentType("text/html");
            pane.setText("<html>" + message.toString() + "</html>");
            pane.setEditable(false);
            JScrollPane jScrollPane = new JScrollPane(pane);
            container.add(jScrollPane);
          }
        } else {
          String msg =
              MessageFormat.format(
                  Bundle.getMessage("DeletePrompt"), new Object[] {t.getSystemName()});
          JLabel question = new JLabel(msg);
          question.setAlignmentX(Component.CENTER_ALIGNMENT);
          container.add(question);
        }

        final JCheckBox remember = new JCheckBox(Bundle.getMessage("MessageRememberSetting"));
        remember.setFont(remember.getFont().deriveFont(10f));
        remember.setAlignmentX(Component.CENTER_ALIGNMENT);

        JButton yesButton = new JButton(Bundle.getMessage("ButtonYes"));
        JButton noButton = new JButton(Bundle.getMessage("ButtonNo"));
        JPanel button = new JPanel();
        button.setAlignmentX(Component.CENTER_ALIGNMENT);
        button.add(yesButton);
        button.add(noButton);
        container.add(button);

        noButton.addActionListener(
            (ActionEvent e) -> {
              // there is no point in remembering this the user will never be
              // able to delete a bean!
              dialog.dispose();
            });

        yesButton.addActionListener(
            (ActionEvent e) -> {
              if (remember.isSelected()) {
                setDisplayDeleteMsg(0x02);
              }
              doDelete(t);
              dialog.dispose();
            });
        container.add(remember);
        container.setAlignmentX(Component.CENTER_ALIGNMENT);
        container.setAlignmentY(Component.CENTER_ALIGNMENT);
        dialog.getContentPane().add(container);
        dialog.pack();
        dialog.setLocation(
            (Toolkit.getDefaultToolkit().getScreenSize().width) / 2 - dialog.getWidth() / 2,
            (Toolkit.getDefaultToolkit().getScreenSize().height) / 2 - dialog.getHeight() / 2);
        dialog.setModal(true);
        dialog.setVisible(true);
      }
      return null;
    }
Пример #5
0
 protected void setCheckBoxFont(JCheckBox checkBox) {
   if (Setup.isTabEnabled()) {
     Font font = new Font(Setup.getFontName(), Font.PLAIN, checkBox.getFont().getSize());
     checkBox.setFont(font);
   }
 }