Пример #1
0
  @Override
  public void deactivate() {
    if (null != myHgRemoteStatusUpdater) {
      myHgRemoteStatusUpdater.deactivate();
      myHgRemoteStatusUpdater = null;
    }
    if (null != myHgCurrentBranchStatusUpdater) {
      myHgCurrentBranchStatusUpdater.deactivate();
      myHgCurrentBranchStatusUpdater = null;
    }
    if (null != myStatusWidget) {
      myStatusWidget.deactivate();
      myStatusWidget = null;
    }
    if (null != myIncomingWidget) {
      myIncomingWidget.deactivate();
      myIncomingWidget = null;
    }
    if (null != myOutgoingWidget) {
      myOutgoingWidget.deactivate();
      myOutgoingWidget = null;
    }
    if (messageBusConnection != null) {
      messageBusConnection.disconnect();
    }

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

    super.deactivate();
  }
Пример #2
0
  @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);
  }