コード例 #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);
     }
   }
 }
コード例 #2
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;
 }
コード例 #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;
 }