public final class CustomConfigurator extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CustomConfigurator.PreferencesUtils
Helper class to do specific Prefrences operation - appending, replacing,
deletion by key and by value
Also contains functions that convert preferences object to JavaScript object and back
|
static class |
CustomConfigurator.XMLCommandProcessor |
Modifier and Type | Field and Description |
---|---|
private static boolean |
busy |
private static StringBuilder |
summary |
Modifier | Constructor and Description |
---|---|
private |
CustomConfigurator() |
Modifier and Type | Method and Description |
---|---|
static int |
askForOption(String text,
String opts)
Simple function for choose window, may be used from JS API and from other code
|
static String |
askForText(String text) |
static Preferences |
clonePreferences(Preferences pref) |
static void |
deleteFile(String path,
String base) |
static void |
deleteFileOrDirectory(File f) |
static void |
deleteFileOrDirectory(String path) |
static void |
downloadAndUnpackFile(String address,
String path,
String base)
Downloads file to one of JOSM standard folders nad unpack it as ZIP/JAR file
|
static void |
downloadFile(String address,
String path,
String base)
Downloads file to one of JOSM standard folders
|
static void |
exportPreferencesKeysByPatternToFile(String fileName,
boolean append,
String pattern)
This function exports part of user preferences to specified file.
|
static void |
exportPreferencesKeysToFile(String filename,
boolean append,
Collection<String> keys)
Export specified preferences keys to configuration file
|
static void |
exportPreferencesKeysToFile(String filename,
boolean append,
String... keys)
This function exports part of user preferences to specified file.
|
private static String |
getDirectoryByAbbr(String base) |
static String |
getLog() |
static void |
log(String s) |
static void |
log(String fmt,
Object... vars) |
static void |
messageBox(String type,
String text)
Simple function to show messageBox, may be used from JS API and from other code
|
static void |
pluginOperation(String install,
String uninstall,
String delete) |
static void |
processDownloadOperation(String address,
String path,
String parentDir,
boolean mkdir,
boolean unzip)
Downloads file to arbitrary folder
|
static void |
readXML(File file)
Read configuration script from XML file, modifying main preferences
|
static void |
readXML(File file,
Preferences prefs)
Read configuration script from XML file, modifying given preferences object
|
static void |
readXML(String dir,
String fileName) |
private static StringBuilder summary
private static boolean busy
private CustomConfigurator()
public static void readXML(File file, Preferences prefs)
file
- - file to open for reading XMLprefs
- - arbitrary Preferences object to modify by scriptpublic static void readXML(File file)
file
- - file to open for reading XMLpublic static void downloadFile(String address, String path, String base)
address
- - URL to downloadpath
- - file path relative to base where to put downloaded filebase
- - only "prefs", "cache" and "plugins" allowed for standard folderspublic static void downloadAndUnpackFile(String address, String path, String base)
address
- - URL to downloadpath
- - file path relative to base where to put downloaded filebase
- - only "prefs", "cache" and "plugins" allowed for standard folderspublic static void processDownloadOperation(String address, String path, String parentDir, boolean mkdir, boolean unzip)
address
- - URL to downloadpath
- - file path relative to parentDir where to put downloaded fileparentDir
- - folder where to put filemkdir
- - if true, non-existing directories will be createdunzip
- - if true file wil be unzipped and deleted after downloadpublic static void messageBox(String type, String text)
type
- - 'i','w','e','q','p' for Information, Warning, Error, Question, Messagetext
- - message to display, HTML allowedpublic static int askForOption(String text, String opts)
text
- - message to show, HTML allowedopts
- -public static String askForText(String text)
public static void exportPreferencesKeysToFile(String filename, boolean append, String... keys)
filename
- - where to exportappend
- - if true, resulting file cause appending to exuisting preferenceskeys
- - which preferences keys you need to export ("imagery.entries", for example)public static void exportPreferencesKeysByPatternToFile(String fileName, boolean append, String pattern)
fileName
- - where to exportappend
- - if true, resulting file cause appending to exuisting preferencespattern
- - Regexp pattern forh preferences keys you need to export (".*imagery.*", for example)public static void exportPreferencesKeysToFile(String filename, boolean append, Collection<String> keys)
filename
- - name of fileappend
- - will the preferences be appended to existing ones when file is imported later. Elsewhere preferences from file will replace existing keys.keys
- - collection of preferences key names to savepublic static void deleteFile(String path, String base)
public static void deleteFileOrDirectory(String path)
public static void deleteFileOrDirectory(File f)
public static void pluginOperation(String install, String uninstall, String delete)
private static String getDirectoryByAbbr(String base)
public static Preferences clonePreferences(Preferences pref)