use of jmri.NamedBean in project JMRI by JMRI.
the class NamedBeanTest method testSetBeanParameter.
public void testSetBeanParameter() {
NamedBean n = createInstance();
n.setProperty("foo", "bar");
}
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"));
}
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"));
}
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);
}
}
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);
}
}
Aggregations