Search in sources :

Example 1 with LoadLibraryModelAction

use of net.parostroj.timetable.gui.actions.impl.LoadLibraryModelAction 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));
}
Also used : Group(net.parostroj.timetable.model.Group) TrainGroupFilter(net.parostroj.timetable.gui.actions.impl.ImportSelectionModelAction.TrainGroupFilter) LoadDiagramModelAction(net.parostroj.timetable.gui.actions.impl.LoadDiagramModelAction) ImportSelectionModelAction(net.parostroj.timetable.gui.actions.impl.ImportSelectionModelAction) ActionContext(net.parostroj.timetable.gui.actions.execution.ActionContext) OpenFileModelAction(net.parostroj.timetable.gui.actions.impl.OpenFileModelAction) TrainDiagram(net.parostroj.timetable.model.TrainDiagram) Predicate(com.google.common.base.Predicate) ImportModelAction(net.parostroj.timetable.gui.actions.execution.ImportModelAction) EventDispatchModelAction(net.parostroj.timetable.gui.actions.execution.EventDispatchModelAction) SelectLoadAction(net.parostroj.timetable.gui.actions.impl.SelectLoadAction) LoadLibraryModelAction(net.parostroj.timetable.gui.actions.impl.LoadLibraryModelAction) Component(java.awt.Component) ActionHandler(net.parostroj.timetable.gui.actions.execution.ActionHandler)

Example 2 with LoadLibraryModelAction

use of net.parostroj.timetable.gui.actions.impl.LoadLibraryModelAction in project grafikon by jub77.

the class ImportReplaceOutputTemplatesAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ActionHandler handler = ActionHandler.getInstance();
    ActionContext context = new ActionContext(GuiComponentUtils.getTopLevelComponent(e.getSource()));
    context.setAttribute("fileType", FileChooserFactory.Type.GTM_GTML);
    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 OutputTemplateSelectionModelAction(context));
    handler.execute(new ImportModelAction(context));
    handler.execute(new CopyTemplatesToOutputsModelAction(context, model));
}
Also used : LoadDiagramModelAction(net.parostroj.timetable.gui.actions.impl.LoadDiagramModelAction) SelectLoadAction(net.parostroj.timetable.gui.actions.impl.SelectLoadAction) LoadLibraryModelAction(net.parostroj.timetable.gui.actions.impl.LoadLibraryModelAction) OutputTemplateSelectionModelAction(net.parostroj.timetable.gui.actions.impl.OutputTemplateSelectionModelAction) ActionContext(net.parostroj.timetable.gui.actions.execution.ActionContext) ActionHandler(net.parostroj.timetable.gui.actions.execution.ActionHandler) OpenFileModelAction(net.parostroj.timetable.gui.actions.impl.OpenFileModelAction) ImportModelAction(net.parostroj.timetable.gui.actions.execution.ImportModelAction) CopyTemplatesToOutputsModelAction(net.parostroj.timetable.gui.actions.impl.CopyTemplatesToOutputsModelAction)

Aggregations

ActionContext (net.parostroj.timetable.gui.actions.execution.ActionContext)2 ActionHandler (net.parostroj.timetable.gui.actions.execution.ActionHandler)2 ImportModelAction (net.parostroj.timetable.gui.actions.execution.ImportModelAction)2 LoadDiagramModelAction (net.parostroj.timetable.gui.actions.impl.LoadDiagramModelAction)2 LoadLibraryModelAction (net.parostroj.timetable.gui.actions.impl.LoadLibraryModelAction)2 OpenFileModelAction (net.parostroj.timetable.gui.actions.impl.OpenFileModelAction)2 SelectLoadAction (net.parostroj.timetable.gui.actions.impl.SelectLoadAction)2 Predicate (com.google.common.base.Predicate)1 Component (java.awt.Component)1 EventDispatchModelAction (net.parostroj.timetable.gui.actions.execution.EventDispatchModelAction)1 CopyTemplatesToOutputsModelAction (net.parostroj.timetable.gui.actions.impl.CopyTemplatesToOutputsModelAction)1 ImportSelectionModelAction (net.parostroj.timetable.gui.actions.impl.ImportSelectionModelAction)1 TrainGroupFilter (net.parostroj.timetable.gui.actions.impl.ImportSelectionModelAction.TrainGroupFilter)1 OutputTemplateSelectionModelAction (net.parostroj.timetable.gui.actions.impl.OutputTemplateSelectionModelAction)1 Group (net.parostroj.timetable.model.Group)1 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)1