예제 #1
0
 private void loadCommentTemplates() {
   IPath pluginStateLocation =
       CVSUIPlugin.getPlugin().getStateLocation().append(COMMENT_TEMPLATES_FILE);
   File file = pluginStateLocation.toFile();
   if (!file.exists()) return;
   try {
     BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
     try {
       readCommentTemplates(is);
     } finally {
       is.close();
     }
   } catch (IOException e) {
     CVSUIPlugin.log(IStatus.ERROR, CVSUIMessages.RepositoryManager_ioException, e);
   } catch (TeamException e) {
     CVSUIPlugin.log(e);
   }
 }
예제 #2
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));
   }
 }
예제 #3
0
 private void loadState() {
   IPath pluginStateLocation =
       CVSUIPlugin.getPlugin().getStateLocation().append(REPOSITORIES_VIEW_FILE);
   File file = pluginStateLocation.toFile();
   if (file.exists()) {
     try {
       BufferedInputStream is = new BufferedInputStream(new FileInputStream(file));
       try {
         readState(is);
       } finally {
         is.close();
       }
     } catch (IOException e) {
       CVSUIPlugin.log(IStatus.ERROR, CVSUIMessages.RepositoryManager_ioException, e);
     } catch (TeamException e) {
       CVSUIPlugin.log(e);
     }
   } else {
     IPath oldPluginStateLocation = CVSUIPlugin.getPlugin().getStateLocation().append(STATE_FILE);
     file = oldPluginStateLocation.toFile();
     if (file.exists()) {
       try {
         DataInputStream dis = new DataInputStream(new FileInputStream(file));
         try {
           readOldState(dis);
         } finally {
           dis.close();
         }
         saveState();
         file.delete();
       } catch (IOException e) {
         CVSUIPlugin.log(IStatus.ERROR, CVSUIMessages.RepositoryManager_ioException, e);
       } catch (TeamException e) {
         CVSUIPlugin.log(e);
       }
     }
   }
 }