1 package com
.intellij
.openapi
.fileChooser
;
3 import com
.intellij
.openapi
.vfs
.VirtualFile
;
4 import org
.jetbrains
.annotations
.NotNull
;
6 import java
.util
.Arrays
;
10 * Defines save dialog behaviour
12 * @author Konstantin Bulenkov
13 * @see FileSaverDialog
14 * @see FileChooserDescriptor
17 public class FileSaverDescriptor
extends FileChooserDescriptor
implements Cloneable
{
18 private final List
<String
> extentions
;
21 * Constructs save dialog properties
23 * @param title save dialog text title (not window title)
24 * @param description description
25 * @param extentions accepted file extentions: "txt", "jpg", etc. Accept all if empty
27 public FileSaverDescriptor(@NotNull String title
, @NotNull String description
, String
... extentions
) {
28 super(true, true, true, true, false, false);
30 setDescription(description
);
31 this.extentions
= Arrays
.asList(extentions
);
35 public boolean isFileVisible(VirtualFile file
, boolean showHiddenFiles
) {
36 return extentions
.isEmpty() || file
.isDirectory() ?
37 super.isFileVisible(file
, showHiddenFiles
)
39 extentions
.contains(file
.getExtension());
43 * Returns accepted file extentions
45 * @return accepted file extentions
47 public String
[] getFileExtentions() {
48 return extentions
.toArray(new String
[extentions
.size()]);