use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class GroovyCompilerConfigurable method createExcludedConfigurable.
private ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
final ExcludesConfiguration configuration = myConfig.getExcludeFromStubGeneration();
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return super.isFileVisible(file, showHiddenFiles) && !index.isExcluded(file);
}
};
descriptor.setRoots(ContainerUtil.concat(ContainerUtil.map(ModuleManager.getInstance(project).getModules(), new Function<Module, List<VirtualFile>>() {
@Override
public List<VirtualFile> fun(final Module module) {
return ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
}
})));
return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class SdkHomeConfigurable method createComponent.
@Override
public JComponent createComponent() {
myPanel = new JPanel(new BorderLayout(10, 5));
final JPanel contentPanel = new JPanel(new BorderLayout(4, 0));
myPanel.add(contentPanel, BorderLayout.NORTH);
contentPanel.add(new JLabel(myFrameworkName + " home:"), BorderLayout.WEST);
myPathField = new TextFieldWithBrowseButton();
contentPanel.add(myPathField);
myPathField.addBrowseFolderListener("Select " + myFrameworkName + " home", "", myProject, new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
return isSdkHome(file);
}
});
return myPanel;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class SvnConfigurable method selectConfigurationDirectory.
public static void selectConfigurationDirectory(@NotNull String path, @NotNull final Consumer<String> dirConsumer, final Project project, @Nullable final Component component) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(SvnBundle.message("dialog.title.select.configuration.directory")).withDescription(SvnBundle.message("dialog.description.select.configuration.directory")).withShowFileSystemRoots(true).withHideIgnored(false).withShowHiddenFiles(true);
path = "file://" + path.replace(File.separatorChar, '/');
VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(path);
VirtualFile file = FileChooser.chooseFile(descriptor, component, project, root);
if (file == null) {
return;
}
final String resultPath = file.getPath().replace('/', File.separatorChar);
dirConsumer.consume(resultPath);
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class TestNGConfigurationEditor method createView.
private void createView() {
commonParametersPanel.add(commonJavaParameters, BorderLayout.CENTER);
classField.setComponent(new EditorTextFieldWithBrowseButton(project, true, new JavaCodeFragment.VisibilityChecker() {
@Override
public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) {
if (declaration instanceof PsiClass && place.getParent() instanceof PsiJavaCodeReferenceElement) {
return Visibility.VISIBLE;
}
try {
if (declaration instanceof PsiClass && new TestClassBrowser(project, TestNGConfigurationEditor.this).getFilter().isAccepted((PsiClass) declaration)) {
return Visibility.VISIBLE;
}
} catch (MessageInfoException e) {
return Visibility.NOT_VISIBLE;
}
return Visibility.NOT_VISIBLE;
}
}));
final EditorTextFieldWithBrowseButton methodEditorTextField = new EditorTextFieldWithBrowseButton(project, true, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, PlainTextLanguage.INSTANCE.getAssociatedFileType());
methodField.setComponent(methodEditorTextField);
groupField.setComponent(new TextFieldWithBrowseButton.NoPathCompletion());
suiteField.setComponent(new TextFieldWithBrowseButton());
packageField.setVisible(true);
packageField.setEnabled(true);
packageField.setComponent(new EditorTextFieldWithBrowseButton(project, false));
TextFieldWithBrowseButton outputDirectoryButton = new TextFieldWithBrowseButton();
outputDirectory.setComponent(outputDirectoryButton);
outputDirectoryButton.addBrowseFolderListener("TestNG", "Select test output directory", project, FileChooserDescriptorFactory.createSingleFolderDescriptor());
moduleClasspath.setEnabled(true);
moduleClasspath.setComponent(new ModulesComboBox());
propertiesTableModel = new TestNGParametersTableModel();
listenerModel = new TestNGListenersTableModel();
TextFieldWithBrowseButton textFieldWithBrowseButton = new TextFieldWithBrowseButton();
propertiesFile.setComponent(textFieldWithBrowseButton);
FileChooserDescriptor propertiesFileDescriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileVisible(VirtualFile virtualFile, boolean showHidden) {
if (!showHidden && virtualFile.getName().charAt(0) == '.')
return false;
return virtualFile.isDirectory() || "properties".equals(virtualFile.getExtension());
}
};
textFieldWithBrowseButton.addBrowseFolderListener("TestNG", "Select .properties file for test properties", project, propertiesFileDescriptor);
propertiesTableView = new TableView(propertiesTableModel);
myPropertiesPanel.add(ToolbarDecorator.createDecorator(propertiesTableView).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
propertiesTableModel.addParameter();
int index = propertiesTableModel.getRowCount() - 1;
propertiesTableView.setRowSelectionInterval(index, index);
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int idx = propertiesTableView.getSelectedRow() - 1;
for (int row : propertiesTableView.getSelectedRows()) {
propertiesTableModel.removeProperty(row);
}
if (idx > -1)
propertiesTableView.setRowSelectionInterval(idx, idx);
}
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
myListenersList = new JBList(listenerModel);
myListenersPanel.add(ToolbarDecorator.createDecorator(myListenersList).setAddAction(new AddActionButtonRunnable()).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int idx = myListenersList.getSelectedIndex() - 1;
for (int row : myListenersList.getSelectedIndices()) {
listenerModel.removeListener(row);
}
if (idx > -1)
myListenersList.setSelectedIndex(idx);
}
}).setAddActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return !project.isDefault();
}
}).disableUpDownActions().createPanel(), BorderLayout.CENTER);
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class TerminalSettingsPanel method createPanel.
public JComponent createPanel(@NotNull TerminalOptionsProvider provider, @NotNull TerminalProjectOptionsProvider projectOptionsProvider) {
myOptionsProvider = provider;
myProjectOptionsProvider = projectOptionsProvider;
myProjectSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Project settings"));
myGlobalSettingsPanel.setBorder(IdeBorderFactory.createTitledBorder("Application settings"));
FileChooserDescriptor fileChooserDescriptor = new FileChooserDescriptor(true, false, false, false, false, false);
myShellPathField.addBrowseFolderListener("", "Shell executable path", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
fileChooserDescriptor = new FileChooserDescriptor(false, true, false, false, false, false);
myStartDirectoryField.addBrowseFolderListener("", "Starting directory", null, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
myShellPathField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
myShellPathField.getTextField().setForeground(StringUtil.equals(myShellPathField.getText(), myProjectOptionsProvider.getDefaultShellPath()) ? getDefaultValueColor() : getChangedValueColor());
}
});
myStartDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
myStartDirectoryField.getTextField().setForeground(StringUtil.equals(myStartDirectoryField.getText(), myProjectOptionsProvider.getDefaultStartingDirectory()) ? getDefaultValueColor() : getChangedValueColor());
}
});
for (LocalTerminalCustomizer c : LocalTerminalCustomizer.EP_NAME.getExtensions()) {
UnnamedConfigurable configurable = c.getConfigurable(projectOptionsProvider.getProject());
if (configurable != null) {
myConfigurables.add(configurable);
JComponent component = configurable.createComponent();
if (component != null) {
myConfigurablesPanel.add(component, BorderLayout.CENTER);
}
}
}
return myWholePanel;
}
Aggregations