Java Code Examples for com.intellij.openapi.ui.TextFieldWithBrowseButton#MyDoClickAction

The following examples show how to use com.intellij.openapi.ui.TextFieldWithBrowseButton#MyDoClickAction . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComboBoxFieldPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void createComponent() {
  super.createComponent();
  TextFieldWithBrowseButton.MyDoClickAction doClickAction = getDoClickAction();
  if (doClickAction != null) {
    doClickAction.registerShortcut(myComboBox);
  }

  myComboBox.setMaximumRowCount(8);

  myComboBox.setEditable(true);
  final JTextField editorComponent = (JTextField)myComboBox.getEditor().getEditorComponent();
  editorComponent.getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      final String text = getText();
      if (!Comparing.equal(text, oldText, true)) {
        oldText = text;
        final Runnable changeListener = getChangeListener();
        if (changeListener != null) {
          changeListener.run();
        }
      }
    }
  });
}
 
Example 2
Source File: AbstractFieldPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void createComponent() {
  removeAll();
  setLayout(new GridBagLayout());

  if (myLabelText != null) {
    myLabel = new JLabel(myLabelText);
    this.add(myLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));
    myLabel.setLabelFor(myComponent);
  }

  this.add(myComponent, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

  if (myBrowseButtonActionListener != null) {
    FixedSizeButton browseButton = new FixedSizeButton(getComponent());
    myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(browseButton);
    browseButton.setFocusable(false);
    browseButton.addActionListener(myBrowseButtonActionListener);
    myButtons.add(browseButton);
    this.add(browseButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 0), 0, 0));
  }
  if (myViewerDialogTitle != null) {
    final FixedSizeButton showViewerButton = new FixedSizeButton(getComponent());
    if (myBrowseButtonActionListener == null) {
      LOG.assertTrue(myDoClickAction == null);
      myDoClickAction = new TextFieldWithBrowseButton.MyDoClickAction(showViewerButton);
    }
    showViewerButton.setFocusable(false);
    showViewerButton.setIcon(AllIcons.Actions.ShowViewer);
    showViewerButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        Viewer viewer = new Viewer();
        viewer.setTitle(myViewerDialogTitle);
        viewer.show();
      }
    });
    myButtons.add(showViewerButton);
    this.add(showViewerButton, new GridBagConstraints(GridBagConstraints.RELATIVE, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  }
}
 
Example 3
Source File: FieldPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void createComponent() {
  super.createComponent();
  TextFieldWithBrowseButton.MyDoClickAction doClickAction = getDoClickAction();
  if (doClickAction != null) {
    doClickAction.registerShortcut(getTextField());
  }

  myTextField.getDocument().addDocumentListener(new DocumentAdapter() {
    public void textChanged(DocumentEvent event) {
      if (getChangeListener() != null) {
        getChangeListener().run();
      }
    }
  });
}
 
Example 4
Source File: AbstractFieldPanel.java    From consulo with Apache License 2.0 votes vote down vote up
protected TextFieldWithBrowseButton.MyDoClickAction getDoClickAction() { return myDoClickAction; }