List of usage examples for com.intellij.openapi.wm StatusBar addWidget
@Deprecated
@ApiStatus.ScheduledForRemoval
void addWidget(@NotNull StatusBarWidget widget, @NotNull Disposable parentDisposable);
From source file:com.microsoft.alm.plugin.idea.common.statusBar.StatusBarManager.java
License:Open Source License
private static void updateWidgets(final StatusBar statusBar, final Project project, final boolean allowPrompt) { // Update the build widget BuildWidget buildWidget = (BuildWidget) statusBar.getWidget(BuildWidget.getID()); if (buildWidget == null) { buildWidget = new BuildWidget(); statusBar.addWidget(buildWidget, project); }//from www. j a v a 2 s . c o m // Attempt to get the current repository context (if none, then the status stays as it was) final RepositoryContext repositoryContext = VcsHelper.getRepositoryContext(project); if (repositoryContext != null) { final BuildWidget widget = buildWidget; // Create the operation and start the background work to get the latest build information final BuildStatusLookupOperation op = OperationFactory .createBuildStatusLookupOperation(repositoryContext, allowPrompt); op.addListener(new Operation.Listener() { @Override public void notifyLookupStarted() { /* do nothing */ } @Override public void notifyLookupCompleted() { /* do nothing */ } @Override public void notifyLookupResults(final Operation.Results results) { updateBuildWidget(project, statusBar, widget, (BuildStatusLookupOperation.BuildStatusResults) results); } }); op.doWorkAsync(null); } else { // The repository hasn't been opened yet, we should get an event when it is opened } }
From source file:com.microsoft.alm.plugin.idea.statusBar.StatusBarManager.java
License:Open Source License
private static void updateWidgets(final StatusBar statusBar, final Project project, final boolean allowPrompt) { // Update the build widget BuildWidget buildWidget = (BuildWidget) statusBar.getWidget(BuildWidget.getID()); if (buildWidget == null) { buildWidget = new BuildWidget(); statusBar.addWidget(buildWidget, project); }/*from w ww.j a v a 2 s. c o m*/ // Attempt to get the current repo and branch (if none, then the status stays as it was) final GitRepository repository = GitBranchUtil.getCurrentRepository(project); if (repository != null) { final String repoUrl = TfGitHelper.getTfGitRemoteUrl(repository); if (!StringUtil.isNullOrEmpty(repoUrl)) { // It's a tf git url so continue final BuildWidget widget = buildWidget; // TODO: Fix this HACK. There doesn't seem to be a clear way to get the full name of the current branch final String branch = "refs/heads/" + GitBranchUtil.getDisplayableBranchText(repository); // Create the operation and start the background work to get the latest build information final BuildStatusLookupOperation op = new BuildStatusLookupOperation(repoUrl, branch, allowPrompt); op.addListener(new Operation.Listener() { @Override public void notifyLookupStarted() { /* do nothing */ } @Override public void notifyLookupCompleted() { /* do nothing */ } @Override public void notifyLookupResults(final Operation.Results results) { updateBuildWidget(project, statusBar, widget, (BuildStatusLookupOperation.BuildStatusResults) results); } }); op.doWorkAsync(null); } } else { // The repository hasn't been opened yet, so try again quickly timer.setInitialDelay(MIN_TIMER_DELAY); timer.restart(); } }
From source file:limitedwip.IdeNotifications.java
License:Apache License
private void updateStatusBar() { StatusBar statusBar = statusBarFor(project); if (statusBar == null) return;//from w w w .ja v a 2 s . c o m boolean hasAutoRevertWidget = statusBar.getWidget(autoRevertWidget.ID()) != null; if (hasAutoRevertWidget && settings.autoRevertEnabled) { statusBar.updateWidget(autoRevertWidget.ID()); } else if (hasAutoRevertWidget) { statusBar.removeWidget(autoRevertWidget.ID()); } else if (settings.autoRevertEnabled) { autoRevertWidget.showStoppedText(); statusBar.addWidget(autoRevertWidget, "before Position"); statusBar.updateWidget(autoRevertWidget.ID()); } boolean hasWatchdogWidget = statusBar.getWidget(watchdogWidget.ID()) != null; boolean shouldShowWatchdog = settings.watchdogEnabled && settings.showRemainingChangesInToolbar; if (hasWatchdogWidget && shouldShowWatchdog) { statusBar.updateWidget(watchdogWidget.ID()); } else if (hasWatchdogWidget) { statusBar.removeWidget(watchdogWidget.ID()); } else if (shouldShowWatchdog) { watchdogWidget.showInitialText(settings.maxLinesInChange); statusBar.addWidget(watchdogWidget, "before Position"); statusBar.updateWidget(watchdogWidget.ID()); } }
From source file:org.zmlx.hg4idea.status.ui.HgIncomingOutgoingWidget.java
License:Apache License
@CalledInAwt public void activate() { MessageBusConnection busConnection = myProject.getMessageBus().connect(); busConnection.subscribe(HgVcs.STATUS_TOPIC, this); busConnection.subscribe(HgVcs.INCOMING_OUTGOING_CHECK_TOPIC, this); StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject); if (null != statusBar && isVisible()) { statusBar.addWidget(this, myProject); isAlreadyShown = true;/* w w w . j a v a2s .c om*/ } }
From source file:org.zmlx.hg4idea.status.ui.HgIncomingOutgoingWidget.java
License:Apache License
public void show() { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override//from www. ja v a 2 s. c om public void run() { if (isAlreadyShown) { return; } StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject); if (null != statusBar && isVisible()) { statusBar.addWidget(HgIncomingOutgoingWidget.this, myProject); isAlreadyShown = true; myProject.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, null); } } }, ModalityState.any()); }