use of java.awt.Component in project ats-framework by Axway.
the class SwingElementFinder method find.
public static <T extends Component> T find(Robot robot, Container root, GenericTypeMatcher<T> m) {
ComponentHierarchy hierarchy = robot.hierarchy();
List<Component> found = null;
if (root == null) {
found = find(hierarchy, m);
} else {
found = find(new SingleComponentHierarchy(root, hierarchy), m);
}
if (found.isEmpty()) {
throw componentNotFound(robot, hierarchy, m);
}
if (found.size() > 1) {
throw multipleComponentsFound(found, m);
}
Component component = found.iterator().next();
return m.supportedType().cast(component);
}
use of java.awt.Component in project ats-framework by Axway.
the class SwingElementFinder method menuItemWithPath.
public static JMenuItemFixture menuItemWithPath(Robot robot, Container root, String... path) {
ComponentMatcher m = new JMenuItemMatcher(path);
Component item = robot.finder().find(root, m);
assertThat(item).as(format(item)).isInstanceOf(JMenuItem.class);
return new JMenuItemFixture(robot, (JMenuItem) item);
}
use of java.awt.Component in project zaproxy by zaproxy.
the class ExtensionKeyboard method initAllMenuItems.
private void initAllMenuItems(JMenu menu) {
for (Component c : menu.getMenuComponents()) {
if (c instanceof ZapMenuItem) {
this.registerMenuItem((ZapMenuItem) c);
} else if (c instanceof JMenu) {
initAllMenuItems((JMenu) c);
} else if (c instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) c;
logger.debug("Unable to set accelerators on menu " + menuItem.getText());
}
}
}
use of java.awt.Component in project zaproxy by zaproxy.
the class ExtensionKeyboard method addAllMenuItems.
private void addAllMenuItems(List<KeyboardShortcut> kss, JMenu menu, boolean reset) {
for (Component c : menu.getMenuComponents()) {
if (c instanceof ZapMenuItem) {
kss.add(menuToShortcut((ZapMenuItem) c, reset));
} else if (c instanceof JMenu) {
addAllMenuItems(kss, (JMenu) c, reset);
} else if (c instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) c;
logger.debug("Unable to set accelerators on menu " + menuItem.getText());
}
}
}
use of java.awt.Component in project intellij-community by JetBrains.
the class RadBoxLayoutManager method createSnapshotLayout.
@Override
public void createSnapshotLayout(final SnapshotContext context, final JComponent parent, final RadContainer container, final LayoutManager layout) {
int rowCount = 1;
int colCount = 1;
boolean hasFiller = false;
// workaround for lack of BoxLayout.getAxis()
if (parent.getComponentCount() > 1) {
for (Component component : parent.getComponents()) {
if (component instanceof Box.Filler) {
hasFiller = true;
}
}
Rectangle bounds1 = parent.getComponent(0).getBounds();
Rectangle bounds2 = parent.getComponent(1).getBounds();
if (bounds2.x >= bounds1.x + bounds1.width) {
colCount = parent.getComponentCount();
if (!hasFiller)
colCount++;
myHorizontal = true;
} else {
rowCount = parent.getComponentCount();
if (!hasFiller)
rowCount++;
}
}
container.setLayout(new GridLayoutManager(rowCount, colCount));
if (!hasFiller) {
if (myHorizontal) {
container.addComponent(new RadHSpacer(context.newId(), colCount - 1));
} else {
container.addComponent(new RadVSpacer(context.newId(), rowCount - 1));
}
}
}
Aggregations