use of net.parostroj.timetable.gui.components.GroupSelect in project grafikon by jub77.
the class CreateTrainView method updateView.
public void updateView(Group selectedGroup) {
this.createTrainCommand = null;
DefaultComboBoxModel<Node> fromModel = new DefaultComboBoxModel<>();
DefaultComboBoxModel<Node> toModel = new DefaultComboBoxModel<>();
Collection<Node> v = diagram.getNet().getNodes();
ElementSort<Node> sort = new ElementSort<>(new NodeComparator());
List<Node> list = sort.sort(v);
for (Node node : list) {
if (node.getType() != NodeType.SIGNAL) {
fromModel.addElement(node);
toModel.addElement(node);
}
}
fromComboBox.setModel(fromModel);
toComboBox.setModel(toModel);
// model for train types
typeComboBox.setModel(new DefaultComboBoxModel<>(diagram.getTrainTypes().toArray(new TrainType[0])));
typeComboBox.addItem(NO_TYPE);
// reset through nodes
throughNodes = new ArrayList<>();
throughTextField.setText(throughNodes.toString());
// update groups
groupComboBox.updateGroups(diagram, new GroupSelect(selectedGroup != null ? GroupSelect.Type.GROUP : GroupSelect.Type.NONE, selectedGroup));
}
use of net.parostroj.timetable.gui.components.GroupSelect in project grafikon by jub77.
the class TrainListView method buildGroupsMenu.
private void buildGroupsMenu() {
groupsMenu.removeAll();
groupsBG = new ButtonGroup();
// all and none
addToGroupsMenu(new GroupMenuItem("<" + ResourceLoader.getString("groups.all") + ">", new GroupSelect(GroupSelect.Type.ALL, null)), null);
addToGroupsMenu(new GroupMenuItem("<" + ResourceLoader.getString("groups.none") + ">", new GroupSelect(GroupSelect.Type.NONE, null)), null);
// fill groups
if (model != null && model.getDiagram() != null)
for (Group group : model.getDiagram().getGroups()) {
addToGroupsMenu(new GroupMenuItem(group.getName(), new GroupSelect(GroupSelect.Type.GROUP, group)), null);
}
// select first
groupsMenu.getItem(0).setSelected(true);
}
use of net.parostroj.timetable.gui.components.GroupSelect in project grafikon by jub77.
the class TrainListView method updateGroupsMenu.
private void updateGroupsMenu(boolean added, Group group) {
if (added) {
GroupMenuItem newItem = new GroupMenuItem(group.getName(), new GroupSelect(GroupSelect.Type.GROUP, group));
// skip first two items <all>,<none>
for (int i = 2; i < groupsMenu.getItemCount(); i++) {
JMenuItem item = groupsMenu.getItem(i);
if (newItem.getText().compareTo(item.getText()) < 0) {
addToGroupsMenu(newItem, i);
newItem = null;
break;
}
}
if (newItem != null) {
addToGroupsMenu(newItem, null);
}
} else {
GroupMenuItem item = findByGroup(group);
if (item.isSelected()) {
groupsMenu.getItem(0).setSelected(true);
}
removeFromGroupsMenu(item);
}
}
Aggregations