private void click() throws ClassNotFoundException { final Class<?> comboBoxButtonClass = getClass().getClassLoader().loadClass(ComboBoxAction.class.getCanonicalName() + "$ComboBoxButton"); final ActionButtonFixture runButton = projectFrame.findRunApplicationButton(); Container actionToolbarContainer = execute(new GuiQuery<Container>() { @Override protected Container executeInEDT() throws Throwable { return runButton.target().getParent(); } }); assertNotNull(actionToolbarContainer); JButton comboBoxButton = robot.finder().find(actionToolbarContainer, new GenericTypeMatcher<JButton>(JButton.class) { @Override protected boolean isMatching(@NotNull JButton component) { return comboBoxButtonClass.isInstance(component); } }); final JButtonFixture comboBoxButtonFixture = new JButtonFixture(robot, comboBoxButton); pause(new Condition("Wait until comboBoxButton is enabled") { @Override public boolean test() { //noinspection ConstantConditions return execute(new GuiQuery<Boolean>() { @Override protected Boolean executeInEDT() throws Throwable { return comboBoxButtonFixture.target().isEnabled(); } }); } }, SHORT_TIMEOUT); comboBoxButtonFixture.click(); }
@Override public Dimension getPreferredSize(JComponent c) { ComboBoxButton comboBoxButton = (ComboBoxButton)c; ComboBoxAction comboBoxAction = comboBoxButton.getComboBoxAction(); final boolean isEmpty = comboBoxButton.getIcon() == null && StringUtil.isEmpty(comboBoxButton.getText()); int width = isEmpty ? JBUI.scale(10) + getArrowIcon().getIconWidth() : super.getPreferredSize(c).width; if (comboBoxAction.isSmallVariant()) width += JBUI.scale(4); return new Dimension(width, comboBoxAction.isSmallVariant() ? JBUI.scale(19) : super.getPreferredSize(c).height); }
@Override public Dimension getPreferredSize(JComponent c) { ComboBoxButton comboBoxButton = (ComboBoxButton)c; ComboBoxAction comboBoxAction = comboBoxButton.getComboBoxAction(); final boolean isEmpty = comboBoxButton.getIcon() == null && StringUtil.isEmpty(comboBoxButton.getText()); int width = isEmpty ? JBUI.scale(18) : super.getPreferredSize(c).width; if (comboBoxAction.isSmallVariant()) width += JBUI.scale(4); return new Dimension(width, comboBoxAction.isSmallVariant() ? JBUI.scale(21) : super.getPreferredSize(c).height); }
private static boolean isNeedGap(final AnAction group) { final AnAction firstAction = getFirstAction(group); return firstAction instanceof ComboBoxAction; }