use of javax.swing.plaf.basic.ComboPopup in project intellij-community by JetBrains.
the class PopupUtil method isComboPopupKeyEvent.
public static boolean isComboPopupKeyEvent(@NotNull ComponentEvent event, @NotNull JComboBox comboBox) {
final Component component = event.getComponent();
if (!comboBox.isPopupVisible() || component == null)
return false;
ComboPopup popup = ReflectionUtil.getField(comboBox.getUI().getClass(), comboBox.getUI(), ComboPopup.class, "popup");
return popup != null && SwingUtilities.isDescendingFrom(popup.getList(), component);
}
use of javax.swing.plaf.basic.ComboPopup in project intellij-community by JetBrains.
the class TreeInplaceEditor method eventDispatched.
@Override
public void eventDispatched(AWTEvent event) {
if (!isShown()) {
return;
}
MouseEvent mouseEvent = (MouseEvent) event;
if (mouseEvent.getClickCount() == 0 && !(event instanceof MouseWheelEvent)) {
return;
}
final int id = mouseEvent.getID();
if (id != MouseEvent.MOUSE_PRESSED && id != MouseEvent.MOUSE_RELEASED && id != MouseEvent.MOUSE_CLICKED && id != MouseEvent.MOUSE_WHEEL) {
return;
}
final Component sourceComponent = mouseEvent.getComponent();
final Point originalPoint = mouseEvent.getPoint();
final Editor editor = getEditor();
if (editor == null)
return;
Project project = editor.getProject();
LookupImpl activeLookup = project != null ? (LookupImpl) LookupManager.getInstance(project).getActiveLookup() : null;
if (activeLookup != null) {
final Point lookupPoint = SwingUtilities.convertPoint(sourceComponent, originalPoint, activeLookup.getComponent());
if (activeLookup.getComponent().getBounds().contains(lookupPoint)) {
//mouse click inside lookup
return;
} else {
//hide popup on mouse position changed
activeLookup.hide();
}
}
// do not cancel editing if we click in editor popup
final List<JBPopup> popups = JBPopupFactory.getInstance().getChildPopups(myInplaceEditorComponent);
for (JBPopup popup : popups) {
if (SwingUtilities.isDescendingFrom(sourceComponent, popup.getContent())) {
return;
}
}
final Point point = SwingUtilities.convertPoint(sourceComponent, originalPoint, myInplaceEditorComponent);
if (myInplaceEditorComponent.contains(point)) {
return;
}
final Component componentAtPoint = SwingUtilities.getDeepestComponentAt(sourceComponent, originalPoint.x, originalPoint.y);
for (Component comp = componentAtPoint; comp != null; comp = comp.getParent()) {
if (comp instanceof ComboPopup) {
if (id != MouseEvent.MOUSE_WHEEL) {
doPopupOKAction();
}
return;
}
}
if (id != MouseEvent.MOUSE_RELEASED) {
// do not cancel on release outside of the component
cancelEditing();
}
}
use of javax.swing.plaf.basic.ComboPopup in project android by JetBrains.
the class GradleEditorComboBoxEditor method getComboboxPopup.
@Nullable
private static ComboPopup getComboboxPopup(final JComboBox comboBox) {
final ComboBoxUI ui = comboBox.getUI();
ComboPopup popup = null;
if (ui instanceof BasicComboBoxUI) {
try {
final Field popupField = BasicComboBoxUI.class.getDeclaredField("popup");
popupField.setAccessible(true);
popup = (ComboPopup) popupField.get(ui);
} catch (NoSuchFieldException e1) {
popup = null;
} catch (IllegalAccessException e1) {
popup = null;
}
}
return popup;
}
use of javax.swing.plaf.basic.ComboPopup in project android by JetBrains.
the class NlEnumEditorFixture method showPopup.
public NlEnumEditorFixture showPopup() {
assertThat(myCombo).isNotNull();
myCombo.isPopupVisible();
myCombo.showPopup();
ComboPopup popup = myCombo.getPopup();
assertThat(popup).isNotNull();
setFocusedComponent(popup.getList());
assertThat(myCombo.isPopupVisible()).isTrue();
return this;
}
use of javax.swing.plaf.basic.ComboPopup in project intellij-community by JetBrains.
the class XDebuggerTreeInplaceEditor method doPopupOKAction.
@Override
protected void doPopupOKAction() {
ComboPopup popup = myExpressionEditor.getComboBox().getPopup();
if (popup != null && popup.isVisible()) {
Object value = popup.getList().getSelectedValue();
if (value != null) {
myExpressionEditor.setExpression((XExpression) value);
}
}
doOKAction();
}
Aggregations