Search in sources :

Example 31 with IdeFrame

use of com.intellij.openapi.wm.IdeFrame in project intellij-plugins by JetBrains.

the class DocumentProblemManager method report.

// Notification.notify is not suitable for us -
// 1) it is not suitable for content with <ul> tags (due to <p> around message, see NotificationsUtil.buildHtml)
// 2) it is buggy - balloon disappeared while user selects message text
// 3) in any case, event log cannot show our message, may be due to <ul> tags?
// todo fix platform Notification impl or how use it correctly?
public void report(@Nullable final Project project, String message, MessageType messageType) {
    //Notification notification = new Notification(FlashUIDesignerBundle.message("plugin.name"),
    //  title == null ? FlashUIDesignerBundle.message("plugin.name") : title, message, NotificationType.ERROR);
    //notification.notify(project);
    final Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType, BrowserHyperlinkListener.INSTANCE).setShowCallout(false).setHideOnAction(false).createBalloon();
    ApplicationManager.getApplication().invokeLater(() -> {
        Window window = WindowManager.getInstance().getFrame(project);
        if (window == null) {
            window = JOptionPane.getRootFrame();
        }
        if (window instanceof IdeFrame) {
            BalloonLayout layout = ((IdeFrame) window).getBalloonLayout();
            if (layout != null) {
                layout.add(balloon);
            }
        }
    });
}
Also used : BalloonLayout(com.intellij.ui.BalloonLayout) Balloon(com.intellij.openapi.ui.popup.Balloon) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 32 with IdeFrame

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

the class ActionMacroManager method playbackMacro.

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);
    }
    final PlaybackRunner runner = new PlaybackRunner(script.toString(), new PlaybackRunner.StatusCallback.Edt() {

        @Override
        public void messageEdt(PlaybackContext context, String text, Type type) {
            if (type == Type.message || type == Type.error) {
                StatusBar statusBar = frame.getStatusBar();
                if (statusBar != null) {
                    if (context != null) {
                        text = "Line " + context.getCurrentLine() + ": " + text;
                    }
                    statusBar.setInfo(text);
                }
            }
        }
    }, Registry.is("actionSystem.playback.useDirectActionCall"), true, Registry.is("actionSystem.playback.useTypingTargets"));
    myIsPlaying = true;
    runner.run().doWhenDone(() -> {
        StatusBar statusBar = frame.getStatusBar();
        statusBar.setInfo("Script execution finished");
    }).doWhenProcessed(() -> myIsPlaying = false);
}
Also used : PlaybackRunner(com.intellij.openapi.ui.playback.PlaybackRunner) IdeFrame(com.intellij.openapi.wm.IdeFrame) StatusBar(com.intellij.openapi.wm.StatusBar) PlaybackContext(com.intellij.openapi.ui.playback.PlaybackContext)

Example 33 with IdeFrame

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

the class IdeEventQueue method storeLastFocusedComponent.

private static void storeLastFocusedComponent(@NotNull WindowEvent we) {
    final Window eventWindow = we.getWindow();
    if (we.getID() == WindowEvent.WINDOW_DEACTIVATED || we.getID() == WindowEvent.WINDOW_LOST_FOCUS) {
        Component frame = UIUtil.findUltimateParent(eventWindow);
        Component focusOwnerInDeactivatedWindow = eventWindow.getMostRecentFocusOwner();
        IdeFrame[] allProjectFrames = WindowManager.getInstance().getAllProjectFrames();
        if (focusOwnerInDeactivatedWindow != null) {
            for (IdeFrame ideFrame : allProjectFrames) {
                JFrame aFrame = WindowManager.getInstance().getFrame(ideFrame.getProject());
                if (aFrame.equals(frame)) {
                    IdeFocusManager focusManager = IdeFocusManager.getGlobalInstance();
                    if (focusManager instanceof FocusManagerImpl) {
                        ((FocusManagerImpl) focusManager).setLastFocusedAtDeactivation(ideFrame, focusOwnerInDeactivatedWindow);
                    }
                }
            }
        }
    }
}
Also used : FocusManagerImpl(com.intellij.openapi.wm.impl.FocusManagerImpl) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 34 with IdeFrame

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

the class ApplicationActivationStateManager method setActive.

private static boolean setActive(Application application, Window window) {
    IdeFrame ideFrame = getIdeFrameFromWindow(window);
    state = State.ACTIVE;
    LOG.debug("The app is in the active state");
    if (ideFrame != null) {
        application.getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC).applicationActivated(ideFrame);
        return true;
    }
    return false;
}
Also used : IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 35 with IdeFrame

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

the class CommandLineProcessor method findBestProject.

@NotNull
private static Project findBestProject(VirtualFile virtualFile, Project[] projects) {
    for (Project aProject : projects) {
        if (ProjectRootManager.getInstance(aProject).getFileIndex().isInContent(virtualFile)) {
            return aProject;
        }
    }
    IdeFrame frame = IdeFocusManager.getGlobalInstance().getLastFocusedFrame();
    Project project = frame == null ? null : frame.getProject();
    return project != null ? project : projects[0];
}
Also used : Project(com.intellij.openapi.project.Project) IdeFrame(com.intellij.openapi.wm.IdeFrame) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IdeFrame (com.intellij.openapi.wm.IdeFrame)49 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)7 Balloon (com.intellij.openapi.ui.popup.Balloon)5 IdeFocusManager (com.intellij.openapi.wm.IdeFocusManager)5 NotNull (org.jetbrains.annotations.NotNull)5 ProgressManager (com.intellij.openapi.progress.ProgressManager)4 MessageType (com.intellij.openapi.ui.MessageType)3 StatusBarEx (com.intellij.openapi.wm.ex.StatusBarEx)3 IdeFrameImpl (com.intellij.openapi.wm.impl.IdeFrameImpl)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 HyperlinkEvent (javax.swing.event.HyperlinkEvent)3 Application (com.intellij.openapi.application.Application)2 ApplicationActivationListener (com.intellij.openapi.application.ApplicationActivationListener)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 ModalityState (com.intellij.openapi.application.ModalityState)2 Extensions (com.intellij.openapi.extensions.Extensions)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Ref (com.intellij.openapi.util.Ref)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2