Example #1
0
 public void save() {
   getPreferenceStore();
   if (preferenceStore.needsSaving() || needsSaving) {
     try {
       if (defaultSet != -1) preferenceStore.setValue(KEY_DEFAULT, defaultSet > 0);
       preferenceStore.save();
       needsSaving = false;
     } catch (IOException e) {
       String message = Messages.bind(Messages.ScopeSet_errorSaving, name);
       HelpUIPlugin.logError(message, e);
     }
   }
 }
Example #2
0
 private void copy(PreferenceStore store) {
   try {
     File file = File.createTempFile("sset", null); // $NON-NLS-1$
     FileOutputStream fos = new FileOutputStream(file);
     store.save(fos, ""); // $NON-NLS-1$
     fos.close();
     FileInputStream fis = new FileInputStream(file);
     getPreferenceStore();
     preferenceStore.load(fis);
     // when we clone the defult set, we should
     // clear the default marker
     preferenceStore.setValue(KEY_DEFAULT, false);
     fis.close();
   } catch (IOException e) {
   }
 }
Example #3
0
 /** @param name The name to set. */
 public void setName(String name) {
   String oldFileName = getFileName(this.name);
   File oldFile = new File(oldFileName);
   if (oldFile.exists()) {
     // store under the old name already exists
     if (preferenceStore == null) {
       // just rename the file
       oldFile.renameTo(new File(getFileName(name)));
     } else {
       // remove the old file, set the new file name,
       // then save to create the new file
       oldFile.delete();
       preferenceStore.setFilename(getFileName(name));
       try {
         preferenceStore.save();
       } catch (IOException e) {
         String message = Messages.bind(Messages.ScopeSet_errorSaving, name);
         HelpUIPlugin.logError(message, e);
       }
     }
   }
   this.name = name;
 }
Example #4
0
 public IPreferenceStore getPreferenceStore() {
   if (preferenceStore == null) {
     preferenceStore = new PreferenceStore(getFileName(this.name));
     try {
       File file = new File(getFileName(this.name));
       if (file.exists()) {
         preferenceStore.load();
       }
     } catch (IOException e) {
       String message = Messages.bind(Messages.ScopeSet_errorLoading, name);
       HelpUIPlugin.logError(message, e);
     }
   }
   return preferenceStore;
 }