Search in sources :

Example 6 with JBPopupMenu

use of com.intellij.openapi.ui.JBPopupMenu in project intellij-community by JetBrains.

the class TabContentLayout method showPopup.

private void showPopup() {
    myPopup = new JBPopupMenu();
    myPopup.addPopupMenuListener(myPopupListener);
    ArrayList<ContentTabLabel> tabs = myTabs;
    for (final ContentTabLabel each : tabs) {
        final JCheckBoxMenuItem item = new JCheckBoxMenuItem(each.getText());
        if (myUi.myManager.isSelected(each.myContent)) {
            item.setSelected(true);
        }
        item.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent e) {
                myUi.myManager.setSelectedContent(each.myContent, true);
            }
        });
        myPopup.add(item);
    }
    myPopup.show(myUi, myLastLayout.moreRect.x, myLastLayout.moreRect.y);
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu)

Example 7 with JBPopupMenu

use of com.intellij.openapi.ui.JBPopupMenu in project intellij-community by JetBrains.

the class JBPopupFixture method findContextMenu.

public static JBPopupFixture findContextMenu(Robot robot) {
    pause(new Condition("Find context menu") {

        @Override
        public boolean test() {
            final JBPopupMenu contextMenu = robot.finder().findByType(JBPopupMenu.class);
            return contextMenu != null;
        }
    }, SHORT_TIMEOUT);
    final JBPopupMenu contextMenu = robot.finder().findByType(JBPopupMenu.class);
    assertNotNull(contextMenu);
    return new JBPopupFixture(contextMenu, robot);
}
Also used : Condition(org.fest.swing.timing.Condition) JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu)

Example 8 with JBPopupMenu

use of com.intellij.openapi.ui.JBPopupMenu in project intellij-community by JetBrains.

the class FilterDialog method makePopup.

private void makePopup() {
    myPopup = new JBPopupMenu();
    String[] macrosName = RegexpFilter.getMacrosName();
    JMenuItem[] items = new JMenuItem[macrosName.length];
    for (int i = 0; i < macrosName.length; i++) {
        items[i] = myPopup.add(macrosName[i]);
        items[i].addActionListener(new MenuItemListener(macrosName[i]));
    }
    myRegexpField.addMouseListener(new PopupListener());
}
Also used : JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu)

Example 9 with JBPopupMenu

use of com.intellij.openapi.ui.JBPopupMenu in project intellij-community by JetBrains.

the class IdeEventQueue method _dispatchEvent.

public void _dispatchEvent(@NotNull AWTEvent e, boolean typeAheadFlushing) {
    if (e.getID() == MouseEvent.MOUSE_DRAGGED) {
        DnDManagerImpl dndManager = (DnDManagerImpl) DnDManager.getInstance();
        if (dndManager != null) {
            dndManager.setLastDropHandler(null);
        }
    }
    myEventCount++;
    if (processAppActivationEvents(e))
        return;
    if (!typeAheadFlushing) {
        fixStickyFocusedComponents(e);
    }
    if (!myPopupManager.isPopupActive()) {
        enterSuspendModeIfNeeded(e);
    }
    myKeyboardBusy = e instanceof KeyEvent || myKeyboardEventsPosted.get() > myKeyboardEventsDispatched.get();
    if (e instanceof KeyEvent) {
        if (e.getID() == KeyEvent.KEY_RELEASED && ((KeyEvent) e).getKeyCode() == KeyEvent.VK_SHIFT) {
            myMouseEventDispatcher.resetHorScrollingTracker();
        }
    }
    if (!typeAheadFlushing && typeAheadDispatchToFocusManager(e)) {
        LOG.debug("Typeahead dispatch for event ", e);
        return;
    }
    if (e instanceof WindowEvent) {
        ActivityTracker.getInstance().inc();
    }
    if (e instanceof MouseWheelEvent) {
        final MenuElement[] selectedPath = MenuSelectionManager.defaultManager().getSelectedPath();
        if (selectedPath.length > 0 && !(selectedPath[0] instanceof ComboPopup)) {
            ((MouseWheelEvent) e).consume();
            Component component = selectedPath[0].getComponent();
            if (component instanceof JBPopupMenu) {
                ((JBPopupMenu) component).processMouseWheelEvent((MouseWheelEvent) e);
            }
            return;
        }
    }
    // Process "idle" and "activity" listeners
    if (e instanceof KeyEvent || e instanceof MouseEvent) {
        ActivityTracker.getInstance().inc();
        synchronized (myLock) {
            myIdleRequestsAlarm.cancelAllRequests();
            for (Runnable idleListener : myIdleListeners) {
                final MyFireIdleRequest request = myListener2Request.get(idleListener);
                if (request == null) {
                    LOG.error("There is no request for " + idleListener);
                } else {
                    myIdleRequestsAlarm.addRequest(request, request.getTimeout(), ModalityState.NON_MODAL);
                }
            }
            if (KeyEvent.KEY_PRESSED == e.getID() || KeyEvent.KEY_TYPED == e.getID() || MouseEvent.MOUSE_PRESSED == e.getID() || MouseEvent.MOUSE_RELEASED == e.getID() || MouseEvent.MOUSE_CLICKED == e.getID()) {
                addIdleTimeCounterRequest();
                for (Runnable activityListener : myActivityListeners) {
                    activityListener.run();
                }
            }
        }
    }
    if (myPopupManager.isPopupActive() && myPopupManager.dispatch(e)) {
        if (myKeyEventDispatcher.isWaitingForSecondKeyStroke()) {
            myKeyEventDispatcher.setState(KeyState.STATE_INIT);
        }
        return;
    }
    if (dispatchByCustomDispatchers(e))
        return;
    if (e instanceof InputMethodEvent) {
        if (SystemInfo.isMac && myKeyEventDispatcher.isWaitingForSecondKeyStroke()) {
            return;
        }
    }
    if (e instanceof ComponentEvent && myWindowManager != null) {
        myWindowManager.dispatchComponentEvent((ComponentEvent) e);
    }
    if (e instanceof KeyEvent) {
        if (mySuspendMode || !myKeyEventDispatcher.dispatchKeyEvent((KeyEvent) e)) {
            defaultDispatchEvent(e);
        } else {
            ((KeyEvent) e).consume();
            defaultDispatchEvent(e);
        }
    } else if (e instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) e;
        if (IdeMouseEventDispatcher.patchClickCount(me) && me.getID() == MouseEvent.MOUSE_CLICKED) {
            final MouseEvent toDispatch = new MouseEvent(me.getComponent(), me.getID(), System.currentTimeMillis(), me.getModifiers(), me.getX(), me.getY(), 1, me.isPopupTrigger(), me.getButton());
            //noinspection SSBasedInspection
            SwingUtilities.invokeLater(() -> dispatchEvent(toDispatch));
        }
        if (!myMouseEventDispatcher.dispatchMouseEvent(me)) {
            defaultDispatchEvent(e);
        }
    } else {
        defaultDispatchEvent(e);
    }
}
Also used : JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu) DnDManagerImpl(com.intellij.ide.dnd.DnDManagerImpl) ComboPopup(javax.swing.plaf.basic.ComboPopup)

Example 10 with JBPopupMenu

use of com.intellij.openapi.ui.JBPopupMenu in project intellij-community by JetBrains.

the class LafManagerImpl method fixGtkPopupStyle.

private static void fixGtkPopupStyle() {
    if (!UIUtil.isUnderGTKLookAndFeel())
        return;
    final SynthStyleFactory original = SynthLookAndFeel.getStyleFactory();
    SynthLookAndFeel.setStyleFactory(new SynthStyleFactory() {

        @Override
        public SynthStyle getStyle(final JComponent c, final Region id) {
            final SynthStyle style = original.getStyle(c, id);
            if (id == Region.POPUP_MENU) {
                final Integer x = ReflectionUtil.getField(style.getClass(), style, int.class, "xThickness");
                if (x != null && x == 0) {
                    // workaround for Sun bug #6636964
                    ReflectionUtil.setField(style.getClass(), style, int.class, "xThickness", 1);
                    ReflectionUtil.setField(style.getClass(), style, int.class, "yThickness", 3);
                }
            }
            return style;
        }
    });
    // invokes updateUI() -> updateStyle()
    new JBPopupMenu();
    SynthLookAndFeel.setStyleFactory(original);
}
Also used : Region(javax.swing.plaf.synth.Region) SynthStyle(javax.swing.plaf.synth.SynthStyle) SynthStyleFactory(javax.swing.plaf.synth.SynthStyleFactory) JBPopupMenu(com.intellij.openapi.ui.JBPopupMenu)

Aggregations

JBPopupMenu (com.intellij.openapi.ui.JBPopupMenu)13 ActionEvent (java.awt.event.ActionEvent)4 JBMenuItem (com.intellij.openapi.ui.JBMenuItem)3 NotNull (org.jetbrains.annotations.NotNull)3 ActionListener (java.awt.event.ActionListener)2 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)1 ResourceResolver (com.android.ide.common.resources.ResourceResolver)1 XmlNode (com.android.manifmerger.XmlNode)1 AttributesTableModel (com.android.tools.idea.editors.theme.attributes.AttributesTableModel)1 ConfiguredThemeEditorStyle (com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)1 EditedStyleItem (com.android.tools.idea.editors.theme.datamodels.EditedStyleItem)1 DnDManagerImpl (com.intellij.ide.dnd.DnDManagerImpl)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Project (com.intellij.openapi.project.Project)1 JBCheckboxMenuItem (com.intellij.openapi.ui.JBCheckboxMenuItem)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)1 PsiFile (com.intellij.psi.PsiFile)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1