예제 #1
0
 // Close the program.
 private void closeProgram() {
   guiCapture.stopCapture();
   System.exit(0);
 }
예제 #2
0
  public CaptureReplay() {

    // Define layout of overall window, create space, then components.
    super(new BorderLayout(10, 10));
    setBorder(BorderFactory.createEmptyBorder(15, 3, 0, 0));
    createMainPanel();

    // Define classes used to collect and save test data.
    efgtstCapture = new JFCXTestCase();
    guiCapture =
        new CaptureAsYouGo(
            new MouseListener() {
              public void mousePressed(MouseEvent e) {}

              public void mouseReleased(MouseEvent e) {}

              public void mouseClicked(MouseEvent e) {
                efgtstCapture.addComponent((Component) e.getSource());
              }

              public void mouseEntered(MouseEvent e) {}

              public void mouseExited(MouseEvent e) {}
            });

    guiCapture.addComponentInspector(
        new CaptureAsYouGo.ComponentInspector() {
          private ActionListener actionCapture =
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  System.out.println("ActionPerformed");
                  efgtstCapture.addComponent((Component) e.getSource());
                }
              };

          public boolean inspect(Component component) {
            boolean add = component instanceof AbstractButton && !(component instanceof JMenu);
            if (add) ((AbstractButton) component).addActionListener(this.actionCapture);
            return add;
          }

          public String getReplayableActionType() {
            return "edu.umd.cs.guitar.event.JFCActionHandler";
          }
          /* public void inspectComponent(Component component, ComponentTypeWrapper componentType) {
           	if(component instanceof AbstractButton && !(component instanceof JMenu)) {
          	((AbstractButton)component).addActionListener(this.actionCapture) ;
          	componentType.addAttribute("ReplayableAction", "edu.umd.cs.guitar.JFCActionHandler") ;
          }
           } */
        });

    guiCapture.addComponentInspector(
        new CaptureAsYouGo.ComponentInspector() {
          private ActionListener actionCapture =
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  System.out.println("ActionPerformed");
                  efgtstCapture.addComponent((Component) e.getSource());
                }
              };

          public boolean inspect(Component component) {
            boolean add = component instanceof Button;
            if (add) ((Button) component).addActionListener(this.actionCapture);
            return add;
          }

          public String getReplayableActionType() {
            return "edu.umd.cs.guitar.event.JFCActionHandler";
          }
        });

    guiCapture.addComponentInspector(
        new CaptureAsYouGo.ComponentInspector() {
          private MenuListener menuCapture =
              new MenuListener() {
                public void menuCanceled(MenuEvent e) {}

                public void menuDeselected(MenuEvent e) {}

                public void menuSelected(MenuEvent e) {
                  System.out.println("MenuSelected");
                  efgtstCapture.addComponent((Component) e.getSource());
                }
              };

          public boolean inspect(Component component) {
            boolean add = component instanceof JMenu;
            if (add) ((JMenu) component).addMenuListener(this.menuCapture);
            return add;
          }

          public String getReplayableActionType() {
            return "edu.umd.cs.guitar.event.JFCSelectionHandler";
          }
        });

    // Define list of test name for replaying.
    tests = new ArrayList<JCheckBox>();
  }