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;
  }
  /**
   * 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);
  }
    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());
              }
            }
          });
    }
示例#4
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));
            }
          });
    }
示例#5
0
  /** 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);
    }
  }