Search in sources :

Example 66 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class NamedBeanTest method testSetBeanParameter.

public void testSetBeanParameter() {
    NamedBean n = createInstance();
    n.setProperty("foo", "bar");
}
Also used : NamedBean(jmri.NamedBean)

Example 67 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class CatalogTreeFSTest method testGetSetNull.

public void testGetSetNull() {
    NamedBean n = new CatalogTreeFS("sys", "usr") {

        @Override
        public int getState() {
            return 0;
        }

        @Override
        public void setState(int i) {
        }
    };
    n.setProperty("foo", "bar");
    Assert.assertEquals("bar", n.getProperty("foo"));
    n.setProperty("foo", null);
    Assert.assertEquals(null, n.getProperty("foo"));
}
Also used : NamedBean(jmri.NamedBean)

Example 68 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class CatalogTreeFSTest method testGetParameter.

public void testGetParameter() {
    NamedBean n = new CatalogTreeFS("sys", "usr") {

        @Override
        public int getState() {
            return 0;
        }

        @Override
        public void setState(int i) {
        }
    };
    n.setProperty("foo", "bar");
    Assert.assertEquals("bar", n.getProperty("foo"));
}
Also used : NamedBean(jmri.NamedBean)

Example 69 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class BeanEditAction method renameBean.

/**
     * Generic method to change the user name of a Bean.
     *
     * @param _newName string to use as the new user name
     */
public void renameBean(String _newName) {
    NamedBean nBean = bean;
    String oldName = nBean.getUserName();
    String value = _newName;
    if (value.equals(oldName)) {
        //name not changed.
        return;
    } else {
        NamedBean nB = getByUserName(value);
        if (nB != null) {
            // NOI18N
            log.error("User name is not unique " + value);
            String msg;
            msg = java.text.MessageFormat.format(Bundle.getMessage("WarningUserName"), new Object[] { ("" + value) });
            JOptionPane.showMessageDialog(null, msg, Bundle.getMessage("WarningTitle"), JOptionPane.ERROR_MESSAGE);
            return;
        }
    }
    nBean.setUserName(value);
    if (!value.equals("")) {
        if (oldName == null || oldName.equals("")) {
            if (!nbMan.inUse(nBean.getSystemName(), nBean)) {
                return;
            }
            String msg = Bundle.getMessage("UpdateToUserName", new Object[] { getBeanType(), value, nBean.getSystemName() });
            int optionPane = JOptionPane.showConfirmDialog(null, msg, Bundle.getMessage("UpdateToUserNameTitle"), JOptionPane.YES_NO_OPTION);
            if (optionPane == JOptionPane.YES_OPTION) {
                //This will update the bean reference from the systemName to the userName
                try {
                    nbMan.updateBeanFromSystemToUser(nBean);
                } catch (jmri.JmriException ex) {
                //We should never get an exception here as we already check that the username is not valid
                }
            }
        } else {
            nbMan.renameBean(oldName, value, nBean);
        }
    } else {
        //This will update the bean reference from the old userName to the SystemName
        nbMan.updateBeanFromUserToSystem(nBean);
    }
}
Also used : NamedBean(jmri.NamedBean)

Example 70 with NamedBean

use of jmri.NamedBean in project JMRI by JMRI.

the class AddSignalMastPanel method refreshHeadComboBox.

protected void refreshHeadComboBox() {
    if (!Bundle.getMessage("HeadCtlMast").equals(signalMastDriver.getSelectedItem())) {
        return;
    }
    if (includeUsed.isSelected()) {
        alreadyUsed = new ArrayList<NamedBean>();
    } else {
        List<SignalHead> alreadyUsedHeads = SignalHeadSignalMast.getSignalHeadsUsed();
        alreadyUsed = new ArrayList<NamedBean>();
        for (SignalHead head : alreadyUsedHeads) {
            alreadyUsed.add(head);
        }
    }
    for (JmriBeanComboBox head : headList) {
        head.excludeItems(alreadyUsed);
    }
}
Also used : JmriBeanComboBox(jmri.util.swing.JmriBeanComboBox) NamedBean(jmri.NamedBean) SignalHead(jmri.SignalHead)

Aggregations

NamedBean (jmri.NamedBean)104 ArrayList (java.util.ArrayList)18 JTextField (javax.swing.JTextField)12 JmriException (jmri.JmriException)12 SignalMast (jmri.SignalMast)12 JTable (javax.swing.JTable)11 Manager (jmri.Manager)9 Sensor (jmri.Sensor)9 JButton (javax.swing.JButton)8 InstanceManager (jmri.InstanceManager)8 JComboBox (javax.swing.JComboBox)7 MouseEvent (java.awt.event.MouseEvent)6 Hashtable (java.util.Hashtable)6 SignalHead (jmri.SignalHead)6 Turnout (jmri.Turnout)6 OBlock (jmri.jmrit.logix.OBlock)5 File (java.io.File)4 JLabel (javax.swing.JLabel)4 TableCellEditor (javax.swing.table.TableCellEditor)4 TableCellRenderer (javax.swing.table.TableCellRenderer)4