コード例 #1
0
  public void eventDispatched(AWTEvent event) {
    if (!isAssertTrigger(event)) {
      return;
    }

    MouseEvent mouse = (MouseEvent) event;

    GuiComponent guiComponent = factory.find(mouse);

    if (guiComponent == null) {
      return;
    }

    assertContext.setGuiComponent(guiComponent);
    assertContext.setPoint(mouse.getPoint());

    JPopupMenu menu = dialogManager.newPopupMenu();

    for (Iterator iterator = actionManager.actions(); iterator.hasNext(); ) {
      AbstractAssert assertAction = (AbstractAssert) iterator.next();
      String actionId = (String) assertAction.getValue(AbstractAssert.ACTION_ID);

      ActionViewUtil.connectActionTo(assertAction, menu.add(actionId));
      assertAction.update();

      if (!guiComponent.isFindable()
          && AbstractAssert.COMPONENT_ASSERT == assertAction.getAssertType()) {
        assertAction.setEnabled(false);
      }
    }

    menu.setBorder(BorderFactory.createLineBorder(Color.blue, 5));
    menu.show(guiComponent.getSwingComponent(), mouse.getX(), mouse.getY());
  }
コード例 #2
0
 public AssertManager(Recorder recorder, DialogManager dialogManager) {
   assertContext = new AssertContext(recorder);
   this.dialogManager = dialogManager;
   this.factory = recorder.getFinder();
   actionManager.declare(new AssertFrame(assertContext));
   actionManager.declare(new AssertSelected(assertContext));
   actionManager.declare(new AssertListSize(assertContext));
   actionManager.declare(new AssertList(assertContext));
   actionManager.declare(new AssertTable(assertContext));
   actionManager.declare(new AssertTree(assertContext));
   actionManager.declare(new AssertValue(assertContext));
 }