Package org.gradle.gradleplugin.foundation.settings

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


        //now try it with one that doesn't exist. We should get the default value
        assertEquals(44, rootNode.getValueOfChildAsInt("nonexistent", 44));

        //now add a single node but don't give it a value (which means its null)
        SettingsNode valuelessNode = rootNode.addChild("valueless");
        assertNull(valuelessNode.getValue());

        //now try to get its value. We should get the default value
        assertEquals(17, rootNode.getValueOfChildAsInt("valueless", 17));

        //now add a single node that has an illegal value
        SettingsNode illegalNode = rootNode.addChild("illegal");
        illegalNode.setValue("abcdefg");

        //now try to get its value. We should get the default value
        assertEquals(333, rootNode.getValueOfChildAsInt("illegal", 333));
    }
View Full Code Here


        //set the value of a child
        rootNode.setValueOfChildAsLong(SAMPLE_NAME_1, 8000000000l);

        //verify it was set properly
        SettingsNode childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("8000000000", 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.setValueOfChildAsLong(SAMPLE_NAME_1, 3900000000l);
        childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("3900000000", childNode1.getValue());

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

        //now try it with one that doesn't exist. We should get the default value
        assertEquals(4400000000l, rootNode.getValueOfChildAsLong("nonexistent", 4400000000l));

        //now add a single node but don't give it a value (which means its null)
        SettingsNode valuelessNode = rootNode.addChild("valueless");
        assertNull(valuelessNode.getValue());

        //now try to get its value. We should get the default value
        assertEquals(1700000000l, rootNode.getValueOfChildAsLong("valueless", 1700000000l));

        //now add a single node that has an illegal value
        SettingsNode illegalNode = rootNode.addChild("illegal");
        illegalNode.setValue("abcdefg");

        //now try to get its value. We should get the default value
        assertEquals(33300000000l, rootNode.getValueOfChildAsLong("illegal", 33300000000l));
    }
View Full Code Here

        //set the value of a child
        rootNode.setValueOfChildAsBoolean(SAMPLE_NAME_1, true);

        //verify it was set properly
        SettingsNode childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("true", 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.setValueOfChildAsBoolean(SAMPLE_NAME_1, false);
        childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("false", childNode1.getValue());

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

        //set the value again to the same value. Again, this should set the value and NOT add an additional node
        rootNode.setValueOfChildAsBoolean(SAMPLE_NAME_1, false);
        childNode1 = rootNode.getChildNode(SAMPLE_NAME_1);
        assertNotNull(childNode1);
        assertEquals("false", childNode1.getValue());

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

        //see header
        assertEquals(false, rootNode.getValueOfChildAsBoolean("nonexistent2", false));

        //now add a single node but don't give it a value (which means its null)
        SettingsNode valuelessNode = rootNode.addChild("valueless");
        assertNull(valuelessNode.getValue());

        //now try to get its value. We should get the default value
        assertEquals(true, rootNode.getValueOfChildAsBoolean("valueless", true));

        //see header
        assertEquals(false, rootNode.getValueOfChildAsBoolean("valueless", false));

        //now add a single node that has an illegal value
        SettingsNode illegalNode = rootNode.addChild("illegal");
        illegalNode.setValue("abcdefg");

        //now try to get its value. We should get the default value
        assertEquals(true, rootNode.getValueOfChildAsBoolean("illegal", true));

        //see header
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

    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.