Package org.gradle.gradleplugin.foundation.settings

Examples of org.gradle.gradleplugin.foundation.settings.SettingsNode


     * @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;
View Full Code Here


    /**
     * This restores the position of a frame. We not only restore the size, but we'll maximize it if its was maximized when saved.
     */
    public static void restoreSettings(SettingsNode settingsNode, JFrame frame, String id, Class windowClass) {
        SettingsNode childNode = restoreSettings(settingsNode, (Window) frame, id, windowClass);
        if (childNode == null) {
            return;
        }

        int extendedState = childNode.getValueOfChildAsInt(EXTENDED_STATE, frame.getExtendedState());

        if (extendedState != JFrame.ICONIFIED) {
            frame.setExtendedState(extendedState);
        }
    }
View Full Code Here

            frame.setExtendedState(extendedState);
        }
    }

    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());
    }
View Full Code Here

        childNode.setValueOfChildAsInt(DIVIDER_LOCATION, splitter.getDividerLocation());
    }

    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);
    }
View Full Code Here

     * 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);
        }
    }
View Full Code Here

            childNode.setValueOfChild(DIRECTORY_NAME, save);
        }
    }

    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));
        }
    }
View Full Code Here

     * Call this to saves the current settings.
     *
     * @param settings where you save the settings.
     */
    public void serializeOut(SettingsNode settings) {
        SettingsNode rootNode = settings.addChildIfNotPresent(BASIC_PROJECT_AND_TASK_FILTER);
        rootNode.removeAllChildren(); //clear out whatever may have already been there

        rootNode.setValueOfChildAsBoolean(FILTER_OUT_TASKS_WITH_NO_DESCRIPTION, filterOutTasksWithNoDescription);

        SettingsNode filteredOutProjectsNode = rootNode.addChild(FILTERED_OUT_PROJECTS);
        serializeOutStringList(filteredOutProjectsNode, filteredOutProjectNames);

        SettingsNode filteredOutTasksNode = rootNode.addChild(FILTERED_OUT_TASKS);
        serializeOutStringList(filteredOutTasksNode, filteredOutTaskNames);
    }
View Full Code Here

     */
    private void serializeOutStringList(SettingsNode parentNode, List<String> strings) {
        Iterator<String> iterator = strings.iterator();
        while (iterator.hasNext()) {
            String item = iterator.next();
            SettingsNode itemNode = parentNode.addChild(ITEM);
            itemNode.setValue(item);
        }
    }
View Full Code Here

     */
    public void serializeIn(SettingsNode settings) {
        filteredOutProjectNames.clear();
        filteredOutTaskNames.clear();

        SettingsNode rootNode = settings.getChildNode(BASIC_PROJECT_AND_TASK_FILTER);
        if (rootNode == null) {
            return;
        }

        filterOutTasksWithNoDescription = rootNode.getValueOfChildAsBoolean(FILTER_OUT_TASKS_WITH_NO_DESCRIPTION, filterOutTasksWithNoDescription);

        SettingsNode filteredOutProjectsNode = rootNode.getChildNode(FILTERED_OUT_PROJECTS);
        if (filteredOutProjectsNode != null) {
            serializeInStringList(filteredOutProjectsNode, filteredOutProjectNames);
        }

        SettingsNode filteredOutTasksNode = rootNode.getChildNode(FILTERED_OUT_TASKS);
        if (filteredOutTasksNode != null) {
            serializeInStringList(filteredOutTasksNode, filteredOutTaskNames);
        }
    }
View Full Code Here

     * Reads in a list of strings as 'item' element children of parentElement.
     */
    private void serializeInStringList(SettingsNode parentNode, List<String> strings) {
        Iterator<SettingsNode> iterator = parentNode.getChildNodes(ITEM).iterator();
        while (iterator.hasNext()) {
            SettingsNode itemNode = iterator.next();
            String item = itemNode.getValue();
            if (item != null) {
                strings.add(item);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.gradle.gradleplugin.foundation.settings.SettingsNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.