Java 类com.intellij.openapi.ui.FixedSizeButton 实例源码

项目:intellij-ce-playground    文件:ToolEditorDialog.java   
protected void addWorkingDirectoryBrowseAction(final JPanel pane,
                                               FixedSizeButton browseDirectoryButton,
                                               JTextField tfCommandWorkingDirectory) {
  browseDirectoryButton.addActionListener(
    new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
        PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);

        chooser.choose(null, new Consumer<List<VirtualFile>>() {
          @Override
          public void consume(List<VirtualFile> files) {
            VirtualFile file = !files.isEmpty() ? files.get(0) : null;
            if (file != null) {
              myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
            }
          }
        });
      }
    }
  );
}
项目:intellij-ce-playground    文件:SelectTemplateDialog.java   
@Override
protected JComponent createCenterPanel(){
  loadCombo();

  JButton editTemplatesButton = new FixedSizeButton(myCbxTemplates);

  JPanel centerPanel = new JPanel(new GridBagLayout());
  JLabel selectTemplateLabel = new JLabel(IdeBundle.message("label.name"));

  centerPanel.add(selectTemplateLabel,       new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
  centerPanel.add(myCbxTemplates,       new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 50, 0));
  centerPanel.add(editTemplatesButton,       new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));

  editTemplatesButton.addActionListener(new ActionListener(){
    @Override
    public void actionPerformed(ActionEvent e){
      onEditTemplates();
    }
  });

  return centerPanel;
}
项目:intellij-ce-playground    文件:ChooseGradleHomeDialogFixture.java   
@NotNull
public ChooseGradleHomeDialogFixture chooseGradleHome(@NotNull File gradleHomePath) {
  FixedSizeButton browseButton = robot().finder().findByType(target(), FixedSizeButton.class, true);
  robot().click(browseButton);

  FileChooserDialogFixture fileChooserDialog = FileChooserDialogFixture.findDialog(robot(), new GenericTypeMatcher<JDialog>(JDialog.class) {
    @Override
    protected boolean isMatching(@NotNull JDialog dialog) {
      Collection<JLabel> descriptionLabels = robot().finder().findAll(dialog, JLabelMatcher.withText("Gradle home:"));
      return descriptionLabels.size() == 1;
    }
  });

  VirtualFile toSelect = findFileByIoFile(gradleHomePath, true);
  assertNotNull(toSelect);

  fileChooserDialog.select(toSelect);
  fileChooserDialog.clickOk();

  return this;
}
项目:idea-jflex    文件:JFlexSettingsForm.java   
private void fixButton(final TextFieldWithStoredHistory historyField, ComponentWithBrowseButton<TextFieldWithStoredHistory> control) {
    FixedSizeButton button = control.getButton();
    control.remove(button);
    BorderLayout borderLayout = new BorderLayout();
    JPanel buttonPanel = new JPanel(borderLayout);
    buttonPanel.setBorder(IdeBorderFactory.createEmptyBorder(4, 0, 4, 0));
    buttonPanel.add(button, BorderLayout.CENTER);
    control.add(buttonPanel, BorderLayout.EAST);
    button.setAttachedComponent(new JComponent() {
        public Dimension getPreferredSize() {
            Dimension size = historyField.getTextEditor().getPreferredSize();
            return new Dimension(-1, size.height + 6);
        }

    });
}
项目:tools-idea    文件:ExportToFileUtil.java   
public ExportDialogBase(Project project, ExporterToTextFile exporter) {
  super(project, true);
  myProject = project;
  myExporter = exporter;

  myTfFile = new JTextField();
  myFileButton = new FixedSizeButton(myTfFile);

  setHorizontalStretch(1.5f);
  setTitle(IdeBundle.message("title.export.preview"));
  setOKButtonText(IdeBundle.message("button.save"));
  setButtonsMargin(null);
  init();
  try {
    myListener = new ChangeListener() {
      public void stateChanged(ChangeEvent e) {
        initText();
      }
    };
    myExporter.addSettingsChangedListener(myListener);
  }
  catch (TooManyListenersException e) {
    LOG.error(e);
  }
  initText();
}
项目:tools-idea    文件:ToolEditorDialog.java   
protected void addWorkingDirectoryBrowseAction(final JPanel pane,
                                               FixedSizeButton browseDirectoryButton,
                                               JTextField tfCommandWorkingDirectory) {
  browseDirectoryButton.addActionListener(
    new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
        PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);

        chooser.choose(null, new Consumer<List<VirtualFile>>() {
          @Override
          public void consume(List<VirtualFile> files) {
            VirtualFile file = files.size() > 0 ? files.get(0) : null;
            if (file != null) {
              myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
            }
          }
        });
      }
    }
  );
}
项目:tools-idea    文件:SelectTemplateDialog.java   
@Override
protected JComponent createCenterPanel(){
  loadCombo();

  JButton editTemplatesButton = new FixedSizeButton(myCbxTemplates);

  JPanel centerPanel = new JPanel(new GridBagLayout());
  JLabel selectTemplateLabel = new JLabel(IdeBundle.message("label.name"));

  centerPanel.add(selectTemplateLabel,       new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
  centerPanel.add(myCbxTemplates,       new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 50, 0));
  centerPanel.add(editTemplatesButton,       new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));

  editTemplatesButton.addActionListener(new ActionListener(){
    @Override
    public void actionPerformed(ActionEvent e){
      onEditTemplates();
    }
  });

  return centerPanel;
}
项目:consulo    文件:CommonProgramParametersPanel.java   
@Deprecated // use MacroComboBoxWithBrowseButton instead
protected JComponent createComponentWithMacroBrowse(@Nonnull final TextFieldWithBrowseButton textAccessor) {
  final FixedSizeButton button = new FixedSizeButton(textAccessor);
  button.setIcon(AllIcons.RunConfigurations.Variables);
  button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      //noinspection unchecked
      final JList list = new JBList(myWorkingDirectoryComboBox.getChildComponent().getModel());
      JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(() -> {
        final Object value = list.getSelectedValue();
        if (value instanceof String) {
          textAccessor.setText((String)value);
        }
      }).setMovable(false).setResizable(false).createPopup().showUnderneathOf(button);
    }
  });

  JPanel panel = new JPanel(new BorderLayout());
  panel.add(textAccessor, BorderLayout.CENTER);
  panel.add(button, BorderLayout.EAST);
  return panel;
}
项目:consulo    文件:ToolEditorDialog.java   
protected void addWorkingDirectoryBrowseAction(final JPanel pane,
                                               FixedSizeButton browseDirectoryButton,
                                               JTextField tfCommandWorkingDirectory) {
  browseDirectoryButton.addActionListener(
    new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
        PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);

        chooser.choose(null, new Consumer<List<VirtualFile>>() {
          @Override
          public void consume(List<VirtualFile> files) {
            VirtualFile file = files.size() > 0 ? files.get(0) : null;
            if (file != null) {
              myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
            }
          }
        });
      }
    }
  );
}
项目:consulo    文件:SelectTemplateDialog.java   
@Override
protected JComponent createCenterPanel(){
  loadCombo();

  JButton editTemplatesButton = new FixedSizeButton(myCbxTemplates);

  JPanel centerPanel = new JPanel(new GridBagLayout());
  JLabel selectTemplateLabel = new JLabel(IdeBundle.message("label.name"));

  centerPanel.add(selectTemplateLabel,       new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
  centerPanel.add(myCbxTemplates,       new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 50, 0));
  centerPanel.add(editTemplatesButton,       new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));

  editTemplatesButton.addActionListener(e -> onEditTemplates());

  return centerPanel;
}
项目:educational-plugin    文件:EduIntellijCourseProjectGeneratorBase.java   
@Nullable
@Override
public LabeledComponent<JComponent> getLanguageSettingsComponent(@NotNull Course selectedCourse) {
  myModel = ProjectStructureConfigurable.getInstance(ProjectManager.getInstance().getDefaultProject()).getProjectJdksModel();
  myJdkComboBox = new JdkComboBox(myModel, sdkTypeId -> sdkTypeId instanceof JavaSdkType && !((JavaSdkType)sdkTypeId).isDependent(), sdk -> true, sdkTypeId -> sdkTypeId instanceof JavaSdkType && !((JavaSdkType)sdkTypeId).isDependent(), true);
  ComboboxWithBrowseButton comboboxWithBrowseButton = new ComboboxWithBrowseButton(myJdkComboBox);
  FixedSizeButton setupButton = comboboxWithBrowseButton.getButton();
  myJdkComboBox.setSetupButton(setupButton, null, myModel, (JdkComboBox.JdkComboBoxItem) myJdkComboBox.getModel().getSelectedItem(), null, false);
  return LabeledComponent.create(comboboxWithBrowseButton, "Jdk", BorderLayout.WEST);
}
项目:intellij-ce-playground    文件:ConfigurationArgumentsHelpArea.java   
public ConfigurationArgumentsHelpArea() {
  super(new BorderLayout());
  add(myPanel);
  setBorder(IdeBorderFactory.createEmptyBorder(10, 0, 0, 0));

  final DefaultActionGroup group = new DefaultActionGroup();
  group.add(new MyCopyAction());
  myHelpArea.addMouseListener(
    new PopupHandler(){
      @Override
      public void invokePopup(final Component comp,final int x,final int y){
        ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group).getComponent().show(comp, x, y);
      }
    }
  );

  FixedSizeButton copyButton = new FixedSizeButton(22);
  copyButton.setIcon(PlatformIcons.COPY_ICON);
  copyButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final StringSelection contents = new StringSelection(myHelpArea.getText().trim());
      CopyPasteManager.getInstance().setContents(contents);
    }
  });
  myToolbarPanel.add(copyButton, BorderLayout.NORTH);
  myToolbarPanel.setVisible(false);
}
项目:intellij-ce-playground    文件:GuiUtils.java   
private static JPanel constructFieldWithBrowseButton(final JComponent aComponent, final ActionListener aActionListener, int delta) {
  JPanel result = new JPanel(new GridBagLayout());
  result.add(aComponent, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0,0));
  FixedSizeButton browseButton = new FixedSizeButton(aComponent.getPreferredSize().height - delta);//ignore border in case of browse button
  TextFieldWithBrowseButton.MyDoClickAction.addTo(browseButton, aComponent);
  result.add(browseButton, new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,0), 0,0));
  browseButton.addActionListener(aActionListener);

  return result;
}
项目:intellij-ce-playground    文件:AbstractFieldPanel.java   
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(PlatformIcons.OPEN_EDIT_DIALOG_ICON);
    showViewerButton.addActionListener(new ActionListener() {
      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));
  }
}
项目:intellij-ce-playground    文件:ExternalProjectPathField.java   
public MyPathAndProjectButtonPanel(@NotNull EditorTextField textField,
                                   @NotNull FixedSizeButton registeredProjectsButton)
{
  super(new GridBagLayout());
  myTextField = textField;
  myRegisteredProjectsButton = registeredProjectsButton;
  add(myTextField, new GridBag().weightx(1).fillCellHorizontally());
  add(myRegisteredProjectsButton, new GridBag().insets(0, 3, 0, 0));
}
项目:intellij-ce-playground    文件:TableCellEditorWithButton.java   
public MyComponent() {
  super(new GridBagLayout());

  myTextField = new JTextField();
  myButton = new FixedSizeButton(myTextField);

  add(myTextField, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  add(myButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
项目:intellij-ce-playground    文件:ValueMarkerPresentationDialogBase.java   
private void createUIComponents() {
  myColorSample = new SimpleColoredComponent();
  mySamplePanel = new JPanel(new BorderLayout());
  mySamplePanel.setBorder(BorderFactory.createEtchedBorder());
  mySamplePanel.add(BorderLayout.CENTER, myColorSample);
  myChooseColorButton = new FixedSizeButton(mySamplePanel);
}
项目:intellij-ce-playground    文件:CommonProgramParametersPanel.java   
protected JComponent createComponentWithMacroBrowse(@NotNull final TextFieldWithBrowseButton textAccessor) {
  final FixedSizeButton button = new FixedSizeButton(textAccessor);
  button.setIcon(AllIcons.RunConfigurations.Variables);
  button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      List<String> macros = new SmartList<String>(PathMacros.getInstance().getUserMacroNames());
      if (myModuleContext != null || myHasModuleMacro) {
        macros.add(PathMacroUtil.MODULE_DIR_MACRO_NAME);
      }

      final JList list = new JBList(ArrayUtil.toStringArray(macros));
      JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(new Runnable() {
        @Override
        public void run() {
          final Object value = list.getSelectedValue();
          if (value instanceof String) {
            textAccessor.setText('$' + ((String)value) + '$');
          }
        }
      }).setMovable(false).setResizable(false).createPopup().showUnderneathOf(button);
    }
  });

  JPanel panel = new JPanel(new BorderLayout());
  panel.add(textAccessor, BorderLayout.CENTER);
  panel.add(button, BorderLayout.EAST);
  return panel;
}
项目:intellij-ce-playground    文件:ToolEditorDialog.java   
protected void addCommandBrowseAction(final JPanel pane, FixedSizeButton browseCommandButton, JTextField tfCommand) {
  browseCommandButton.addActionListener(
    new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor();
        PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
        chooser.choose(null, new Consumer<List<VirtualFile>>() {
          @Override
          public void consume(List<VirtualFile> files) {
            VirtualFile file = !files.isEmpty() ? files.get(0) : null;
            if (file != null) {
              myTfCommand.setText(file.getPresentableUrl());
              String workingDirectory = myTfCommandWorkingDirectory.getText();
              if (workingDirectory == null || workingDirectory.isEmpty()) {
                VirtualFile parent = file.getParent();
                if (parent != null && parent.isDirectory()) {
                  myTfCommandWorkingDirectory.setText(parent.getPresentableUrl());
                }
              }
            }
          }
        });
      }
    }
  );
}
项目:intellij-ce-playground    文件:EditLocationDialog.java   
@Override
protected void init() {
  setTitle(myTitle);
  myTfUrl = new JTextField();
  myTfPath = new JTextField();
  myBtnBrowseLocalPath = new FixedSizeButton(myTfPath);
  super.init();
}
项目:intellij-ce-playground    文件:AntUIUtil.java   
public PropertyValueCellEditor() {
  myComponent = new CellEditorComponentWithBrowseButton<JTextField>(new TextFieldWithBrowseButton(), this);
  getChildComponent().setBorder(BorderFactory.createLineBorder(Color.black));

  FixedSizeButton button = myComponent.getComponentWithButton().getButton();
  button.setIcon(IconUtil.getAddIcon());
  button.setToolTipText(AntBundle.message("ant.property.value.editor.insert.macro.tooltip.text"));
  button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      MacrosDialog dialog = new MacrosDialog(getChildComponent());
      if (dialog.showAndGet() && dialog.getSelectedMacro() != null) {
        JTextField textField = getChildComponent();

        String macro = dialog.getSelectedMacro().getName();
        int position = textField.getCaretPosition();
        try {
          textField.getDocument().insertString(position, "$" + macro + "$", null);
          textField.setCaretPosition(position + macro.length() + 2);
        }
        catch (BadLocationException ex) {
          LOG.error(ex);
        }
        textField.requestFocus();
      }
    }
  });
}
项目:google-cloud-intellij    文件:ProjectSelector.java   
private void createUIComponents() {
  projectNameLabel = new HyperlinkLabelWithStateAccess();
  projectNameLabel.setHyperlinkText(
      GctBundle.getString("cloud.project.selector.no.selected.project"));
  projectNameLabel.addHyperlinkListener(
      (event) -> {
        if (event.getEventType() == EventType.ACTIVATED) {
          handleOpenProjectSelectionDialog();
        }
      });

  projectAccountSeparatorLabel = new JBLabel("/");
  projectAccountSeparatorLabel.setVisible(false /* only visible when project is selected. */);

  accountInfoLabel = new HyperlinkLabelWithStateAccess();
  accountInfoLabel.addHyperlinkListener(
      (event) -> {
        if (event.getEventType() == EventType.ACTIVATED) {
          handleOpenProjectSelectionDialog();
        }
      });

  hyperlinksPanel = new JPanel();
  hyperlinksPanel.setBorder(UIManager.getBorder("TextField.border"));
  hyperlinksPanel.setLayout(new BoxLayout(hyperlinksPanel, BoxLayout.X_AXIS));

  browseButton = new FixedSizeButton(hyperlinksPanel);
  browseButton.addActionListener((actionEvent) -> handleOpenProjectSelectionDialog());
  browseButton.setFocusable(true);
  browseButton.setToolTipText(GctBundle.getString("cloud.project.selector.open.dialog.tooltip"));
}
项目:tools-idea    文件:ConfigurationArgumentsHelpArea.java   
public ConfigurationArgumentsHelpArea() {
  super(new BorderLayout());
  add(myPanel);
  setBorder(IdeBorderFactory.createEmptyBorder(10, 0, 0, 0));

  final DefaultActionGroup group = new DefaultActionGroup();
  group.add(new MyCopyAction());
  myHelpArea.addMouseListener(
    new PopupHandler(){
      public void invokePopup(final Component comp,final int x,final int y){
        createPopupMenu(group).getComponent().show(comp,x,y);
      }
    }
  );

  FixedSizeButton copyButton = new FixedSizeButton(22);
  copyButton.setIcon(PlatformIcons.COPY_ICON);
  copyButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      final StringSelection contents = new StringSelection(myHelpArea.getText().trim());
      CopyPasteManager.getInstance().setContents(contents);
    }
  });
  myToolbarPanel.add(copyButton, BorderLayout.NORTH);
  myToolbarPanel.setVisible(false);
}
项目:tools-idea    文件:GuiUtils.java   
private static JPanel constructFieldWithBrowseButton(final JComponent aComponent, final ActionListener aActionListener, int delta) {
  JPanel result = new JPanel(new GridBagLayout());
  result.add(aComponent, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0,0));
  FixedSizeButton browseButton = new FixedSizeButton(aComponent.getPreferredSize().height - delta);//ignore border in case of browse button
  TextFieldWithBrowseButton.MyDoClickAction.addTo(browseButton, aComponent);
  result.add(browseButton, new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,0), 0,0));
  browseButton.addActionListener(aActionListener);

  return result;
}
项目:tools-idea    文件:AbstractFieldPanel.java   
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(PlatformIcons.OPEN_EDIT_DIALOG_ICON);
    showViewerButton.addActionListener(new ActionListener() {
      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));
  }
}
项目:tools-idea    文件:ExternalProjectPathField.java   
public MyPathAndProjectButtonPanel(@NotNull EditorTextField textField,
                                   @NotNull FixedSizeButton registeredProjectsButton)
{
  super(new GridBagLayout());
  myTextField = textField;
  myRegisteredProjectsButton = registeredProjectsButton;
  add(myTextField, new GridBag().weightx(1).fillCellHorizontally());
  add(myRegisteredProjectsButton, new GridBag().insets(0, 3, 0, 0));
}
项目:tools-idea    文件:TableCellEditorWithButton.java   
public MyComponent() {
  super(new GridBagLayout());

  myTextField = new JTextField();
  myButton = new FixedSizeButton(myTextField);

  add(myTextField, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  add(myButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
项目:tools-idea    文件:ValueMarkerPresentationDialogBase.java   
private void createUIComponents() {
  myColorSample = new SimpleColoredComponent();
  mySamplePanel = new JPanel(new BorderLayout());
  mySamplePanel.setBorder(BorderFactory.createEtchedBorder());
  mySamplePanel.add(BorderLayout.CENTER, myColorSample);
  myChooseColorButton = new FixedSizeButton(mySamplePanel);
}
项目:tools-idea    文件:ToolEditorDialog.java   
protected void addCommandBrowseAction(final JPanel pane, FixedSizeButton browseCommandButton, JTextField tfCommand) {
  browseCommandButton.addActionListener(
    new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor();
        PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
        chooser.choose(null, new Consumer<List<VirtualFile>>() {
          @Override
          public void consume(List<VirtualFile> files) {
            VirtualFile file = files.size() > 0 ? files.get(0) : null;
            if (file != null) {
              myTfCommand.setText(file.getPresentableUrl());
              String workingDirectory = myTfCommandWorkingDirectory.getText();
              if (workingDirectory == null || workingDirectory.length() == 0) {
                VirtualFile parent = file.getParent();
                if (parent != null && parent.isDirectory()) {
                  myTfCommandWorkingDirectory.setText(parent.getPresentableUrl());
                }
              }
            }
          }
        });
      }
    }
  );
}
项目:tools-idea    文件:EditLocationDialog.java   
protected void init() {
  setTitle(myTitle);
  myTfUrl = new JTextField();
  myTfPath = new JTextField();
  myBtnBrowseLocalPath = new FixedSizeButton(myTfPath);
  super.init();
}
项目:tools-idea    文件:AntUIUtil.java   
public PropertyValueCellEditor() {
  myComponent = new CellEditorComponentWithBrowseButton<JTextField>(new TextFieldWithBrowseButton(), this);
  getChildComponent().setBorder(BorderFactory.createLineBorder(Color.black));

  FixedSizeButton button = myComponent.getComponentWithButton().getButton();
  button.setIcon(IconUtil.getAddIcon());
  button.setToolTipText(AntBundle.message("ant.property.value.editor.insert.macro.tooltip.text"));
  button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      MacrosDialog dialog = new MacrosDialog(getChildComponent());
      dialog.show();
      if (dialog.isOK() && dialog.getSelectedMacro() != null) {
        JTextField textField = getChildComponent();

        String macro = dialog.getSelectedMacro().getName();
        int position = textField.getCaretPosition();
        try {
          textField.getDocument().insertString(position, "$" + macro + "$", null);
          textField.setCaretPosition(position + macro.length() + 2);
        }
        catch (BadLocationException ex) {
          LOG.error(ex);
        }
        textField.requestFocus();
      }
    }
  });
}
项目:consulo-apache-ant    文件:AntUIUtil.java   
public PropertyValueCellEditor()
{
    myComponent = new CellEditorComponentWithBrowseButton<JTextField>(new TextFieldWithBrowseButton(), this);
    getChildComponent().setBorder(BorderFactory.createLineBorder(Color.black));

    FixedSizeButton button = myComponent.getComponentWithButton().getButton();
    button.setIcon(IconUtil.getAddIcon());
    button.setToolTipText(AntBundle.message("ant.property.value.editor.insert.macro.tooltip.text"));
    button.addActionListener(new ActionListener()
    {
        @Override
        public void actionPerformed(ActionEvent e)
        {
            MacrosDialog dialog = new MacrosDialog(getChildComponent());
            dialog.show();
            if(dialog.isOK() && dialog.getSelectedMacro() != null)
            {
                JTextField textField = getChildComponent();

                String macro = dialog.getSelectedMacro().getName();
                int position = textField.getCaretPosition();
                try
                {
                    textField.getDocument().insertString(position, "$" + macro + "$", null);
                    textField.setCaretPosition(position + macro.length() + 2);
                }
                catch(BadLocationException ex)
                {
                    LOG.error(ex);
                }
                textField.requestFocus();
            }
        }
    });
}
项目:consulo    文件:GuiUtils.java   
private static JPanel constructFieldWithBrowseButton(final JComponent aComponent, final ActionListener aActionListener, int delta) {
  JPanel result = new JPanel(new GridBagLayout());
  result.add(aComponent, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0,0));
  FixedSizeButton browseButton = new FixedSizeButton(aComponent.getPreferredSize().height - delta);//ignore border in case of browse button
  TextFieldWithBrowseButton.MyDoClickAction.addTo(browseButton, aComponent);
  result.add(browseButton, new GridBagConstraints(1, 0, 1, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0,0,0,0), 0,0));
  browseButton.addActionListener(aActionListener);

  return result;
}
项目:consulo    文件:AbstractFieldPanel.java   
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));
  }
}
项目:consulo    文件:ExternalProjectPathField.java   
public MyPathAndProjectButtonPanel(@Nonnull EditorTextField textField,
                                   @Nonnull FixedSizeButton registeredProjectsButton)
{
  super(new GridBagLayout());
  myTextField = textField;
  myRegisteredProjectsButton = registeredProjectsButton;
  add(myTextField, new GridBag().weightx(1).fillCellHorizontally());
  add(myRegisteredProjectsButton, new GridBag().insets(0, 3, 0, 0));
}
项目:consulo    文件:TableCellEditorWithButton.java   
public MyComponent() {
  super(new GridBagLayout());

  myTextField = new JTextField();
  myButton = new FixedSizeButton(myTextField);

  add(myTextField, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  add(myButton, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
项目:consulo    文件:ExportToFileUtil.java   
public ExportDialogBase(Project project, ExporterToTextFile exporter) {
  super(project, true);
  myProject = project;
  myExporter = exporter;

  myTfFile = new JTextField();
  myFileButton = new FixedSizeButton(myTfFile);

  setHorizontalStretch(1.5f);
  setTitle(IdeBundle.message("title.export.preview"));
  setOKButtonText(IdeBundle.message("button.save"));
  setButtonsMargin(null);
  init();
  try {
    myListener = new ChangeListener() {
      @Override
      public void stateChanged(ChangeEvent e) {
        initText();
      }
    };
    myExporter.addSettingsChangedListener(myListener);
  }
  catch (TooManyListenersException e) {
    LOG.error(e);
  }
  initText();
}
项目:consulo    文件:ValueMarkerPresentationDialogBase.java   
private void createUIComponents() {
  myColorSample = new SimpleColoredComponent();
  mySamplePanel = new JPanel(new BorderLayout());
  mySamplePanel.setBorder(BorderFactory.createEtchedBorder());
  mySamplePanel.add(BorderLayout.CENTER, myColorSample);
  myChooseColorButton = new FixedSizeButton(mySamplePanel);
}
项目:consulo    文件:ToolEditorDialog.java   
protected void addCommandBrowseAction(final JPanel pane, FixedSizeButton browseCommandButton, JTextField tfCommand) {
  browseCommandButton.addActionListener(
    new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrExecutableAppDescriptor();
        PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
        chooser.choose(null, new Consumer<List<VirtualFile>>() {
          @Override
          public void consume(List<VirtualFile> files) {
            VirtualFile file = files.size() > 0 ? files.get(0) : null;
            if (file != null) {
              myTfCommand.setText(file.getPresentableUrl());
              String workingDirectory = myTfCommandWorkingDirectory.getText();
              if (workingDirectory == null || workingDirectory.length() == 0) {
                VirtualFile parent = file.getParent();
                if (parent != null && parent.isDirectory()) {
                  myTfCommandWorkingDirectory.setText(parent.getPresentableUrl());
                }
              }
            }
          }
        });
      }
    }
  );
}
项目:consulo-xml    文件:EditLocationDialog.java   
protected void init() {
  setTitle(myTitle);
  myTfUrl = new JTextField();
  myTfPath = new JTextField();
  myBtnBrowseLocalPath = new FixedSizeButton(myTfPath);
  super.init();
}