Exemple #1
1
 /**
  * Factory method, equivalent to a "fromXML" for step creation. Looks for a class with the same
  * name as the XML tag, with the first letter capitalized. For example, <call /> is
  * abbot.script.Call.
  */
 public static Step createStep(Resolver resolver, Element el) throws InvalidScriptException {
   String tag = el.getName();
   Map attributes = createAttributeMap(el);
   String name = tag.substring(0, 1).toUpperCase() + tag.substring(1);
   if (tag.equals(TAG_WAIT)) {
     attributes.put(TAG_WAIT, "true");
     name = "Assert";
   }
   try {
     name = "abbot.script." + name;
     Log.debug("Instantiating " + name);
     Class cls = Class.forName(name);
     try {
       // Steps with contents require access to the XML element
       Class[] argTypes = new Class[] {Resolver.class, Element.class, Map.class};
       Constructor ctor = cls.getConstructor(argTypes);
       return (Step) ctor.newInstance(new Object[] {resolver, el, attributes});
     } catch (NoSuchMethodException nsm) {
       // All steps must support this ctor
       Class[] argTypes = new Class[] {Resolver.class, Map.class};
       Constructor ctor = cls.getConstructor(argTypes);
       return (Step) ctor.newInstance(new Object[] {resolver, attributes});
     }
   } catch (ClassNotFoundException cnf) {
     String msg = Strings.get("step.unknown_tag", new Object[] {tag});
     throw new InvalidScriptException(msg);
   } catch (InvocationTargetException ite) {
     Log.warn(ite);
     throw new InvalidScriptException(ite.getTargetException().getMessage());
   } catch (Exception exc) {
     Log.warn(exc);
     throw new InvalidScriptException(exc.getMessage());
   }
 }
 public void start() {
   super.start();
   steps.clear();
   MessageFormat mf = new MessageFormat(Strings.get("RecordingX"));
   setStatus(mf.format(new Object[] {toString()}));
   lastStepTime = getLastEventTime();
 }
Exemple #3
0
 /**
  * Store an invalid script exception describing the proper script usage. This should be used by
  * derived classes whenever parsing indicates invalid input.
  */
 protected void usage(String details) {
   String msg = getUsage();
   if (details != null) {
     msg = Strings.get("step.usage", new Object[] {msg, details});
   }
   setScriptError(new InvalidScriptException(msg));
 }
 /** Return the name of the type of GUI action to be recorded. */
 public String toString() {
   return captureMotion ? Strings.get("actions.capture-all") : Strings.get("actions.capture");
 }