コード例 #1
0
  private JComponent makeCheckBoxPanel(AbstractComponent repository) {
    JPanel p = new JPanel();

    p.setBorder(BorderFactory.createTitledBorder(repository.getDisplayName()));
    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
    for (AbstractComponent child : repository.getComponents()) {
      String id = child.getComponentId();
      loadedComponents.put(id, child);

      JCheckBox checkBox = new JCheckBox(child.getDisplayName());
      checkBox.setSelected(selectedIds.contains(id));
      checkBox.addActionListener(new Selector(id));
      checkBox.setAlignmentX(LEFT_ALIGNMENT);
      p.add(checkBox);
    }
    JPanel rigid = new JPanel();
    p.add(rigid);
    rigid.setAlignmentX(LEFT_ALIGNMENT);
    rigid.add(Box.createRigidArea(new Dimension(240, 1)));

    p.setAlignmentX(CENTER_ALIGNMENT);

    JScrollPane pane = new JScrollPane();
    pane.getViewport().add(p);

    return pane;
  }
コード例 #2
0
  private void createForcesPanel() {
    forcesPanel = new JPanel();
    forcesPanel.setBorder(BorderFactory.createTitledBorder("Force Field Parameters"));
    forcesPanel.setLayout(new BoxLayout(forcesPanel, BoxLayout.Y_AXIS));

    Map<String, Object> params = (Map<String, Object>) config.get("ffParams");

    for (Map.Entry<String, Object> e : params.entrySet()) {
      if (e.getValue() instanceof Boolean) {
        JCheckBox cb = new JCheckBox(e.getKey());
        cb.setAlignmentX(LEFT_ALIGNMENT);
        if ((Boolean) e.getValue()) {
          cb.setSelected(true);
        }
        cb.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                JCheckBox cb = (JCheckBox) e.getSource();
                config.put(cb.getText(), cb.isSelected());
              }
            });
        forcesPanel.add(cb);
        ffParamComponents.add(cb);
      }
    }

    JLabel label1 = new JLabel("Forces");
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);

    disableForcePanel();
  }
コード例 #3
0
  protected JPanel createOptionPanel() {
    JPanel oP = new JPanel();
    oP.setLayout(new BoxLayout(oP, BoxLayout.Y_AXIS));

    preservePermBox.setEnabled(false);

    preservePermBox.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            boolean selected = preservePermBox.isSelected();
            boolean enableTargetPerm = !selected;
            permBox.setEnabled(enableTargetPerm);
            permButton.setEnabled(enableTargetPerm);
          }
        });

    permButton.setActionCommand("permissions");
    permButton.addActionListener(this);

    JPanel permPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    permPanel.add(permBox);
    permPanel.add(permButton);
    permBox.setEnabled(false);
    permButton.setEnabled(false);

    followSymLinkBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    preserveMtimeBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    preservePermBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    permPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    oP.add(followSymLinkBox);
    oP.add(preserveMtimeBox);
    oP.add(preservePermBox);
    oP.add(permPanel);

    return oP;
  }
コード例 #4
0
  /**
   * Constructor.
   *
   * @param tileset A tileset.
   * @param oldPatternId The tile pattern id to change in this tileset.
   */
  public TilePatternIdRefactoringComponent(Tileset tileset, String oldPatternId) {
    super();

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel patternIdPanel = new JPanel();
    patternIdPanel.setLayout(new BoxLayout(patternIdPanel, BoxLayout.LINE_AXIS));
    patternIdPanel.setAlignmentX(1.0f);
    JLabel patternIdLabel = new JLabel("Tile pattern id:");
    patternIdPanel.add(patternIdLabel);
    patternIdPanel.add(Box.createHorizontalStrut(10));
    patternIdField = new JTextField(oldPatternId, 20);
    patternIdField.selectAll();
    patternIdPanel.add(patternIdField);
    patternIdPanel.setAlignmentX(0.0f);
    add(patternIdPanel);
    add(Box.createVerticalStrut(10));
    updateMapsCheckBox = new JCheckBox("Update references in existing maps");
    updateMapsCheckBox.setSelected(true);
    updateMapsCheckBox.setAlignmentX(0.0f);
    add(updateMapsCheckBox);
  }
コード例 #5
0
    protected void initComponents(
        AirspaceBuilderModel model, final AirspaceBuilderController controller) {
      final JCheckBox resizeNewShapesCheckBox;
      final JCheckBox enableEditCheckBox;

      JPanel newShapePanel = new JPanel();
      {
        JButton newShapeButton = new JButton("New shape");
        newShapeButton.setActionCommand(NEW_AIRSPACE);
        newShapeButton.addActionListener(controller);
        newShapeButton.setToolTipText("Create a new shape centered in the viewport");

        this.factoryComboBox = new JComboBox(defaultAirspaceFactories);
        this.factoryComboBox.setEditable(false);
        this.factoryComboBox.setToolTipText("Choose shape type to create");

        resizeNewShapesCheckBox = new JCheckBox("Fit new shapes to viewport");
        resizeNewShapesCheckBox.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT);
        resizeNewShapesCheckBox.addActionListener(controller);
        resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport());
        resizeNewShapesCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
        resizeNewShapesCheckBox.setToolTipText(
            "New shapes are sized to fit the geographic viewport");

        enableEditCheckBox = new JCheckBox("Enable shape editing");
        enableEditCheckBox.setActionCommand(ENABLE_EDIT);
        enableEditCheckBox.addActionListener(controller);
        enableEditCheckBox.setSelected(controller.isEnableEdit());
        enableEditCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);
        enableEditCheckBox.setToolTipText("Allow modifications to shapes");

        Box newShapeBox = Box.createHorizontalBox();
        newShapeBox.add(newShapeButton);
        newShapeBox.add(Box.createHorizontalStrut(5));
        newShapeBox.add(this.factoryComboBox);
        newShapeBox.setAlignmentX(Component.LEFT_ALIGNMENT);

        JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap
        gridPanel.add(newShapeBox);
        gridPanel.add(resizeNewShapesCheckBox);
        gridPanel.add(enableEditCheckBox);

        newShapePanel.setLayout(new BorderLayout());
        newShapePanel.add(gridPanel, BorderLayout.NORTH);
      }

      JPanel entryPanel = new JPanel();
      {
        this.entryTable = new JTable(model);
        this.entryTable.setColumnSelectionAllowed(false);
        this.entryTable.setRowSelectionAllowed(true);
        this.entryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.entryTable
            .getSelectionModel()
            .addListSelectionListener(
                new ListSelectionListener() {
                  public void valueChanged(ListSelectionEvent e) {
                    if (!ignoreSelectEvents) {
                      controller.actionPerformed(
                          new ActionEvent(e.getSource(), -1, SELECTION_CHANGED));
                    }
                  }
                });
        this.entryTable.setToolTipText("<html>Click to select<br>Double-Click to rename</html>");

        JScrollPane tablePane = new JScrollPane(this.entryTable);
        tablePane.setPreferredSize(new Dimension(200, 100));

        entryPanel.setLayout(new BorderLayout(0, 0)); // hgap, vgap
        entryPanel.add(tablePane, BorderLayout.CENTER);
      }

      JPanel selectionPanel = new JPanel();
      {
        JButton delselectButton = new JButton("Deselect");
        delselectButton.setActionCommand(CLEAR_SELECTION);
        delselectButton.addActionListener(controller);
        delselectButton.setToolTipText("Clear the selection");

        JButton deleteButton = new JButton("Delete Selected");
        deleteButton.setActionCommand(REMOVE_SELECTED);
        deleteButton.addActionListener(controller);
        deleteButton.setToolTipText("Delete selected shapes");

        JPanel gridPanel = new JPanel(new GridLayout(0, 1, 0, 5)); // rows, cols, hgap, vgap
        gridPanel.add(delselectButton);
        gridPanel.add(deleteButton);

        selectionPanel.setLayout(new BorderLayout());
        selectionPanel.add(gridPanel, BorderLayout.NORTH);
      }

      this.setLayout(new BorderLayout(30, 0)); // hgap, vgap
      this.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // top, left, bottom, right
      this.add(newShapePanel, BorderLayout.WEST);
      this.add(entryPanel, BorderLayout.CENTER);
      this.add(selectionPanel, BorderLayout.EAST);

      controller.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals(e.getPropertyName())) {
                resizeNewShapesCheckBox.setSelected(controller.isResizeNewShapesToViewport());
              } else if (ENABLE_EDIT.equals(e.getPropertyName())) {
                enableEditCheckBox.setSelected(controller.isEnableEdit());
              }
            }
          });
    }
コード例 #6
0
  private JPanel buildMainContentPane() {
    JPanel backPanel = new JPanel();
    backPanel.setSize(600, 400);
    backPanel.setLayout(new BoxLayout(backPanel, BoxLayout.Y_AXIS));
    backPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.LINE_AXIS));
    // mainPanel.setBorder(BorderFactory.createEmptyBorder(0,0,20,0));
    final JTextArea textArea = new JTextArea("Type your troll text here");
    textArea.addKeyListener(
        new KeyListener() {

          @Override
          public void keyTyped(KeyEvent arg0) {}

          @Override
          public void keyReleased(KeyEvent arg0) {
            if (autoupdate) destinationGUI.setTextCenter(textArea.getText());
          }

          @Override
          public void keyPressed(KeyEvent arg0) {}
        });
    textArea.setPreferredSize(new Dimension(260, 200));
    textArea.setMaximumSize(new Dimension(260, 200));
    textArea.setMinimumSize(new Dimension(260, 200));
    mainPanel.add(textArea);

    JPanel settingsPanel = new JPanel();
    settingsPanel.setSize(150, 220);
    settingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));

    // CheckBox - Mise à jour auto du texte
    JCheckBox autoUpdateCB = new JCheckBox("Mise à jour auto du texte");
    autoUpdateCB.setSelected(autoupdate);
    autoUpdateCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdate = !autoupdate;
          }
        });
    autoUpdateCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateCB);

    // CheckBox - Mise à jour auto de la couleur du texte
    JCheckBox autoUpdateTextColorCB = new JCheckBox("Mise à jour auto de la couleur du texte");
    autoUpdateTextColorCB.setSelected(autoupdateTextColor);
    autoUpdateTextColorCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateTextColor = !autoupdateTextColor;
          }
        });
    autoUpdateTextColorCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateTextColorCB);

    // CheckBox - Mise à jour auto de la couleur d'arri�re plan
    JCheckBox autoUpdateBackgroundColorCB =
        new JCheckBox("Mise à jour auto de la couleur d'arrière-plan");
    autoUpdateBackgroundColorCB.setSelected(autoupdateBackgroundColor);
    autoUpdateBackgroundColorCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateBackgroundColor = !autoupdateBackgroundColor;
          }
        });
    autoUpdateBackgroundColorCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateBackgroundColorCB);

    // Checkbox - MAJ auto de la taille du texte
    JCheckBox autoUpdateTextSizeCB = new JCheckBox("Mise à jour auto de la taille du texte");
    autoUpdateTextSizeCB.setSelected(autoupdateTextSize);
    autoUpdateTextSizeCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            autoupdateTextSize = !autoupdateTextSize;
          }
        });
    autoUpdateTextSizeCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(autoUpdateTextSizeCB);

    // Chekbox - fullscreen on second Screen
    JCheckBox fullscreenCB = new JCheckBox("Activer le plein écran sur le deuxième écran");
    fullscreenCB.setSelected(fullscreen);
    fullscreenCB.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            fullscreen = !fullscreen;
          }
        });
    fullscreenCB.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(fullscreenCB);

    JPanel backgroundColorPanel = new JPanel();
    backgroundColorPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    final JPanel backgroundColorPreviewPanel = new JPanel();
    backgroundColorPreviewPanel.setMaximumSize(new Dimension(50, 25));
    backgroundColorPreviewPanel.setPreferredSize(new Dimension(50, 25));
    backgroundColorPreviewPanel.setBackground(backgroundColor);

    JButton backgroundColorButton = new JButton("Choisir la couleur d'arrière-plan");
    backgroundColorButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            Color newColor =
                JColorChooser.showDialog(colorChooser, "Couleur d'arrière-plan", backgroundColor);
            if (newColor != null) {
              backgroundColor = newColor;
              backgroundColorPreviewPanel.setBackground(backgroundColor);
              if (autoupdateBackgroundColor) destinationGUI.setBackgroundColor(backgroundColor);
            }
          }
        });
    backgroundColorPanel.add(backgroundColorPreviewPanel);
    backgroundColorPanel.add(backgroundColorButton);
    backgroundColorPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(backgroundColorPanel);

    JPanel textColorPanel = new JPanel();
    textColorPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    final JPanel textColorPreviewPanel = new JPanel();
    textColorPreviewPanel.setMaximumSize(new Dimension(50, 25));
    textColorPreviewPanel.setPreferredSize(new Dimension(50, 25));
    textColorPreviewPanel.setBackground(textColor);

    JButton textColorButton = new JButton("Choisir la couleur du texte");
    textColorButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            Color newColor = JColorChooser.showDialog(colorChooser, "Couleur du texte", textColor);
            if (newColor != null) {
              textColor = newColor;
              textColorPreviewPanel.setBackground(textColor);
              if (autoupdateTextColor) destinationGUI.setTextColor(textColor);
            }
          }
        });

    textColorPanel.add(textColorPreviewPanel);
    textColorPanel.add(textColorButton);
    textColorPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(textColorPanel);

    colorChooser = new JColorChooser();

    SpinnerModel textSizeSpinnerModel = new SpinnerNumberModel(textSize, 1, 300, 1);
    final JSpinner textSizeSpinner = new JSpinner(textSizeSpinnerModel);
    textSizeSpinner.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent arg0) {
            if ((int) textSizeSpinner.getValue() != textSize) {
              textSize = (int) textSizeSpinner.getValue();
              if (autoupdateTextSize) destinationGUI.setTextSize(textSize);
            }
          }
        });
    JPanel textSizePanel = new JPanel();
    textSizePanel.setMaximumSize(new Dimension(300, 60));
    textSizePanel.setPreferredSize(new Dimension(300, 30));
    textSizePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    textSizePanel.setAlignmentX(LEFT_ALIGNMENT);
    JLabel textSizeLabel = new JLabel("Taille du texte");
    textSizeSpinner.setMaximumSize(new Dimension(45, 20));
    textSizePanel.add(textSizeLabel);
    textSizePanel.add(textSizeSpinner);
    JLabel screenLabel = new JLabel("Second écran");
    Integer[] screens = {0, 1};
    JComboBox<Integer> screenComboBox = new JComboBox<Integer>(screens);
    screenComboBox.setSelectedIndex(Main.secondScreen);
    screenComboBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            JComboBox<Integer> cb = (JComboBox<Integer>) e.getSource();
            if (cb.getSelectedItem().equals(0)) {
              Main.mainScreen = 1;
              Main.secondScreen = 0;
            } else {
              Main.mainScreen = 0;
              Main.secondScreen = 1;
            }
          }
        });
    screenComboBox.setMaximumSize(new Dimension(45, 20));
    textSizePanel.add(screenLabel);
    textSizePanel.add(screenComboBox);

    settingsPanel.add(textSizePanel);
    mainPanel.add(settingsPanel);
    backPanel.add(mainPanel);

    // RAINBOW PANEL
    JPanel rainbowPanel = new JPanel();
    rainbowPanel.setMinimumSize(new Dimension(50, 40));
    rainbowPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
    final JButton rainbowButton = new JButton("Activer le Rainbow Mode");
    rainbowButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // rainbow mode is already activated :
            // stopping it...
            if (destinationGUI.isRainbowEnabled()) {
              destinationGUI.stopTimer();
              destinationGUI.setTextColor(textColor);
              destinationGUI.setBackgroundColor(backgroundColor);
              rainbowButton.setText("Activer le Rainbow Mode");
            }
            // Rainbow Mode is stopped :
            // starting it...
            else {
              destinationGUI.startTimer();
              rainbowButton.setText("Désactiver le Rainbow Mode");
            }
          }
        });

    JLabel epilepticLabel = new JLabel("Mode épileptique");
    final JCheckBox epilepticCheckBox = new JCheckBox();
    epilepticCheckBox.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            destinationGUI.setEpileptic(epilepticCheckBox.isSelected());
          }
        });
    JLabel speedLabel = new JLabel("Vitesse");
    final JSlider speedSlider =
        new JSlider(SwingConstants.HORIZONTAL, SPEED_MIN, SPEED_MAX, SPEED_INIT);
    speedSlider.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            if (!speedSlider.getValueIsAdjusting()) {
              destinationGUI.setSpeed(speedSlider.getValue());
            }
          }
        });
    destinationGUI.setSpeed(SPEED_INIT);
    speedSlider.setPreferredSize(new Dimension(100, 30));

    rainbowPanel.add(rainbowButton);
    rainbowPanel.add(speedLabel);
    rainbowPanel.add(speedSlider);
    rainbowPanel.add(epilepticLabel);
    rainbowPanel.add(epilepticCheckBox);
    backPanel.add(rainbowPanel);

    // BOTTOM PANEL
    JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 30, 10));
    bottomPanel.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0));
    JButton updateButton = new JButton("Mettre à jour les modifications");
    updateButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            destinationGUI.setTextCenter(textArea.getText().replaceAll("\n", "<br>"));
            destinationGUI.setTextColor(textColor);
            destinationGUI.setBackgroundColor(backgroundColor);
            destinationGUI.setTextSize(textSize);
          }
        });
    bottomPanel.add(updateButton);

    final JButton secondScreen = new JButton("Envoyer sur le second écran");
    secondScreen.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] gd = ge.getScreenDevices();
            // Ramener sur le premier ecran
            if (isOnSecondScreen) {
              secondScreen.setText("Envoyer sur le second écran");
              showDestGUIOnScreen(Main.mainScreen);
              isOnSecondScreen = false;
              if (wasFullscreen) {
                quitFullscreen();
                destinationGUI = new GUI();
                destinationGUI.setTextCenter(textArea.getText());
                destinationGUI.setTextColor(textColor);
                destinationGUI.setBackgroundColor(backgroundColor);
                destinationGUI.setTextSize(textSize);
              }
            }
            // Envoyer sur le deuxieme ecran
            else {
              if (Main.protection && gd.length <= 1) {
                System.out.println("Erreur : Pas de second écran trouve");
                return;
              }
              showDestGUIOnScreen(Main.secondScreen);
              secondScreen.setText("Ramener sur le premier écran");
              isOnSecondScreen = true;
              wasFullscreen = fullscreen;
            }
          }
        });

    bottomPanel.add(secondScreen);
    bottomPanel.setAlignmentX(CENTER_ALIGNMENT);

    destinationGUI.setTextSize(textSize);
    destinationGUI.setTextColor(textColor);
    destinationGUI.setBackgroundColor(backgroundColor);
    destinationGUI.setTextCenter(textArea.getText());

    backPanel.add(bottomPanel);
    return backPanel;
  }
コード例 #7
0
ファイル: SeekAction.java プロジェクト: hof/jin
    /** Creates the ui of this panel, laying out all the ui elements. */
    private void createUI() {
      I18n i18n = getI18n();

      final int labelPad = 4; // To align labels with checkboxes

      // Time controls
      JLabel timeLabel = i18n.createLabel("timeLabel");
      timeLabel.setLabelFor(timeField);

      JLabel incLabel = i18n.createLabel("incrementLabel");
      incLabel.setLabelFor(incField);

      JLabel secondsLabel = i18n.createLabel("secondsLabel");
      JLabel minutesLabel = i18n.createLabel("minutesLabel");

      timeField.setMaximumSize(timeField.getPreferredSize());
      incField.setMaximumSize(incField.getPreferredSize());

      JComponent timeContainer = new JPanel(new TableLayout(5, labelPad, 2));
      timeContainer.add(Box.createHorizontalStrut(0));
      timeContainer.add(timeLabel);
      timeContainer.add(Box.createHorizontalStrut(10));
      timeContainer.add(timeField);
      timeContainer.add(minutesLabel);
      timeContainer.add(Box.createHorizontalStrut(0));
      timeContainer.add(incLabel);
      timeContainer.add(Box.createHorizontalStrut(10));
      timeContainer.add(incField);
      timeContainer.add(secondsLabel);

      // Variant
      JLabel variantLabel = i18n.createLabel("variantLabel");
      variantLabel.setLabelFor(variantChoice);
      variantChoice.setMaximumSize(variantChoice.getPreferredSize());

      JComponent variantContainer = SwingUtils.createHorizontalBox();
      variantContainer.add(Box.createHorizontalStrut(labelPad));
      variantContainer.add(variantLabel);
      variantContainer.add(Box.createHorizontalStrut(10));
      variantContainer.add(variantChoice);
      variantContainer.add(Box.createHorizontalGlue());

      // Color
      JLabel colorLabel = i18n.createLabel("colorLabel");

      JComponent colorContainer = SwingUtils.createHorizontalBox();
      colorContainer.add(Box.createHorizontalStrut(labelPad));
      colorContainer.add(colorLabel);
      colorContainer.add(Box.createHorizontalStrut(15));
      colorContainer.add(autoColor);
      colorContainer.add(Box.createHorizontalStrut(10));
      colorContainer.add(whiteColor);
      colorContainer.add(Box.createHorizontalStrut(10));
      colorContainer.add(blackColor);
      colorContainer.add(Box.createHorizontalGlue());

      // Limit opponent rating
      JLabel minLabel = i18n.createLabel("minRatingLabel");
      minLabel.setLabelFor(minRatingField);
      JLabel maxLabel = i18n.createLabel("maxRatingLabel");
      maxLabel.setLabelFor(maxRatingField);
      minRatingField.setMaximumSize(minRatingField.getPreferredSize());
      maxRatingField.setMaximumSize(minRatingField.getPreferredSize());

      JComponent limitRatingBoxContainer = SwingUtils.createHorizontalBox();
      limitRatingBoxContainer.add(limitRatingBox);
      limitRatingBoxContainer.add(Box.createHorizontalGlue());

      final JComponent minMaxContainer = SwingUtils.createHorizontalBox();
      minMaxContainer.add(Box.createHorizontalStrut(40));
      minMaxContainer.add(minLabel);
      minMaxContainer.add(Box.createHorizontalStrut(10));
      minMaxContainer.add(minRatingField);
      minMaxContainer.add(Box.createHorizontalStrut(20));
      minMaxContainer.add(maxLabel);
      minMaxContainer.add(Box.createHorizontalStrut(10));
      minMaxContainer.add(maxRatingField);
      minMaxContainer.add(Box.createHorizontalGlue());

      JComponent limitRatingContainer = SwingUtils.createVerticalBox();
      limitRatingContainer.add(limitRatingBoxContainer);
      limitRatingContainer.add(Box.createVerticalStrut(3));
      limitRatingContainer.add(minMaxContainer);

      // Buttons panel
      JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      JButton issueSeekButton = i18n.createButton("issueSeekButton");
      JButton cancelButton = i18n.createButton("cancelButton");

      setDefaultButton(issueSeekButton);
      cancelButton.setDefaultCapable(false);

      buttonsPanel.add(issueSeekButton);
      buttonsPanel.add(cancelButton);

      JButton moreLessButton = i18n.createButton("moreOptionsButton");
      moreLessButton.setDefaultCapable(false);
      moreLessButton.setActionCommand("more");
      JPanel moreLessPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
      moreLessPanel.add(moreLessButton);

      final JComponent advancedPanelHolder = new JPanel(new BorderLayout());

      // Layout the subcontainers in the main container
      setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
      timeContainer.setAlignmentX(LEFT_ALIGNMENT);
      add(timeContainer);
      add(Box.createVerticalStrut(2));
      isRatedBox.setAlignmentX(LEFT_ALIGNMENT);
      add(isRatedBox);
      advancedPanelHolder.setAlignmentX(LEFT_ALIGNMENT);
      add(advancedPanelHolder);
      add(Box.createVerticalStrut(5));
      moreLessPanel.setAlignmentX(LEFT_ALIGNMENT);
      add(moreLessPanel);

      add(Box.createVerticalStrut(10));
      buttonsPanel.setAlignmentX(LEFT_ALIGNMENT);
      add(buttonsPanel);

      // Advanced options panel
      final JComponent advancedPanel = SwingUtils.createVerticalBox();
      advancedPanel.add(Box.createVerticalStrut(4));
      variantContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(variantContainer);
      advancedPanel.add(Box.createVerticalStrut(4));
      colorContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(colorContainer);
      advancedPanel.add(Box.createVerticalStrut(2));
      limitRatingContainer.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(limitRatingContainer);
      advancedPanel.add(Box.createVerticalStrut(2));
      manualAcceptBox.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(manualAcceptBox);
      advancedPanel.add(Box.createVerticalStrut(2));
      useFormulaBox.setAlignmentX(LEFT_ALIGNMENT);
      advancedPanel.add(useFormulaBox);

      AWTUtilities.setContainerEnabled(minMaxContainer, limitRatingBox.isSelected());
      limitRatingBox.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              AWTUtilities.setContainerEnabled(minMaxContainer, limitRatingBox.isSelected());
            }
          });

      moreLessButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              if (evt.getActionCommand().equals("more")) {
                JButton moreLessButton = (JButton) evt.getSource();
                moreLessButton.setText(getI18n().getString("lessOptionsButton.text"));
                moreLessButton.setActionCommand("less");
                advancedPanelHolder.add(advancedPanel, BorderLayout.CENTER);
                SeekPanel.this.resizeContainerToFit();
              } else {
                JButton moreLessButton = (JButton) evt.getSource();
                moreLessButton.setText(getI18n().getString("moreOptionsButton.text"));
                moreLessButton.setActionCommand("more");
                advancedPanelHolder.remove(advancedPanel);
                SeekPanel.this.resizeContainerToFit();
              }
            }
          });

      cancelButton.addActionListener(new ClosingListener(null));
      issueSeekButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              int time, inc;

              try {
                time = Integer.parseInt(timeField.getText());
              } catch (NumberFormatException e) {
                getI18n().error("timeError");
                return;
              }

              try {
                inc = Integer.parseInt(incField.getText());
              } catch (NumberFormatException e) {
                getI18n().error("incError");
                return;
              }

              boolean isRated = isRatedBox.isSelected();

              WildVariant variant = (WildVariant) variantChoice.getSelectedItem();

              Player color =
                  autoColor.isSelected()
                      ? null
                      : whiteColor.isSelected() ? Player.WHITE_PLAYER : Player.BLACK_PLAYER;

              int minRating, maxRating;
              if (limitRatingBox.isSelected()) {
                try {
                  minRating = Integer.parseInt(minRatingField.getText());
                } catch (NumberFormatException e) {
                  getI18n().error("minRatingError");
                  return;
                }
                try {
                  maxRating = Integer.parseInt(maxRatingField.getText());
                } catch (NumberFormatException e) {
                  getI18n().error("maxRatingError");
                  return;
                }
              } else {
                minRating = Integer.MIN_VALUE;
                maxRating = Integer.MAX_VALUE;
              }

              boolean manualAccept = manualAcceptBox.isSelected();
              boolean useFormula = useFormulaBox.isSelected();

              close(
                  new UserSeek(
                      time,
                      inc,
                      isRated,
                      variant,
                      color,
                      minRating,
                      maxRating,
                      manualAccept,
                      useFormula));
            }
          });
    }
コード例 #8
0
ファイル: BeanTableDataModel.java プロジェクト: KenC57/JMRI
    @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;
    }
コード例 #9
0
  public ProceedDialog(long id, int numberOfDirectionErrors, int numberOfRoadTypeErrors) {

    panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    JLabel label1 =
        new JLabel(tr("PT_Assistant plugin found that this relation (id={0}) has errors:", id));
    panel.add(label1);
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);

    if (true) {
      JLabel label2 =
          new JLabel(
              "     "
                  + trn(
                      "{0} direction error",
                      "{0} direction errors", numberOfDirectionErrors, numberOfDirectionErrors));
      panel.add(label2);
      label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    }

    if (numberOfRoadTypeErrors != 0) {
      JLabel label3 =
          new JLabel(
              "     "
                  + trn(
                      "{0} road type error",
                      "{0} road type errors", numberOfRoadTypeErrors, numberOfRoadTypeErrors));
      panel.add(label3);
      label3.setAlignmentX(Component.LEFT_ALIGNMENT);
    }

    JLabel label4 = new JLabel(tr("How do you want to proceed?"));
    panel.add(label4);
    label4.setAlignmentX(Component.LEFT_ALIGNMENT);

    radioButtonFixAutomatically = new JRadioButton("Fix all errors automatically and proceed");
    radioButtonFixManually =
        new JRadioButton("I will fix the errors manually and click the button to proceed");
    radioButtonDontFix =
        new JRadioButton("Do not fix anything and proceed with further tests", true);
    ButtonGroup fixOptionButtonGroup = new ButtonGroup();
    fixOptionButtonGroup.add(radioButtonFixAutomatically);
    fixOptionButtonGroup.add(radioButtonFixManually);
    fixOptionButtonGroup.add(radioButtonDontFix);
    panel.add(radioButtonFixAutomatically);
    // panel.add(radioButtonFixManually);
    panel.add(radioButtonDontFix);
    radioButtonFixAutomatically.setAlignmentX(Component.LEFT_ALIGNMENT);
    radioButtonFixManually.setAlignmentX(Component.LEFT_ALIGNMENT);
    radioButtonDontFix.setAlignmentX(Component.LEFT_ALIGNMENT);

    checkbox = new JCheckBox(tr("Remember my choice and do not ask me again in this session"));
    panel.add(checkbox);
    checkbox.setAlignmentX(Component.LEFT_ALIGNMENT);

    options = new String[2];
    options[0] = "OK";
    options[1] = "Cancel & stop testing";

    selectedOption = Integer.MIN_VALUE;
  }
コード例 #10
0
  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);
  }
コード例 #11
0
ファイル: LoggingConfigForm.java プロジェクト: 0xbb/jitsi
  /** Creating the configuration form */
  private void init() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    enableCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE"));
    enableCheckBox.addActionListener(this);

    sipProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME"));
    sipProtocolCheckBox.addActionListener(this);

    jabberProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME"));
    jabberProtocolCheckBox.addActionListener(this);

    String rtpDescription =
        resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION");
    rtpProtocolCheckBox =
        new SIPCommCheckBox(
            resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP")
                + " "
                + rtpDescription);
    rtpProtocolCheckBox.addActionListener(this);
    rtpProtocolCheckBox.setToolTipText(rtpDescription);

    ice4jProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J"));
    ice4jProtocolCheckBox.addActionListener(this);

    JPanel mainPanel = new TransparentPanel();

    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    mainPanel.add(enableCheckBox, c);

    String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION");
    JLabel descriptionLabel = new JLabel(label);
    descriptionLabel.setToolTipText(label);
    enableCheckBox.setToolTipText(label);
    descriptionLabel.setForeground(Color.GRAY);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8));
    c.gridy = 1;
    c.insets = new Insets(0, 25, 10, 0);
    mainPanel.add(descriptionLabel, c);

    final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1));

    loggersButtonPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL")));

    loggersButtonPanel.add(sipProtocolCheckBox);
    loggersButtonPanel.add(jabberProtocolCheckBox);
    loggersButtonPanel.add(rtpProtocolCheckBox);
    loggersButtonPanel.add(ice4jProtocolCheckBox);

    c.insets = new Insets(0, 20, 10, 0);
    c.gridy = 2;
    mainPanel.add(loggersButtonPanel, c);

    final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2));

    advancedPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED")));

    fileCountField.getDocument().addDocumentListener(this);
    fileSizeField.getDocument().addDocumentListener(this);

    fileCountLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT"));
    advancedPanel.add(fileCountLabel);
    advancedPanel.add(fileCountField);
    fileSizeLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE"));
    advancedPanel.add(fileSizeLabel);
    advancedPanel.add(fileSizeField);

    c.gridy = 3;
    mainPanel.add(advancedPanel, c);

    archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"));
    archiveButton.addActionListener(this);

    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 4;
    mainPanel.add(archiveButton, c);

    if (!StringUtils.isNullOrEmpty(getUploadLocation())) {
      uploadLogsButton =
          new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON"));
      uploadLogsButton.addActionListener(this);

      c.insets = new Insets(10, 0, 0, 0);
      c.gridy = 5;
      mainPanel.add(uploadLogsButton, c);
    }
  }