コード例 #1
0
ファイル: UiPlugin.java プロジェクト: egouge/udig-platform
  private static void processAppIni(boolean readOnly, Function<String, String> func)
      throws IOException {
    File iniFile = getIniFile();
    if (iniFile != null && iniFile.exists()) {
      BufferedReader bR = null;
      BufferedWriter bW = null;
      try {
        Collection<String> updatedLines = new ArrayList<String>();
        bR = new BufferedReader(new FileReader(iniFile));
        String line = null;
        while ((line = bR.readLine()) != null) {
          String newLine = func.apply(line);
          updatedLines.add(newLine);
          updatedLines.add("\n"); // $NON-NLS-1$
        }
        if (!readOnly) {
          bW = new BufferedWriter(new FileWriter(iniFile));
          for (String string : updatedLines) {
            bW.write(string);
          }
        }
      } finally {
        try {
          if (bR != null) bR.close();
        } finally {
          if (bW != null) bW.close();
        }
      }
    }

    if (!readOnly) {
      UiPlugin.log("udig.ini changed:" + iniFile, null);
    }
  }
コード例 #2
0
 /** Return the dialog store to cache values into */
 protected IDialogSettings getDialogSettings() {
   IDialogSettings workbenchSettings = UiPlugin.getDefault().getDialogSettings();
   IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTING_SECTION_NAME);
   if (section == null) section = workbenchSettings.addNewSection(DIALOG_SETTING_SECTION_NAME);
   return section;
 }