@Override public void executionFinished(ExecutionResult result) { ReturnCode returnCode; returnCode = result.getReturnCode(); switch (returnCode) { case COMPLETED_SUCCESSFULLY: break; case OPEN_DEVICE_ERROR: case EEPROM_PROGRAMMING_ERROR: getView() .showErrorDialog( returnCode.getTitle(), SwingViewUtility.convertTextToHTML(returnCode.getMessage(), null)); break; default: getView() .showErrorDialog( MessageHelper.get(this, "saveErrorTitle"), MessageHelper.get(this, "saveErrorMessage", result.saveMessage())); } if (returnCode.isError()) getView().setStatusLabelText(MessageHelper.get(this, "saveErrorStatus")); else getView().setStatusLabelText(MessageHelper.get(this, "savedStatus")); super.executionFinished(result); }
synchronized void load(final File file) { if (!file.exists()) { view.showErrorDialog( MessageHelper.get(this, "fileMissingErrorTitle"), MessageHelper.get(this, "fileMissingErrorMessage", file)); view.setStatusLabelText(MessageHelper.get(this, "loadFileErrorStatus")); } else { try { byte[] data; data = HexFilesUtility.readSimpleHexFile(file); ByteView.loadBytes(view.getModel(), data); this.file = file; view.setWindowTitleAmendment(file.getAbsolutePath()); view.setStatusLabelText(MessageHelper.get(this, "fileLoadedStatus")); modelChanged = false; } catch (IOException e) { view.showErrorDialog( MessageHelper.get(this, "fileLoadingErrorTitle"), MessageHelper.get(this, "fileLoadingErrorMessage", file, e.getLocalizedMessage())); view.setStatusLabelText(MessageHelper.get(this, "loadFileErrorStatus")); } catch (ByteLoadingException e) { view.showErrorDialog(e.getTitle(), e.getLocalizedMessage()); view.setStatusLabelText(MessageHelper.get(this, "loadFileErrorStatus")); } } }
synchronized void save(File file) { try { byte[] data; file = addFileExtension(file); data = ByteView.saveBytes(view.getModel()); HexFilesUtility.writeSimpleHexFile(file, data); view.setWindowTitleAmendment(file.getAbsolutePath()); view.setStatusLabelText(MessageHelper.get(this, "fileSavedStatus")); modelChanged = false; } catch (IOException e) { view.showErrorDialog( MessageHelper.get(this, "fileSavingErrorTitle"), MessageHelper.get(this, "fileSavingErrorMessage", file, e.getLocalizedMessage())); view.setStatusLabelText(MessageHelper.get(this, "saveFileErrorStatus")); } }
synchronized void forget() { if (file != null) { file = null; view.setWindowTitleAmendment(null); view.setStatusLabelText(MessageHelper.get(this, "fileForgottenStatus")); modelChanged = false; } }