mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
jscs: first sketch on code style settings importing. allow several file extensions for config file
This commit is contained in:
+4
-3
@@ -53,7 +53,7 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -184,15 +184,16 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper {
|
||||
private String importExternalCodeStyle(String importerName) throws SchemeImportException {
|
||||
final SchemeImporter<CodeStyleScheme> importer = SchemeImporterEP.getImporter(importerName, CodeStyleScheme.class);
|
||||
if (importer != null) {
|
||||
final Set<String> extensions = new HashSet<String>(Arrays.asList(importer.getSourceExtensions()));
|
||||
FileChooserDialog fileChooser = FileChooserFactory.getInstance()
|
||||
.createFileChooser(new FileChooserDescriptor(true, false, false, false, false, false) {
|
||||
@Override
|
||||
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
|
||||
return file.isDirectory() || importer.getSourceExtension().equals(file.getExtension());
|
||||
return file.isDirectory() || extensions.contains(file.getExtension());
|
||||
}
|
||||
@Override
|
||||
public boolean isFileSelectable(VirtualFile file) {
|
||||
return !file.isDirectory() && importer.getSourceExtension().equals(file.getExtension());
|
||||
return !file.isDirectory() && extensions.contains(file.getExtension());
|
||||
}
|
||||
}, null, myContentPane);
|
||||
VirtualFile[] selection = fileChooser.choose(null, CodeStyleSchemesUIConfiguration.Util.getRecentImportFile());
|
||||
|
||||
@@ -15,7 +15,8 @@ public interface SchemeImporter <T extends Scheme> {
|
||||
/**
|
||||
* @return An extension of a source file which can be imported, for example, "xml".
|
||||
*/
|
||||
String getSourceExtension();
|
||||
@NotNull
|
||||
String[] getSourceExtensions();
|
||||
|
||||
/**
|
||||
* Attempts to read scheme names from the given stream. The stream may contain several schemes in which case all the available
|
||||
|
||||
+3
-2
@@ -48,9 +48,10 @@ public class EclipseCodeStyleSchemeImporter implements SchemeImporter<CodeStyleS
|
||||
myImportMap.load();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getSourceExtension() {
|
||||
return "xml";
|
||||
public String[] getSourceExtensions() {
|
||||
return new String[]{"xml"};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user