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);
}
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);
}
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());
}
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);
}
}
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);
}
Aggregations