use of com.intellij.openapi.ui.TextBrowseFolderListener in project ballerina by ballerina-lang.
the class BallerinaRunUtil method installFileChooser.
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 {
// noinspection unchecked
field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT));
}
}
use of com.intellij.openapi.ui.TextBrowseFolderListener in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRunUtil method installFileChooser.
public static void installFileChooser(@NotNull Project project, @NotNull 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 {
// noinspection unchecked
field.addBrowseFolderListener(project, new ComponentWithBrowseButton.BrowseFolderActionListener(null, null, field, project, chooseDirectoryDescriptor, TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT));
}
}
use of com.intellij.openapi.ui.TextBrowseFolderListener in project android by JetBrains.
the class KeyValuePane method init.
public void init(GradleBuildFile gradleBuildFile, Collection<BuildFileKey> properties) {
GridLayoutManager layout = new GridLayoutManager(properties.size() + 1, 2);
setLayout(layout);
GridConstraints constraints = new GridConstraints();
constraints.setAnchor(GridConstraints.ANCHOR_WEST);
constraints.setVSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
for (BuildFileKey property : properties) {
constraints.setColumn(0);
constraints.setFill(GridConstraints.FILL_NONE);
constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
JBLabel label = new JBLabel(property.getDisplayName());
add(label, constraints);
constraints.setColumn(1);
constraints.setFill(GridConstraints.FILL_HORIZONTAL);
constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_WANT_GROW);
JComponent component;
switch(property.getType()) {
case BOOLEAN:
{
constraints.setFill(GridConstraints.FILL_NONE);
ComboBox comboBox = createComboBox(false);
comboBox.addItem("");
comboBox.addItem("true");
comboBox.addItem("false");
comboBox.setPrototypeDisplayValue("(false) ");
component = comboBox;
break;
}
case FILE:
case FILE_AS_STRING:
{
JBTextField textField = new JBTextField();
TextFieldWithBrowseButton fileField = new TextFieldWithBrowseButton(textField);
FileChooserDescriptor d = new FileChooserDescriptor(true, false, false, true, false, false);
d.setShowFileSystemRoots(true);
fileField.addBrowseFolderListener(new TextBrowseFolderListener(d));
fileField.getTextField().getDocument().addDocumentListener(this);
component = fileField;
break;
}
case REFERENCE:
{
constraints.setFill(GridConstraints.FILL_NONE);
ComboBox comboBox = createComboBox(true);
if (hasKnownValues(property)) {
for (String s : myKeysWithKnownValues.get(property).values()) {
comboBox.addItem(s);
}
}
// If there are no hardcoded values, the combo box's values will get populated later when the panel for the container reference
// type wakes up and notifies us of its current values.
component = comboBox;
break;
}
case CLOSURE:
case STRING:
case INTEGER:
default:
{
if (hasKnownValues(property)) {
constraints.setFill(GridConstraints.FILL_NONE);
ComboBox comboBox = createComboBox(true);
for (String s : myKeysWithKnownValues.get(property).values()) {
comboBox.addItem(s);
}
component = comboBox;
} else {
JBTextField textField = new JBTextField();
textField.getDocument().addDocumentListener(this);
component = textField;
}
break;
}
}
add(component, constraints);
label.setLabelFor(component);
myProperties.put(property, component);
constraints.setRow(constraints.getRow() + 1);
}
constraints.setColumn(0);
constraints.setVSizePolicy(GridConstraints.FILL_VERTICAL);
constraints.setHSizePolicy(GridConstraints.SIZEPOLICY_FIXED);
add(new JBLabel(""), constraints);
updateUiFromCurrentObject();
}
use of com.intellij.openapi.ui.TextBrowseFolderListener in project android by JetBrains.
the class ImportSourceLocationStep method setupSourceLocationControls.
private void setupSourceLocationControls() {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
descriptor.setTitle("Select Source Location");
descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject");
mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor));
mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
invalidate();
}
});
applyBackgroundOperationResult(checkPath(mySourceLocation.getText()));
myErrorWarning.setIcon(null);
myErrorWarning.setText(null);
}
use of com.intellij.openapi.ui.TextBrowseFolderListener in project intellij-community by JetBrains.
the class JavaSettingsStep method addSourcePath.
private void addSourcePath(SettingsStep settingsStep) {
Project project = settingsStep.getContext().getProject();
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle(IdeBundle.message("prompt.select.source.directory"));
mySourcePath.addBrowseFolderListener(new TextBrowseFolderListener(descriptor, project) {
@NotNull
@Override
protected String chosenFileToResultingText(@NotNull VirtualFile chosenFile) {
String contentEntryPath = myModuleBuilder.getContentEntryPath();
String path = chosenFile.getPath();
return contentEntryPath == null ? path : path.substring(StringUtil.commonPrefixLength(contentEntryPath, path));
}
});
myCreateSourceRoot.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mySourcePath.setEnabled(myCreateSourceRoot.isSelected());
}
});
settingsStep.addExpertPanel(myPanel);
}
Aggregations