use of jmri.NamedBean in project JMRI by JMRI.
the class JmriBeanComboBox method getDisplayList.
/**
* Get the display list used by this combo box
*
* @return the display list used by this combo box
*/
public String[] getDisplayList() {
ArrayList<String> nameList = new ArrayList<>(Arrays.asList(_manager.getSystemNameArray()));
for (NamedBean bean : exclude) {
if (bean != null) {
nameList.remove(bean.getSystemName());
}
}
String[] displayList = new String[nameList.size()];
if (_displayOrder == DisplayOptions.SYSTEMNAME) {
displayList = nameList.toArray(displayList);
} else {
for (int i = 0; i < nameList.size(); i++) {
String name = nameList.get(i);
NamedBean nBean = _manager.getBeanBySystemName(name);
if (nBean != null) {
String uname = nBean.getUserName();
switch(_displayOrder) {
case DISPLAYNAME:
displayList[i] = nBean.getDisplayName();
break;
case USERNAME:
if (uname != null && !uname.equals("")) {
displayList[i] = uname;
} else {
displayList[i] = name;
}
break;
case USERNAMESYSTEMNAME:
if (uname != null && !uname.equals("")) {
displayList[i] = nBean.getUserName() + " - " + name;
} else {
displayList[i] = name;
}
break;
case SYSTEMNAMEUSERNAME:
if (uname != null && !uname.equals("")) {
displayList[i] = name + " - " + nBean.getUserName();
} else {
displayList[i] = name;
}
break;
default:
displayList[i] = nBean.getDisplayName();
}
displayToBean.put(displayList[i], nBean);
}
}
}
java.util.Arrays.sort(displayList, new AlphanumComparator());
return displayList;
}
use of jmri.NamedBean in project JMRI by JMRI.
the class JmriBeanComboBox method getSelectedDisplayName.
/**
* Get the display name of the selected namedBean
*
* @return the display name of the selected bean or null if there is no
* selection
*/
public String getSelectedDisplayName() {
String result = null;
NamedBean nBean = getSelectedBean();
if (nBean != null) {
result = nBean.getDisplayName();
}
return result;
}
use of jmri.NamedBean in project JMRI by JMRI.
the class JmriBeanComboBox method setDisplayOrder.
/**
* Set the display order of the combobox
*
* @param inDisplayOrder - the desired display order for this combobox
*/
public void setDisplayOrder(DisplayOptions inDisplayOrder) {
if (_displayOrder != inDisplayOrder) {
NamedBean selectedBean = getSelectedBean();
_displayOrder = inDisplayOrder;
//refreshCombo();
setSelectedBean(selectedBean);
}
}
use of jmri.NamedBean in project JMRI by JMRI.
the class JmriBeanComboBox method getDisplayName.
//getUserName
/**
* Get the display name for the selection in this JmriBeanComboBox (based on
* typed in text or drop down list)
*
* @return the display name or null if no selection
*/
public String getDisplayName() {
String result = null;
NamedBean b = null;
if (isEditable()) {
result = getEditor().getItem().toString();
result = (null != result) ? NamedBean.normalizeUserName(result) : "";
b = getNamedBean();
} else {
b = getSelectedBean();
}
if (null != b) {
result = b.getDisplayName();
}
return result;
}
use of jmri.NamedBean in project JMRI by JMRI.
the class NamedBeanTest method testGetBeanPropertyKeys.
public void testGetBeanPropertyKeys() {
NamedBean n = createInstance();
n.setProperty("foo", "bar");
n.setProperty("biff", "bar");
java.util.Set<String> s = n.getPropertyKeys();
Assert.assertEquals("size", 2, s.size());
Assert.assertEquals("contains foo", true, s.contains("foo"));
Assert.assertEquals("contains biff", true, s.contains("biff"));
}
Aggregations