コード例 #1
0
  public CustomizableComboBox() {
    super(new BorderLayout());

    myThemedCombo.setEditable(true);

    PopupMouseListener listener = new PopupMouseListener();
    // GTK always draws a border on the textbox.  It cannot be removed,
    // so to compensate, we remove our own border so we don't have a double border.
    if (UIUtil.isUnderGTKLookAndFeel()) {
      this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    } else {
      this.setBorder(
          BorderFactory.createCompoundBorder(
              BorderFactory.createEmptyBorder(2, 2, 2, 2),
              BorderFactory.createLineBorder(getBorderColor(), 1)));
    }

    // Try to turn off the border on the JTextField.
    myTextField =
        new JBTextField() {
          @Override
          public void setBorder(Border border) {
            super.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
          }
        };
    myTextField.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
    myTextField.addMouseListener(listener);
    myTextField.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {
            myTextField.selectAll();
          }

          @Override
          public void focusLost(FocusEvent e) {
            // no-op
          }
        });

    JButton popupButton = createArrowButton();
    popupButton.addMouseListener(listener);

    this.add(popupButton, BorderLayout.EAST);
    this.add(myTextField, BorderLayout.CENTER);
  }
コード例 #2
0
 @Override
 public void paint(Graphics g) {
   super.paint(g);
   if (myTextField.isFocusOwner() || (getPopup() != null && getPopup().isPopupVisible())) {
     if (isUsingDarculaUIFlavor()) {
       DarculaUIUtil.paintFocusRing(g, 3, 3, getWidth() - 4, getHeight() - 4);
     }
   }
 }
コード例 #3
0
 @Override
 public void reset() {
   myOSCombo.setSelectedItem(expandDefault(myBuildTargetSettings.getOS(), myDefaultOSValue));
   myArchCombo.setSelectedItem(expandDefault(myBuildTargetSettings.getArch(), myDefaultArchValue));
   myGoVersionCombo.setSelectedItem(
       expandDefault(myBuildTargetSettings.getGoVersion(), myDefaultGoVersion));
   myCgoCombo.setSelectedItem(expandDefault(cgo(myBuildTargetSettings.getCgo()), myDefaultCgo));
   myCompilerCombo.setSelectedItem(myBuildTargetSettings.getCompiler());
   myCustomFlagsField.setText(StringUtil.join(myBuildTargetSettings.getCustomFlags(), " "));
 }
コード例 #4
0
  @Override
  public void addNotify() {
    super.addNotify();

    myTextField.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            CustomizableComboBox.this.repaint();
          }

          @Override
          public void focusLost(FocusEvent e) {
            CustomizableComboBox.this.repaint();
          }
        });
  }
  public ArrangementTextFieldUiComponent(@NotNull ArrangementSettingsToken token) {
    myToken = token;
    myTextField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                scheduleUpdate();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                scheduleUpdate();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                scheduleUpdate();
              }
            });
  }
  @Nullable
  private DependencyOnPlugin editPluginDependency(
      @NotNull JComponent parent, @NotNull final DependencyOnPlugin original) {
    List<String> pluginIds = new ArrayList<String>(getPluginNameByIdMap().keySet());
    if (!original.getPluginId().isEmpty() && !pluginIds.contains(original.getPluginId())) {
      pluginIds.add(original.getPluginId());
    }
    Collections.sort(
        pluginIds,
        new Comparator<String>() {
          @Override
          public int compare(String o1, String o2) {
            return getPluginNameById(o1).compareToIgnoreCase(getPluginNameById(o2));
          }
        });

    final ComboBox pluginChooser = new ComboBox(ArrayUtilRt.toStringArray(pluginIds), 250);
    pluginChooser.setRenderer(
        new ListCellRendererWrapper<String>() {
          @Override
          public void customize(
              JList list, String value, int index, boolean selected, boolean hasFocus) {
            setText(getPluginNameById(value));
          }
        });
    new ComboboxSpeedSearch(pluginChooser) {
      @Override
      protected String getElementText(Object element) {
        return getPluginNameById((String) element);
      }
    };
    pluginChooser.setSelectedItem(original.getPluginId());

    final JBTextField minVersionField =
        new JBTextField(StringUtil.notNullize(original.getMinVersion()));
    final JBTextField maxVersionField =
        new JBTextField(StringUtil.notNullize(original.getMaxVersion()));
    final JBTextField channelField = new JBTextField(StringUtil.notNullize(original.getChannel()));
    minVersionField.getEmptyText().setText("<any>");
    minVersionField.setColumns(10);
    maxVersionField.getEmptyText().setText("<any>");
    maxVersionField.setColumns(10);
    channelField.setColumns(10);
    JPanel panel =
        FormBuilder.createFormBuilder()
            .addLabeledComponent("Plugin:", pluginChooser)
            .addLabeledComponent("Minimum version:", minVersionField)
            .addLabeledComponent("Maximum version:", maxVersionField)
            .addLabeledComponent("Channel:", channelField)
            .getPanel();
    final DialogBuilder dialogBuilder =
        new DialogBuilder(parent).title("Required Plugin").centerPanel(panel);
    dialogBuilder.setPreferredFocusComponent(pluginChooser);
    pluginChooser.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dialogBuilder.setOkActionEnabled(
                !StringUtil.isEmpty((String) pluginChooser.getSelectedItem()));
          }
        });
    if (dialogBuilder.show() == DialogWrapper.OK_EXIT_CODE) {
      return new DependencyOnPlugin(
          ((String) pluginChooser.getSelectedItem()),
          StringUtil.nullize(minVersionField.getText().trim()),
          StringUtil.nullize(maxVersionField.getText().trim()),
          StringUtil.nullize(channelField.getText().trim()));
    }
    return null;
  }
 @NotNull
 @Override
 public ArrangementMatchCondition getMatchCondition() {
   String text = myTextField.getText();
   return new ArrangementAtomMatchCondition(myToken, StringUtil.isEmpty(text) ? "" : text.trim());
 }
 @Override
 public int getBaselineToUse(int width, int height) {
   return myTextField.getBaseline(width, height);
 }
 @Override
 public void doReset() {
   myTextField.setText("");
 }
コード例 #10
0
 @Override
 public void setEnabled(boolean enabled) {
   myTextField.setEnabled(enabled);
 }
コード例 #11
0
 @Override
 public boolean isEnabled() {
   return myTextField.isEnabled();
 }
コード例 #12
0
 @Override
 public boolean isSelected() {
   return !StringUtil.isEmpty(myTextField.getText());
 }
コード例 #13
0
 public String getText() {
   return myTextField.getText();
 }
コード例 #14
0
 public void setText(@Nullable String text) {
   myTextField.setText(text);
 }
コード例 #15
0
 @NotNull
 private String[] selectedCustomFlags() {
   return ArrayUtil.toStringArray(StringUtil.split(myCustomFlagsField.getText(), " "));
 }