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

项目:intellij-ce-playground    文件:ApplicationRunParameters.java   
private void createUIComponents() {
  final EditorTextField editorTextField = new LanguageTextField(PlainTextLanguage.INSTANCE, myProject, "") {
    @Override
    protected EditorEx createEditor() {
      final EditorEx editor = super.createEditor();
      final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());

      if (file != null) {
        DaemonCodeAnalyzer.getInstance(myProject).setHighlightingEnabled(file, false);
      }
      editor.putUserData(ACTIVITY_CLASS_TEXT_FIELD_KEY, ApplicationRunParameters.this);
      return editor;
    }
  };
  myActivityField = new ComponentWithBrowseButton<EditorTextField>(editorTextField, null);
}
项目:intellij-ce-playground    文件:MavenEnvironmentForm.java   
private void createUIComponents() {
  mavenHomeField = new TextFieldWithHistory();
  mavenHomeField.setHistorySize(-1);
  final ArrayList<String> foundMavenHomes = new ArrayList<String>();
  foundMavenHomes.add(MavenServerManager.BUNDLED_MAVEN_2);
  foundMavenHomes.add(MavenServerManager.BUNDLED_MAVEN_3);
  final File mavenHomeDirectory = MavenUtil.resolveMavenHomeDirectory(null);
  if (mavenHomeDirectory != null) {
    foundMavenHomes.add(FileUtil.toSystemIndependentName(mavenHomeDirectory.getPath()));
  }
  mavenHomeField.setHistory(foundMavenHomes);
  mavenHomeComponent = LabeledComponent.create(
    new ComponentWithBrowseButton<TextFieldWithHistory>(mavenHomeField, null), "Maven &amp;home directory");

  final JBLabel versionLabel = new JBLabel();
  versionLabel.setOpaque(true);
  versionLabel.setVerticalAlignment(SwingConstants.TOP);
  versionLabel.setVerticalTextPosition(SwingConstants.TOP);
  mavenVersionLabelComponent = LabeledComponent.create(versionLabel, "");
}
项目:intellij-ce-playground    文件:ClassToBindProperty.java   
public MyEditor(final Project project) {
  myProject = project;
  myEditorTextField = new EditorTextField("", project, StdFileTypes.JAVA) {
    protected boolean shouldHaveBorder() {
      return false;
    }
  };
  myActionListener = new MyActionListener();
  myTfWithButton = new ComponentWithBrowseButton<EditorTextField>(myEditorTextField, myActionListener);
  myEditorTextField.setBorder(null);
  new MyCancelEditingAction().registerCustomShortcutSet(CommonShortcuts.ESCAPE, myTfWithButton);
  /*
  myEditorTextField.addActionListener(
    new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        fireValueCommitted();
      }
    }
  );
  */
}
项目:intellij    文件:BlazeAndroidBinaryRunConfigurationStateEditor.java   
private void createUIComponents(Project project) {
  final EditorTextField editorTextField =
      new LanguageTextField(PlainTextLanguage.INSTANCE, project, "") {
        @Override
        protected EditorEx createEditor() {
          final EditorEx editor = super.createEditor();
          final PsiFile file =
              PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());

          if (file != null) {
            DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(file, false);
          }
          editor.putUserData(
              ACTIVITY_CLASS_TEXT_FIELD_KEY, BlazeAndroidBinaryRunConfigurationStateEditor.this);
          return editor;
        }
      };
  activityField = new ComponentWithBrowseButton<EditorTextField>(editorTextField, null);
}
项目: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);
        }

    });
}
项目:TheRPlugin    文件:TheRRunConfigurationForm.java   
private void setupScriptPathField(@NotNull final Project project) {
  final ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
    new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
      "Select Script",
      "",
      myScriptPathField,
      project,
      FileChooserDescriptorFactory.createSingleFileDescriptor(TheRFileType.INSTANCE),
      TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT
    ) {
      @Override
      protected void onFileChosen(@NotNull final VirtualFile chosenFile) {
        super.onFileChosen(chosenFile);

        TheRRunConfigurationUtils.setSuggestedWorkingDirectoryPathIfNotSpecified(TheRRunConfigurationForm.this);
      }
    };

  myScriptPathField.addActionListener(listener);
}
项目:tools-idea    文件:ClassToBindProperty.java   
public MyEditor(final Project project) {
  myProject = project;
  myEditorTextField = new EditorTextField("", project, StdFileTypes.JAVA) {
    protected boolean shouldHaveBorder() {
      return false;
    }
  };
  myActionListener = new MyActionListener();
  myTfWithButton = new ComponentWithBrowseButton<EditorTextField>(myEditorTextField, myActionListener);
  myEditorTextField.setBorder(null);
  new MyCancelEditingAction().registerCustomShortcutSet(CommonShortcuts.ESCAPE, myTfWithButton);
  /*
  myEditorTextField.addActionListener(
    new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        fireValueCommitted();
      }
    }
  );
  */
}
项目:consulo-ui-designer    文件:ClassToBindProperty.java   
public MyEditor(final Project project) {
  myProject = project;
  myEditorTextField = new EditorTextField("", project, JavaFileType.INSTANCE) {
    protected boolean shouldHaveBorder() {
      return false;
    }
  };
  myActionListener = new MyActionListener();
  myTfWithButton = new ComponentWithBrowseButton<EditorTextField>(myEditorTextField, myActionListener);
  myEditorTextField.setBorder(null);
  new MyCancelEditingAction().registerCustomShortcutSet(CommonShortcuts.ESCAPE, myTfWithButton);
  /*
  myEditorTextField.addActionListener(
    new ActionListener() {
      public void actionPerformed(final ActionEvent e) {
        fireValueCommitted();
      }
    }
  );
  */
}
项目:intellij-ce-playground    文件:JavaExtractSuperBaseDialog.java   
protected ComponentWithBrowseButton<EditorComboBox> createPackageNameField() {
  String name = "";
  PsiFile file = mySourceClass.getContainingFile();
  if (file instanceof PsiJavaFile) {
    name = ((PsiJavaFile)file).getPackageName();
  }
  return new PackageNameReferenceEditorCombo(name, myProject, DESTINATION_PACKAGE_RECENT_KEY,
                                                           RefactoringBundle.message("choose.destination.package"));
}
项目:intellij-ce-playground    文件:EditVarConstraintsDialog.java   
private void createUIComponents() {
  regexp = createRegexComponent();
  regexprForExprType = createRegexComponent();
  formalArgType = createRegexComponent();
  customScriptCode = new ComponentWithBrowseButton<EditorTextField>(createScriptComponent(), null);

  myRegExHelpLabel = RegExHelpPopup.createRegExLink(SSRBundle.message("regular.expression.help.label"), regexp, LOG);
  myRegExHelpLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
}
项目:intellij-ce-playground    文件:PythonRunConfigurationForm.java   
public PythonRunConfigurationForm(PythonRunConfiguration configuration) {
  myCommonOptionsForm = PyCommonOptionsFormFactory.getInstance().createForm(configuration.getCommonOptionsFormData());
  myCommonOptionsPlaceholder.add(myCommonOptionsForm.getMainPanel(), BorderLayout.CENTER);

  myProject = configuration.getProject();

  FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
    @Override
    public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
      return file.isDirectory() || file.getExtension() == null || Comparing.equal(file.getExtension(), "py");
    }
  };
  //chooserDescriptor.setRoot(s.getProject().getBaseDir());

  ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
    new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>("Select Script", "", myScriptTextField, myProject,
                                                                         chooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {

      @Override
      protected void onFileChosen(@NotNull VirtualFile chosenFile) {
        super.onFileChosen(chosenFile);
        myCommonOptionsForm.setWorkingDirectory(chosenFile.getParent().getPath());
      }
    };

  myScriptTextField.addActionListener(listener);

  setAnchor(myCommonOptionsForm.getAnchor());
}
项目:intellij-ce-playground    文件:AppEngineSdkEditor.java   
public AppEngineSdkEditor(final @Nullable Project project) {
  myPathEditor = new ComboboxWithBrowseButton(new ComboBox(100));
  myPathEditor.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener<JComboBox>("Google App Engine SDK",
                                   "Specify Google App Engine Java SDK home",
                                   myPathEditor, project,
                                   FileChooserDescriptorFactory.createSingleFolderDescriptor(),
                                   TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT));
  final JComboBox comboBox = myPathEditor.getComboBox();
  comboBox.setEditable(true);
  comboBox.removeAllItems();
  for (AppEngineSdk sdk : AppEngineSdkManager.getInstance().getValidSdks()) {
    comboBox.addItem(FileUtil.toSystemDependentName(sdk.getSdkHomePath()));
  }
}
项目:aem-ide-tooling-4-intellij    文件:AemdcConfigurationDialog.java   
private void propagateToolTip(JComponent source, JComponent ... targets) {
    String toolTip = source.getToolTipText();
    for(JComponent target: targets) {
        if(target instanceof ComponentWithBrowseButton) {
            ((ComponentWithBrowseButton) target).getChildComponent().setToolTipText(toolTip);
        } else {
            target.setToolTipText(toolTip);
        }
    }
}
项目:vso-intellij    文件:LocalAndServerPathsForm.java   
public LocalAndServerPathsForm() {
  Disposer.register(this, myServerPathForm);

  myServerPathForm.addListener(new TfsTreeForm.SelectionListener() {
    @Override
    public void selectionChanged() {
      myEventDispatcher.getMulticaster().stateChanged(new ChangeEvent(this));
    }
  });

  myLocalPathLabel.setLabelFor(myLocalPathField.getChildComponent());
  myLocalPathField.getChildComponent().getDocument().addDocumentListener(new DocumentAdapter() {
    protected void textChanged(final DocumentEvent e) {
      myEventDispatcher.getMulticaster().stateChanged(new ChangeEvent(this));
    }
  });

  FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
    new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(TFSBundle.message("choose.local.path.title"),
                                                                         TFSBundle.message("choose.local.path.description"),
                                                                         myLocalPathField, null, descriptor,
                                                                         TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);

  myServerPathLabel.setLabelFor(myServerPathForm.getPreferredFocusedComponent());
  myLocalPathField.addActionListener(listener);
  myMessageLabel.setIcon(UIUtil.getBalloonWarningIcon());
}
项目:google-cloud-intellij    文件:CloneCloudRepositoryDialog.java   
private void initComponents() {
  FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  fcd.setShowFileSystemRoots(true);
  fcd.setTitle(GctBundle.message("clonefromgcp.destination.directory.title"));
  fcd.setDescription(GctBundle.message("clonefromgcp.destination.directory.description"));
  fcd.setHideIgnored(false);
  parentDirectory.addActionListener(
      new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
          fcd.getTitle(),
          fcd.getDescription(),
          parentDirectory,
          project,
          fcd,
          TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
        @Override
        protected VirtualFile getInitialFile() {
          String text = getComponentText();
          if (text.length() == 0) {
            VirtualFile file = project.getBaseDir();
            if (file != null) {
              return file;
            }
          }
          return super.getInitialFile();
        }
      });

  final DocumentListener updateOkButtonListener =
      new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent event) {
          updateButtons();
        }
      };
  parentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
  parentDirectory.setText(ProjectUtil.getBaseDir());
  directoryName.getDocument().addDocumentListener(updateOkButtonListener);

  setOKActionEnabled(false);
}
项目:plgin    文件:ImageFileBrowserFolderActionListener.java   
public ImageFileBrowserFolderActionListener(String title,
                                            Project project,
                                            ComponentWithBrowseButton<JTextField> componentWithBrowseButton,
                                            FileChooserDescriptor fileChooserDescriptor) {
    super(title, null, componentWithBrowseButton, project, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
    this.title = title;
    this.project = project;
}
项目:idea-jflex    文件:JFlexSettingsForm.java   
private void createUIComponents() {
    enabledCompilationCheckBox = new StateRestoringCheckBox(JFLEX_ENABLED_COMPILATION_KEY, true);
    TextFieldWithStoredHistory jflexHomeHistory = createHistoryTextField(JFLEX_HOME_KEY, JFlexSettings.getDefaultJFlexHome());
    jFlexHomeTextField = new ComponentWithBrowseButton<TextFieldWithStoredHistory>(jflexHomeHistory, null);
    fixButton(jflexHomeHistory, jFlexHomeTextField);
    TextFieldWithStoredHistory skeletonPathHistory = createHistoryTextField(JFLEX_SKELETON_KEY, JFlexSettings.getDefaultSkeletonPath(JFlexSettings.getDefaultJFlexHome()));
    skeletonPathTextField = new ComponentWithBrowseButton<TextFieldWithStoredHistory>(skeletonPathHistory, null);
    fixButton(skeletonPathHistory, skeletonPathTextField);
    commandLineOptionsTextField = createHistoryTextField(JFLEX_OPTIONS_KEY, JFlexSettings.DEFAULT_OPTIONS_CHARAT_NOBAK);
    enabledEmbedJavaCheckBox = new StateRestoringCheckBox(JFLEX_ENABLED_EMBED_JAVA_KEY, true);
}
项目:tools-idea    文件:AlternativeJREPanel.java   
public AlternativeJREPanel() {
  myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox"));

  myFieldWithHistory = new TextFieldWithHistory();
  final ArrayList<String> foundJDKs = new ArrayList<String>();
  for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) {
    String path = provider.getJrePath();
    if (!StringUtil.isEmpty(path)) {
      foundJDKs.add(path);
    }
  }
  final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks();
  for (Sdk jdk : allJDKs) {
    foundJDKs.add(jdk.getHomePath());
  }
  myFieldWithHistory.setHistory(foundJDKs);
  myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null);
  myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"),
                                      ExecutionBundle.message("run.configuration.select.jre.dir.label"),
                                      null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR,
                                      TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);

  setLayout(new MigLayout("ins 0, gap 10, fill, flowx"));
  add(myCbEnabled, "shrinkx");
  add(myPathField, "growx, pushx");

  InsertPathAction.addTo(myFieldWithHistory.getTextEditor());

  myCbEnabled.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      enabledChanged();
    }
  });
  enabledChanged();

  setAnchor(myCbEnabled);

  updateUI();
}
项目:tools-idea    文件:JavaExtractSuperBaseDialog.java   
protected ComponentWithBrowseButton<EditorComboBox> createPackageNameField() {
  String name = "";
  PsiFile file = mySourceClass.getContainingFile();
  if (file instanceof PsiJavaFile) {
    name = ((PsiJavaFile)file).getPackageName();
  }
  return new PackageNameReferenceEditorCombo(name, myProject, DESTINATION_PACKAGE_RECENT_KEY,
                                                           RefactoringBundle.message("choose.destination.package"));
}
项目:tools-idea    文件:JavaSettingsStep.java   
private void addSourcePath(SettingsStep settingsStep) {
  Project project = settingsStep.getContext().getProject();
  ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
    new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
      IdeBundle.message("prompt.select.source.directory"), null, mySourcePath, project, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR,
      TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT)
    {
      @Override
      protected void onFileChoosen(VirtualFile chosenFile) {
        String contentEntryPath = myModuleBuilder.getContentEntryPath();
        String path = chosenFile.getPath();
        if (contentEntryPath != null) {

          int i = StringUtil.commonPrefixLength(contentEntryPath, path);
          mySourcePath.setText(path.substring(i));
        }
        else {
          mySourcePath.setText(path);
        }
      }
    };
  mySourcePath.addBrowseFolderListener(project, listener);
  myCreateSourceRoot.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      mySourcePath.setEnabled(myCreateSourceRoot.isSelected());
    }
  });
  settingsStep.addExpertPanel(myPanel);
}
项目:tools-idea    文件:AppEngineSdkEditor.java   
public AppEngineSdkEditor(final @Nullable Project project) {
  myPathEditor = new ComboboxWithBrowseButton();
  final ComboboxWithBrowseButton pathEditor = myPathEditor;
  myPathEditor.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener<JComboBox>("Google App Engine SDK",
                                   "Specify Google App Engine Java SDK home",
                                   pathEditor, project,
                                   FileChooserDescriptorFactory.createSingleFolderDescriptor(),
                                   TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT));
  final JComboBox comboBox = myPathEditor.getComboBox();
  comboBox.setEditable(true);
  comboBox.removeAllItems();
  for (AppEngineSdk sdk : AppEngineSdkManager.getInstance().getValidSdks()) {
    comboBox.addItem(FileUtil.toSystemDependentName(sdk.getSdkHomePath()));
  }
}
项目:intellij-haxe    文件:JavaExtractSuperBaseDialog.java   
protected ComponentWithBrowseButton<EditorComboBox> createPackageNameField() {
  String name = "";
  PsiFile file = mySourceClass.getContainingFile();
  if (file instanceof PsiJavaFile) {
    name = ((PsiJavaFile)file).getPackageName();
  }
  return new PackageNameReferenceEditorCombo(name, myProject, DESTINATION_PACKAGE_RECENT_KEY,
                                                           RefactoringBundle.message("choose.destination.package"));
}
项目:consulo    文件:XDebuggerEditorBase.java   
protected JPanel addMultilineButton(JComponent component) {
  ComponentWithBrowseButton<JComponent> componentWithButton =
          new ComponentWithBrowseButton<>(component, e -> showCodeFragmentEditor(component, this));
  componentWithButton.setButtonIcon(AllIcons.Actions.ShowViewer);
  componentWithButton.getButton().setDisabledIcon(IconLoader.getDisabledIcon(AllIcons.Actions.ShowViewer));
  return componentWithButton;
}
项目:consulo-java    文件:AlternativeJREPanel.java   
public AlternativeJREPanel() {
  myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox"));

  myFieldWithHistory = new TextFieldWithHistory();
  final ArrayList<String> foundJDKs = new ArrayList<String>();
  final Sdk[] allJDKs = SdkTable.getInstance().getAllSdks();
  for (Sdk jdk : allJDKs) {
    foundJDKs.add(jdk.getHomePath());
  }
  myFieldWithHistory.setHistory(foundJDKs);
  myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null);
  myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"),
                                      ExecutionBundle.message("run.configuration.select.jre.dir.label"),
                                      null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR,
                                      TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);

  setLayout(new MigLayout("ins 0, gap 10, fill, flowx"));
  add(myCbEnabled, "shrinkx");
  add(myPathField, "growx, pushx");

  InsertPathAction.addTo(myFieldWithHistory.getTextEditor());

  myCbEnabled.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      enabledChanged();
    }
  });
  enabledChanged();

  setAnchor(myCbEnabled);

  updateUI();
}
项目:consulo-java    文件:JavaExtractSuperBaseDialog.java   
protected ComponentWithBrowseButton<EditorComboBox> createPackageNameField() {
  String name = "";
  PsiFile file = mySourceClass.getContainingFile();
  if (file instanceof PsiJavaFile) {
    name = ((PsiJavaFile)file).getPackageName();
  }
  return new PackageNameReferenceEditorCombo(name, myProject, DESTINATION_PACKAGE_RECENT_KEY,
                                                           RefactoringBundle.message("choose.destination.package"));
}
项目:intellij-ce-playground    文件:AlternativeJREPanel.java   
public AlternativeJREPanel() {
  myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox"));

  myFieldWithHistory = new TextFieldWithHistory();
  myFieldWithHistory.setHistorySize(-1);
  final ArrayList<String> foundJDKs = new ArrayList<String>();
  final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks();

  for (Sdk sdk : allJDKs) {
    foundJDKs.add(sdk.getName());
  }

  for (JreProvider provider : JreProvider.EP_NAME.getExtensions()) {
    String path = provider.getJrePath();
    if (!StringUtil.isEmpty(path)) {
      foundJDKs.add(path);
    }
  }

  for (Sdk jdk : allJDKs) {
    String homePath = jdk.getHomePath();

    if (!SystemInfo.isMac) {
      final File jre = new File(jdk.getHomePath(), "jre");
      if (jre.isDirectory()) {
        homePath = jre.getPath();
      }
    }

    if (!foundJDKs.contains(homePath)) {
      foundJDKs.add(homePath);
    }
  }
  myFieldWithHistory.setHistory(foundJDKs);
  myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null);
  myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"),
                                      ExecutionBundle.message("run.configuration.select.jre.dir.label"),
                                      null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR,
                                      TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);

  setLayout(new MigLayout("ins 0, gap 10, fill, flowx"));
  add(myCbEnabled, "shrinkx");
  add(myPathField, "growx, pushx");

  InsertPathAction.addTo(myFieldWithHistory.getTextEditor());

  myCbEnabled.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      enabledChanged();
    }
  });
  enabledChanged();

  setAnchor(myCbEnabled);

  updateUI();
}
项目:intellij-ce-playground    文件:GenerateGetterSetterHandlerBase.java   
protected static JComponent getHeaderPanel(final Project project, final TemplatesManager templatesManager, final String templatesTitle) {
  final JPanel panel = new JPanel(new BorderLayout());
  final JLabel templateChooserLabel = new JLabel(templatesTitle);
  panel.add(templateChooserLabel, BorderLayout.WEST);
  final ComboBox comboBox = new ComboBox();
  templateChooserLabel.setLabelFor(comboBox);
  comboBox.setRenderer(new ListCellRendererWrapper<TemplateResource>() {
    @Override
    public void customize(JList list, TemplateResource value, int index, boolean selected, boolean hasFocus) {
      setText(value.getName());
    }
  });
  final ComponentWithBrowseButton<ComboBox> comboBoxWithBrowseButton =
    new ComponentWithBrowseButton<ComboBox>(comboBox, new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
          final TemplatesPanel ui = new TemplatesPanel(project, templatesManager) {
            @Override
            protected boolean onMultipleFields() {
              return false;
            }

            @Nls
            @Override
            public String getDisplayName() {
              return StringUtil.capitalizeWords(UIUtil.removeMnemonic(StringUtil.trimEnd(templatesTitle, ":")), true);
            }
          };
          ui.selectNodeInTree(templatesManager.getDefaultTemplate());
          if (ShowSettingsUtil.getInstance().editConfigurable(panel, ui)) {
            setComboboxModel(templatesManager, comboBox);
          }
    }});

  setComboboxModel(templatesManager, comboBox);
  comboBox.addActionListener(new ActionListener() {
    public void actionPerformed(@NotNull final ActionEvent M) {
      templatesManager.setDefaultTemplate((TemplateResource)comboBox.getSelectedItem());
    }
  });

  panel.add(comboBoxWithBrowseButton, BorderLayout.CENTER);
  return panel;
}
项目:intellij-ce-playground    文件:CellEditorComponentWithBrowseButton.java   
public ComponentWithBrowseButton<Comp> getComponentWithButton() {
  return myComponent;
}
项目:intellij-ce-playground    文件:BrowseModuleValueActionListener.java   
public void setField(final ComponentWithBrowseButton<T> field) {
  myField = field;
  myField.addActionListener(this);
  myField.setButtonEnabled(!myProject.isDefault());
}
项目:intellij-ce-playground    文件:EditLocationDialog.java   
@Override
protected JComponent createCenterPanel() {
  JPanel panel = new JPanel(new GridBagLayout());

  panel.add(
    new JLabel(myName),
    new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 3, 5), 0, 0)
  );
  panel.add(
    myTfUrl,
    new GridBagConstraints(0, 1, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)
  );

  myTfUrl.setPreferredSize(new Dimension(350, myTfUrl.getPreferredSize().height));

  if (myShowPath) {
    panel.add(
      new JLabel(myLocation),
      new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 5, 3, 5), 0, 0)
    );
    panel.add(
      myTfPath,
      new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 10, 0), 0, 0)
    );
    panel.add(
      myBtnBrowseLocalPath,
      new GridBagConstraints(1, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 10, 5), 0, 0)
    );

    ComponentWithBrowseButton.MyDoClickAction.addTo(myBtnBrowseLocalPath, myTfPath);
    myBtnBrowseLocalPath.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent ignored) {
        FileChooserDescriptor descriptor = getChooserDescriptor();
        FileChooser.chooseFile(descriptor, myProject, null, new Consumer<VirtualFile>() {
          @Override
          public void consume(VirtualFile file) {
            myTfPath.setText(file.getPath().replace('/', File.separatorChar));
          }
        });
      }
    });
  }
  return panel;
}
项目:intellij-ce-playground    文件:TestRunParameters.java   
private static void bind(final LabeledComponent<? extends ComponentWithBrowseButton<?>> labeledComponent,
                         BrowseModuleValueActionListener browser) {
  browser.setField(labeledComponent.getComponent());
}
项目:intellij-ce-playground    文件:BuildFilePropertiesPanel.java   
private static void setLabelFor(JLabel label, ComponentWithBrowseButton component) {
  label.setLabelFor(component.getChildComponent());
}
项目:tools-idea    文件:LocationNameFieldsBinding.java   
public LocationNameFieldsBinding(@Nullable Project project, final TextFieldWithBrowseButton locationTextField,
                                 final JTextField nameTextField, String baseDir, final String browseFolderTitle) {

  myBaseDir = baseDir;
  File suggestedProjectDirectory = FileUtil.findSequentNonexistentFile(new File(baseDir), "untitled", "");
  locationTextField.setText(suggestedProjectDirectory.toString());
  nameTextField.setDocument(new NameFieldDocument(nameTextField, locationTextField));
  mySuggestedProjectName = suggestedProjectDirectory.getName();
  nameTextField.setText(mySuggestedProjectName);
  nameTextField.selectAll();

  FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
    new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(browseFolderTitle, "", locationTextField,
                                                                         project,
                                                                         descriptor,
                                                                         TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
      protected void onFileChoosen(VirtualFile chosenFile) {
        myBaseDir = chosenFile.getPath();
        if (isProjectNameChanged(nameTextField.getText()) && !nameTextField.getText().equals(chosenFile.getName())) {
          myExternalModify = true;
          locationTextField.setText(new File(chosenFile.getPath(), nameTextField.getText()).toString());
          myExternalModify = false;
        }
        else {
          myExternalModify = true;
          locationTextField.setText(chosenFile.getPath());
          nameTextField.setText(chosenFile.getName());
          myExternalModify = false;
        }
      }
    };
  locationTextField.addActionListener(listener);
  locationTextField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      if (myExternalModify) {
        return;
      }
      myModifyingLocation = true;
      String path = locationTextField.getText().trim();
      if (path.endsWith(File.separator)) {
        path = path.substring(0, path.length() - File.separator.length());
      }
      int ind = path.lastIndexOf(File.separator);
      if (ind != -1) {
        String projectName = path.substring(ind + 1, path.length());
        if (!nameTextField.getText().trim().isEmpty()) {
          myBaseDir = path.substring(0, ind);
        }
        if (!projectName.equals(nameTextField.getText())) {
          if (!myModifyingProjectName) {
            nameTextField.setText(projectName);
          }
        }
      }
      myModifyingLocation = false;
    }
  });
}
项目:tools-idea    文件:CellEditorComponentWithBrowseButton.java   
public ComponentWithBrowseButton<Comp> getComponentWithButton() {
  return myComponent;
}
项目:tools-idea    文件:BrowseModuleValueActionListener.java   
public void setField(final ComponentWithBrowseButton<T> field) {
  myField = field;
  myField.addActionListener(this);
  myField.setButtonEnabled(!myProject.isDefault());
}
项目:tools-idea    文件:BuildFilePropertiesPanel.java   
private static void setLabelFor(JLabel label, ComponentWithBrowseButton component) {
  label.setLabelFor(component.getChildComponent());
}
项目:intellij-xquery    文件:AlternativeJREPanel.java   
public AlternativeJREPanel() {
    myCbEnabled = new JBCheckBox(ExecutionBundle.message("run.configuration.use.alternate.jre.checkbox"));

    myFieldWithHistory = new TextFieldWithHistory();
    myFieldWithHistory.setHistorySize(-1);
    final List<String> foundJDKs = new ArrayList<>();
    final Sdk[] allJDKs = ProjectJdkTable.getInstance().getAllJdks();

    String javaHomeOfCurrentProcess = System.getProperty("java.home");
    if (javaHomeOfCurrentProcess != null && !javaHomeOfCurrentProcess.isEmpty()) {
        foundJDKs.add(javaHomeOfCurrentProcess);
    }

    for (Sdk sdk : allJDKs) {
        String name = sdk.getName();
        if (!foundJDKs.contains(name)) {
            foundJDKs.add(name);
        }
    }

    for (Sdk jdk : allJDKs) {
        String homePath = jdk.getHomePath();

        if (!SystemInfo.isMac) {
            final File jre = new File(jdk.getHomePath(), "jre");
            if (jre.isDirectory()) {
                homePath = jre.getPath();
            }
        }

        if (!foundJDKs.contains(homePath)) {
            foundJDKs.add(homePath);
        }
    }

    myFieldWithHistory.setHistory(foundJDKs);
    myPathField = new ComponentWithBrowseButton<>(myFieldWithHistory, null);
    myPathField.addBrowseFolderListener(ExecutionBundle.message("run.configuration.select.alternate.jre.label"),
            ExecutionBundle.message("run.configuration.select.jre.dir.label"),
            null, BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR,
            TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT);

    setLayout(new MigLayout("ins 0, gap 10, fill, flowx"));
    add(myCbEnabled, "shrinkx");
    add(myPathField, "growx, pushx");

    InsertPathAction.addTo(myFieldWithHistory.getTextEditor());

    myCbEnabled.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            enabledChanged();
        }
    });
    enabledChanged();

    setAnchor(myCbEnabled);

    updateUI();
}
项目:consulo-apache-ant    文件:BuildFilePropertiesPanel.java   
private static void setLabelFor(JLabel label, ComponentWithBrowseButton component)
{
    label.setLabelFor(component.getChildComponent());
}
项目:consulo    文件:LocationNameFieldsBinding.java   
public LocationNameFieldsBinding(@Nullable Project project, final TextFieldWithBrowseButton locationTextField,
                                 final JTextField nameTextField, String baseDir, final String browseFolderTitle) {

  myBaseDir = baseDir;
  File suggestedProjectDirectory = FileUtil.findSequentNonexistentFile(new File(baseDir), "untitled", "");
  locationTextField.setText(suggestedProjectDirectory.toString());
  nameTextField.setDocument(new NameFieldDocument(nameTextField, locationTextField));
  mySuggestedProjectName = suggestedProjectDirectory.getName();
  nameTextField.setText(mySuggestedProjectName);
  nameTextField.selectAll();

  FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  ComponentWithBrowseButton.BrowseFolderActionListener<JTextField> listener =
    new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(browseFolderTitle, "", locationTextField,
                                                                         project,
                                                                         descriptor,
                                                                         TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
      protected void onFileChoosen(VirtualFile chosenFile) {
        myBaseDir = chosenFile.getPath();
        if (isProjectNameChanged(nameTextField.getText()) && !nameTextField.getText().equals(chosenFile.getName())) {
          myExternalModify = true;
          locationTextField.setText(new File(chosenFile.getPath(), nameTextField.getText()).toString());
          myExternalModify = false;
        }
        else {
          myExternalModify = true;
          locationTextField.setText(chosenFile.getPath());
          nameTextField.setText(chosenFile.getName());
          myExternalModify = false;
        }
      }
    };
  locationTextField.addActionListener(listener);
  locationTextField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      if (myExternalModify) {
        return;
      }
      myModifyingLocation = true;
      String path = locationTextField.getText().trim();
      if (path.endsWith(File.separator)) {
        path = path.substring(0, path.length() - File.separator.length());
      }
      int ind = path.lastIndexOf(File.separator);
      if (ind != -1) {
        String projectName = path.substring(ind + 1, path.length());
        if (!nameTextField.getText().trim().isEmpty()) {
          myBaseDir = path.substring(0, ind);
        }
        if (!projectName.equals(nameTextField.getText())) {
          if (!myModifyingProjectName) {
            nameTextField.setText(projectName);
          }
        }
      }
      myModifyingLocation = false;
    }
  });
}
项目:consulo    文件:CellEditorComponentWithBrowseButton.java   
public ComponentWithBrowseButton<Comp> getComponentWithButton() {
  return myComponent;
}