[Mercurial] Better HgInit: added notification about repository creation.
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Fri, 18 Jun 2010 13:12:31 +0000 (17:12 +0400)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Fri, 18 Jun 2010 13:12:31 +0000 (17:12 +0400)
plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties
plugins/hg4idea/src/org/zmlx/hg4idea/HgVcs.java
plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java

index 14fb6f21925b5c70b2fe1edce8f2001e9a9140a3..3471afa949bc56754ab69bf056c3a509f17ee89c 100644 (file)
@@ -34,6 +34,8 @@ hg4idea.init.already.under.hg.dialog.title=Directory is under hg
 hg4idea.init.already.under.hg.option.create.project.at.parent=Use parent repository and create IDEA project for it.
 hg4idea.init.already.under.hg.option.use.parent=Use parent repository, but keep working in this project.
 hg4idea.init.already.under.hg.option.create.repo.here=Create new repository here.
+hg4idea.init.created.notification.title=Mercurial repository created
+hg4idea.init.created.notification.description=Repository was created in {0}
 
 hg4idea.clone.title=Clone Mercurial Repostiroy
 hg4idea.clone.button.clone=Clone
index 26a700e2eda587f23c11158f06d1c897f6ccd726..377857fe35d1357dc8aaf496c20a5625f5c61df7 100644 (file)
 // limitations under the License.
 package org.zmlx.hg4idea;
 
-import com.intellij.concurrency.*;
-import com.intellij.openapi.application.*;
-import com.intellij.openapi.fileEditor.*;
-import com.intellij.openapi.options.*;
-import com.intellij.openapi.project.*;
-import com.intellij.openapi.util.*;
-import com.intellij.openapi.vcs.*;
-import com.intellij.openapi.vcs.annotate.*;
-import com.intellij.openapi.vcs.changes.*;
-import com.intellij.openapi.vcs.checkin.*;
-import com.intellij.openapi.vcs.diff.*;
-import com.intellij.openapi.vcs.history.*;
-import com.intellij.openapi.vcs.rollback.*;
-import com.intellij.openapi.vcs.update.*;
-import com.intellij.openapi.vfs.*;
-import com.intellij.openapi.wm.*;
-import com.intellij.util.messages.*;
+import com.intellij.concurrency.JobScheduler;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
+import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
+import com.intellij.openapi.fileEditor.FileEditorManagerListener;
+import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.openapi.util.IconLoader;
+import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.vcs.AbstractVcs;
+import com.intellij.openapi.vcs.CommittedChangesProvider;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
+import com.intellij.openapi.vcs.VcsException;
+import com.intellij.openapi.vcs.annotate.AnnotationProvider;
+import com.intellij.openapi.vcs.changes.ChangeListManager;
+import com.intellij.openapi.vcs.changes.ChangeProvider;
+import com.intellij.openapi.vcs.checkin.CheckinEnvironment;
+import com.intellij.openapi.vcs.diff.DiffProvider;
+import com.intellij.openapi.vcs.history.VcsHistoryProvider;
+import com.intellij.openapi.vcs.rollback.RollbackEnvironment;
+import com.intellij.openapi.vcs.update.UpdateEnvironment;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.openapi.vfs.VirtualFileListener;
+import com.intellij.openapi.vfs.VirtualFileManager;
+import com.intellij.openapi.wm.StatusBar;
+import com.intellij.openapi.wm.WindowManager;
+import com.intellij.util.messages.MessageBus;
+import com.intellij.util.messages.MessageBusConnection;
+import com.intellij.util.messages.Topic;
 import org.zmlx.hg4idea.provider.*;
-import org.zmlx.hg4idea.provider.annotate.*;
-import org.zmlx.hg4idea.provider.commit.*;
-import org.zmlx.hg4idea.provider.update.*;
-import org.zmlx.hg4idea.ui.*;
+import org.zmlx.hg4idea.provider.annotate.HgAnnotationProvider;
+import org.zmlx.hg4idea.provider.commit.HgCheckinEnvironment;
+import org.zmlx.hg4idea.provider.commit.HgCommitExecutor;
+import org.zmlx.hg4idea.provider.update.HgIntegrateEnvironment;
+import org.zmlx.hg4idea.provider.update.HgUpdateEnvironment;
+import org.zmlx.hg4idea.ui.HgChangesetStatus;
+import org.zmlx.hg4idea.ui.HgCurrentBranchStatus;
 
 import javax.swing.*;
 import java.io.File;
-import java.util.concurrent.*;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
 
 public class HgVcs extends AbstractVcs {
 
@@ -57,6 +74,7 @@ public class HgVcs extends AbstractVcs {
 
   public static final String VCS_NAME = "hg4idea";
   public static final String DIRSTATE_FILE_PATH = ".hg/dirstate";
+  public static final String NOTIFICATION_GROUP_ID = "Mercurial";
 
   private final HgChangeProvider changeProvider;
   private final HgProjectConfigurable configurable;
index 8f3d2a7521e7c1d6533141b36211e96541d50e0b..a5171d0bb50f6917cdb466f153d176ecbc6cb63c 100644 (file)
@@ -1,6 +1,9 @@
 package org.zmlx.hg4idea.action;
 
 import com.intellij.ide.impl.NewProjectUtil;
+import com.intellij.notification.Notification;
+import com.intellij.notification.NotificationType;
+import com.intellij.notification.Notifications;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.actionSystem.Presentation;
@@ -12,6 +15,7 @@ import com.intellij.openapi.vcs.VcsDirectoryMapping;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.zmlx.hg4idea.HgUtil;
 import org.zmlx.hg4idea.HgVcs;
+import org.zmlx.hg4idea.HgVcsMessages;
 import org.zmlx.hg4idea.command.HgInitCommand;
 import org.zmlx.hg4idea.ui.HgInitAlreadyUnderHgDialog;
 import org.zmlx.hg4idea.ui.HgInitDialog;
@@ -26,20 +30,21 @@ import java.util.List;
 public class HgInit extends DumbAwareAction {
 
   private static final Logger LOG = Logger.getInstance(HgInit.class.getName());
+  private Project myProject;
 
   public HgInit() {
   }
 
   @Override
   public void actionPerformed(AnActionEvent e) {
-    final Project project = e.getData(PlatformDataKeys.PROJECT);
-    if (project == null) {
+    myProject = e.getData(PlatformDataKeys.PROJECT);
+    if (myProject == null) {
       LOG.warn("[actionPerformed] project is null");
       return;
     }
 
     // provide window to select the root directory
-    final HgInitDialog hgInitDialog = new HgInitDialog(project);
+    final HgInitDialog hgInitDialog = new HgInitDialog(myProject);
     hgInitDialog.show();
     if (!hgInitDialog.isOK()) {
       return;
@@ -53,7 +58,7 @@ public class HgInit extends DumbAwareAction {
     final VirtualFile vcsRoot = HgUtil.getNearestHgRoot(selectedRoot);
     VirtualFile mapRoot = selectedRoot;
     if (vcsRoot != null) {
-      final HgInitAlreadyUnderHgDialog dialog = new HgInitAlreadyUnderHgDialog(project,
+      final HgInitAlreadyUnderHgDialog dialog = new HgInitAlreadyUnderHgDialog(myProject,
                                                    selectedRoot.getPresentableUrl(), vcsRoot.getPresentableUrl());
       dialog.show();
       if (!dialog.isOK()) {
@@ -61,21 +66,21 @@ public class HgInit extends DumbAwareAction {
       }
 
       if (dialog.getAnswer() == HgInitAlreadyUnderHgDialog.Answer.CREATE_PROJECT_AT_PARENT) {
-        NewProjectUtil.createNewProject(project, vcsRoot.getPath());
+        NewProjectUtil.createNewProject(myProject, vcsRoot.getPath());
         return;
       } else if (dialog.getAnswer() == HgInitAlreadyUnderHgDialog.Answer.USE_PARENT_REPO_BUT_THIS_PROJECT) {
         mapRoot = vcsRoot;
       } else if (dialog.getAnswer() == HgInitAlreadyUnderHgDialog.Answer.CREATE_REPO_HERE) {
-        (new HgInitCommand(project)).execute(selectedRoot);
+        createRepository(selectedRoot);
       }
     } else { // no parent repository => creating the repository here.
-       (new HgInitCommand(project)).execute(selectedRoot);  
+       createRepository(selectedRoot);
     }
 
     // update vcs directory mappings
     mapRoot.refresh(false, false);
-    final String path = mapRoot.equals(project.getBaseDir()) ? "" : mapRoot.getPath();
-    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project);
+    final String path = mapRoot.equals(myProject.getBaseDir()) ? "" : mapRoot.getPath();
+    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
     final List<VcsDirectoryMapping> vcsDirectoryMappings = new ArrayList<VcsDirectoryMapping>(vcsManager.getDirectoryMappings());
     VcsDirectoryMapping mapping = new VcsDirectoryMapping(path, HgVcs.VCS_NAME);
     for (int i = 0; i < vcsDirectoryMappings.size(); i++) {
@@ -106,5 +111,13 @@ public class HgInit extends DumbAwareAction {
     presentation.setEnabled(project != null);
     presentation.setVisible(project != null);
   }
+
+  private void createRepository(VirtualFile selectedRoot) {
+    (new HgInitCommand(myProject)).execute(selectedRoot);
+    Notifications.Bus.notify(new Notification(HgVcs.NOTIFICATION_GROUP_ID,
+                                              HgVcsMessages.message("hg4idea.init.created.notification.title"),
+                                              HgVcsMessages.message("hg4idea.init.created.notification.description", selectedRoot.getPresentableUrl()),
+                                              NotificationType.INFORMATION), myProject);
+  }
   
 }