Java 类com.intellij.ui.InsertPathAction 实例源码

项目:intellij-ce-playground    文件:ProjectConfigurable.java   
private void createUIComponents() {
  myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {
    @Override
    protected LanguageLevel getDefaultLevel() {
      Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
      if (sdk == null) return null;
      JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
      return version == null ? null : version.getMaxLanguageLevel();
    }
  };
  final JTextField textField = new JTextField();
  final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
  outputPathsChooserDescriptor.setHideIgnored(false);
  BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
  myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
  FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
项目:intellij-ce-playground    文件:CustomizableActionsPanel.java   
private static TextFieldWithBrowseButton createBrowseField(){
  TextFieldWithBrowseButton textField = new TextFieldWithBrowseButton();
  textField.setPreferredSize(new Dimension(200, textField.getPreferredSize().height));
  textField.setMinimumSize(new Dimension(200, textField.getPreferredSize().height));
  final FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
    @Override
    public boolean isFileSelectable(VirtualFile file) {
      //noinspection HardCodedStringLiteral
      return file.getName().endsWith(".png");
    }
  };
  textField.addBrowseFolderListener(IdeBundle.message("title.browse.icon"), IdeBundle.message("prompt.browse.icon.for.selected.action"), null,
                                    fileChooserDescriptor);
  InsertPathAction.addTo(textField.getTextField(), fileChooserDescriptor);
  return textField;
}
项目:consulo    文件:BuildElementsEditor.java   
private CommitableFieldPanel createOutputPathPanel(final String title, final CommitPathRunnable commitPathRunnable) {
  final JTextField textField = new JTextField();
  final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  outputPathsChooserDescriptor.setHideIgnored(false);
  InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
  FileChooserFactory.getInstance().installFileCompletion(textField, outputPathsChooserDescriptor, true, null);

  CommitableFieldPanel commitableFieldPanel =
          new CommitableFieldPanel(textField, null, null, new BrowseFilesListener(textField, title, "", outputPathsChooserDescriptor), null);
  commitableFieldPanel.myCommitRunnable = new Runnable() {
    @Override
    public void run() {
      if (!getModel().isWritable()) {
        return;
      }
      String url = commitableFieldPanel.getUrl();
      commitPathRunnable.saveUrl(url);
    }
  };
  return commitableFieldPanel;
}
项目:intellij-ce-playground    文件:Messages.java   
/**
 * Shows dialog with text area to edit long strings that don't fit in text field.
 */
public static void showTextAreaDialog(final JTextField textField,
                                      final @Nls(capitalization = Nls.Capitalization.Title) String title,
                                      @NonNls final String dimensionServiceKey,
                                      final Function<String, List<String>> parser,
                                      final Function<List<String>, String> lineJoiner) {
  if (isApplicationInUnitTestOrHeadless()) {
    ourTestImplementation.show(title);
  }
  else {
    final JTextArea textArea = new JTextArea(10, 50);
    UIUtil.addUndoRedoActions(textArea);
    textArea.setWrapStyleWord(true);
    textArea.setLineWrap(true);
    List<String> lines = parser.fun(textField.getText());
    textArea.setText(StringUtil.join(lines, "\n"));
    InsertPathAction.copyFromTo(textField, textArea);
    final DialogBuilder builder = new DialogBuilder(textField);
    builder.setDimensionServiceKey(dimensionServiceKey);
    builder.setCenterPanel(ScrollPaneFactory.createScrollPane(textArea));
    builder.setPreferredFocusComponent(textArea);
    String rawText = title;
    if (StringUtil.endsWithChar(rawText, ':')) {
      rawText = rawText.substring(0, rawText.length() - 1);
    }
    builder.setTitle(rawText);
    builder.addOkAction();
    builder.addCancelAction();
    builder.setOkOperation(new Runnable() {
      @Override
      public void run() {
        textField.setText(lineJoiner.fun(Arrays.asList(StringUtil.splitByLines(textArea.getText()))));
        builder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
      }
    });
    builder.show();
  }
}
项目: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    文件:ProjectConfigurable.java   
private void createUIComponents() {
  myLanguageLevelCombo = new LanguageLevelCombo();
  final JTextField textField = new JTextField();
  final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
  outputPathsChooserDescriptor.setHideIgnored(false);
  BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
  myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
  FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
项目:tools-idea    文件:CustomizableActionsPanel.java   
private static TextFieldWithBrowseButton createBrowseField(){
  TextFieldWithBrowseButton textField = new TextFieldWithBrowseButton();
  textField.setPreferredSize(new Dimension(200, textField.getPreferredSize().height));
  textField.setMinimumSize(new Dimension(200, textField.getPreferredSize().height));
  final FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
    public boolean isFileSelectable(VirtualFile file) {
      //noinspection HardCodedStringLiteral
      return file.getName().endsWith(".png");
    }
  };
  textField.addBrowseFolderListener(IdeBundle.message("title.browse.icon"), IdeBundle.message("prompt.browse.icon.for.selected.action"), null,
                                    fileChooserDescriptor);
  InsertPathAction.addTo(textField.getTextField(), fileChooserDescriptor);
  return textField;
}
项目:consulo    文件:CustomizableActionsPanel.java   
private static TextFieldWithBrowseButton createBrowseField(){
  TextFieldWithBrowseButton textField = new TextFieldWithBrowseButton();
  textField.setPreferredSize(new Dimension(200, textField.getPreferredSize().height));
  textField.setMinimumSize(new Dimension(200, textField.getPreferredSize().height));
  final FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
    public boolean isFileSelectable(VirtualFile file) {
      //noinspection HardCodedStringLiteral
      return file.getName().endsWith(".png");
    }
  };
  textField.addBrowseFolderListener(IdeBundle.message("title.browse.icon"), IdeBundle.message("prompt.browse.icon.for.selected.action"), null,
                                    fileChooserDescriptor);
  InsertPathAction.addTo(textField.getTextField(), fileChooserDescriptor);
  return textField;
}
项目: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();
}
项目: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    文件:ConfigureProxiesOptionsPanel.java   
private void initBrowseActions() {
  InsertPathAction.addTo(myPathToCertificatesField, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
  myClientCertificatePathField.addBrowseFolderListener(
      SvnBundle.message("dialog.edit.http.proxies.settings.dialog.select.ssl.client.certificate.path.title"),
      null, null, new FileChooserDescriptor(true, false, false, false, false, false));
}
项目:tools-idea    文件:ConfigureProxiesOptionsPanel.java   
private void initBrowseActions() {
  InsertPathAction.addTo(myPathToCertificatesField, FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor());
  myClientCertificatePathField.addBrowseFolderListener(
      SvnBundle.message("dialog.edit.http.proxies.settings.dialog.select.ssl.client.certificate.path.title"),
      null, null, new FileChooserDescriptor(true, false, false, false, false, false));
}
项目: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    文件:ProjectConfigurable.java   
private void init() {
  myPanel = new JPanel(new VerticalFlowLayout(true, false));

  final JPanel namePanel = new JPanel(new BorderLayout());
  final JLabel label = new JLabel("<html><body><b>Project name:</b></body></html>", SwingConstants.LEFT);
  namePanel.add(label, BorderLayout.NORTH);

  myProjectName = new JTextField();
  myProjectName.setColumns(40);

  final JPanel nameFieldPanel = new JPanel();
  nameFieldPanel.setLayout(new BoxLayout(nameFieldPanel, BoxLayout.X_AXIS));
  nameFieldPanel.add(Box.createHorizontalStrut(4));
  nameFieldPanel.add(myProjectName);

  namePanel.add(nameFieldPanel, BorderLayout.CENTER);
  final JPanel wrapper = new JPanel(new FlowLayout(FlowLayout.LEFT));
  wrapper.add(namePanel);
  wrapper.setAlignmentX(0);
  myPanel.add(wrapper);

  myPanel.add(new JLabel(ProjectBundle.message("project.compiler.output")));

  final JTextField textField = new JTextField();
  final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
  outputPathsChooserDescriptor.setHideIgnored(false);
  BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
  myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
  FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);

  myProjectCompilerOutput.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
    @Override
    protected void textChanged(DocumentEvent e) {
      if (myFreeze) return;
      myModulesConfigurator.processModuleCompilerOutputChanged(getCompilerOutputUrl());
    }
  });

  myPanel.add(myProjectCompilerOutput);
  myPanel.add(ScrollPaneFactory.createScrollPane(myErrorsComponent, true));
}