use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.
the class PreferencesAssistant method restoreSettings.
public static void restoreSettings(SettingsNode settingsNode, JFileChooser fileChooser, String id, Class fileChooserClass) {
SettingsNode childNode = settingsNode.getChildNode(getPrefix(fileChooserClass, id));
if (childNode == null) {
return;
}
String lastDirectory = childNode.getValueOfChild(DIRECTORY_NAME, null);
if (lastDirectory != null) {
fileChooser.setCurrentDirectory(new File(lastDirectory));
}
}
use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.
the class PreferencesAssistant method saveSettings.
public static void saveSettings(SettingsNode settingsNode, JSplitPane splitter, String id, Class splitterClass) {
SettingsNode childNode = settingsNode.addChildIfNotPresent(getPrefix(splitterClass, id));
childNode.setValueOfChildAsInt(DIVIDER_LOCATION, splitter.getDividerLocation());
}
use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.
the class PreferencesAssistant method saveSettings.
/**
* Saves the settings of the file chooser; and by settings I mean the 'last visited directory'.
*
* @param saveCurrentDirectoryVsSelectedFilesParent this should be true if you're selecting only directories, false if you're selecting only files. I don't know what if you allow both.
*/
public static void saveSettings(SettingsNode settingsNode, JFileChooser fileChooser, String id, Class fileChooserClass, boolean saveCurrentDirectoryVsSelectedFilesParent) {
SettingsNode childNode = settingsNode.addChildIfNotPresent(getPrefix(fileChooserClass, id));
String save;
try {
if (saveCurrentDirectoryVsSelectedFilesParent) {
save = fileChooser.getCurrentDirectory().getCanonicalPath();
} else {
save = fileChooser.getSelectedFile().getCanonicalPath();
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
if (save != null) {
childNode.setValueOfChild(DIRECTORY_NAME, save);
}
}
use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.
the class PreferencesAssistant method restoreSettings.
public static void restoreSettings(SettingsNode settingsNode, JSplitPane splitter, String id, Class splitterClass) {
SettingsNode childNode = settingsNode.getChildNode(getPrefix(splitterClass, id));
if (childNode == null) {
return;
}
int location = childNode.getValueOfChildAsInt(DIVIDER_LOCATION, splitter.getDividerLocation());
splitter.setDividerLocation(location);
}
use of org.gradle.gradleplugin.foundation.settings.SettingsNode in project gradle by gradle.
the class PreferencesAssistant method restoreSettings.
/**
* Call this to restore the preferences that were saved via a call to save settings. Note: if no preferences are found it doesn't do anything.
*
* @param window the window who's settings to save
* @param id a unique ID for these settings.
* @param windowClass Any class. Just used for the preferences mechanism to obtain an instance. Making this an argument gives you more flexibility.
*/
public static SettingsNode restoreSettings(SettingsNode settingsNode, Window window, String id, Class windowClass) {
SettingsNode childNode = settingsNode.getChildNode(getPrefix(windowClass, id));
if (childNode == null) {
return null;
}
int x = childNode.getValueOfChildAsInt(WINDOW_X, window.getLocation().x);
int y = childNode.getValueOfChildAsInt(WINDOW_Y, window.getLocation().y);
int width = childNode.getValueOfChildAsInt(WINDOW_WIDTH, window.getSize().width);
int height = childNode.getValueOfChildAsInt(WINDOW_HEIGHT, window.getSize().height);
window.setLocation(x, y);
window.setSize(width, height);
return childNode;
}
Aggregations