Package org.gradle.gradleplugin.foundation.settings

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


        //set the value of a child
        rootNode.setValueOfChild(SAMPLE_NAME_1, "myValue");

        //verify it was set properly
        SettingsNode childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("myValue", childNode1.getValue());

        //make sure there's only 1 child.
        children = rootNode.getChildNodes();
        assertEquals(1, children.size());

        //set the value again. This should set the value and NOT add an additional node
        rootNode.setValueOfChild(SAMPLE_NAME_1, "newvalue");
        childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("newvalue", childNode1.getValue());

        //make sure there's still only 1 child.
        children = rootNode.getChildNodes();
        assertEquals(1, children.size());
    }
View Full Code Here


    /**
     * Call this to read the JDOMSerializable from a file.
     */
    public static boolean importFromFile(ImportInteraction importInteraction, FileFilter fileFilter,
                                         SettingsSerializable... serializables) {
        SettingsNode settings = readSettingsFile(importInteraction, fileFilter);
        if (settings == null) {
            return false;
        }

        for (int index = 0; index < serializables.length; index++) {
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

    public void serializeOut(SettingsNode settings) {
        serializeOut(settings, favorites);
    }

    public static void serializeOut(SettingsNode settings, List<FavoriteTask> favorites) {
        SettingsNode rootNode = settings.addChildIfNotPresent(ROOT_TAG);
        rootNode.removeAllChildren(); //clear out whatever may have already been there

        Iterator<FavoriteTask> iterator = favorites.iterator();
        while (iterator.hasNext()) {
            FavoriteTask favoriteTask = iterator.next();

            SettingsNode taskNode = rootNode.addChild(FAVORITE_ELEMENT_TAG);
            taskNode.setValueOfChild(FULL_COMMAND_LINE, favoriteTask.getFullCommandLine());
            taskNode.setValueOfChild(DISPLAY_NAME, favoriteTask.getDisplayName());
            taskNode.setValueOfChildAsBoolean(SHOW_OUTPUT, favoriteTask.alwaysShowOutput());
        }
    }
View Full Code Here

    }

    public static void serializeIn(SettingsNode settings, List<FavoriteTask> favorites) {
        favorites.clear()//remove everything already there

        SettingsNode rootElement = settings.getChildNode(ROOT_TAG);
        if (rootElement == null) {
            return;
        }

        Iterator<SettingsNode> iterator = rootElement.getChildNodes(FAVORITE_ELEMENT_TAG).iterator();
        while (iterator.hasNext()) {
            SettingsNode taskNode = iterator.next();

            String fullCommandLine = taskNode.getValueOfChild(FULL_COMMAND_LINE, null);
            if (fullCommandLine != null) {
                String displayName = taskNode.getValueOfChild(DISPLAY_NAME, fullCommandLine);
                boolean showOutput = taskNode.getValueOfChildAsBoolean(SHOW_OUTPUT, false);

                addFavoriteTask(favorites, fullCommandLine, displayName, showOutput);
            }
        }
    }
View Full Code Here

    public static SettingsNode saveSettings(SettingsNode settingsNode, Window window, String id, Class windowClass) {
        Point p = window.getLocation();
        Dimension size = window.getSize();

        SettingsNode childNode = settingsNode.addChildIfNotPresent(getPrefix(windowClass, id));

        childNode.setValueOfChildAsInt(WINDOW_X, p.x);
        childNode.setValueOfChildAsInt(WINDOW_Y, p.y);
        childNode.setValueOfChildAsInt(WINDOW_WIDTH, size.width);
        childNode.setValueOfChildAsInt(WINDOW_HEIGHT, size.height);

        return childNode;
    }
View Full Code Here

    public static void saveSettings(SettingsNode settingsNode, JFrame frame, String id, Class windowClass) {
        if (frame.getExtendedState() == JFrame.ICONIFIED) {
            return;
        }

        SettingsNode childNode = saveSettings(settingsNode, (Window) frame, id, windowClass);

        if (frame.getExtendedState() != JFrame.ICONIFIED) {
            childNode.setValueOfChildAsInt(EXTENDED_STATE, frame.getExtendedState());
        }
    }
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.