Search in sources :

Example 1 with ExportImportSelectionDialog

use of net.parostroj.timetable.gui.dialogs.ExportImportSelectionDialog 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());
        }
    }
}
Also used : ExportImportSelectionDialog(net.parostroj.timetable.gui.dialogs.ExportImportSelectionDialog) Library(net.parostroj.timetable.model.library.Library) ExportImportSelectionSource(net.parostroj.timetable.gui.components.ExportImportSelectionSource) TrainDiagram(net.parostroj.timetable.model.TrainDiagram)

Aggregations

ExportImportSelectionSource (net.parostroj.timetable.gui.components.ExportImportSelectionSource)1 ExportImportSelectionDialog (net.parostroj.timetable.gui.dialogs.ExportImportSelectionDialog)1 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)1 Library (net.parostroj.timetable.model.library.Library)1