Ejemplo n.º 1
0
 protected void saveState() throws TeamException {
   IPath pluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation();
   File tempFile =
       pluginStateLocation.append(REPOSITORIES_VIEW_FILE + ".tmp").toFile(); // $NON-NLS-1$
   File stateFile = pluginStateLocation.append(REPOSITORIES_VIEW_FILE).toFile();
   try {
     XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(tempFile)));
     try {
       writeState(writer);
     } finally {
       writer.close();
     }
     if (stateFile.exists()) {
       stateFile.delete();
     }
     boolean renamed = tempFile.renameTo(stateFile);
     if (!renamed) {
       throw new TeamException(
           new Status(
               IStatus.ERROR,
               CVSUIPlugin.ID,
               TeamException.UNABLE,
               NLS.bind(
                   CVSUIMessages.RepositoryManager_rename,
                   new String[] {tempFile.getAbsolutePath()}),
               null));
     }
   } catch (IOException e) {
     throw new TeamException(
         new Status(
             IStatus.ERROR,
             CVSUIPlugin.ID,
             TeamException.UNABLE,
             NLS.bind(
                 CVSUIMessages.RepositoryManager_save, new String[] {stateFile.getAbsolutePath()}),
             e));
   }
 }