mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FileChooserDialog now supports several files
This commit is contained in:
@@ -23,7 +23,22 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface FileChooserDialog {
|
||||
DataKey<Boolean> PREFER_LAST_OVER_TO_SELECT = PathChooserDialog.PREFER_LAST_OVER_EXPLICIT;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link #choose(com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile...)} because
|
||||
* it supports several selections
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
VirtualFile[] choose(@Nullable VirtualFile toSelect, @Nullable Project project);
|
||||
|
||||
/**
|
||||
* Choose one or more files
|
||||
*
|
||||
* @param project use this project (you may pass null if you already set project in ctor)
|
||||
* @param toSelect files to be selected automatically.
|
||||
* @return files chosen by user
|
||||
*/
|
||||
@NotNull
|
||||
VirtualFile[] choose(@Nullable Project project, @NotNull VirtualFile... toSelect);
|
||||
}
|
||||
+16
-4
@@ -114,16 +114,29 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public VirtualFile[] choose(@Nullable VirtualFile toSelect, Project project) {
|
||||
public VirtualFile[] choose(@Nullable final Project project, @NotNull final VirtualFile... toSelect) {
|
||||
init();
|
||||
if (myProject == null && project != null) {
|
||||
if ((myProject == null) && (project != null)) {
|
||||
myProject = project;
|
||||
}
|
||||
restoreSelection(toSelect);
|
||||
if (toSelect.length == 1) {
|
||||
restoreSelection(toSelect[0]);
|
||||
}
|
||||
else {
|
||||
selectInTree(toSelect, true);
|
||||
}
|
||||
|
||||
show();
|
||||
return myChosenFiles;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public VirtualFile[] choose(@Nullable final VirtualFile toSelect, @Nullable final Project project) {
|
||||
return choose(project, toSelect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void choose(@Nullable VirtualFile toSelect, @NotNull Consumer<List<VirtualFile>> callback) {
|
||||
init();
|
||||
@@ -163,7 +176,6 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
|
||||
if (file != null && file.getFileSystem() instanceof LocalFileSystem) {
|
||||
saveRecent(file.getPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void saveRecent(String path) {
|
||||
|
||||
Reference in New Issue
Block a user