Exemple #1
0
  public void startup() {
    loadState();
    loadCommentHistory();
    loadCommentTemplates();
    CVSProviderPlugin.getPlugin()
        .addRepositoryListener(
            new ICVSListener() {
              public void repositoryAdded(ICVSRepositoryLocation root) {
                rootAdded(root);
              }

              public void repositoryRemoved(ICVSRepositoryLocation root) {
                rootRemoved(root);
              }
            });

    IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
    store.addPropertyChangeListener(
        new IPropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY)) {
              Object newValue = event.getNewValue();
              if (newValue instanceof String) {
                try {
                  setMaxComments(Integer.parseInt((String) newValue));
                } catch (NumberFormatException e) {
                  // fail silently
                }
              }
            }
          }
        });
    setMaxComments(store.getInt(ICVSUIConstants.PREF_COMMIT_COMMENTS_MAX_HISTORY));
  }
Exemple #2
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);
       }
     }
   }
 }
Exemple #3
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);
   }
 }
Exemple #4
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));
   }
 }