Merge branch 'master' of git.labs.intellij.net:idea/community
authorirengrig <Irina.Chernushina@jetbrains.com>
Fri, 4 Dec 2009 06:26:35 +0000 (09:26 +0300)
committerirengrig <Irina.Chernushina@jetbrains.com>
Fri, 4 Dec 2009 06:26:35 +0000 (09:26 +0300)
platform/vcs-impl/src/com/intellij/lifecycle/PeriodicalTasksCloser.java
platform/vcs-impl/src/com/intellij/lifecycle/SlowlyClosingAlarm.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchDifferentiatedDialog.java

index 10dd889ab6d0175ad97760ee0c0586cf0a104d24..1f45b6f6a85377e1b2d50f431d408dc8675ef5e3 100644 (file)
@@ -44,8 +44,10 @@ public class PeriodicalTasksCloser implements ProjectManagerListener {
   private final static Object ourLock = new Object();
   private final List<Pair<String, Runnable>> myInterrupters;
   private final static Map<Project, Boolean> myStates = new HashMap<Project, Boolean>();
+  private final Project myProject;
 
   private PeriodicalTasksCloser(final Project project, final ProjectManager projectManager) {
+    myProject = project;
     myInterrupters = new ArrayList<Pair<String, Runnable>>();
     projectManager.addProjectManagerListener(project, this);
   }
@@ -54,8 +56,14 @@ public class PeriodicalTasksCloser implements ProjectManagerListener {
     return ServiceManager.getService(project, PeriodicalTasksCloser.class);
   }
 
-  public void register(final String name, final Runnable runnable) {
-    myInterrupters.add(new Pair<String, Runnable>(name, runnable));
+  public boolean register(final String name, final Runnable runnable) {
+    synchronized (ourLock) {
+      if (Boolean.FALSE.equals(myStates.get(myProject))) {
+        return false;
+      }
+      myInterrupters.add(new Pair<String, Runnable>(name, runnable));
+      return true;
+    }
   }       
 
   public void projectOpened(Project project) {
@@ -81,7 +89,11 @@ public class PeriodicalTasksCloser implements ProjectManagerListener {
     ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
       public void run() {
         final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
-        for (Pair<String, Runnable> pair : myInterrupters) {
+        final List<Pair<String, Runnable>> list;
+        synchronized (ourLock) {
+          list = myInterrupters;
+        }
+        for (Pair<String, Runnable> pair : list) {
           if (indicator != null) {
             indicator.setText(pair.getFirst());
             indicator.checkCanceled();
index e15cab7c6fd9c563cec49f76ef380d9dbb80b07f..164c181955fe5d7edde8643bf0186ffb2d901e7c 100644 (file)
@@ -80,7 +80,7 @@ public class SlowlyClosingAlarm implements AtomicSectionsAware, Disposable {
     myLock = new Object();
     myFutureList = new ArrayList<Future<?>>();
     Disposer.register(project, this);
-    PeriodicalTasksCloser.getInstance(project).register(name, new Runnable() {
+    myDisposeStarted = ! PeriodicalTasksCloser.getInstance(project).register(name, new Runnable() {
       public void run() {
         waitAndInterrupt(ProgressManager.getInstance().getProgressIndicator());
       }
index 2d9d21ab385ab18fc1cbc74791b8452cd9e5e816..9026e98f86a99ef396940f71b0fc35521b46944d 100644 (file)
@@ -162,7 +162,9 @@ public class ApplyPatchAction extends AnAction {
   private static ApplyPatchStatus showMergeDialog(Project project, VirtualFile file, CharSequence content, final String patchedContent,
                                                   final PatchMergeRequestFactory mergeRequestFactory) {
     CharSequence fileContent = LoadTextUtil.loadText(file);
-
+    if (fileContent == null || content == null) {
+      return ApplyPatchStatus.FAILURE;
+    }
     final MergeRequest request = mergeRequestFactory.createMergeRequest(fileContent.toString(), patchedContent, content.toString(), file,
                                                       project);
     DiffManager.getInstance().getDiffTool().show(request);
index 9727b21565cbb6dce8ecc81fd090cb064e976f00..87c4eec435857f6818f4b960ff17e4283041052a 100644 (file)
@@ -159,6 +159,11 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
     return "vcs.ApplyPatchDifferentiatedDialog";
   }
 
+  @Override
+  protected String getHelpId() {
+    return "reference.dialogs.vcs.patch.apply";
+  }
+
   private void setPathFileChangeDefault() {
     myRecentPathFileChange.set(new FilePresentation(myPatchFile.getText()));
   }