List of usage examples for com.intellij.openapi.ui TextComponentAccessor TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT
TextComponentAccessor TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT
To view the source code for com.intellij.openapi.ui TextComponentAccessor TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT.
Click Source Link
From source file:com.goide.runconfig.GoRunUtil.java
License:Apache License
public static void installFileChooser(@Nonnull Project project, @Nonnull ComponentWithBrowseButton field, boolean directory, boolean showFileSystemRoots, @Nullable Condition<VirtualFile> fileFilter) { FileChooserDescriptor chooseDirectoryDescriptor = directory ? FileChooserDescriptorFactory.createSingleFolderDescriptor() : FileChooserDescriptorFactory.createSingleLocalFileDescriptor(); chooseDirectoryDescriptor.setRoots(project.getBaseDir()); chooseDirectoryDescriptor.setShowFileSystemRoots(showFileSystemRoots); chooseDirectoryDescriptor.withFileFilter(fileFilter); if (field instanceof TextFieldWithBrowseButton) { ((TextFieldWithBrowseButton) field) .addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project)); } else {//from w w w . j a v a2s. co m //noinspection unchecked field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT)); } }
From source file:com.intellij.execution.ui.AlternativeJREPanel.java
License:Apache License
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);//from w w w . ja va2 s .co m } } 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(); }
From source file:com.intellij.refactoring.copy.CopyFilesOrDirectoriesDialog.java
License:Apache License
@Override protected JComponent createNorthPanel() { myInformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myInformationLabel) .addVerticalGap(UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP); DocumentListener documentListener = new DocumentAdapter() { @Override// www . j av a 2s .c o m public void textChanged(DocumentEvent event) { validateOKButton(); } }; if (myShowNewNameField) { myNewNameField = new JTextField(); myNewNameField.getDocument().addDocumentListener(documentListener); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"), myNewNameField); } if (myShowDirectoryField) { myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton(); myTargetDirectoryField.setTextFieldPreferredWidth(MAX_PATH_LENGTH); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), RefactoringBundle.message("the.file.will.be.copied.to.this.directory"), myProject, descriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); myTargetDirectoryField.getChildComponent().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.to.directory.label"), myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText( ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); formBuilder.addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)); } final JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(myOpenFilesInEditor, BorderLayout.EAST); formBuilder.addComponent(wrapper); return formBuilder.getPanel(); }
From source file:com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesDialog.java
License:Apache License
@Override protected JComponent createNorthPanel() { myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); myTargetDirectoryField = new TextFieldWithHistoryWithBrowseButton(); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); }/*from w ww. j a va 2s. c o m*/ final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addBrowseFolderListener(RefactoringBundle.message("select.target.directory"), RefactoringBundle.message("the.file.will.be.moved.to.this.directory"), myProject, descriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor(); FileChooserFactory.getInstance().installFileCompletion(textField, descriptor, true, getDisposable()); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); myTargetDirectoryField.setTextFieldPreferredWidth(CopyFilesOrDirectoriesDialog.MAX_PATH_LENGTH); Disposer.register(getDisposable(), myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText( ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); return FormBuilder.createFormBuilder().addComponent(myNameLabel) .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"), myTargetDirectoryField, UIUtil.LARGE_VGAP) .addTooltip(RefactoringBundle.message("path.completion.shortcut", shortcutText)) .addComponentToRightColumn(myCbSearchForReferences, UIUtil.LARGE_VGAP).getPanel(); }
From source file:com.perl5.lang.perl.idea.run.PerlAlternativeSdkPanel.java
License:Apache License
public PerlAlternativeSdkPanel() { myCbEnabled = new JBCheckBox("Use alternative Perl"); myFieldWithHistory = new TextFieldWithHistory(); myFieldWithHistory.setHistorySize(-1); final ArrayList<String> foundSdks = new ArrayList<String>(); final List<Sdk> perlSdks = ProjectJdkTable.getInstance().getSdksOfType(PerlSdkType.getInstance()); for (Sdk sdk : perlSdks) { if (sdk.getSdkType() == PerlSdkType.getInstance()) { foundSdks.add(sdk.getName()); }/*from w w w. ja v a2 s .c o m*/ } for (Sdk sdk : perlSdks) { String homePath = sdk.getHomePath(); if (!foundSdks.contains(homePath)) { foundSdks.add(homePath); } } myFieldWithHistory.setHistory(foundSdks); myPathField = new ComponentWithBrowseButton<TextFieldWithHistory>(myFieldWithHistory, null); myPathField.addBrowseFolderListener("Select Perl", "Select Perl SDK", null, new FileChooserDescriptor(false, true, false, false, false, false) { @Override public boolean isFileSelectable(VirtualFile file) { return super.isFileSelectable(file) && PerlSdkType.getInstance().isValidSdkHome(file.getPath()); } }, 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(); }
From source file:io.ballerina.plugins.idea.runconfig.BallerinaRunUtil.java
License:Open Source License
private static void installFileChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field, @Nullable Condition<VirtualFile> fileFilter) { FileChooserDescriptor chooseDirectoryDescriptor = FileChooserDescriptorFactory .createSingleFileDescriptor(BallerinaFileType.INSTANCE); chooseDirectoryDescriptor.setRoots(project.getBaseDir()); chooseDirectoryDescriptor.setShowFileSystemRoots(false); chooseDirectoryDescriptor.withShowHiddenFiles(false); chooseDirectoryDescriptor.withFileFilter(fileFilter); if (field instanceof TextFieldWithBrowseButton) { ((TextFieldWithBrowseButton) field) .addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project)); } else {//from w ww . j a v a2 s. c o m //noinspection unchecked field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT)); } }
From source file:io.ballerina.plugins.idea.runconfig.BallerinaRunUtil.java
License:Open Source License
private static void installWorkingDirectoryChooser(@NotNull Project project, @NotNull ComponentWithBrowseButton field) { FileChooserDescriptor chooseDirectoryDescriptor = FileChooserDescriptorFactory .createSingleFolderDescriptor(); chooseDirectoryDescriptor.setShowFileSystemRoots(true); chooseDirectoryDescriptor.withShowHiddenFiles(false); if (field instanceof TextFieldWithBrowseButton) { ((TextFieldWithBrowseButton) field) .addBrowseFolderListener(new TextBrowseFolderListener(chooseDirectoryDescriptor, project)); } else {//from w w w . j av a2s . c om //noinspection unchecked field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT)); } }
From source file:org.intellij.xquery.runner.ui.run.AlternativeJREPanel.java
License:Apache License
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); }/*from w ww . j av a 2 s .c o m*/ 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(); }