com.intellij.openapi.wm.StatusBar Java Examples

The following examples show how to use com.intellij.openapi.wm.StatusBar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Symfony2ProjectComponent.java    From idea-php-symfony2-plugin with MIT License 7 votes vote down vote up
public void projectOpened() {
    this.checkProject();

    // attach toolbar popup (right bottom)
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(this.project);
    if(statusBar == null) {
        return;
    }

    // clean bar on project open; we can have multiple projects att some time
    if(statusBar.getWidget(SymfonyProfilerWidget.ID) != null) {
        statusBar.removeWidget(SymfonyProfilerWidget.ID);
    }

    if(isEnabled()) {
        SymfonyProfilerWidget symfonyProfilerWidget = new SymfonyProfilerWidget(this.project);
        statusBar.addWidget(symfonyProfilerWidget);
    }

}
 
Example #2
Source File: GTMProject.java    From gtm-jetbrains-plugin with MIT License 6 votes vote down vote up
private void installGtmWidget() {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
    if (statusBar != null) {
        statusBar.addWidget(myStatusWidget, myProject);
        myStatusWidget.installed();
        if (!GTMRecord.initGtmExePath()) {
            JBPopupFactory.getInstance()
                    .createHtmlTextBalloonBuilder(GTMConfig.getInstance().gtmNotFound, ERROR, null)
                    .setFadeoutTime(30000)
                    .createBalloon()
                    .show(RelativePoint.getSouthEastOf(statusBar.getComponent()),
                            Balloon.Position.atRight);
            return;
        }
        if (!GTMRecord.checkVersion()) {
            JBPopupFactory.getInstance()
                    .createHtmlTextBalloonBuilder(GTMConfig.getInstance().gtmVerOutdated, WARNING, null)
                    .setFadeoutTime(30000)
                    .createBalloon()
                    .show(RelativePoint.getSouthEastOf(statusBar.getComponent()),
                            Balloon.Position.atRight);
        }
    }
}
 
Example #3
Source File: HighlightingUtil.java    From needsmoredojo with Apache License 2.0 6 votes vote down vote up
public static void highlightElement(Editor editor, @NotNull com.intellij.openapi.project.Project project, @NotNull PsiElement[] elements)
{
    final HighlightManager highlightManager =
            HighlightManager.getInstance(project);
    final EditorColorsManager editorColorsManager =
            EditorColorsManager.getInstance();
    final EditorColorsScheme globalScheme =
            editorColorsManager.getGlobalScheme();
    final TextAttributes textattributes =
            globalScheme.getAttributes(
                    EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES);

    highlightManager.addOccurrenceHighlights(
            editor, elements, textattributes, true, null);
    final WindowManager windowManager = WindowManager.getInstance();
    final StatusBar statusBar = windowManager.getStatusBar(project);
    statusBar.setInfo("Press Esc to remove highlighting");
}
 
Example #4
Source File: DesktopWindowManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public StatusBar getStatusBar(@Nonnull Component c, @Nullable Project project) {
  Component parent = UIUtil.findUltimateParent(c);
  if (parent instanceof Window) {
    consulo.ui.Window uiWindow = TargetAWT.from((Window)parent);

    IdeFrame ideFrame = uiWindow.getUserData(IdeFrame.KEY);
    if(ideFrame != null) {
      return ideFrame.getStatusBar().findChild(c);
    }
  }

  IdeFrame frame = findFrameFor(project);
  if (frame != null) {
    return frame.getStatusBar().findChild(c);
  }

  assert false : "Cannot find status bar for " + c;

  return null;
}
 
Example #5
Source File: LineEndingsManager.java    From editorconfig-jetbrains with MIT License 6 votes vote down vote up
private void updateStatusBar() {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            IdeFrame frame = WindowManager.getInstance().getIdeFrame(project);
            StatusBar statusBar = frame.getStatusBar();
            StatusBarWidget widget = statusBar != null ? statusBar.getWidget("LineSeparator") : null;

            if (widget instanceof LineSeparatorPanel) {
                FileEditorManagerEvent event = new FileEditorManagerEvent(FileEditorManager.getInstance(project),
                                                                          null, null, null, null);
                ((LineSeparatorPanel)widget).selectionChanged(event);
            }
        }
    });
}
 
Example #6
Source File: Flog.java    From floobits-intellij with Apache License 2.0 6 votes vote down vote up
public static void flashMessage(final String message, final Project project) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                public void run() {
                    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
                    if (statusBar == null) {
                        return;
                    }
                    JLabel jLabel = new JLabel(message);
                    statusBar.fireNotificationPopup(jLabel, JBColor.WHITE);
                }
            });
        }
    });
}
 
Example #7
Source File: LSPServerStatusWidget.java    From lsp4intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a widget given a LanguageServerWrapper and adds it to the status bar
 *
 * @param wrapper The wrapper
 * @return The widget
 */
public static LSPServerStatusWidget createWidgetFor(LanguageServerWrapper wrapper) {
    LSPServerStatusWidget widget = new LSPServerStatusWidget(wrapper);
    Project project = wrapper.getProject();
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    if (widgetIDs.get(project) == null || widgetIDs.get(project).isEmpty()) {
        ArrayList<String> list = new ArrayList<>();
        list.add("Position");
        widgetIDs.put(project, list);
    }

    statusBar.addWidget(widget, "before " + widgetIDs.get(project).get(0));
    widgetIDs.get(project).add(0, widget.ID());
    return widget;
}
 
Example #8
Source File: EditorBasedStatusBarPopup.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void install(@Nonnull StatusBar statusBar) {
  super.install(statusBar);
  registerCustomListeners();
  EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentListener() {
    @Override
    public void documentChanged(@Nonnull DocumentEvent e) {
      Document document = e.getDocument();
      updateForDocument(document);
    }
  }, this);
  if (myWriteableFileRequired) {
    ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new VirtualFileListener() {
      @Override
      public void propertyChanged(@Nonnull VirtualFilePropertyEvent event) {
        if (VirtualFile.PROP_WRITABLE.equals(event.getPropertyName())) {
          updateForFile(event.getFile());
        }
      }
    }));
  }
}
 
Example #9
Source File: ToggleReadOnlyAttributePanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void install(@Nonnull StatusBar statusBar) {
  myStatusBar = statusBar;
  Project project = statusBar.getProject();
  if (project == null) {
    return;
  }

  project.getMessageBus().connect(this).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
    @Override
    public void selectionChanged(@Nonnull FileEditorManagerEvent event) {
      if (myStatusBar != null) {
        myStatusBar.updateWidget(ID());
      }
    }
  });
}
 
Example #10
Source File: DvcsStatusWidget.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void installWidgetToStatusBar(@Nonnull final Project project, @Nonnull final StatusBarWidget widget) {
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
      if (statusBar != null && !isDisposed()) {
        statusBar.addWidget(widget, "after " + (SystemInfo.isMac ? "Encoding" : "InsertOverwrite"), project);
        subscribeToMappingChanged();
        subscribeToRepoChangeEvents(project);
        update();
      }
    }
  });
}
 
Example #11
Source File: DvcsStatusWidget.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void removeWidgetFromStatusBar(@Nonnull final Project project, @Nonnull final StatusBarWidget widget) {
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
      if (statusBar != null && !isDisposed()) {
        statusBar.removeWidget(widget.ID());
      }
    }
  });
}
 
Example #12
Source File: LSPServerStatusWidget.java    From lsp4intellij with Apache License 2.0 5 votes vote down vote up
private void updateWidget() {
    WindowManager manager = WindowManager.getInstance();
    if (manager != null && project != null && !project.isDisposed()) {
        StatusBar statusBar = manager.getStatusBar(project);
        if (statusBar != null) {
            statusBar.updateWidget(ID());
        }
    }
}
 
Example #13
Source File: SynchronizeCurrentFileAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  final Project project = getEventProject(e);
  final VirtualFile[] files = getFiles(e);
  if (project == null || files == null || files.length == 0) return;

  CallChain.first(UIAccess.current()).linkWrite(() -> {
    for (VirtualFile file : files) {
      final VirtualFileSystem fs = file.getFileSystem();
      if (fs instanceof LocalFileSystem && file instanceof NewVirtualFile) {
        ((NewVirtualFile)file).markDirtyRecursively();
      }
    }
  }).linkUI(() -> {
    final Runnable postRefreshAction = () -> {
      final VcsDirtyScopeManager dirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
      for (VirtualFile f : files) {
        if (f.isDirectory()) {
          dirtyScopeManager.dirDirtyRecursively(f);
        }
        else {
          dirtyScopeManager.fileDirty(f);
        }
      }

      final StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
      if (statusBar != null) {
        final String message = IdeBundle.message("action.sync.completed.successfully", getMessage(files));
        statusBar.setInfo(message);
      }
    };

    RefreshQueue.getInstance().refresh(true, true, postRefreshAction, files);
  }).toss();
}
 
Example #14
Source File: Toast.java    From GsonFormat with Apache License 2.0 5 votes vote down vote up
/**
 * Display simple notification of given type
 *
 * @param project
 * @param type
 * @param text
 */
public static void make(Project project, MessageType type, String text) {

    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, type, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
}
 
Example #15
Source File: ActionMacroManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private Widget(StatusBar statusBar) {
  myStatusBar = statusBar;
  myPresentation = new WidgetPresentation() {
    @Override
    public String getTooltipText() {
      return "Macro is being recorded now";
    }

    @Override
    public Consumer<MouseEvent> getClickConsumer() {
      return Widget.this;
    }
  };


  new BaseButtonBehavior(myIcon) {
    @Override
    protected void execute(MouseEvent e) {
      showBalloon();
    }
  };

  myBalloonComponent = new NonOpaquePanel(new BorderLayout());

  final AnAction stopAction = ActionManager.getInstance().getAction("StartStopMacroRecording");
  final DefaultActionGroup group = new DefaultActionGroup();
  group.add(stopAction);
  final ActionToolbar tb = ActionManager.getInstance().createActionToolbar(ActionPlaces.STATUS_BAR_PLACE, group, true);
  tb.setMiniMode(true);

  final NonOpaquePanel top = new NonOpaquePanel(new BorderLayout());
  top.add(tb.getComponent(), BorderLayout.WEST);
  myText = new JLabel(RECORDED + "..." + TYPING_SAMPLE, SwingConstants.LEFT);
  final Dimension preferredSize = myText.getPreferredSize();
  myText.setPreferredSize(preferredSize);
  myText.setText("Macro recording started...");
  myLastTyping = "";
  top.add(myText, BorderLayout.CENTER);
  myBalloonComponent.add(top, BorderLayout.CENTER);
}
 
Example #16
Source File: VcsUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Shows message in the status bar.
 *
 * @param project Current project component
 * @param message information message
 */
public static void showStatusMessage(final Project project, final String message) {
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      if (project.isOpen()) {
        StatusBar.Info.set(message, project);
      }
    }
  });
}
 
Example #17
Source File: GTMProject.java    From gtm-jetbrains-plugin with MIT License 5 votes vote down vote up
private void uninstallGtmWidget() {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
    if (statusBar != null) {
        statusBar.removeWidget(myStatusWidget.ID());
        myStatusWidget.uninstalled();
    }

}
 
Example #18
Source File: ActionMacroManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void startRecording(String macroName) {
  LOG.assertTrue(!myIsRecording);
  myIsRecording = true;
  myRecordingMacro = new ActionMacro(macroName);

  final StatusBar statusBar = WindowManager.getInstance().getIdeFrame(null).getStatusBar();
  myWidget = new Widget(statusBar);
  statusBar.addWidget(myWidget);
}
 
Example #19
Source File: UsageViewUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean reportNonRegularUsages(UsageInfo[] usages, final Project project) {
  boolean inGeneratedCode = hasUsagesInGeneratedCode(usages, project);
  if (hasNonCodeUsages(usages) || inGeneratedCode) {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
    if (statusBar != null) {
      statusBar.setInfo(inGeneratedCode ? RefactoringBundle.message("occurrences.found.in.comments.strings.non.java.files.and.generated.code")
                                        : RefactoringBundle.message("occurrences.found.in.comments.strings.and.non.java.files"));
    }
    return true;
  }
  return false;
}
 
Example #20
Source File: LombokProjectValidatorActivity.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void enableAnnotations(Project project) {
  getCompilerConfiguration(project).getDefaultProcessorProfile().setEnabled(true);

  StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
  JBPopupFactory.getInstance()
    .createHtmlTextBalloonBuilder(
      "Java annotation processing has been enabled",
      MessageType.INFO,
      null
    )
    .setFadeoutTime(3000)
    .createBalloon()
    .show(RelativePoint.getNorthEastOf(statusBar.getComponent()), Balloon.Position.atRight);
}
 
Example #21
Source File: SvnToolBoxProject.java    From SVNToolBox with Apache License 2.0 5 votes vote down vote up
@Override
public void projectOpened() {
    if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
        myBranchWidget = new SvnBranchWidget(myProject);
        StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
        if (statusBar != null) {
            statusBar.addWidget(myBranchWidget, myProject);
        }
    }
    LOG.debug("Project opened");
}
 
Example #22
Source File: SvnToolBoxProject.java    From SVNToolBox with Apache License 2.0 5 votes vote down vote up
@Override
public void projectClosed() {
    if (myBranchWidget != null && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
        StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
        if (statusBar != null) {
            statusBar.removeWidget(myBranchWidget.ID());
        }
    }
    LOG.debug("Project closed");
}
 
Example #23
Source File: Utils.java    From android-butterknife-zelezny with Apache License 2.0 5 votes vote down vote up
/**
 * Display simple notification of given type
 *
 * @param project
 * @param type
 * @param text
 */
public static void showNotification(Project project, MessageType type, String text) {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, type, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
}
 
Example #24
Source File: ActionMenu.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void showDescriptionInStatusBar(boolean isIncluded, Component component, String description) {
  IdeFrame ideFrame = null;
  if (component instanceof Window) {
    ideFrame = TargetAWT.from((Window)component).getUserData(IdeFrame.KEY);
  }

  if (ideFrame == null) {
    ideFrame = DesktopIdeFrameUtil.findIdeFrameFromParent(component);
  }

  StatusBar statusBar;
  if (ideFrame != null && (statusBar = ideFrame.getStatusBar()) != null) {
    statusBar.setInfo(isIncluded ? description : null);
  }
}
 
Example #25
Source File: StatusBarProgress.java    From consulo with Apache License 2.0 5 votes vote down vote up
private String updateRestoreText(StatusBar statusBar) {
  Pair<String, String> textsPair = myStatusBar2SavedText.get(statusBar);
  // if current status bar info doesn't match the value, that we set, use this value as a restore value
  String info = ObjectUtil.notNull(statusBar.getInfo(), "");
  if (!textsPair.getSecond().equals(info)) {
    myStatusBar2SavedText.put(statusBar, pair(info, textsPair.second));
  }
  return textsPair.getFirst();
}
 
Example #26
Source File: StatusBarProgress.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void update() {
  String text;
  if (!isRunning()) {
    text = "";
  }
  else {
    text = getText();
    double fraction = getFraction();
    if (fraction > 0) {
      text += " " + (int)(fraction * 100 + 0.5) + "%";
    }
  }
  final String _text = text;
  if (!myScheduledStatusBarTextSave) {
    myScheduledStatusBarTextSave = true;
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(() -> {
      if (ApplicationManager.getApplication().isDisposed()) return;
      WindowManager windowManager = WindowManager.getInstance();
      if (windowManager == null) return;

      Project[] projects = ProjectManager.getInstance().getOpenProjects();
      if (projects.length == 0) projects = new Project[]{null};

      for (Project project : projects) {
        StatusBar statusBar = windowManager.getStatusBar(project);
        if (statusBar != null) {
          String info = ObjectUtil.notNull(statusBar.getInfo(), "");
          myStatusBar2SavedText.put(statusBar, pair(info, info));  // initial value
        }
      }
    });
  }
  //noinspection SSBasedInspection
  SwingUtilities.invokeLater(() -> {
    for (StatusBar statusBarEx : myStatusBar2SavedText.keySet()) {
      setStatusBarText(statusBarEx, _text);
    }
  });
}
 
Example #27
Source File: ProcessTerminatedListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void processTerminated(ProcessEvent event) {
  final ProcessHandler processHandler = event.getProcessHandler();
  processHandler.removeProcessListener(this);
  final String message = myProcessFinishedMessage.replaceAll(EXIT_CODE_REGEX, String.valueOf(event.getExitCode()));
  processHandler.notifyTextAvailable(message, ProcessOutputTypes.SYSTEM);
  if (myProject != null) ApplicationManager.getApplication().invokeLater(new Runnable(){
    public void run() {
      if (myProject.isDisposed()) return;
      StatusBar.Info.set(message, myProject);
    }
  });
}
 
Example #28
Source File: LinkLabel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void setStatusBarText(String statusBarText) {
  if (ApplicationManager.getApplication() == null) return; // makes this component work in UIDesigner preview.
  final Project[] projects = ProjectManager.getInstance().getOpenProjects();
  for (Project project : projects) {
    StatusBar.Info.set(statusBarText, project);
  }
}
 
Example #29
Source File: StatusBarProgress.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() {
  super.stop();

  if (myScheduledStatusBarTextSave) {
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(() -> {
      for (StatusBar statusBar : myStatusBar2SavedText.keySet()) {
        String textToRestore = updateRestoreText(statusBar);
        statusBar.setInfo(textToRestore);
      }
      myStatusBar2SavedText.clear();
    });
  }
}
 
Example #30
Source File: PositionPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void install(@Nonnull StatusBar statusBar) {
  super.install(statusBar);
  myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this);
  EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
  multicaster.addCaretListener(this, this);
  multicaster.addSelectionListener(this, this);
  multicaster.addDocumentListener(this, this);
  KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(SWING_FOCUS_OWNER_PROPERTY, this);
  Disposer.register(this, () -> KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(SWING_FOCUS_OWNER_PROPERTY, this));
}