List of usage examples for com.intellij.openapi.wm IdeGlassPaneUtil find
@NotNull
public static IdeGlassPane find(@NotNull Component component)
From source file:com.intellij.debugger.ui.impl.TipManager.java
License:Apache License
private void installListeners() { if (myIsDisposed) { return;/*w ww. ja v a 2s . co m*/ } myGP = IdeGlassPaneUtil.find(myComponent); assert myGP != null; myGP.addMousePreprocessor(myMouseListener, this); myGP.addMouseMotionPreprocessor(myMouseMotionListener, this); myHideCanceller = new MyAwtPreprocessor(); Toolkit.getDefaultToolkit().addAWTEventListener(myHideCanceller, AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK); FrameStateManager.getInstance().addListener(myFrameStateListener); }
From source file:com.intellij.execution.ui.layout.impl.RunnerContentUi.java
License:Apache License
@Override public Image processDropOver(@NotNull DockableContent dockable, RelativePoint dropTarget) { JBTabs current = getTabsAt(dockable, dropTarget); if (myCurrentOver != null && myCurrentOver != current) { resetDropOver(dockable);/*from w w w . ja v a 2s .c o m*/ } if (myCurrentOver == null && current != null) { myCurrentOver = current; Presentation presentation = dockable.getPresentation(); myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()) .setIcon(presentation.getIcon()); myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, dropTarget); } if (myCurrentOver != null) { myCurrentOver.processDropOver(myCurrentOverInfo, dropTarget); } if (myCurrentPainter == null) { myCurrentPainter = new MyDropAreaPainter(); IdeGlassPaneUtil.find(myComponent).addPainter(myComponent, myCurrentPainter, this); } myCurrentPainter.processDropOver(this, dockable, dropTarget); return myCurrentOverImg; }
From source file:com.intellij.execution.ui.layout.impl.RunnerContentUi.java
License:Apache License
@Override public void resetDropOver(@NotNull DockableContent content) { if (myCurrentOver != null) { myCurrentOver.resetDropOver(myCurrentOverInfo); myCurrentOver = null;/*w w w . jav a2s.co m*/ myCurrentOverInfo = null; myCurrentOverImg = null; IdeGlassPaneUtil.find(myComponent).removePainter(myCurrentPainter); myCurrentPainter = null; } }
From source file:com.intellij.ui.BalloonImpl.java
License:Apache License
private void show(PositionTracker<Balloon> tracker, AbstractPosition position) { assert !myDisposed : "Balloon is already disposed"; if (isVisible()) return;/*from ww w.ja v a2 s . c o m*/ final Component comp = tracker.getComponent(); if (!comp.isShowing()) return; myTracker = tracker; myTracker.init(this); JRootPane root = null; JDialog dialog = IJSwingUtilities.findParentOfType(comp, JDialog.class); if (dialog != null) { root = dialog.getRootPane(); } else { JWindow jwindow = IJSwingUtilities.findParentOfType(comp, JWindow.class); if (jwindow != null) { root = jwindow.getRootPane(); } else { JFrame frame = IJSwingUtilities.findParentOfType(comp, JFrame.class); if (frame != null) { root = frame.getRootPane(); } else { assert false; } } } myVisible = true; myLayeredPane = root.getLayeredPane(); myPosition = position; UIUtil.setFutureRootPane(myContent, root); myFocusManager = IdeFocusManager.findInstanceByComponent(myLayeredPane); final Ref<Component> originalFocusOwner = new Ref<Component>(); final Ref<FocusRequestor> focusRequestor = new Ref<FocusRequestor>(); final Ref<ActionCallback> proxyFocusRequest = new Ref<ActionCallback>(new ActionCallback.Done()); boolean mnemonicsFix = myDialogMode && SystemInfo.isMac && Registry.is("ide.mac.inplaceDialogMnemonicsFix"); if (mnemonicsFix) { final IdeGlassPaneEx glassPane = (IdeGlassPaneEx) IdeGlassPaneUtil.find(myLayeredPane); assert glassPane != null; proxyFocusRequest.set(new ActionCallback()); myFocusManager.doWhenFocusSettlesDown(new ExpirableRunnable() { @Override public boolean isExpired() { return isDisposed(); } @Override public void run() { IdeEventQueue.getInstance().disableInputMethods(BalloonImpl.this); originalFocusOwner.set(myFocusManager.getFocusOwner()); myFocusManager.requestFocus(glassPane.getProxyComponent(), true) .notify(proxyFocusRequest.get()); focusRequestor.set(myFocusManager.getFurtherRequestor()); } }); } myLayeredPane.addComponentListener(myComponentListener); myTargetPoint = myPosition.getShiftedPoint(myTracker.recalculateLocation(this).getPoint(myLayeredPane), myCalloutShift); int positionChangeFix = 0; if (myShowPointer) { Rectangle rec = getRecForPosition(myPosition, true); if (!myPosition.isOkToHavePointer(myTargetPoint, rec, getPointerLength(myPosition), getPointerWidth(myPosition), getArc())) { rec = getRecForPosition(myPosition, false); Rectangle lp = new Rectangle(new Point(myContainerInsets.left, myContainerInsets.top), myLayeredPane.getSize()); lp.width -= myContainerInsets.right; lp.height -= myContainerInsets.bottom; if (!lp.contains(rec)) { Rectangle2D currentSquare = lp.createIntersection(rec); double maxSquare = currentSquare.getWidth() * currentSquare.getHeight(); AbstractPosition targetPosition = myPosition; for (AbstractPosition eachPosition : myPosition.getOtherPositions()) { Rectangle2D eachIntersection = lp .createIntersection(getRecForPosition(eachPosition, false)); double eachSquare = eachIntersection.getWidth() * eachIntersection.getHeight(); if (maxSquare < eachSquare) { maxSquare = eachSquare; targetPosition = eachPosition; } } myPosition = targetPosition; positionChangeFix = myPosition.getChangeShift(position, myPositionChangeXShift, myPositionChangeYShift); } } } if (myPosition != position) { myTargetPoint = myPosition.getShiftedPoint(myTracker.recalculateLocation(this).getPoint(myLayeredPane), myCalloutShift > 0 ? myCalloutShift + positionChangeFix : positionChangeFix); } createComponent(); myComp.validate(); Rectangle rec = myComp.getContentBounds(); if (myShowPointer && !myPosition.isOkToHavePointer(myTargetPoint, rec, getPointerLength(myPosition), getPointerWidth(myPosition), getArc())) { myShowPointer = false; myComp.removeAll(); myLayeredPane.remove(myComp); createComponent(); if (!new Rectangle(myLayeredPane.getSize()).contains(new Rectangle(myComp.getSize()))) { // Balloon is bigger than window, don't show it at all. myLayeredPane = null; hide(); return; } } for (JBPopupListener each : myListeners) { each.beforeShown(new LightweightWindowEvent(this)); } runAnimation(true, myLayeredPane, null); myLayeredPane.revalidate(); myLayeredPane.repaint(); if (mnemonicsFix) { proxyFocusRequest.get().doWhenDone(new Runnable() { @Override public void run() { myFocusManager.requestFocus(originalFocusOwner.get(), true); } }); } Toolkit.getDefaultToolkit().addAWTEventListener(myAwtActivityListener, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.KEY_EVENT_MASK); if (ApplicationManager.getApplication() != null) { ActionManager.getInstance().addAnActionListener(new AnActionListener.Adapter() { @Override public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) { if (myHideOnAction) { hide(); } } }, this); } if (myHideOnLinkClick) { final Ref<JEditorPane> ref = Ref.create(null); new AwtVisitor(myContent) { @Override public boolean visit(Component component) { if (component instanceof JEditorPane) { ref.set((JEditorPane) component); return true; } return false; } }; if (!ref.isNull()) { ref.get().addHyperlinkListener(new HyperlinkAdapter() { @Override protected void hyperlinkActivated(HyperlinkEvent e) { hide(); } }); } } }
From source file:com.intellij.ui.components.JBOptionButton.java
License:Apache License
@Override public void addNotify() { super.addNotify(); if (!ScreenUtil.isStandardAddRemoveNotify(this)) return;//from w ww .ja va 2s .c o m myGlassPane = IdeGlassPaneUtil.find(this); if (myGlassPane != null) { myGlassPane.addMouseMotionPreprocessor(this, myDisposable); } }
From source file:com.intellij.ui.MouseDragHelper.java
License:Apache License
private void attach() { if (myDetachPostponed) { myDetachPostponed = false;/* www. ja v a 2 s .c om*/ return; } myGlassPane = IdeGlassPaneUtil.find(myDragComponent); myGlassPane.addMousePreprocessor(this, myParentDisposable); myGlassPane.addMouseMotionPreprocessor(this, myParentDisposable); KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this); Disposer.register(myParentDisposable, new Disposable() { @Override public void dispose() { KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(MouseDragHelper.this); } }); }
From source file:com.intellij.ui.switcher.SwitchingSession.java
License:Apache License
public SwitchingSession(SwitchManager mgr, SwitchProvider provider, KeyEvent e, @Nullable SwitchTarget preselected, boolean showSpots) { myManager = mgr;/*from w w w. j a v a 2 s .c om*/ myProvider = provider; myInitialEvent = e; KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this); myTargets.addAll(myProvider.getTargets(true, true)); Component eachParent = myProvider.getComponent(); eachParent = eachParent.getParent(); while (eachParent != null) { if (eachParent instanceof SwitchProvider) { SwitchProvider eachProvider = (SwitchProvider) eachParent; myTargets.addAll(eachProvider.getTargets(true, false)); if (eachProvider.isCycleRoot()) { break; } } eachParent = eachParent.getParent(); } if (myTargets.size() == 0) { Disposer.dispose(this); return; } mySelection = myProvider.getCurrentTarget(); if (myTargets.contains(preselected)) { mySelection = preselected; } myStartSelection = mySelection; myGlassPane = IdeGlassPaneUtil.find(myProvider.getComponent()); myRootComponent = myProvider.getComponent().getRootPane(); mySpotlight = new Spotlight(myRootComponent); myGlassPane.addPainter(myRootComponent, mySpotlight, myPainterDisposable); myShowspotsAlarm = new Alarm(this); restartShowspotsAlarm(); myShowspots = showSpots; mySpotlight.setNeedsRepaint(true); }