use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class PerFileConfigurableBase method doAddAction.
private void doAddAction(@NotNull AnActionButton button) {
TableCellEditor editor = myTable.getCellEditor();
if (editor != null)
editor.cancelCellEditing();
int row = myTable.getSelectedRow();
Object selectedTarget = row >= 0 ? myModel.data.get(myTable.convertRowIndexToModel(row)).first : null;
VirtualFile toSelect = myFileToSelect != null ? myFileToSelect : ObjectUtils.tryCast(selectedTarget, VirtualFile.class);
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, true, true, true);
FileChooser.chooseFiles(descriptor, myProject, myTable, toSelect, this::doAddFiles);
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class FileDownloaderImpl method chooseDirectoryForFiles.
@Nullable
private static VirtualFile chooseDirectoryForFiles(Project project, JComponent parentComponent) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor().withTitle(IdeBundle.message("dialog.directory.for.downloaded.files.title")).withDescription(IdeBundle.message("dialog.directory.for.downloaded.files.description"));
VirtualFile baseDir = project != null ? project.getBaseDir() : null;
return FileChooser.chooseFile(descriptor, parentComponent, project, baseDir);
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class CustomLibraryDescriptionBase method createNewLibrary.
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
descriptor.setTitle(IdeBundle.message("new.library.file.chooser.title"));
descriptor.setDescription(IdeBundle.message("new.library.file.chooser.description"));
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, parentComponent, null, contextDirectory);
if (files.length == 0) {
return null;
}
return new NewLibraryConfiguration(myDefaultLibraryName, getDownloadableLibraryType(), new LibraryVersionProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor editor) {
for (VirtualFile file : files) {
editor.addRoot(file, OrderRootType.CLASSES);
}
}
};
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class UnscrambleDialog method createLogFileChooser.
private void createLogFileChooser() {
myLogFile = new TextFieldWithHistory();
JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
FileChooser.chooseFiles(descriptor, myProject, null, files -> myLogFile.setText(FileUtil.toSystemDependentName(files.get(files.size() - 1).getPath())));
}
});
myLogFileChooserPanel.setLayout(new BorderLayout());
myLogFileChooserPanel.add(panel, BorderLayout.CENTER);
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class CloneDvcsDialog method initListeners.
/**
* Init components
*/
private void initListeners() {
FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
fcd.setShowFileSystemRoots(true);
fcd.setTitle(DvcsBundle.getString("clone.destination.directory.title"));
fcd.setDescription(DvcsBundle.getString("clone.destination.directory.description"));
fcd.setHideIgnored(false);
myParentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(fcd.getTitle(), fcd.getDescription(), myParentDirectory, myProject, fcd, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
@Override
protected VirtualFile getInitialFile() {
// suggest project base directory only if nothing is typed in the component.
String text = getComponentText();
if (text.length() == 0) {
VirtualFile file = myProject.getBaseDir();
if (file != null) {
return file;
}
}
return super.getInitialFile();
}
});
final DocumentListener updateOkButtonListener = new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
updateButtons();
}
};
myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
String parentDir = getRememberedInputs().getCloneParentDir();
if (StringUtil.isEmptyOrSpaces(parentDir)) {
parentDir = ProjectUtil.getBaseDir();
}
myParentDirectory.setText(parentDir);
myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);
myTestButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
test();
}
});
setOKActionEnabled(false);
myTestButton.setEnabled(false);
}
Aggregations