Search in sources :

Example 1 with WindowManager

use of com.intellij.openapi.wm.WindowManager in project intellij-community by JetBrains.

the class StatusBarProgress method start.

@Override
public void start() {
    super.start();
    //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 = notNull(statusBar.getInfo(), "");
                // initial value
                myStatusBar2SavedText.put(statusBar, pair(info, info));
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) StatusBar(com.intellij.openapi.wm.StatusBar) WindowManager(com.intellij.openapi.wm.WindowManager)

Example 2 with WindowManager

use of com.intellij.openapi.wm.WindowManager in project intellij-community by JetBrains.

the class RefreshProgress method updateIndicators.

private void updateIndicators(final boolean start) {
    // wrapping in invokeLater here reduces the number of events posted to EDT in case of multiple IDE frames
    UIUtil.invokeLaterIfNeeded(() -> {
        if (ApplicationManager.getApplication().isDisposed())
            return;
        WindowManager windowManager = WindowManager.getInstance();
        if (windowManager == null)
            return;
        Project[] projects = ProjectManager.getInstance().getOpenProjects();
        if (projects.length == 0)
            projects = NULL_ARRAY;
        for (Project project : projects) {
            StatusBarEx statusBar = (StatusBarEx) windowManager.getStatusBar(project);
            if (statusBar != null) {
                if (start) {
                    statusBar.startRefreshIndication(myMessage);
                } else {
                    statusBar.stopRefreshIndication();
                }
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) StatusBarEx(com.intellij.openapi.wm.ex.StatusBarEx) WindowManager(com.intellij.openapi.wm.WindowManager)

Example 3 with WindowManager

use of com.intellij.openapi.wm.WindowManager in project intellij-community by JetBrains.

the class HighlightUtil method highlightElements.

public static void highlightElements(@NotNull final Collection<? extends PsiElement> elementCollection, @NotNull final String statusBarText) {
    if (elementCollection.isEmpty()) {
        return;
    }
    final Application application = ApplicationManager.getApplication();
    application.invokeLater(() -> {
        final PsiElement[] elements = PsiUtilCore.toPsiElementArray(elementCollection);
        final PsiElement firstElement = elements[0];
        if (!firstElement.isValid()) {
            return;
        }
        final Project project = firstElement.getProject();
        final FileEditorManager editorManager = FileEditorManager.getInstance(project);
        final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
        final Editor editor = editorManager.getSelectedTextEditor();
        if (editor == null) {
            return;
        }
        final EditorColorsScheme globalScheme = editorColorsManager.getGlobalScheme();
        final TextAttributes textattributes = globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        final HighlightManager highlightManager = HighlightManager.getInstance(project);
        highlightManager.addOccurrenceHighlights(editor, elements, textattributes, true, null);
        final FindManager findmanager = FindManager.getInstance(project);
        FindModel findmodel = findmanager.getFindNextModel();
        if (findmodel == null) {
            findmodel = findmanager.getFindInFileModel();
        }
        findmodel.setSearchHighlighters(true);
        findmanager.setFindWasPerformed();
        findmanager.setFindNextModel(findmodel);
        application.invokeLater(() -> {
            final WindowManager windowManager = WindowManager.getInstance();
            final StatusBar statusBar = windowManager.getStatusBar(project);
            if (statusBar != null) {
                statusBar.setInfo(statusBarText);
            }
        });
    });
}
Also used : FindModel(com.intellij.find.FindModel) HighlightManager(com.intellij.codeInsight.highlighting.HighlightManager) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) StatusBar(com.intellij.openapi.wm.StatusBar) WindowManager(com.intellij.openapi.wm.WindowManager) Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FindManager(com.intellij.find.FindManager) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) Editor(com.intellij.openapi.editor.Editor) Application(com.intellij.openapi.application.Application) PsiElement(com.intellij.psi.PsiElement)

Example 4 with WindowManager

use of com.intellij.openapi.wm.WindowManager in project intellij-community by JetBrains.

the class HighlightUtils method highlightElements.

public static void highlightElements(@NotNull final Collection<? extends PsiElement> elementCollection) {
    if (elementCollection.isEmpty()) {
        return;
    }
    if (elementCollection.contains(null)) {
        throw new IllegalArgumentException("Nulls passed in collection: " + elementCollection);
    }
    final Application application = ApplicationManager.getApplication();
    application.invokeLater(() -> {
        final PsiElement[] elements = PsiUtilCore.toPsiElementArray(elementCollection);
        final PsiElement firstElement = elements[0];
        if (ContainerUtil.exists(elements, element -> !element.isValid())) {
            return;
        }
        final Project project = firstElement.getProject();
        if (project.isDisposed())
            return;
        final FileEditorManager editorManager = FileEditorManager.getInstance(project);
        final EditorColorsManager editorColorsManager = EditorColorsManager.getInstance();
        final Editor editor = editorManager.getSelectedTextEditor();
        if (editor == null) {
            return;
        }
        final EditorColorsScheme globalScheme = editorColorsManager.getGlobalScheme();
        final TextAttributes textattributes = globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
        final HighlightManager highlightManager = HighlightManager.getInstance(project);
        highlightManager.addOccurrenceHighlights(editor, elements, textattributes, true, null);
        final WindowManager windowManager = WindowManager.getInstance();
        final StatusBar statusBar = windowManager.getStatusBar(project);
        statusBar.setInfo(InspectionGadgetsBundle.message("press.escape.to.remove.highlighting.message"));
        final FindManager findmanager = FindManager.getInstance(project);
        FindModel findmodel = findmanager.getFindNextModel();
        if (findmodel == null) {
            findmodel = findmanager.getFindInFileModel();
        }
        findmodel.setSearchHighlighters(true);
        findmanager.setFindWasPerformed();
        findmanager.setFindNextModel(findmodel);
    });
}
Also used : FindModel(com.intellij.find.FindModel) HighlightManager(com.intellij.codeInsight.highlighting.HighlightManager) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) StatusBar(com.intellij.openapi.wm.StatusBar) WindowManager(com.intellij.openapi.wm.WindowManager) Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FindManager(com.intellij.find.FindManager) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) Editor(com.intellij.openapi.editor.Editor) Application(com.intellij.openapi.application.Application) PsiElement(com.intellij.psi.PsiElement)

Example 5 with WindowManager

use of com.intellij.openapi.wm.WindowManager in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudSdkServiceManager method openBackgroundProcessWindow.

/**
 * Exposes process window so that installation / dependent processes are explicitly visible.
 */
private void openBackgroundProcessWindow(Project project) {
    WindowManager windowManager = WindowManager.getInstance();
    StatusBar statusBar = windowManager.getStatusBar(project);
    if (statusBar != null && statusBar instanceof StatusBarEx) {
        ((StatusBarEx) statusBar).setProcessWindowOpen(true);
    }
}
Also used : StatusBar(com.intellij.openapi.wm.StatusBar) StatusBarEx(com.intellij.openapi.wm.ex.StatusBarEx) WindowManager(com.intellij.openapi.wm.WindowManager)

Aggregations

WindowManager (com.intellij.openapi.wm.WindowManager)5 Project (com.intellij.openapi.project.Project)4 StatusBar (com.intellij.openapi.wm.StatusBar)4 HighlightManager (com.intellij.codeInsight.highlighting.HighlightManager)2 FindManager (com.intellij.find.FindManager)2 FindModel (com.intellij.find.FindModel)2 Application (com.intellij.openapi.application.Application)2 Editor (com.intellij.openapi.editor.Editor)2 EditorColorsManager (com.intellij.openapi.editor.colors.EditorColorsManager)2 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)2 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)2 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 StatusBarEx (com.intellij.openapi.wm.ex.StatusBarEx)2 PsiElement (com.intellij.psi.PsiElement)2