示例#1
0
  @Override
  public void deactivate() {
    if (myHgRemoteStatusUpdater != null) {
      myHgRemoteStatusUpdater.deactivate();
      myHgRemoteStatusUpdater = null;
    }
    if (myStatusWidget != null) {
      myStatusWidget.deactivate();
      myStatusWidget = null;
    }
    if (myIncomingWidget != null) {
      myIncomingWidget.deactivate();
      myIncomingWidget = null;
    }
    if (myOutgoingWidget != null) {
      myOutgoingWidget.deactivate();
      myOutgoingWidget = null;
    }
    if (messageBusConnection != null) {
      messageBusConnection.disconnect();
    }

    if (myVFSListener != null) {
      Disposer.dispose(myVFSListener);
      myVFSListener = null;
    }

    super.deactivate();
  }
  @Override
  public void activate() {
    super.activate();

    // validate hg executable on start
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      getExecutableValidator().checkExecutableAndNotifyIfNeeded();
    }

    // status bar
    myStatusWidget = new HgStatusWidget(this, getProject(), projectSettings);
    myStatusWidget.activate();

    myIncomingWidget = new HgIncomingOutgoingWidget(this, getProject(), projectSettings, true);
    myIncomingWidget.activate();

    myOutgoingWidget = new HgIncomingOutgoingWidget(this, getProject(), projectSettings, false);
    myOutgoingWidget.activate();

    // updaters and listeners
    myHgRemoteStatusUpdater =
        new HgRemoteStatusUpdater(
            this,
            myIncomingWidget.getChangesetStatus(),
            myOutgoingWidget.getChangesetStatus(),
            projectSettings);
    myHgRemoteStatusUpdater.activate();

    myHgCurrentBranchStatusUpdater =
        new HgCurrentBranchStatusUpdater(this, myStatusWidget.getCurrentBranchStatus());
    myHgCurrentBranchStatusUpdater.activate();

    messageBusConnection = myProject.getMessageBus().connect();
    messageBusConnection.subscribe(
        FileEditorManagerListener.FILE_EDITOR_MANAGER,
        new FileEditorManagerAdapter() {
          @Override
          public void selectionChanged(FileEditorManagerEvent event) {
            Project project = event.getManager().getProject();
            project.getMessageBus().syncPublisher(BRANCH_TOPIC).update(project, null);
          }
        });

    myVFSListener = new HgVFSListener(myProject, this);

    // ignore temporary files
    final String ignoredPattern = FileTypeManager.getInstance().getIgnoredFilesList();
    if (!ignoredPattern.contains(ORIG_FILE_PATTERN)) {
      final String newPattern =
          ignoredPattern + (ignoredPattern.endsWith(";") ? "" : ";") + ORIG_FILE_PATTERN;
      HgUtil.runWriteActionLater(
          new Runnable() {
            public void run() {
              FileTypeManager.getInstance().setIgnoredFilesList(newPattern);
            }
          });
    }

    // Force a branch topic update
    myProject.getMessageBus().syncPublisher(BRANCH_TOPIC).update(myProject, null);
  }