use of org.mapton.api.MLocalGrid in project mapton by trixon.
the class FileExportAction method getAction.
@Override
public Action getAction(Node owner) {
FxActionSwing action = new FxActionSwing(Dict.EXPORT.toString(), () -> {
ArrayList<MLocalGrid> selectedGrids = new ArrayList<>();
mManager.getItems().stream().filter((grid) -> (grid.isVisible())).forEachOrdered((grid) -> {
selectedGrids.add(grid);
});
if (!selectedGrids.isEmpty()) {
SimpleDialog.clearFilters();
SimpleDialog.addFilters("grid");
SimpleDialog.setFilter("grid");
final String dialogTitle = String.format("%s %s", Dict.EXPORT.toString(), mTitle.toLowerCase());
SimpleDialog.setTitle(dialogTitle);
if (mFile == null) {
SimpleDialog.setPath(FileUtils.getUserDirectory());
} else {
SimpleDialog.setPath(mFile.getParentFile());
SimpleDialog.setSelectedFile(new File(""));
}
if (SimpleDialog.saveFile(new String[] { "grid" })) {
new Thread(() -> {
mFile = SimpleDialog.getPath();
try {
mManager.gridExport(mFile, selectedGrids);
NotificationDisplayer.getDefault().notify(Dict.OPERATION_COMPLETED.toString(), MNotificationIcons.getInformationIcon(), dialogTitle, null, NotificationDisplayer.Priority.LOW);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}).start();
}
}
});
action.setGraphic(MaterialIcon._Content.SAVE.getImageView(getIconSizeToolBarInt()));
return action;
}
use of org.mapton.api.MLocalGrid in project mapton by trixon.
the class LocalGridEditor method edit.
public void edit(final MLocalGrid aLocalGrid) {
SwingUtilities.invokeLater(() -> {
MLocalGrid newLocalGrid = aLocalGrid;
boolean add = aLocalGrid == null;
if (add) {
newLocalGrid = new MLocalGrid();
}
final MLocalGrid localGrid = newLocalGrid;
LocalGridPanel localGridPanel = new LocalGridPanel();
DialogDescriptor d = new DialogDescriptor(localGridPanel, MDict.GRID.toString());
localGridPanel.setNotifyDescriptor(d);
localGridPanel.initFx(() -> {
localGridPanel.load(localGrid);
});
localGridPanel.setPreferredSize(SwingHelper.getUIScaledDim(600, 380));
if (DialogDescriptor.OK_OPTION == DialogDisplayer.getDefault().notify(d)) {
Platform.runLater(() -> {
localGridPanel.save(localGrid);
if (add) {
mManager.getItems().add(localGrid);
}
FXCollections.sort(mManager.getItems(), (MLocalGrid o1, MLocalGrid o2) -> o1.getName().compareTo(o2.getName()));
});
}
});
}
Aggregations