com.intellij.openapi.wm.IdeFrame Java Examples
The following examples show how to use
com.intellij.openapi.wm.IdeFrame.
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: NotificationsManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @RequiredUIAccess public static Window findWindowForBalloon(@Nullable Project project) { Window frame = TargetAWT.to(WindowManager.getInstance().getWindow(project)); if (frame == null && project == null) { IdeFrame currentFrame = WelcomeFrameManager.getInstance().getCurrentFrame(); frame = currentFrame == null ? null : TargetAWT.to(currentFrame.getWindow()); } if (frame == null && project == null) { frame = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); while (frame instanceof DialogWrapperDialog && ((DialogWrapperDialog)frame).getDialogWrapper().isModalProgress()) { frame = frame.getOwner(); } } return frame; }
Example #2
Source File: IdeMessagePanel.java From consulo with Apache License 2.0 | 6 votes |
public IdeMessagePanel(@Nonnull IdeFrame frame, @Nonnull MessagePool messagePool) { super(new BorderLayout()); myIdeFatal = new IdeFatalErrorsIcon(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFatals(null); } }); myIdeFatal.setVerticalAlignment(SwingConstants.CENTER); add(myIdeFatal, BorderLayout.CENTER); myFrame = frame; myMessagePool = messagePool; messagePool.addListener(this); updateFatalErrorsIcon(); setOpaque(false); }
Example #3
Source File: PopupUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void showBalloonForActiveFrame(@Nonnull final String message, final MessageType type) { final Runnable runnable = new Runnable() { public void run() { final IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame(); if (frame == null) { final Project[] projects = ProjectManager.getInstance().getOpenProjects(); final Project project = projects == null || projects.length == 0 ? ProjectManager.getInstance().getDefaultProject() : projects[0]; final JFrame jFrame = WindowManager.getInstance().getFrame(project); if (jFrame != null) { showBalloonForComponent(jFrame, message, type, true, project); } else { LOG.info("Can not get component to show message: " + message); } return; } showBalloonForComponent(frame.getComponent(), message, type, true, frame.getProject()); } }; UIUtil.invokeLaterIfNeeded(runnable); }
Example #4
Source File: IdeEventQueue.java From consulo with Apache License 2.0 | 6 votes |
private static void storeLastFocusedComponent(@Nonnull 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) { Window aFrame = TargetAWT.to(WindowManager.getInstance().getWindow(ideFrame.getProject())); if (aFrame.equals(frame)) { IdeFocusManager focusManager = IdeFocusManager.getGlobalInstance(); if (focusManager instanceof FocusManagerImpl) { ((FocusManagerImpl)focusManager).setLastFocusedAtDeactivation(ideFrame, focusOwnerInDeactivatedWindow); } } } } } }
Example #5
Source File: MouseGestureManager.java From consulo with Apache License 2.0 | 6 votes |
public void remove(IdeFrame frame) { if (!Registry.is("actionSystem.mouseGesturesEnabled")) return; if (SystemInfo.isMacOSSnowLeopard) { try { Object listener = myListeners.get(frame); JComponent cmp = frame.getComponent(); myListeners.remove(frame); if (listener != null && cmp != null && cmp.isShowing()) { ((MacGestureAdapter)listener).remove(cmp); } } catch (Throwable e) { LOG.debug(e); } } }
Example #6
Source File: Alarm.java From consulo with Apache License 2.0 | 6 votes |
public void addRequest(@Nonnull final Runnable request, final int delay, boolean runWithActiveFrameOnly) { if (runWithActiveFrameOnly && !ApplicationManager.getApplication().isActive()) { final MessageBus bus = ApplicationManager.getApplication().getMessageBus(); final MessageBusConnection connection = bus.connect(this); connection.subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener() { @Override public void applicationActivated(@Nonnull IdeFrame ideFrame) { connection.disconnect(); addRequest(request, delay); } }); } else { addRequest(request, delay); } }
Example #7
Source File: AppIcon.java From consulo with Apache License 2.0 | 6 votes |
@Override public boolean _setProgress(IdeFrame frame, Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { myCurrentProcessId = processId; if (Math.abs(myLastValue - value) < 0.02d) { return true; } try { if (isValid(frame)) { Win7TaskBar.setProgress(frame, value, isOk); } } catch (Throwable e) { LOG.error(e); } myLastValue = value; myCurrentProcessId = null; return true; }
Example #8
Source File: DesktopIdeFrameUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static IdeFrame findIdeFrameFromParent(@Nullable Component component) { if(component == null) { return null; } Component target = component; while (target != null) { if(target instanceof Window) { consulo.ui.Window uiWindow = TargetAWT.from((Window)target); IdeFrame ideFrame = uiWindow.getUserData(IdeFrame.KEY); if(ideFrame != null) { return ideFrame; } } target = target.getParent(); } return null; }
Example #9
Source File: ActionMenu.java From consulo with Apache License 2.0 | 6 votes |
private void fillMenu(JMenu menu) { DataContext context; boolean mayContextBeInvalid; if (myContext != null) { context = myContext; mayContextBeInvalid = false; } else { @SuppressWarnings("deprecation") DataContext contextFromFocus = DataManager.getInstance().getDataContext(); context = contextFromFocus; if (context.getData(PlatformDataKeys.CONTEXT_COMPONENT) == null) { IdeFrame frame = DesktopIdeFrameUtil.findIdeFrameFromParent(this); context = DataManager.getInstance().getDataContext(IdeFocusManager.getGlobalInstance().getLastFocusedFor(frame)); } mayContextBeInvalid = true; } Utils.fillMenu(myGroup.getAction(), menu, myMnemonicEnabled, myPresentationFactory, context, myPlace, true, mayContextBeInvalid, LaterInvocator.isInModalContext()); }
Example #10
Source File: DesktopIdeFrameUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nullable public static IdeFrameEx findIdeFrameExFromParent(@Nullable Component component) { if (component == null) { return null; } Component target = component; while (target != null) { if (target instanceof Window) { consulo.ui.Window uiWindow = TargetAWT.from((Window)target); IdeFrame ideFrame = uiWindow.getUserData(IdeFrame.KEY); if (ideFrame instanceof IdeFrameEx) { return (IdeFrameEx)ideFrame; } } target = target.getParent(); } return null; }
Example #11
Source File: X11UiUtil.java From consulo with Apache License 2.0 | 5 votes |
public static boolean isFullScreenSupported() { if (X11 == null) return false; IdeFrame[] frames = WindowManager.getInstance().getAllProjectFrames(); if (frames.length == 0) return true; // no frame to check the property so be optimistic here IdeFrame frame = frames[0]; Window awtWindow = TargetAWT.to(frame.getWindow()); return awtWindow instanceof JFrame && hasWindowProperty(awtWindow, X11.NET_WM_ALLOWED_ACTIONS, X11.NET_WM_ACTION_FULLSCREEN); }
Example #12
Source File: AppIcon.java From consulo with Apache License 2.0 | 5 votes |
@Override public void _requestAttention(IdeFrame frame, boolean critical) { try { if (isValid(frame)) { Win7TaskBar.attention(frame, critical); } } catch (Throwable e) { LOG.error(e); } }
Example #13
Source File: AppIcon.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean _hideProgress(IdeFrame frame, Object processId) { assertIsDispatchThread(); if (getAppImage() == null) return false; if (myCurrentProcessId != null && !myCurrentProcessId.equals(processId)) return false; setDockIcon(getAppImage()); myCurrentProcessId = null; myLastValue = 0; return true; }
Example #14
Source File: Win7TaskBar.java From consulo with Apache License 2.0 | 5 votes |
static void attention(IdeFrame frame, boolean critical) { if (!isEnabled()) { return; } User32Ex.INSTANCE.FlashWindow(getHandle(frame), true); }
Example #15
Source File: OwnerOptional.java From consulo with Apache License 2.0 | 5 votes |
public OwnerOptional ifFrame(Consumer<? super Frame> consumer) { if (myPermanentOwner instanceof Frame) { if (myPermanentOwner instanceof IdeFrame.Child) { IdeFrame.Child ideFrameChild = (IdeFrame.Child)myPermanentOwner; myPermanentOwner = WindowManager.getInstance().getFrame(ideFrameChild.getProject()); } consumer.consume((Frame)this.myPermanentOwner); } return this; }
Example #16
Source File: AppIcon.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean _hideProgress(IdeFrame frame, Object processId) { if(myTaskbarWrapper.isSupported(TaskbarWrapper.FeatureWrapper.PROGRESS_VALUE)) { myTaskbarWrapper.setProgressValue(-1); } return true; }
Example #17
Source File: DockManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override protected JFrame createJFrame(IdeFrame parent) { JFrame frame = super.createJFrame(parent); installListeners(frame); return frame; }
Example #18
Source File: UnityOpenFilePostHandler.java From consulo-unity3d with Apache License 2.0 | 5 votes |
private void activateFrame(@Nullable Project openedProject, @Nonnull UnityOpenFilePostHandlerRequest body) { if(openedProject == null) { return; } IdeFrame ideFrame = WindowManager.getInstance().getIdeFrame(openedProject); if(ideFrame == null || !ideFrame.getWindow().isVisible()) { return; } if(SystemInfo.isMac) { RequestFocusHttpRequestHandler.activateFrame(ideFrame); ID id = MacUtil.findWindowFromJavaWindow(TargetAWT.to(ideFrame.getWindow())); if(id != null) { Foundation.invoke(id, "makeKeyAndOrderFront:", ID.NIL); } } else if(SystemInfo.isWindows) { Pointer windowPointer = Native.getWindowPointer(TargetAWT.to(ideFrame.getWindow())); User32.INSTANCE.SetForegroundWindow(new WinDef.HWND(windowPointer)); } else { RequestFocusHttpRequestHandler.activateFrame(ideFrame); } }
Example #19
Source File: PopupUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void showBalloonForActiveComponent(@Nonnull final String message, final MessageType type) { Runnable runnable = new Runnable() { public void run() { Window[] windows = Window.getWindows(); Window targetWindow = null; for (Window each : windows) { if (each.isActive()) { targetWindow = each; break; } } if (targetWindow == null) { targetWindow = JOptionPane.getRootFrame(); } if (targetWindow == null) { final IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame(); if (frame == null) { final Project[] projects = ProjectManager.getInstance().getOpenProjects(); final Project project = projects == null || projects.length == 0 ? ProjectManager.getInstance().getDefaultProject() : projects[0]; final JFrame jFrame = WindowManager.getInstance().getFrame(project); if (jFrame != null) { showBalloonForComponent(jFrame, message, type, true, project); } else { LOG.info("Can not get component to show message: " + message); } return; } showBalloonForComponent(frame.getComponent(), message, type, true, frame.getProject()); } else { showBalloonForComponent(targetWindow, message, type, true, null); } } }; UIUtil.invokeLaterIfNeeded(runnable); }
Example #20
Source File: ModalityHelper.java From consulo with Apache License 2.0 | 5 votes |
public static JDialog getBlockerForFrame(final IdeFrame ideFrame) { if (ideFrame == null) return null; Component c = ideFrame.getComponent(); if (c == null) return null; Window window = SwingUtilities.getWindowAncestor(c); if (window == null) return null; if (!isModalBlocked(window)) return null; return getModalBlockerFor(window); }
Example #21
Source File: ApplicationActivationStateManager.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static IdeFrame getIdeFrameFromWindow(Window window) { final Component frame = UIUtil.findUltimateParent(window); if (!(frame instanceof Window)) { return null; } consulo.ui.Window uiWindow = TargetAWT.from((Window)frame); return uiWindow.getUserData(IdeFrame.KEY); }
Example #22
Source File: StatusPanel.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private Project getActiveProject() { // a better way of finding a project would be great for (Project project : ProjectManager.getInstance().getOpenProjects()) { IdeFrame ideFrame = WindowManager.getInstance().getIdeFrame(project); if (ideFrame != null) { final JComponent frame = ideFrame.getComponent(); if (SwingUtilities.isDescendingFrom(myTextPanel, frame)) { return project; } } } return null; }
Example #23
Source File: ToggleFullScreenAction.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static IdeFrameEx getFrame() { Component focusOwner = IdeFocusManager.getGlobalInstance().getFocusOwner(); if (focusOwner != null) { Window awtWindow = focusOwner instanceof JFrame ? (Window)focusOwner : SwingUtilities.getWindowAncestor(focusOwner); consulo.ui.Window window = TargetAWT.from(awtWindow); if (window != null) { return (IdeFrameEx)window.getUserData(IdeFrame.KEY); } } return null; }
Example #24
Source File: RequestFocusHttpRequestHandler.java From consulo with Apache License 2.0 | 5 votes |
public static boolean activateFrame(@Nullable final IdeFrame ideFrame) { if (ideFrame == null) { return false; } Window awtWindow = TargetAWT.to(ideFrame.getWindow()); return awtWindow instanceof Frame && activateFrame((Frame)awtWindow); }
Example #25
Source File: NotificationsManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Balloon createBalloon(@Nonnull final IdeFrame window, @Nonnull final Notification notification, final boolean showCallout, final boolean hideOnClickOutside, @Nonnull Ref<BalloonLayoutData> layoutDataRef, @Nonnull Disposable parentDisposable) { return createBalloon(window.getComponent(), notification, showCallout, hideOnClickOutside, layoutDataRef, parentDisposable); }
Example #26
Source File: NotificationsManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @RequiredUIAccess public static IdeFrame findIdeFrameForBalloon(@Nullable Project project) { Window windowForBalloon = findWindowForBalloon(project); consulo.ui.Window uiWindow = TargetAWT.from(windowForBalloon); return uiWindow == null ? null : uiWindow.getUserData(IdeFrame.KEY); }
Example #27
Source File: WelcomeFrameManager.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess public void closeFrame() { UIAccess.assertIsUIThread(); IdeFrame frameInstance = myFrameInstance; if (frameInstance == null) { return; } frameInstance.getWindow().close(); }
Example #28
Source File: WelcomeFrameManager.java From consulo with Apache License 2.0 | 5 votes |
public void showIfNoProjectOpened() { myApplication.invokeLater((DumbAwareRunnable)() -> { WindowManagerEx windowManager = (WindowManagerEx)WindowManager.getInstance(); windowManager.disposeRootFrame(); IdeFrame[] frames = windowManager.getAllProjectFrames(); if (frames.length == 0) { showFrame(); } }, ModalityState.NON_MODAL); }
Example #29
Source File: DumbServiceImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void showDumbModeNotification(@Nonnull final String message) { UIUtil.invokeLaterIfNeeded(() -> { final IdeFrame ideFrame = WindowManager.getInstance().getIdeFrame(myProject); if (ideFrame != null) { ((StatusBarEx)ideFrame.getStatusBar()).notifyProgressByBalloon(MessageType.WARNING, message); } }); }
Example #30
Source File: FrameWrapperPeerFactoryImpl.java From consulo with Apache License 2.0 | 5 votes |
private MyJDialog(FrameWrapper owner, @Nullable IdeFrame parent) throws HeadlessException { super(parent == null ? null : parent.getWindow(), null); myOwner = owner; myParent = parent; setGlassPane(new IdeGlassPaneImpl(getRootPane())); getRootPane().putClientProperty("Window.style", "small"); setBackground(UIUtil.getPanelBackground()); MouseGestureManager.getInstance().add(this); setFocusTraversalPolicy(new LayoutFocusTraversalPolicyExt()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); toUIWindow().putUserData(IdeFrame.KEY, this); toUIWindow().addUserDataProvider(this::getData); }