use of net.parostroj.timetable.model.Group in project grafikon by jub77.
the class NodeDelegateGroupImpl method isNode.
@Override
public boolean isNode(TrainTreeNode trainTreeNode, Train train) {
Group trainGroup = train.getAttributes().get(Train.ATTR_GROUP, Group.class);
Group nodeGroup = (Group) trainTreeNode.getUserObject();
return trainGroup == nodeGroup;
}
use of net.parostroj.timetable.model.Group in project grafikon by jub77.
the class ImportAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
final Component parent = GuiComponentUtils.getTopLevelComponent(event.getSource());
ActionContext context = new ActionContext(parent);
ActionHandler handler = ActionHandler.getInstance();
context.setAttribute("fileType", supportLibrary ? FileChooserFactory.Type.GTM_GTML : FileChooserFactory.Type.GTM);
context.setAttribute("diagramImport", model.getDiagram());
handler.execute(new OpenFileModelAction(context));
handler.execute(new SelectLoadAction(context));
handler.execute(new LoadDiagramModelAction(context));
handler.execute(new LoadLibraryModelAction(context));
handler.execute(new EventDispatchModelAction(context) {
@Override
protected void eventDispatchAction() {
TrainDiagram diagram = (TrainDiagram) context.getAttribute("diagram");
boolean cancelled = false;
Predicate<ObjectWithId> filter = null;
if (trainImport) {
groupDialog.setLocationRelativeTo(parent);
groupDialog.showDialog(diagram, null, model.getDiagram(), null);
if (groupDialog.isSelected()) {
final Group group = groupDialog.getSelectedFrom();
filter = new TrainGroupFilter(group);
} else {
cancelled = !groupDialog.isSelected();
}
}
context.setAttribute("trainFilter", filter);
context.setCancelled(cancelled);
if (trainImport) {
context.setAttribute("trainImport", new ImportModelAction.TrainImportConfig(groupDialog.isRemoveExistingTrains(), groupDialog.getSelectedFrom(), groupDialog.getSelectedTo()));
}
}
});
handler.execute(new ImportSelectionModelAction(context));
handler.execute(new ImportModelAction(context));
}
use of net.parostroj.timetable.model.Group in project grafikon by jub77.
the class GroupImport method importObjectImpl.
@Override
protected ObjectWithId importObjectImpl(ObjectWithId o) {
// check class
if (!(o instanceof Group))
return null;
Group importedGroup = (Group) o;
// check existence
Group checkedGroup = this.getGroup(importedGroup);
if (checkedGroup != null) {
String message = "group already exists";
this.addError(importedGroup, message);
log.debug("{}: {}", message, checkedGroup);
return null;
}
// create new group
Group group = getDiagram().getPartFactory().createGroup(this.getId(importedGroup));
group.getAttributes().add(this.importAttributes(importedGroup.getAttributes()));
// add to diagram
this.getDiagram().getGroups().add(group);
this.addImportedObject(group);
log.trace("Successfully imported group: {}", group);
return group;
}
Aggregations