use of com.willwinder.ugs.nbp.designer.io.ugsd.UgsDesignWriter in project Universal-G-Code-Sender by winder.
the class UgsSaveCookie method save.
@Override
public void save() {
Controller controller = CentralLookup.getDefault().lookup(Controller.class);
if (controller == null) {
throw new IllegalStateException("Couldn't find an instance of the drawing controller");
}
try {
boolean valid = dataObject.getPrimaryFile().getFileSystem().isValid();
} catch (FileStateInvalidException e) {
e.printStackTrace();
}
UgsDesignWriter writer = new UgsDesignWriter();
writer.write(new File(dataObject.getPrimaryFile().getPath()), controller);
dataObject.setModified(false);
}
use of com.willwinder.ugs.nbp.designer.io.ugsd.UgsDesignWriter in project Universal-G-Code-Sender by winder.
the class CopyAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (controller.getSelectionManager().getSelection().isEmpty()) {
StatusDisplayer.getDefault().setStatusText("");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(null, null);
} else {
StatusDisplayer.getDefault().setStatusText("Clipboard: " + controller.getSelectionManager().getSelection().size());
UgsDesignWriter writer = new UgsDesignWriter();
String data = writer.serialize(controller.getSelectionManager().getSelection());
Transferable content = new StringSelection(data);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(content, null);
}
}
use of com.willwinder.ugs.nbp.designer.io.ugsd.UgsDesignWriter in project Universal-G-Code-Sender by winder.
the class SaveAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
controller.getSelectionManager().clearSelection();
JFileChooser fileDialog = new JFileChooser();
fileDialog.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileDialog.setDialogType(JFileChooser.CUSTOM_DIALOG);
fileDialog.addChoosableFileFilter(OpenAction.DESIGN_FILE_FILTER);
fileDialog.setSelectedFile(new File("out.ugsd"));
fileDialog.showSaveDialog(null);
File f = fileDialog.getSelectedFile();
if (f != null) {
ThreadHelper.invokeLater(() -> {
UgsDesignWriter writer = new UgsDesignWriter();
writer.write(f, controller);
});
}
}
Aggregations