Ejemplo n.º 1
0
  /** Save attributes to an XML file. */
  static void saveAttributes(IPath filenameHint, AttributeValueSets attributes) {
    final IPath pathHint =
        filenameHint.isAbsolute()
            ? filenameHint
            : FileDialogs.recallPath(REMEMBER_DIRECTORY).append(filenameHint);

    final Path saveLocation = FileDialogs.openSaveXML(pathHint);
    if (saveLocation != null) {
      try {
        final Persister persister = new Persister(new Format(2));
        persister.write(attributes, saveLocation.toFile());
      } catch (Exception e) {
        Utils.showError(
            new Status(
                IStatus.ERROR,
                WorkbenchCorePlugin.PLUGIN_ID,
                "An error occurred while saving attributes.",
                e));
      }

      FileDialogs.rememberDirectory(REMEMBER_DIRECTORY, saveLocation);
    }
  }