Пример #1
0
  /**
   * @param args
   * @throws SshToolsApplicationException
   */
  public void init(String[] args) throws SshToolsApplicationException {
    File f = getApplicationPreferencesDirectory();

    if (f != null) {
      //
      PreferencesStore.init(new File(f, getApplicationName() + ".properties"));
      log.info("Preferences will be saved to " + f.getAbsolutePath());
    } else {
      log.warn("No preferences can be saved.");
    }

    try {
      setLookAndFeel(PreferencesStore.get(PREF_LAF, SYSTEM_LAF));

      UIManager.put(
          "OptionPane.errorIcon", new ResourceIcon(SshToolsApplication.class, "dialog-error4.png"));
      UIManager.put(
          "OptionPane.informationIcon",
          new ResourceIcon(SshToolsApplication.class, "dialog-information.png"));
      UIManager.put(
          "OptionPane.warningIcon",
          new ResourceIcon(SshToolsApplication.class, "dialog-warning2.png"));
      UIManager.put(
          "OptionPane.questionIcon",
          new ResourceIcon(SshToolsApplication.class, "dialog-question3.png"));
    } catch (Throwable t) {
      log.error(t);
    }
  }
  /** initializes the parameters */
  protected void initializeParameters() {

    // getting the parameters from the preference store
    rulersEnabled =
        Boolean.parseBoolean(PreferencesStore.getPreference(null, RULERS_ENABLED_PREF_ID));

    alignWithRulers =
        Boolean.parseBoolean(PreferencesStore.getPreference(null, ALIGN_WITH_RULERS_PREF_ID));
  }
Пример #3
0
  public void testDoesNotCreateSession() throws Exception {
    EasyMock.expect(prefStore.getDefaultPreferences()).andReturn(new PreferencesDto());

    filter();

    assertNotNull(request.getAttribute(Keys.PREFERENCES));
  }
Пример #4
0
  public void exit(boolean kill) {
    log.debug("Exiting application");
    PreferencesStore.savePreferences();

    FileOutputStream out = null;
    File a = getApplicationPreferencesDirectory();

    if (a != null) {
      try {
        File f = new File(getApplicationPreferencesDirectory(), getApplicationName() + ".mru");
        ;

        if (log.isDebugEnabled()) {
          log.debug("Saving MRU to " + f.getAbsolutePath());
        }

        out = new FileOutputStream(f);

        PrintWriter w = new PrintWriter(out, true);
        w.println(mruModel.getMRUList().toString());
      } catch (IOException ioe) {
        log.error("Could not save MRU. ", ioe);
      } finally {
        IOUtil.closeStream(out);
      }
    } else {
      log.debug("Not saving preferences because no preferences directory is available.");
    }
    if (kill) {
      com.sshtools.common.util.ShutdownHooks.exit(kill);
    }
  }
Пример #5
0
 private void saveCalibration() {
   Preferences p = PreferencesStore.get();
   int iv = 0;
   for (View v : getViews()) {
     v.getCalibrationContext().save(p, iv);
     iv++;
   }
 }
Пример #6
0
 private void loadCalibration() {
   Preferences p = PreferencesStore.get();
   int iv = 0;
   for (View v : getViews()) {
     v.getCalibrationContext().load(p, iv);
     calibrate(v);
     iv++;
   }
 }
Пример #7
0
  public void testLoadsPreferencesFromCookieIntoRequest() throws Exception {
    request.addCookie(new Cookie(Keys.PREFERENCES, "descending"));

    EasyMock.expect(prefStore.convertFromString("descending")).andReturn(new PreferencesDto());

    filter();

    assertNotNull(request.getAttribute(Keys.PREFERENCES));
  }
Пример #8
0
    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
      if (key.equals(KEY_PREF_SERVER_IP)) {
        Preference PrefIP = findPreference(key);
        PrefIP.setSummary(sharedPreferences.getString(key, ""));

        Preference PrefGetAPIKey = findPreference(key);
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(
            Uri.parse(
                sharedPreferences.getString(KEY_PREF_SERVER_IP, "")
                    + ":"
                    + sharedPreferences.getString(KEY_PREF_SERVER_PORT, "")
                    + "/config/general/"));
        PrefGetAPIKey.setIntent(i);
      } else if (key.equals(KEY_PREF_SERVER_PORT)) {
        Preference Pref = findPreference(key);
        Pref.setSummary(sharedPreferences.getString(key, ""));
      } else if (key.equals(KEY_PREF_API_KEY)) {
        Preference Pref = findPreference(key);
        Pref.setSummary(sharedPreferences.getString(key, ""));
      } else if (key.equals(KEY_PREF_PAUSE_DURATION1)) {
        Preference Pref = findPreference(key);
        Pref.setSummary(sharedPreferences.getString(key, ""));
      } else if (key.equals(KEY_PREF_PAUSE_DURATION2)) {
        Preference Pref = findPreference(key);
        Pref.setSummary(sharedPreferences.getString(key, ""));
      } else if (key.equals(KEY_PREF_PAUSE_DURATION3)) {
        Preference Pref = findPreference(key);
        Pref.setSummary(sharedPreferences.getString(key, ""));
      } else if (key.equals(KEY_PREF_REFRESH_INTERVAL)) {
        Preference Pref = findPreference(key);
        Pref.setSummary(sharedPreferences.getString(key, ""));
      }
      try {
        PreferencesStore.getInstance().refreshSettings();
      } catch (Exception e) {

      }
    }
  /** updates the preferences values */
  protected void updatePreferences() {

    PreferencesStore.setPreference(null, RULERS_ENABLED_PREF_ID, Boolean.toString(rulersEnabled));
    PreferencesStore.setPreference(
        null, ALIGN_WITH_RULERS_PREF_ID, Boolean.toString(alignWithRulers));
  }