Search in sources :

Example 1 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class RosterFrameAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    mainFrame = new RosterFrame();
    UserPreferencesManager p = InstanceManager.getDefault(jmri.UserPreferencesManager.class);
    if (!p.isWindowPositionSaved(mainFrame.getWindowFrameRef())) {
        mainFrame.setSize(new Dimension(1024, 600));
        mainFrame.setPreferredSize(new Dimension(1024, 600));
    }
    if (wi instanceof RosterGroupSelector) {
        mainFrame.setSelectedRosterGroup(((RosterGroupSelector) wi).getSelectedRosterGroup());
    }
    mainFrame.setVisible(true);
    mainFrame.setAllowQuit(allowQuit);
    mainFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
Also used : Dimension(java.awt.Dimension) UserPreferencesManager(jmri.UserPreferencesManager) RosterGroupSelector(jmri.jmrit.roster.rostergroup.RosterGroupSelector)

Example 2 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testGetWindowSize.

@Test
public void testGetWindowSize() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    Dimension windowSize = new Dimension(666, 999);
    m.setWindowSize(strClass, windowSize);
    Dimension savedWindowSize = m.getWindowSize(strClass);
    Assert.assertEquals(windowSize, savedWindowSize);
}
Also used : Dimension(java.awt.Dimension) UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 3 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testIsSaveAllowed.

@Test
public void testIsSaveAllowed() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    Assert.assertTrue(m.isSaveAllowed());
    m.setSaveAllowed(false);
    Assert.assertFalse(m.isSaveAllowed());
    m.setSaveAllowed(true);
    Assert.assertTrue(m.isSaveAllowed());
}
Also used : UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 4 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testGetPreferencesClasses.

@Test
public void testGetPreferencesClasses() {
    UserPreferencesManager m = new TestJmriUserPreferencesManager();
    m.setSaveAllowed(false);
    Assert.assertEquals(1, m.getPreferencesClasses().size());
    Assert.assertEquals(m.getClass().getName(), m.getPreferencesClasses().get(0));
    m.setPreferenceState(strClass, "test1", true);
    Assert.assertEquals(2, m.getPreferencesClasses().size());
    Assert.assertEquals(strClass, m.getPreferencesClasses().get(1));
}
Also used : UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Example 5 with UserPreferencesManager

use of jmri.UserPreferencesManager in project JMRI by JMRI.

the class JmriUserPreferencesManagerTest method testGetMultipleChoiceDefaultOption.

@Test
public void testGetMultipleChoiceDefaultOption() {
    UserPreferencesManager m = new JmriUserPreferencesManager();
    m.setSaveAllowed(false);
    HashMap<Integer, String> options = new HashMap<>();
    options.put(1, "test1");
    Assert.assertEquals(0, m.getMultipleChoiceDefaultOption(strClass, "item1"));
    m.setMessageItemDetails(strClass, "item1", "description1", options, 0);
    Assert.assertEquals(0, m.getMultipleChoiceDefaultOption(strClass, "item1"));
}
Also used : HashMap(java.util.HashMap) UserPreferencesManager(jmri.UserPreferencesManager) Test(org.junit.Test)

Aggregations

UserPreferencesManager (jmri.UserPreferencesManager)47 Test (org.junit.Test)43 HashMap (java.util.HashMap)10 Dimension (java.awt.Dimension)7 Point (java.awt.Point)5 AppConfigBase (apps.AppConfigBase)2 File (java.io.File)2 JLabel (javax.swing.JLabel)2 RosterGroupSelector (jmri.jmrit.roster.rostergroup.RosterGroupSelector)2 NullProfile (jmri.profile.NullProfile)2 BoxLayout (javax.swing.BoxLayout)1 JCheckBox (javax.swing.JCheckBox)1 JPanel (javax.swing.JPanel)1 ShutDownManager (jmri.ShutDownManager)1