use of net.parostroj.timetable.model.library.Library in project grafikon by jub77.
the class OutputTemplateSelectionModelAction method action.
@Override
protected void action() {
ExportImportSelection selection = new ExportImportSelection();
selection.setImportOverwrite(true);
selection.setImportMatch(ImportMatch.NAME);
if (context.hasAttribute("library")) {
Library library = (Library) context.getAttribute("library");
selection.addItems(ImportComponent.OUTPUT_TEMPLATES, library.getItems().get(LibraryItemType.OUTPUT_TEMPLATE).stream().map(item -> item.getObject()).collect(Collectors.toList()));
} else {
TrainDiagram diagram = (TrainDiagram) context.getAttribute("diagram");
selection.addItems(ImportComponent.OUTPUT_TEMPLATES, diagram.getOutputTemplates());
}
context.setAttribute("selection", selection);
}
use of net.parostroj.timetable.model.library.Library in project grafikon by jub77.
the class ImportSelectionModelAction method eventDispatchAction.
@Override
protected void eventDispatchAction() {
TrainDiagram diagram = (TrainDiagram) context.getAttribute("diagram");
Library library = (Library) context.getAttribute("library");
boolean trainImport = context.hasAttribute("trainImport");
TrainGroupFilter filter = (TrainGroupFilter) context.getAttribute("trainFilter");
if (diagram != null || library != null) {
final ExportImportSelectionDialog importDialog = new ExportImportSelectionDialog(GuiComponentUtils.getWindow(context.getLocationComponent()), true);
ExportImportSelectionSource source;
if (trainImport) {
source = ExportImportSelectionSource.fromDiagramSingleTypeWithFilter(diagram, ImportComponent.TRAINS, filter::apply);
} else {
source = diagram != null ? ExportImportSelectionSource.fromDiagramToDiagram(diagram) : ExportImportSelectionSource.fromLibraryToDiagram(library);
}
importDialog.setSelectionSource(source);
importDialog.setLocationRelativeTo(context.getLocationComponent());
importDialog.setVisible(true);
context.setCancelled(importDialog.isCancelled());
if (!context.isCancelled()) {
context.setAttribute("selection", importDialog.getSelection());
}
}
}
use of net.parostroj.timetable.model.library.Library in project grafikon by jub77.
the class ExportAction method createLibrary.
private Library createLibrary(ExportImportSelection selection) {
LibraryBuilder libBuilder = new LibraryBuilder(new LibraryBuilder.Config().setAddMissing(true));
selection.getObjectMap().values().stream().flatMap(item -> item.stream()).forEach(object -> libBuilder.importObject(object));
return libBuilder.build();
}
Aggregations