Package org.springframework.richclient.settings

Examples of org.springframework.richclient.settings.Settings


  public void testCreate() throws SettingsException {
    XmlSettingsFactory settingsFactory = new XmlSettingsFactory();
    settingsFactory.setReaderWriter(new StringXmlSettingsReaderWriter(null));

    Settings settings = settingsFactory.createSettings("user");
    assertNotNull(settings);
    assertTrue(settings instanceof RootXmlSettings);
    assertEquals("user", settings.getName());

    RootXmlSettings rootXmlSettings = (RootXmlSettings) settings;
    Document document = rootXmlSettings.getDocument();
    assertNotNull(document);
  }
View Full Code Here


        assertTrue(settings.contains("tree.selectedRows"));
        assertEquals("0,2-3", settings.getString("tree.selectedRows"));
    }

    public void testRestoreSelectionState() {
        Settings settings = new TransientSettings();

        settings.setString("tree.selectedRows", "0,2-3");
        memento.restoreSelectionState(settings);

        assertEquals(5, tree.getRowCount());
        assertTrue(tree.isRowSelected(0));
        assertFalse(tree.isRowSelected(1));
View Full Code Here

        assertTrue(tree.isRowSelected(3));
        assertFalse(tree.isRowSelected(4));
    }

    public void testSaveExpansionState() {
        Settings settings = new TransientSettings();

        memento.saveExpansionState(settings);
        assertTrue(settings.contains("tree.expansionState"));
        assertEquals("1,0,0,0,0", settings.getString("tree.expansionState"));

        // expand child2
        tree.expandRow(2);

        memento.saveExpansionState(settings);
        assertTrue(settings.contains("tree.expansionState"));
        assertEquals("1,0,1,0,0,0,0", settings.getString("tree.expansionState"));
    }
View Full Code Here

        assertTrue(settings.contains("tree.expansionState"));
        assertEquals("1,0,1,0,0,0,0", settings.getString("tree.expansionState"));
    }

    public void testRestoreExpansionState() {
        Settings settings = new TransientSettings();
        settings.setString("tree.expansionState", "1,0,1,0,0,0,0");

        memento.restoreExpansionState(settings);

        assertEquals(7, tree.getRowCount());
        assertTrue(tree.isExpanded(0));
View Full Code Here

        assertFalse(tree.isExpanded(5));
        assertFalse(tree.isExpanded(6));
    }

    public void testRestoreExpansionStateWithInvalidSettingsString() {
        Settings settings = new TransientSettings();
        settings.setString("key.expansionState", "invalidPref");

        memento.restoreExpansionState(settings);

        assertEquals(5, tree.getRowCount());
        assertTrue(tree.isExpanded(0));
View Full Code Here

    assertEquals("value-1", settings.getString("key-1"));
    assertFalse(settings.getBoolean("key-2"));
    assertEquals(1.5f, settings.getFloat("key-3"), 0.0f);

    Settings childSettings = settings.getSettings("child-settings");
    assertTrue(childSettings instanceof XmlSettings);
    assertEquals(1, childSettings.getKeys().length);
    assertEquals("child-key", childSettings.getKeys()[0]);
  }
View Full Code Here

    childElement.setAttribute("name", "child-settings");
    parentElement.appendChild(childElement);

    TestableXmlSettingsReaderWriter readerWriter = new TestableXmlSettingsReaderWriter();
    RootXmlSettings parentSettings = new RootXmlSettings(doc, readerWriter);
    Settings childSettings = parentSettings.getSettings("child-settings");
    childSettings.save();

    assertEquals(parentSettings, readerWriter.lastWritten);
  }
View Full Code Here

    return result;
  }

  public Settings createSettings(String name) {
    Assert.state(StringUtils.hasText(id), "An id must be assigned.");
    Settings settings = null;
    if (preferencesFactory == null) {
      settings = new PreferencesSettings(getForId(Preferences.userRoot(), id).node(name));
    } else {
      settings = new PreferencesSettings(getForId(preferencesFactory.userRoot(), id).node(name));
    }

    try {
      settings.load();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    return settings;
View Full Code Here

    this.settingsStoreManager = settingsStoreManager;
  }

  public void saveGoogleKey(String googleKey){
    try{
      Settings userSettings = settingsStoreManager.getUserSettings();
      userSettings.setString(GOOGLE_KEY, googleKey);
      userSettings.save();
    }
    catch (SettingsException e) {
      log.warn("Unable to get user settings", e);
    }
    catch (IOException e) {
View Full Code Here

    }
  }
 
  public String getGoogleKey(){
    try{
      Settings userSettings = settingsStoreManager.getUserSettings();
      if(userSettings.contains(GOOGLE_KEY)){
        return userSettings.getString(GOOGLE_KEY);
      }
      else{
        return DEFAULT_KEY;
      }
    }
View Full Code Here

TOP

Related Classes of org.springframework.richclient.settings.Settings

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.