Search in sources :

Example 1 with ActionContext

use of net.parostroj.timetable.gui.actions.execution.ActionContext in project grafikon by jub77.

the class ExportAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    final Component parent = GuiComponentUtils.getTopLevelComponent(event.getSource());
    ExportImportSelectionSource source = ExportImportSelectionSource.fromDiagramToLibrary(model.getDiagram());
    exportDialog.setSelectionSource(source);
    exportDialog.setLocationRelativeTo(parent);
    exportDialog.setVisible(true);
    boolean cancelled = exportDialog.isCancelled();
    if (!cancelled) {
        // saving library
        try (CloseableFileChooser gtmlFileChooser = FileChooserFactory.getInstance().getFileChooser(FileChooserFactory.Type.GTML)) {
            int retVal = gtmlFileChooser.showSaveDialog(parent);
            if (retVal == JFileChooser.APPROVE_OPTION) {
                ActionContext c = new ActionContext(parent);
                ModelAction action = getSaveModelAction(c, gtmlFileChooser.getSelectedFile(), parent, this.createLibrary(exportDialog.getSelection()));
                ActionHandler.getInstance().execute(action);
            }
        }
    }
}
Also used : EventDispatchAfterModelAction(net.parostroj.timetable.gui.actions.execution.EventDispatchAfterModelAction) ModelAction(net.parostroj.timetable.gui.actions.execution.ModelAction) CloseableFileChooser(net.parostroj.timetable.gui.actions.impl.CloseableFileChooser) ExportImportSelectionSource(net.parostroj.timetable.gui.components.ExportImportSelectionSource) Component(java.awt.Component) ActionContext(net.parostroj.timetable.gui.actions.execution.ActionContext)

Example 2 with ActionContext

use of net.parostroj.timetable.gui.actions.execution.ActionContext in project grafikon by jub77.

the class WaitDialog method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent evt) {
    log.trace("Event received: {}, {}", evt.getPropertyName(), evt.getNewValue());
    if ("state".equals(evt.getPropertyName())) {
        if (evt.getNewValue() == ActionContext.WaitDialogState.HIDE) {
            this.setVisible(false);
        } else if (evt.getNewValue() == ActionContext.WaitDialogState.SHOW) {
            final ActionContext context = (ActionContext) evt.getSource();
            Timer timer = new Timer(context.getDelay(), new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    progressBar.setValue(context.getProgress());
                    progressBar.setVisible(context.isShowProgress());
                    pack();
                    if (context.getLocationComponent() != null) {
                        setLocationRelativeTo(context.getLocationComponent());
                    }
                    setVisible(true);
                }
            });
            timer.setRepeats(false);
            timer.start();
        }
    } else if ("description".equals(evt.getPropertyName())) {
        String newValue = (String) evt.getNewValue();
        if (newValue != null) {
            messageLabel.setText(newValue);
        }
    } else if ("progress".equals(evt.getPropertyName())) {
        progressBar.setValue((Integer) evt.getNewValue());
    } else if ("progressDescription".equals(evt.getPropertyName())) {
        String newValue = (String) evt.getNewValue();
        progressBar.setString(newValue);
    }
}
Also used : Timer(javax.swing.Timer) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ActionContext(net.parostroj.timetable.gui.actions.execution.ActionContext)

Example 3 with ActionContext

use of net.parostroj.timetable.gui.actions.execution.ActionContext in project grafikon by jub77.

the class ImportReplaceOutputTemplatesUrlAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ActionHandler handler = ActionHandler.getInstance();
    ActionContext context = new ActionContext(GuiComponentUtils.getTopLevelComponent(e.getSource()));
    context.setAttribute("diagramImport", model.getDiagram());
    String url = model.getLibraryBaseUrl() + "/" + TEMPLATE;
    context.setAttribute("libraryUrl", url);
    log.debug("Loading library: {}", url);
    handler.execute(new LoadLibraryUrlModelAction(context));
    handler.execute(new OutputTemplateSelectionModelAction(context));
    handler.execute(new ImportModelAction(context));
    handler.execute(new CopyTemplatesToOutputsModelAction(context, model));
}
Also used : LoadLibraryUrlModelAction(net.parostroj.timetable.gui.actions.impl.LoadLibraryUrlModelAction) OutputTemplateSelectionModelAction(net.parostroj.timetable.gui.actions.impl.OutputTemplateSelectionModelAction) ActionContext(net.parostroj.timetable.gui.actions.execution.ActionContext) ActionHandler(net.parostroj.timetable.gui.actions.execution.ActionHandler) ImportModelAction(net.parostroj.timetable.gui.actions.execution.ImportModelAction) CopyTemplatesToOutputsModelAction(net.parostroj.timetable.gui.actions.impl.CopyTemplatesToOutputsModelAction)

Example 4 with ActionContext

use of net.parostroj.timetable.gui.actions.execution.ActionContext in project grafikon by jub77.

the class CirculationViewPanel method saveButtonActionPerformed.

private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (dialog == null)
        dialog = new SaveImageDialog((Dialog) this.getTopLevelAncestor(), true);
    dialog.setLocationRelativeTo(this.getParent());
    dialog.setSaveSize(circulationView.getPreferredSize());
    dialog.setSizeChangeEnabled(false);
    dialog.setVisible(true);
    if (!dialog.isSave()) {
        return;
    }
    ActionContext actionContext = new ActionContext(GuiComponentUtils.getTopLevelComponent(this));
    SaveImageAction action = new SaveImageAction(actionContext, dialog, circulationView);
    ActionHandler.getInstance().execute(action);
}
Also used : SaveImageAction(net.parostroj.timetable.gui.actions.execution.SaveImageAction) SaveImageDialog(net.parostroj.timetable.gui.dialogs.SaveImageDialog) ActionContext(net.parostroj.timetable.gui.actions.execution.ActionContext)

Example 5 with ActionContext

use of net.parostroj.timetable.gui.actions.execution.ActionContext in project grafikon by jub77.

the class EditOutputsDialog method generateOutputs.

private void generateOutputs(final GenerateOutputPM pModel, Collection<Output> outputs) {
    ActionContext context = new ActionContext();
    context.setLocationComponent(this);
    OutputTemplateAction action = new OutputTemplateAction(context, element, settings, pModel.getLocation(), outputs);
    if (pModel.isClearDirectory()) {
        ActionHandler.getInstance().execute(ModelAction.newAction(context, () -> {
            clearDirectory(pModel.getLocation());
        }));
    }
    ActionHandler.getInstance().execute(action);
}
Also used : OutputTemplateAction(net.parostroj.timetable.gui.actions.execution.OutputTemplateAction) ActionContext(net.parostroj.timetable.gui.actions.execution.ActionContext)

Aggregations

ActionContext (net.parostroj.timetable.gui.actions.execution.ActionContext)7 ActionHandler (net.parostroj.timetable.gui.actions.execution.ActionHandler)3 ImportModelAction (net.parostroj.timetable.gui.actions.execution.ImportModelAction)3 Component (java.awt.Component)2 CopyTemplatesToOutputsModelAction (net.parostroj.timetable.gui.actions.impl.CopyTemplatesToOutputsModelAction)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 OutputTemplateSelectionModelAction (net.parostroj.timetable.gui.actions.impl.OutputTemplateSelectionModelAction)2 SelectLoadAction (net.parostroj.timetable.gui.actions.impl.SelectLoadAction)2 Predicate (com.google.common.base.Predicate)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Timer (javax.swing.Timer)1 EventDispatchAfterModelAction (net.parostroj.timetable.gui.actions.execution.EventDispatchAfterModelAction)1 EventDispatchModelAction (net.parostroj.timetable.gui.actions.execution.EventDispatchModelAction)1 ModelAction (net.parostroj.timetable.gui.actions.execution.ModelAction)1 OutputTemplateAction (net.parostroj.timetable.gui.actions.execution.OutputTemplateAction)1 SaveImageAction (net.parostroj.timetable.gui.actions.execution.SaveImageAction)1 CloseableFileChooser (net.parostroj.timetable.gui.actions.impl.CloseableFileChooser)1