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);
}
}
}
}
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);
}
}
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));
}
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);
}
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);
}
Aggregations