Example usage for com.intellij.openapi.wm IdeFrame getStatusBar

List of usage examples for com.intellij.openapi.wm IdeFrame getStatusBar

Introduction

In this page you can find the example usage for com.intellij.openapi.wm IdeFrame getStatusBar.

Prototype

@Nullable
    StatusBar getStatusBar();

Source Link

Usage

From source file:com.android.tools.idea.gradle.project.sync.GradleSyncInvoker.java

License:Apache License

private static boolean isBuildInProgress(@NotNull Project project) {
    IdeFrame frame = ((WindowManagerEx) WindowManager.getInstance()).findFrameFor(project);
    StatusBarEx statusBar = frame == null ? null : (StatusBarEx) frame.getStatusBar();
    if (statusBar == null) {
        return false;
    }/*  w w w  . j a  v a2 s  . c o m*/
    for (Pair<TaskInfo, ProgressIndicator> backgroundProcess : statusBar.getBackgroundProcesses()) {
        TaskInfo task = backgroundProcess.getFirst();
        if (task instanceof GradleTasksExecutor) {
            ProgressIndicator second = backgroundProcess.getSecond();
            if (second.isRunning()) {
                return true;
            }
        }
    }
    return false;
}

From source file:com.intellij.execution.actions.StopAction.java

License:Apache License

private static List<Pair<TaskInfo, ProgressIndicator>> getCancellableProcesses(Project project) {
    IdeFrame frame = ((WindowManagerEx) WindowManager.getInstance()).findFrameFor(project);
    StatusBarEx statusBar = frame == null ? null : (StatusBarEx) frame.getStatusBar();
    if (statusBar == null)
        return Collections.emptyList();

    return ContainerUtil.findAll(statusBar.getBackgroundProcesses(),
            new Condition<Pair<TaskInfo, ProgressIndicator>>() {
                @Override/*ww  w . j  a v a 2s . co  m*/
                public boolean value(Pair<TaskInfo, ProgressIndicator> pair) {
                    return pair.first.isCancellable() && !pair.second.isCanceled();
                }
            });
}

From source file:com.intellij.ide.actionMacro.ActionMacroManager.java

License:Apache License

private void playbackMacro(ActionMacro macro) {
    final IdeFrame frame = WindowManager.getInstance().getIdeFrame(null);
    assert frame != null;

    StringBuffer script = new StringBuffer();
    ActionMacro.ActionDescriptor[] actions = macro.getActions();
    for (ActionMacro.ActionDescriptor each : actions) {
        each.generateTo(script);// w  ww .j a  va 2  s  . c o  m
    }

    final PlaybackRunner runner = new PlaybackRunner(script.toString(),
            new PlaybackRunner.StatusCallback.Edt() {

                public void messageEdt(PlaybackContext context, String text, Type type) {
                    if (type == Type.message || type == Type.error) {
                        if (context != null) {
                            frame.getStatusBar().setInfo("Line " + context.getCurrentLine() + ": " + text);
                        } else {
                            frame.getStatusBar().setInfo(text);
                        }
                    }
                }
            }, Registry.is("actionSystem.playback.useDirectActionCall"), true,
            Registry.is("actionSystem.playback.useTypingTargets"));

    myIsPlaying = true;

    runner.run().doWhenDone(new Runnable() {
        public void run() {
            frame.getStatusBar().setInfo("Script execution finished");
        }
    }).doWhenProcessed(new Runnable() {
        public void run() {
            myIsPlaying = false;
        }
    });
}

From source file:com.intellij.refactoring.rename.RenameProcessor.java

License:Apache License

@Override
public void performRefactoring(UsageInfo[] usages) {
    final int[] choice = myAllRenames.size() > 1 ? new int[] { -1 } : null;
    String message = null;/*from  w w  w  . ja va  2 s .  co m*/
    try {
        for (Iterator<Map.Entry<PsiElement, String>> iterator = myAllRenames.entrySet().iterator(); iterator
                .hasNext();) {
            Map.Entry<PsiElement, String> entry = iterator.next();
            if (entry.getKey() instanceof PsiFile) {
                final PsiFile file = (PsiFile) entry.getKey();
                final PsiDirectory containingDirectory = file.getContainingDirectory();
                if (CopyFilesOrDirectoriesHandler.checkFileExist(containingDirectory, choice, file,
                        entry.getValue(), "Rename")) {
                    iterator.remove();
                    continue;
                }
            }
            RenameUtil.checkRename(entry.getKey(), entry.getValue());
        }
    } catch (IncorrectOperationException e) {
        message = e.getMessage();
    }

    if (message != null) {
        CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("rename.title"), message, getHelpID(),
                myProject);
        return;
    }

    List<Runnable> postRenameCallbacks = new ArrayList<Runnable>();

    final MultiMap<PsiElement, UsageInfo> classified = classifyUsages(myAllRenames.keySet(), usages);
    for (final PsiElement element : myAllRenames.keySet()) {
        String newName = myAllRenames.get(element);

        final RefactoringElementListener elementListener = getTransaction().getElementListener(element);
        final RenamePsiElementProcessor renamePsiElementProcessor = RenamePsiElementProcessor
                .forElement(element);
        Runnable postRenameCallback = renamePsiElementProcessor.getPostRenameCallback(element, newName,
                elementListener);
        final Collection<UsageInfo> infos = classified.get(element);
        try {
            RenameUtil.doRename(element, newName, infos.toArray(new UsageInfo[infos.size()]), myProject,
                    elementListener);
        } catch (final IncorrectOperationException e) {
            RenameUtil.showErrorMessage(e, element, myProject);
            return;
        }
        if (postRenameCallback != null) {
            postRenameCallbacks.add(postRenameCallback);
        }
    }

    for (Runnable runnable : postRenameCallbacks) {
        runnable.run();
    }

    List<NonCodeUsageInfo> nonCodeUsages = new ArrayList<NonCodeUsageInfo>();
    for (UsageInfo usage : usages) {
        if (usage instanceof NonCodeUsageInfo) {
            nonCodeUsages.add((NonCodeUsageInfo) usage);
        }
    }
    myNonCodeUsages = nonCodeUsages.toArray(new NonCodeUsageInfo[nonCodeUsages.size()]);
    if (!mySkippedUsages.isEmpty()) {
        if (!ApplicationManager.getApplication().isUnitTestMode()
                && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    final IdeFrame ideFrame = WindowManager.getInstance().getIdeFrame(myProject);
                    if (ideFrame != null) {

                        StatusBarEx statusBar = (StatusBarEx) ideFrame.getStatusBar();
                        HyperlinkListener listener = new HyperlinkListener() {
                            @Override
                            public void hyperlinkUpdate(HyperlinkEvent e) {
                                if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
                                    return;
                                Messages.showMessageDialog("<html>Following usages were safely skipped:<br>"
                                        + StringUtil.join(mySkippedUsages,
                                                new Function<UnresolvableCollisionUsageInfo, String>() {
                                                    @Override
                                                    public String fun(
                                                            UnresolvableCollisionUsageInfo unresolvableCollisionUsageInfo) {
                                                        return unresolvableCollisionUsageInfo.getDescription();
                                                    }
                                                }, "<br>")
                                        + "</html>", "Not All Usages Were Renamed", null);
                            }
                        };
                        statusBar.notifyProgressByBalloon(MessageType.WARNING,
                                "<html><body>Unable to rename certain usages. <a href=\"\">Browse</a></body></html>",
                                null, listener);
                    }
                }
            }, ModalityState.NON_MODAL);
        }
    }
}