コード例 #1
0
ファイル: FileHandler.java プロジェクト: masebet/Dual-Strike
  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"));
      }
    }
  }
コード例 #2
0
  @Override
  void exec() {
    try {
      byte[] bytes;
      File file;

      bytes = ByteView.saveBytes(getModel());
      file = File.createTempFile("configuration-saving-data", ".txt");
      file.deleteOnExit();
      HexFilesUtility.writeI8HexFile(file, bytes, (byte) -1);
      DeviceHelper.saveConfiguration(this, file);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
コード例 #3
0
ファイル: FileHandler.java プロジェクト: masebet/Dual-Strike
  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"));
    }
  }