示例#1
0
 /**
  * Load preferences from the old file format.
  *
  * @param oldPrefsFile FileWrapper containing the preferences info.
  * @throws XMLException Thrown if an error occurs eradign the rpeferences data.
  */
 private void loadOldPrefs(FileWrapper oldPrefsFile) throws XMLException {
   try {
     XMLBeanReader doc = new XMLBeanReader();
     doc.load(oldPrefsFile, getClass().getClassLoader());
     Iterator<?> it = doc.iterator();
     if (it.hasNext()) {
       _lafPrefs = (LAFPreferences) it.next();
     }
   } catch (FileNotFoundException ignore) {
     // property file not found for user - first time user ran pgm.
   }
 }
  /** Load from preferences file. */
  private void loadPrefs() {
    try {
      XMLBeanReader doc = new XMLBeanReader();

      FileWrapper prefFile = PreferenceUtil.getPreferenceFileToReadFrom(plugin);

      doc.load(prefFile, _prefs.getClass().getClassLoader());

      Iterator<Object> it = doc.iterator();

      if (it.hasNext()) {
        _prefs = (IQueryTokenizerPreferenceBean) it.next();
      }
    } catch (FileNotFoundException ignore) {
      s_log.info(USER_PREFS_FILE_NAME + " not found - will be created");
    } catch (Exception ex) {
      s_log.error("Error occurred reading from preferences file: " + USER_PREFS_FILE_NAME, ex);
    }

    _prefs.setClientName(Version.getApplicationName() + "/" + plugin.getDescriptiveName());
    _prefs.setClientVersion(Version.getShortVersion() + "/" + plugin.getVersion());
  }
示例#3
0
  /** Load from preferences file. */
  private void loadPrefs() {
    try {
      final XMLBeanReader doc = new XMLBeanReader();
      final FileWrapper file =
          fileWrapperFactory.create(_userSettingsFolder, IConstants.USER_PREFS_FILE_NAME);
      doc.load(file, getClass().getClassLoader());

      Iterator<?> it = doc.iterator();

      if (it.hasNext()) {
        _newSessionPrefs = (SyntaxPreferences) it.next();
      }
    } catch (FileNotFoundException ignore) {
      // property file not found for user - first time user ran pgm.
    } catch (Exception ex) {
      final String msg =
          "Error occured reading from preferences file: " + IConstants.USER_PREFS_FILE_NAME;
      s_log.error(msg, ex);
    }

    if (_newSessionPrefs == null) {
      _newSessionPrefs = new SyntaxPreferences();
    }
  }