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);
}
\ No newline at end of file
@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();
if (file != null && file.getFileSystem() instanceof LocalFileSystem) {
saveRecent(file.getPath());
}
-
}
protected void saveRecent(String path) {