private void prepareComponent() {
    CloseEventHandler closeEventHandler = new CloseEventHandler();
    addWindowListener(closeEventHandler);

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    JPanel contentPanel = new JPanel();
    // JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    CellConstraints cc = new CellConstraints();
    FormLayout layout =
        new FormLayout(
            "4dlu, d:grow, 4dlu", // columns
            "4dlu, p, 2dlu, fill:100dlu:grow, 4dlu, "
                + // rows
                "p, 2dlu, p, 4dlu"); // btn rows
    PanelBuilder contentPB = new PanelBuilder(layout, contentPanel);
    int columnCount = layout.getColumnCount();
    int rowCount = layout.getRowCount();

    JLabel label = new JLabel(Localizer.getString("MediaTypeCondEditor_ConditionToAdd"));
    contentPB.add(label, cc.xywh(2, 2, 1, 1));

    mediaTypeModel = new MediaTypeModel();
    mediaTypeTable = new JTable(mediaTypeModel);
    JTableHeader tableHeader = mediaTypeTable.getTableHeader();
    tableHeader.setResizingAllowed(false);
    tableHeader.setReorderingAllowed(false);
    // adjust column witdh of checkbox
    JCheckBox box = (JCheckBox) mediaTypeTable.getDefaultRenderer(Boolean.class);
    TableColumn column = mediaTypeTable.getColumnModel().getColumn(0);
    column.setMaxWidth(box.getPreferredSize().width + 2);
    column.setMinWidth(box.getPreferredSize().width + 2);
    mediaTypeTable.getColumnModel().getColumn(1).setCellRenderer(new MediaTypeCellRenderer());
    // ToolTipManager.sharedInstance().registerComponent( mediaTypeTable );
    contentPB.add(new JScrollPane(mediaTypeTable), cc.xywh(2, 4, 1, 1));

    // button bar
    contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1));

    JButton okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());
    okBtn.setDefaultCapable(true);
    okBtn.setRequestFocusEnabled(true);

    JButton cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(closeEventHandler);

    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);
    contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1));

    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    getRootPane().setDefaultButton(okBtn);

    pack();
    setLocationRelativeTo(getParent());
  }
  public CheckBoxWithDescription(JCheckBox box, @Nullable String description) {
    myCheckBox = box;

    setLayout(new BorderLayout());
    add(myCheckBox, BorderLayout.NORTH);

    if (description != null) {
      final int iconSize = box.getPreferredSize().height;

      final DescriptionLabel desc = new DescriptionLabel(description);
      desc.setBorder(new EmptyBorder(0, iconSize + UIManager.getInt("CheckBox.textIconGap"), 0, 0));
      add(desc, BorderLayout.CENTER);
    }
  }
  /** Create a per-tree instance of the checkbox renderer. */
  public CheckBoxTreeCellRenderer(final JTree tree) {
    this.tree = tree;
    this.tree.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_SPACE) {
              int[] rows = tree.getSelectionRows();
              if (rows == null) return;

              for (int i : rows) {
                toggleChecked(i);
              }
            }
          }
        });
    this.renderer = tree.getCellRenderer();
    checkedPaths = new HashSet<TreePath>();
    checkBox = new JCheckBox();
    checkBox.setOpaque(false);
    checkBox.setSize(checkBox.getPreferredSize());

    listenerList = new EventListenerList();
  }
  private JComponent getButtonPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    choiceType = new JComboBox<PersonTypeItem>();
    choiceType.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personTypeModel = new DefaultComboBoxModel<>();
    personTypeModel.addElement(
        new PersonTypeItem(resourceMap.getString("primaryRole.choice.text"), null)); // $NON-NLS-1$
    for (int i = 1; i < Person.T_NUM; ++i) {
      personTypeModel.addElement(
          new PersonTypeItem(Person.getRoleDesc(i, campaign.getFaction().isClan()), i));
    }
    personTypeModel.addElement(
        new PersonTypeItem(Person.getRoleDesc(0, campaign.getFaction().isClan()), 0));
    // Add "none" for generic AsTechs
    choiceType.setModel(personTypeModel);
    choiceType.setSelectedIndex(0);
    choiceType.addActionListener(
        e -> {
          personnelFilter.setPrimaryRole(((PersonTypeItem) choiceType.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceType);

    choiceExp = new JComboBox<PersonTypeItem>();
    choiceExp.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight()));
    DefaultComboBoxModel<PersonTypeItem> personExpModel = new DefaultComboBoxModel<>();
    personExpModel.addElement(
        new PersonTypeItem(resourceMap.getString("experience.choice.text"), null)); // $NON-NLS-1$
    for (int i = 0; i < 5; ++i) {
      personExpModel.addElement(new PersonTypeItem(SkillType.getExperienceLevelName(i), i));
    }
    choiceExp.setModel(personExpModel);
    choiceExp.setSelectedIndex(0);
    choiceExp.addActionListener(
        e -> {
          personnelFilter.setExpLevel(((PersonTypeItem) choiceExp.getSelectedItem()).id);
          updatePersonnelTable();
        });
    panel.add(choiceExp);

    choiceSkill = new JComboBox<String>();
    choiceSkill.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) choiceSkill.getPreferredSize().getHeight()));
    DefaultComboBoxModel<String> personSkillModel = new DefaultComboBoxModel<>();
    personSkillModel.addElement(choiceNoSkill);
    for (String skill : SkillType.getSkillList()) {
      personSkillModel.addElement(skill);
    }
    choiceSkill.setModel(personSkillModel);
    choiceSkill.setSelectedIndex(0);
    choiceSkill.addActionListener(
        e -> {
          if (choiceNoSkill.equals(choiceSkill.getSelectedItem())) {
            personnelFilter.setSkill(null);
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(10);
            buttonSpendXP.setEnabled(false);
          } else {
            String skillName = (String) choiceSkill.getSelectedItem();
            personnelFilter.setSkill(skillName);
            int maxSkillLevel = SkillType.getType(skillName).getMaxLevel();
            int currentLevel = (Integer) skillLevel.getModel().getValue();
            ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(maxSkillLevel);
            if (currentLevel > maxSkillLevel) {
              skillLevel.getModel().setValue(Integer.valueOf(maxSkillLevel));
            }
            buttonSpendXP.setEnabled(true);
          }
          updatePersonnelTable();
        });
    panel.add(choiceSkill);

    panel.add(Box.createRigidArea(new Dimension(10, 10)));
    panel.add(new JLabel(resourceMap.getString("targetSkillLevel.text"))); // $NON-NLS-1$

    skillLevel = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1));
    skillLevel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) skillLevel.getPreferredSize().getHeight()));
    skillLevel.addChangeListener(
        e -> {
          personnelFilter.setMaxSkillLevel((Integer) skillLevel.getModel().getValue());
          updatePersonnelTable();
        });
    panel.add(skillLevel);

    allowPrisoners = new JCheckBox(resourceMap.getString("allowPrisoners.text")); // $NON-NLS-1$
    allowPrisoners.setHorizontalAlignment(SwingConstants.LEFT);
    allowPrisoners.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisoners.getPreferredSize().getHeight()));
    allowPrisoners.addChangeListener(
        e -> {
          personnelFilter.setAllowPrisoners(allowPrisoners.isSelected());
          updatePersonnelTable();
        });
    JPanel allowPrisonersPanel = new JPanel(new GridLayout(1, 1));
    allowPrisonersPanel.setAlignmentY(JComponent.LEFT_ALIGNMENT);
    allowPrisonersPanel.add(allowPrisoners);
    allowPrisonersPanel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) allowPrisonersPanel.getPreferredSize().getHeight()));
    panel.add(allowPrisonersPanel);

    panel.add(Box.createVerticalGlue());

    matchedPersonnelLabel = new JLabel(""); // $NON-NLS-1$
    matchedPersonnelLabel.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) matchedPersonnelLabel.getPreferredSize().getHeight()));
    panel.add(matchedPersonnelLabel);

    JPanel buttons = new JPanel(new FlowLayout());
    buttons.setMaximumSize(
        new Dimension(Short.MAX_VALUE, (int) buttons.getPreferredSize().getHeight()));

    buttonSpendXP = new JButton(resourceMap.getString("spendXP.text")); // $NON-NLS-1$
    buttonSpendXP.setEnabled(false);
    buttonSpendXP.addActionListener(e -> spendXP());
    buttons.add(buttonSpendXP);

    JButton button = new JButton(resourceMap.getString("close.text")); // $NON-NLS-1$
    button.addActionListener(e -> setVisible(false));
    buttons.add(button);

    panel.add(buttons);

    panel.setMaximumSize(new Dimension((int) panel.getPreferredSize().getWidth(), Short.MAX_VALUE));
    panel.setMinimumSize(new Dimension((int) panel.getPreferredSize().getWidth(), 300));

    return panel;
  }
  public BugZillaAssistant(
      ProgressThread thread, final Throwable exception, final XmlRpcClient client)
      throws XmlRpcException {
    super("send_bugreport", true, new Object[] {});
    rpcClient = client;
    thread.getProgressListener().setCompleted(35);
    if (thread.isCancelled()) {
      return;
    }
    // gather information to fill out combo boxes
    Object[] compVals, severityVals, platformVals, osVals;
    // components
    Map<String, String> valQueryMap = new HashMap<String, String>();
    valQueryMap.put("field", "component");
    valQueryMap.put("product_id", "2");
    Map resultMap = (Map) rpcClient.execute("Bug.legal_values", new Object[] {valQueryMap});
    compVals = (Object[]) resultMap.get("values");
    thread.getProgressListener().setCompleted(50);
    if (thread.isCancelled()) {
      return;
    }
    // severity
    valQueryMap = new HashMap<String, String>();
    valQueryMap.put("field", "severity");
    valQueryMap.put("product_id", "2");
    resultMap = (Map) rpcClient.execute("Bug.legal_values", new Object[] {valQueryMap});
    severityVals = (Object[]) resultMap.get("values");
    thread.getProgressListener().setCompleted(65);
    if (thread.isCancelled()) {
      return;
    }
    // platform
    valQueryMap = new HashMap<String, String>();
    valQueryMap.put("field", "platform");
    valQueryMap.put("product_id", "2");
    resultMap = (Map) rpcClient.execute("Bug.legal_values", new Object[] {valQueryMap});
    platformVals = (Object[]) resultMap.get("values");
    thread.getProgressListener().setCompleted(80);
    if (thread.isCancelled()) {
      return;
    }
    // operating system
    valQueryMap = new HashMap<String, String>();
    valQueryMap.put("field", "op_sys");
    valQueryMap.put("product_id", "2");
    resultMap = (Map) rpcClient.execute("Bug.legal_values", new Object[] {valQueryMap});
    osVals = (Object[]) resultMap.get("values");
    thread.getProgressListener().setCompleted(95);
    if (thread.isCancelled()) {
      return;
    }

    Collection<AbstractButton> buttons = new LinkedList<AbstractButton>();

    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    final JPanel loginPanel = new JPanel();
    loginPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(GAP, 0, 0, GAP);

    JLabel loginLabel =
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_e_mail.label"));
    loginPanel.add(loginLabel, gbc);

    final JTextField loginName = new JTextField(15);
    loginName.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_e_mail.tip"));
    gbc.gridx = 1;
    gbc.weightx = 1;
    loginPanel.add(loginName, gbc);

    JLabel passwordLabel =
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_password.label"));
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    loginPanel.add(passwordLabel, gbc);

    final JPasswordField loginPassword = new JPasswordField(15);
    loginPassword.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_password.tip"));
    gbc.gridx = 1;
    gbc.weightx = 1;
    loginPanel.add(loginPassword, gbc);

    final JCheckBox useAnonymousLogin = new JCheckBox();
    useAnonymousLogin.setText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_as_anonymous.label"));
    useAnonymousLogin.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".login_as_anonymous.tip"));
    useAnonymousLogin.setSelected(false);
    useAnonymousLogin.setAlignmentX(Component.LEFT_ALIGNMENT);
    useAnonymousLogin.setMinimumSize(useAnonymousLogin.getPreferredSize());
    useAnonymousLogin.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              loginName.setEditable(false);
              loginPassword.setEditable(false);
            } else {
              loginName.setEditable(true);
              loginPassword.setEditable(true);
            }
          }
        });
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.weightx = 0;
    loginPanel.add(useAnonymousLogin, gbc);

    gbc.gridwidth = 2;
    gbc.weightx = 1;
    gbc.gridy = 3;
    gbc.insets = new Insets(GAP * 2, 0, GAP, 0);
    loginPanel.add(new JSeparator(), gbc);
    panel.add(loginPanel);

    final JPanel detailPanel = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(GAP, 0, 0, GAP);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.anchor = GridBagConstraints.WEST;
    c.weighty = 0;
    detailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".component.label") + ":"), c);

    c.gridx = 1;
    c.gridy = 0;
    final JComboBox compBox = new JComboBox(compVals);
    compBox.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".component.tip"));
    compBox.setSelectedItem("Vega: Processes, data flow  and meta data");
    detailPanel.add(compBox, c);

    c.gridx = 2;
    c.gridy = 0;
    detailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".severity.label") + ":"), c);

    c.gridx = 3;
    c.gridy = 0;
    final JComboBox severityBox = new JComboBox(severityVals);
    severityBox.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".severity.tip"));
    severityBox.setSelectedItem("normal");
    detailPanel.add(severityBox, c);

    c.gridx = 0;
    c.gridy = 1;
    detailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".platform.label") + ":"), c);

    c.gridx = 1;
    c.gridy = 1;
    final JComboBox platformBox = new JComboBox(platformVals);
    platformBox.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".platform.tip"));
    detailPanel.add(platformBox, c);

    c.gridx = 2;
    c.gridy = 1;
    detailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".os.label") + ":"), c);

    c.gridx = 3;
    c.gridy = 1;
    final JComboBox osBox = new JComboBox(osVals);
    osBox.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".os.tip"));
    String os = System.getProperty("os.name");
    if (os.toLowerCase(Locale.ENGLISH).contains("windows")) {
      osBox.setSelectedItem("Windows");
      platformBox.setSelectedItem("PC");
    } else if (os.toLowerCase(Locale.ENGLISH).contains("linux")) {
      osBox.setSelectedItem("Linux");
      platformBox.setSelectedItem("PC");
    } else if (os.toLowerCase(Locale.ENGLISH).contains("mac")) {
      osBox.setSelectedItem("Mac OS");
      platformBox.setSelectedItem("Macintosh");
    } else {
      osBox.setSelectedItem("Other");
      platformBox.setSelectedItem("Other");
    }
    detailPanel.add(osBox, c);

    c.gridx = 4;
    c.gridy = 0;
    c.weightx = 1;
    detailPanel.add(new JLabel(), c);

    c.gridy = 1;
    detailPanel.add(new JLabel(), c);

    c.gridwidth = 5;
    c.gridx = 0;
    c.gridy = 2;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(GAP * 2, 0, GAP, 0);
    detailPanel.add(new JSeparator(), c);
    panel.add(detailPanel);

    final JPanel mailPanel = new JPanel(new GridBagLayout());
    c = new GridBagConstraints();

    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(GAP, 0, 0, GAP);
    c.weighty = 0;
    c.weightx = 0;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    final JCheckBox addProcessCheckBox = new JCheckBox();
    addProcessCheckBox.setText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".add_process_xml.label"));
    addProcessCheckBox.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".add_process_xml.tip"));
    addProcessCheckBox.setSelected(true);
    addProcessCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    addProcessCheckBox.setMinimumSize(addProcessCheckBox.getPreferredSize());
    mailPanel.add(addProcessCheckBox, c);

    c.gridx = 1;
    final JCheckBox addSysPropsCheckBox = new JCheckBox();
    addSysPropsCheckBox.setText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".add_system_props.label"));
    addSysPropsCheckBox.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".add_system_props.tip"));
    addSysPropsCheckBox.setSelected(true);
    addSysPropsCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    addSysPropsCheckBox.setMinimumSize(addSysPropsCheckBox.getPreferredSize());
    mailPanel.add(addSysPropsCheckBox, c);

    c.gridx = 2;
    c.weightx = 0.75;
    mailPanel.add(new JLabel(), c);

    c.gridwidth = 3;
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy = 1;
    mailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".summary.label") + ":"), c);

    final JTextField summaryField = new JTextField(15);
    summaryField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".summary.tip"));
    c.gridy = 2;
    mailPanel.add(summaryField, c);

    c.gridy = 3;
    mailPanel.add(
        new JLabel(I18N.getMessage(I18N.getGUIBundle(), getKey() + ".description.label") + ":"), c);

    descriptionField.setLineWrap(true);
    descriptionField.setWrapStyleWord(true);
    descriptionField.addFocusListener(
        new FocusAdapter() {

          @Override
          public void focusGained(FocusEvent e) {
            if (descriptionField.getText().equals(descriptionText)) {
              descriptionField.setText("");
              descriptionField.removeFocusListener(this);
            }
          }
        });
    descriptionField.setToolTipText(
        I18N.getMessage(I18N.getGUIBundle(), getKey() + ".description.tip"));
    JScrollPane descriptionPane = new ExtendedJScrollPane(descriptionField);
    descriptionPane.setBorder(createBorder());
    descriptionPane.setPreferredSize(new Dimension(400, 400));
    c.gridy = 4;
    c.weighty = 1;
    mailPanel.add(descriptionPane, c);

    c.insets = new Insets(GAP, 0, 0, 0);
    c.gridx = 3;
    c.gridy = 0;
    c.gridheight = 5;
    c.weightx = 0.25;
    c.weighty = 1;
    attachments.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane attachmentPane = new JScrollPane(attachments);
    attachmentPane.setBorder(createBorder());
    attachmentPane.setPreferredSize(new Dimension(150, 400));
    mailPanel.add(attachmentPane, c);
    panel.add(mailPanel);

    buttons.add(
        new JButton(
            new ResourceAction("send_bugreport.add_file") {
              private static final long serialVersionUID = 5152169309271935854L;

              @Override
              public void actionPerformed(ActionEvent e) {
                File file = SwingTools.chooseFile(null, null, true, null, null);
                if (file != null) {
                  ((DefaultListModel) attachments.getModel()).addElement(file);
                }
              }
            }));
    buttons.add(
        new JButton(
            new ResourceAction("send_bugreport.remove_file") {
              private static final long serialVersionUID = 5353693430346577972L;

              public void actionPerformed(ActionEvent e) {
                if (attachments.getSelectedIndex() >= 0) {
                  ((DefaultListModel) attachments.getModel())
                      .remove(attachments.getSelectedIndex());
                }
              }
            }));
    JButton infoButton =
        new JButton(
            new ResourceAction("send_bugreport.info") {
              private static final long serialVersionUID = 2135052418891516027L;

              @Override
              public void actionPerformed(ActionEvent e) {
                BugReportViewerDialog dialog = new BugReportViewerDialog();
                dialog.setInfoText(
                    BugReport.createCompleteBugDescription(
                        descriptionField.getText().trim(),
                        exception,
                        addProcessCheckBox.isSelected(),
                        addSysPropsCheckBox.isSelected()));
                dialog.setVisible(true);
              }
            });
    buttons.add(infoButton);

    submitButton =
        new JButton(
            new ResourceAction("send_bugreport.submit") {
              private static final long serialVersionUID = -4559762951458936715L;

              @Override
              public void actionPerformed(ActionEvent e) {

                // check fields
                email = loginName.getText().trim();
                pawo = loginPassword.getPassword();
                String summary = summaryField.getText().trim();
                String description = descriptionField.getText().trim();
                final String version = RapidMiner.getShortVersion();
                if (!useAnonymousLogin.isSelected()) {
                  if (email.length() <= 0) {
                    SwingTools.showVerySimpleErrorMessage("enter_email");
                    return;
                  }
                  if (!email.matches("(.+?)@(.+?)[.](.+?)")) {
                    SwingTools.showVerySimpleErrorMessage("enter_correct_email");
                    return;
                  }
                  boolean noPW = true;
                  for (char c : pawo) {
                    if (c != ' ') {
                      noPW = false;
                      break;
                    }
                  }
                  if (noPW) {
                    SwingTools.showVerySimpleErrorMessage("enter_password");
                    return;
                  }
                } else {
                  email = "*****@*****.**";
                  pawo =
                      new char[] {
                        '!', 'z', '4', '8', '#', 'H', 'c', '2', '$', '%', 'm', ')', '9', '+', '*',
                        '*'
                      };
                }
                if (summary.length() <= 0) {
                  SwingTools.showVerySimpleErrorMessage("enter_summary");
                  return;
                }
                // more than a single word for a descriptive summary required!
                String[] splitResult = summary.trim().split("\\s");
                if (splitResult.length < 2) {
                  SwingTools.showVerySimpleErrorMessage("enter_descriptive_summary");
                  return;
                }
                if (description.length() <= 0 || description.equals(descriptionText)) {
                  SwingTools.showVerySimpleErrorMessage("enter_description");
                  return;
                }

                // all checks passed, bug report would be created right now, however we want the
                // user
                // to check his browser for similar/duplicate bugs by opening the bugzilla search
                // page with
                // given parameters
                try {
                  if (Desktop.isDesktopSupported()) {
                    Desktop desktop = Desktop.getDesktop();
                    if (desktop.isSupported(Desktop.Action.BROWSE)) {
                      String bugzillaSearchString =
                          "http://bugs.rapid-i.com/buglist.cgi?field0-0-0=attach_data.thedata&type0-0-1=allwordssubstr&field0-0-1=longdesc&query_format=advanced&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&value0-0-1="
                              + exception.getMessage()
                              + "&type0-0-0=allwordssubstr&value0-0-0="
                              + exception.getMessage();
                      URL bugzillaURL = new URL(bugzillaSearchString);
                      URI bugzillaURI =
                          new URI(
                              bugzillaURL.getProtocol(),
                              bugzillaURL.getHost(),
                              bugzillaURL.getPath(),
                              bugzillaURL.getQuery(),
                              null);
                      desktop.browse(bugzillaURI);
                      int returnVal =
                          SwingTools.showConfirmDialog(
                              "send_bugreport.check_browser_for_duplicates",
                              ConfirmDialog.YES_NO_OPTION);
                      // user clicked no, don't submit
                      if (returnVal == ConfirmDialog.NO_OPTION) {
                        return;
                      }
                    }
                  }
                } catch (URISyntaxException e1) {
                  // should not occur (famous last comment)
                } catch (IOException e1) {
                  // we can't change it, so ignore it
                }

                // create bugreport in own progess thread (cancel not allowed)
                submitButton.setEnabled(false);
                new ProgressThread("send_report_to_bugzilla", false) {

                  @Override
                  public void run() {
                    try {
                      getProgressListener().setTotal(100);
                      ListModel model = attachments.getModel();
                      File[] attachments = new File[model.getSize()];
                      for (int i = 0; i < attachments.length; i++) {
                        attachments[i] = (File) model.getElementAt(i);
                      }
                      getProgressListener().setCompleted(20);

                      XmlRpcClient client =
                          XmlRpcHandler.login(XmlRpcHandler.BUGZILLA_URL, email, pawo);
                      getProgressListener().setCompleted(40);

                      BugReport.createBugZillaReport(
                          client,
                          exception,
                          summaryField.getText().trim(),
                          descriptionField.getText().trim(),
                          String.valueOf(compBox.getSelectedItem()),
                          version,
                          String.valueOf(severityBox.getSelectedItem()),
                          String.valueOf(platformBox.getSelectedItem()),
                          String.valueOf(osBox.getSelectedItem()),
                          RapidMinerGUI.getMainFrame().getProcess(),
                          RapidMinerGUI.getMainFrame().getMessageViewer().getLogMessage(),
                          attachments,
                          addProcessCheckBox.isSelected(),
                          addSysPropsCheckBox.isSelected());

                      getProgressListener().setCompleted(100);
                      SwingTools.showMessageDialog("bugreport_successful");
                      dispose();
                    } catch (XmlRpcException e1) {
                      SwingTools.showVerySimpleErrorMessage(
                          "bugreport_xmlrpc_error", e1.getLocalizedMessage());
                    } catch (Exception e2) {
                      LogService.getRoot().warning(e2.getLocalizedMessage());
                      SwingTools.showVerySimpleErrorMessage("bugreport_creation_failed");
                    } finally {
                      getProgressListener().complete();
                      for (int i = 0; i < pawo.length; i++) {
                        pawo[i] = 0;
                      }
                      submitButton.setEnabled(true);
                    }
                  }
                }.start();
              }
            });
    buttons.add(submitButton);
    buttons.add(makeCancelButton());

    layoutDefault(panel, LARGE, buttons);
  }
  void createFrame() {
    /* see Preferences.java */
    int GUI_BIG = 13;
    int GUI_BETWEEN = 10;
    int GUI_SMALL = 6;
    int FIELD_SIZE = 30;

    int left = GUI_BIG;
    int top = GUI_BIG;
    int right = 0;

    Dimension d;

    frame = new JFrame("Directives Editor");
    Container pane = frame.getContentPane();
    pane.setLayout(null);

    JLabel label = new JLabel("Click here to read about directives.");
    label.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            Base.openURL("http://processingjs.org/reference/pjs%20directive");
          }

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {}

          public void mouseReleased(MouseEvent e) {}
        });
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN + GUI_BETWEEN;

    // CRISP

    crispBox = new JCheckBox("\"crisp\": disable antialiasing for line(), triangle() and rect()");
    pane.add(crispBox);
    d = crispBox.getPreferredSize();
    crispBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // FONTS

    label = new JLabel("\"font\": to load (comma separated)");
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_SMALL;

    fontField = new JTextField(FIELD_SIZE);
    pane.add(fontField);
    d = fontField.getPreferredSize();
    fontField.setBounds(left, top, d.width, d.height);

    JButton button = new JButton("scan");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            handleScanFonts();
          }
        });
    pane.add(button);
    Dimension d2 = button.getPreferredSize();
    button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
    right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
    top += d.height + GUI_BETWEEN;

    // GLOBAL_KEY_EVENTS

    globalKeyEventsBox = new JCheckBox("\"globalKeyEvents\": receive global key events");
    pane.add(globalKeyEventsBox);
    d = globalKeyEventsBox.getPreferredSize();
    globalKeyEventsBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // PAUSE_ON_BLUR

    pauseOnBlurBox = new JCheckBox("\"pauseOnBlur\": pause if applet loses focus");
    pane.add(pauseOnBlurBox);
    d = pauseOnBlurBox.getPreferredSize();
    pauseOnBlurBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // PRELOAD images

    label = new JLabel("\"preload\": images (comma separated)");
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_SMALL;

    preloadField = new JTextField(FIELD_SIZE);
    pane.add(preloadField);
    d = preloadField.getPreferredSize();
    preloadField.setBounds(left, top, d.width, d.height);

    button = new JButton("scan");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            handleScanImages();
          }
        });
    pane.add(button);
    d2 = button.getPreferredSize();
    button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
    right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
    top += d.height + GUI_BETWEEN;

    // TRANSPARENT

    /*transparentBox =
         new JCheckBox("\"transparent\": set applet background to be transparent");
       pane.add(transparentBox);
    d = transparentBox.getPreferredSize();
       transparentBox.setBounds(left, top, d.width + 10, d.height);
       right = Math.max(right, left + d.width);
       top += d.height + GUI_BETWEEN;*/

    // APPLY / OK

    button = new JButton("OK");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            applyDirectives();
            hide();
          }
        });
    pane.add(button);
    d2 = button.getPreferredSize();
    int BUTTON_HEIGHT = d2.height;
    int BUTTON_WIDTH = 80;

    int h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
    h += BUTTON_WIDTH + GUI_SMALL;

    button = new JButton("Cancel");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hide();
          }
        });
    pane.add(button);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);

    top += BUTTON_HEIGHT + GUI_BETWEEN;

    // frame.getContentPane().add(box);
    frame.pack();
    Insets insets = frame.getInsets();
    frame.setSize(
        right + GUI_BIG + insets.left + insets.right, top + GUI_SMALL + insets.top + insets.bottom);

    // frame.setResizable(false);

    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            frame.setVisible(false);
          }
        });
    Toolkit.registerWindowCloseKeys(
        frame.getRootPane(),
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            frame.setVisible(false);
          }
        });
    Toolkit.setIcon(frame);
  }
Example #7
0
 @Override
 public int getIconHeight() {
   return check.getPreferredSize().height;
 }
Example #8
0
 @Override
 public int getIconWidth() {
   return check.getPreferredSize().width;
 }
Example #9
0
  public Preferences() {

    // setup dialog for the prefs

    //dialog = new JDialog(editor, "Preferences", true);
    dialog = new JFrame(_("Preferences"));
    dialog.setResizable(false);

    Container pain = dialog.getContentPane();
    pain.setLayout(null);

    int top = GUI_BIG;
    int left = GUI_BIG;
    int right = 0;

    JLabel label;
    JButton button; //, button2;
    //JComboBox combo;
    Dimension d, d2; //, d3;
    int h, vmax;


    // Sketchbook location:
    // [...............................]  [ Browse ]

    label = new JLabel(_("Sketchbook location:"));
    pain.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height; // + GUI_SMALL;

    sketchbookLocationField = new JTextField(40);
    pain.add(sketchbookLocationField);
    d = sketchbookLocationField.getPreferredSize();

    button = new JButton(PROMPT_BROWSE);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          File dflt = new File(sketchbookLocationField.getText());
          File file =
            Base.selectFolder(_("Select new sketchbook location"), dflt, dialog);
          if (file != null) {
            sketchbookLocationField.setText(file.getAbsolutePath());
          }
        }
      });
    pain.add(button);
    d2 = button.getPreferredSize();

    // take max height of all components to vertically align em
    vmax = Math.max(d.height, d2.height);
    sketchbookLocationField.setBounds(left, top + (vmax-d.height)/2,
                                      d.width, d.height);
    h = left + d.width + GUI_SMALL;
    button.setBounds(h, top + (vmax-d2.height)/2,
                     d2.width, d2.height);

    right = Math.max(right, h + d2.width + GUI_BIG);
    top += vmax + GUI_BETWEEN;


    // Preferred language: [        ] (requires restart of Arduino)
    Container box = Box.createHorizontalBox();
    label = new JLabel(_("Editor language: "));
    box.add(label);
    comboLanguage = new JComboBox(languages);
    comboLanguage.setSelectedIndex((Arrays.asList(languagesISO)).indexOf(Preferences.get("editor.languages.current")));
    box.add(comboLanguage);
    label = new JLabel(_("  (requires restart of Arduino)"));
    box.add(label);
    pain.add(box);
    d = box.getPreferredSize();
    box.setForeground(Color.gray);
    box.setBounds(left, top, d.width, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // Editor font size [    ]

    box = Box.createHorizontalBox();
    label = new JLabel(_("Editor font size: "));
    box.add(label);
    fontSizeField = new JTextField(4);
    box.add(fontSizeField);
    label = new JLabel(_("  (requires restart of Arduino)"));
    box.add(label);
    pain.add(box);
    d = box.getPreferredSize();
    box.setBounds(left, top, d.width, d.height);
    Font editorFont = Preferences.getFont("editor.font");
    fontSizeField.setText(String.valueOf(editorFont.getSize()));
    top += d.height + GUI_BETWEEN;


    // Show verbose output during: [ ] compilation [ ] upload

    box = Box.createHorizontalBox();
    label = new JLabel(_("Show verbose output during: "));
    box.add(label);
    verboseCompilationBox = new JCheckBox(_("compilation "));
    box.add(verboseCompilationBox);
    verboseUploadBox = new JCheckBox(_("upload"));
    box.add(verboseUploadBox);
    pain.add(box);
    d = box.getPreferredSize();
    box.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN;

    // [ ] Verify code after upload

    verifyUploadBox = new JCheckBox(_("Verify code after upload"));
    pain.add(verifyUploadBox);
    d = verifyUploadBox.getPreferredSize();
    verifyUploadBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // [ ] Use external editor

    externalEditorBox = new JCheckBox(_("Use external editor"));
    pain.add(externalEditorBox);
    d = externalEditorBox.getPreferredSize();
    externalEditorBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;


    // [ ] Check for updates on startup

    checkUpdatesBox = new JCheckBox(_("Check for updates on startup"));
    pain.add(checkUpdatesBox);
    d = checkUpdatesBox.getPreferredSize();
    checkUpdatesBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // [ ] Update sketch files to new extension on save (.pde -> .ino)

    updateExtensionBox = new JCheckBox(_("Update sketch files to new extension on save (.pde -> .ino)"));
    pain.add(updateExtensionBox);
    d = updateExtensionBox.getPreferredSize();
    updateExtensionBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    domainPortField= new JTextField();
    domainPortField.setColumns(30);
    Box domainBox = Box.createHorizontalBox();
    domainBox.add(new JLabel("Tftp upload Domain:"));
    domainBox.add(domainPortField);
    pain.add(domainBox);
    d = domainBox.getPreferredSize();
    domainBox.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN;

    autoResetPortField= new JTextField();
    autoResetPortField.setColumns(8);
    Box resetBox = Box.createHorizontalBox();
    resetBox.add(new JLabel("Auto Reset Port:"));
    resetBox.add(autoResetPortField);
    pain.add(resetBox);
    d = resetBox.getPreferredSize();
    resetBox.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN;


    tftpPassField = new JTextField();
    tftpPassField.setColumns(30);
    Box tftpBox = Box.createHorizontalBox();
    tftpBox.add(new JLabel("Tftp Secret Password:"******"Automatically associate .ino files with Arduino"));
      pain.add(autoAssociateBox);
      d = autoAssociateBox.getPreferredSize();
      autoAssociateBox.setBounds(left, top, d.width + 10, d.height);
      right = Math.max(right, left + d.width);
      top += d.height + GUI_BETWEEN;
    }

    // More preferences are in the ...

    label = new JLabel(_("More preferences can be edited directly in the file"));
    pain.add(label);
    d = label.getPreferredSize();
    label.setForeground(Color.gray);
    label.setBounds(left, top, d.width, d.height);
    right = Math.max(right, left + d.width);
    top += d.height; // + GUI_SMALL;

    label = new JLabel(preferencesFile.getAbsolutePath());
    final JLabel clickable = label;
    label.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
          Base.openFolder(Base.getSettingsFolder());
        }

        public void mouseEntered(MouseEvent e) {
          clickable.setForeground(new Color(0, 0, 140));
        }

        public void mouseExited(MouseEvent e) {
          clickable.setForeground(Color.BLACK);
        }
      });
    pain.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    right = Math.max(right, left + d.width);
    top += d.height;

    label = new JLabel(_("(edit only when Arduino is not running)"));
    pain.add(label);
    d = label.getPreferredSize();
    label.setForeground(Color.gray);
    label.setBounds(left, top, d.width, d.height);
    right = Math.max(right, left + d.width);
    top += d.height; // + GUI_SMALL;


    // [  OK  ] [ Cancel ]  maybe these should be next to the message?

    button = new JButton(PROMPT_OK);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          applyFrame();
          disposeFrame();
        }
      });
    pain.add(button);
    d2 = button.getPreferredSize();
    BUTTON_HEIGHT = d2.height;

    h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
    h += BUTTON_WIDTH + GUI_SMALL;

    button = new JButton(PROMPT_CANCEL);
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          disposeFrame();
        }
      });
    pain.add(button);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);

    top += BUTTON_HEIGHT + GUI_BETWEEN;


    // finish up

    wide = right + GUI_BIG;
    high = top + GUI_SMALL;


    // closing the window is same as hitting cancel button

    dialog.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          disposeFrame();
        }
      });

    ActionListener disposer = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
          disposeFrame();
        }
      };
    Base.registerWindowCloseKeys(dialog.getRootPane(), disposer);
    Base.setIcon(dialog);

    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    dialog.setLocation((screen.width - wide) / 2,
                      (screen.height - high) / 2);

    dialog.pack(); // get insets
    Insets insets = dialog.getInsets();
    dialog.setSize(wide + insets.left + insets.right,
                  high + insets.top + insets.bottom);


    // handle window closing commands for ctrl/cmd-W or hitting ESC.

    pain.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
          //System.out.println(e);
          KeyStroke wc = Editor.WINDOW_CLOSE_KEYSTROKE;
          if ((e.getKeyCode() == KeyEvent.VK_ESCAPE) ||
              (KeyStroke.getKeyStrokeForEvent(e).equals(wc))) {
            disposeFrame();
          }
        }
      });
  }