Search in sources :

Example 11 with SettingsNode

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));
    }
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode) File(java.io.File)

Example 12 with SettingsNode

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());
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode)

Example 13 with SettingsNode

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);
    }
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException)

Example 14 with SettingsNode

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);
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode)

Example 15 with SettingsNode

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;
}
Also used : SettingsNode(org.gradle.gradleplugin.foundation.settings.SettingsNode)

Aggregations

SettingsNode (org.gradle.gradleplugin.foundation.settings.SettingsNode)35 DOM4JSettingsNode (org.gradle.gradleplugin.foundation.settings.DOM4JSettingsNode)19 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 SettingsNodeVersion1 (org.gradle.openapi.external.ui.SettingsNodeVersion1)1