use of com.willwinder.ugs.nbp.designer.io.DesignReader in project Universal-G-Code-Sender by winder.
the class OpenAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
UndoManager undoManager = CentralLookup.getDefault().lookup(UndoManager.class);
undoManager.clear();
SelectionManager selectionManager = CentralLookup.getDefault().lookup(SelectionManager.class);
selectionManager.clearSelection();
Controller controller = CentralLookup.getDefault().lookup(Controller.class);
fileChooser.showOpenDialog(null);
ThreadHelper.invokeLater(() -> {
DesignReader designReader = new UgsDesignReader();
if (fileChooser.getFileFilter() == SVG_FILE_FILTER) {
designReader = new SvgReader();
} else if (fileChooser.getFileFilter() == C2D_FILE_FILTER) {
designReader = new C2dReader();
}
File selectedFile = fileChooser.getSelectedFile();
Optional<Design> optional = designReader.read(selectedFile);
if (optional.isPresent()) {
controller.setDesign(optional.get());
} else {
throw new RuntimeException("Could not open svg: " + selectedFile.getName());
}
});
}
Aggregations