Package net.sourceforge.marathon.component

Examples of net.sourceforge.marathon.component.MComponent


        if (c != null)
            c.requestFocus();
    }

    public void play(ComponentFinder resolver) {
        MComponent component = resolver.getMComponentById(getComponentId());
        waitForWindowActive(getParentWindow(component.getComponent()));
        requestFocus(component.getComponent());
        if (actionType == ActionType.MOUSE_PRESSED) {
            component.mousePressed(modifiers, position);
        } else if (actionType == ActionType.MOUSE_RELEASED) {
            component.mouseReleased(modifiers, position);
        } else if (numberOfClicks == 0 || actionType == ActionType.HOVER)
            component.hover(hoverDelay);
        else
            component.click(numberOfClicks, modifiers, position);
    }
View Full Code Here


        keyChar = keyStrokeParser.getKeyChar();
    }

    public void play(final ComponentFinder resolver) {
        if (withComponent) {
            MComponent component = resolver.getMComponentById(getComponentId());
            if (component.getComponent() != null) {
                waitForWindowActive(getParentWindow(component.getComponent()));
                component.getComponent().requestFocus();
                play(component.getComponent());
                return;
            }
        }
        // Delay and recheck just to make sure the app is not messing with
        // focus itself
View Full Code Here

            n = getOMapComponent(component).getName();
        return n;
    }

    public OMapComponent getOMapComponent(Component component) {
        MComponent current = new MComponent(component, windowMonitor);
        List<OMapComponent> omapComponents = omapService.findComponentsByProperties(getWrapper(current), topContainer);
        OMapComponent omapComponent;
        if (omapComponents.size() == 1) {
            return omapComponents.get(0);
        }
        if (omapComponents.size() > 1) {
            String message = "More than one component matched for " + getPropertyDisplayList(component);
            StringBuilder msg = new StringBuilder(message);
            msg.append("\n    The matched object map entries are:\n");
            for (OMapComponent omc : omapComponents) {
                msg.append("        ").append(omc.toString()).append("\n");
            }
            omapComponent = findClosestMatch(component, omapComponents, msg);
            if (omapComponent != null) {
                runtimeLogger.warning(MODULE, message, msg.toString());
                return omapComponent;
            }
            runtimeLogger.error(MODULE, message, msg.toString());
            throw new ComponentNotFoundException("More than one component matched: " + omapComponents, null, null);
        }
        StringBuilder msg = new StringBuilder();
        omapComponent = findClosestMatch(component, msg);
        if (omapComponent != null) {
            runtimeLogger.warning(MODULE, "Could not find object map entry for component: " + getPropertyDisplayList(component),
                    msg.toString());
            return omapComponent;
        }
        List<String> rprops = findUniqueRecognitionProperties(current, component);
        current.setMComponentName(createName(current));
        List<String> values = new ArrayList<String>();
        for (String k : rprops) {
            values.add(current.getProperty(k));
        }
        List<List<String>> rproperties = findRecognitionProperties(current.getProperty("component.class.name"));
        List<List<String>> nproperties = findNamingProperties(current.getProperty("component.class.name"));
        List<String> gproperties = omapService.getGeneralProperties();
        omapComponent = omapService.insertNameForComponent(current.getProperty("MComponentName"), getWrapper(current), rprops,
                rproperties, nproperties, gproperties, topContainer);
        return omapComponent;
    }
View Full Code Here

    public Map<String, Component> getAllComponents() {
        HashMap<String, Component> componentMap = new HashMap<String, Component>();
        Set<Component> components = getAllAWTComponents();
        for (Component component : components) {
            String name = null;
            MComponent w = new MComponent(component, windowMonitor);
            try {
                OMapComponent oMapComponent = omapService.findComponentByProperties(getWrapper(w), topContainer);
                if (oMapComponent != null)
                    name = oMapComponent.getName();
            } catch (ObjectMapException e) {
View Full Code Here

        return System.getProperty("marathon.mode", "other").equals("recording");
    }

    public void setTopLevelComponent(Component pcontainer, boolean createIfNeeded) {
        container = pcontainer;
        MComponent wrapper = findMComponent(container);
        try {
            topContainer = omapService.getTopLevelComponent(getContainerWrapper(wrapper),
                    findContainerRecognitionProperties(getContainerClassName(wrapper)), omapService.getGeneralProperties(),
                    getTitle(container), createIfNeeded);
        } catch (Exception e) {
View Full Code Here

    }

    private void createVisibleStructure(Component c, StringBuilder sb, String indent) {
        if (!c.isVisible() || c instanceof IRecordingArtifact)
            return;
        MComponent wrapper = new MComponent(c, windowMonitor);
        String name = null;
        try {
            OMapComponent oMapComponent = omapService.findComponentByProperties(getWrapper(wrapper), topContainer);
            if (oMapComponent != null)
                name = oMapComponent.getName();
View Full Code Here

            private Component findContainerForName(String name) {
                Set<Component> components = getAllAWTComponents();
                for (Component c : components) {
                    if (c instanceof JInternalFrame || c instanceof Window) {
                        String n = createName(new MComponent(c, windowMonitor));
                        if (n.equals(name))
                            return c;
                    }
                }
                return null;
View Full Code Here

        List<Component> matchedComponents = (List<Component>) found[0];
        return matchedComponents.get(0);
    }

    protected Properties getPropertyDisplayList(Component component) {
        MComponent mc = new MComponent(component, windowMonitor);
        Properties props = new Properties();
        List<List<String>> properties = findRecognitionProperties(component.getClass().getName());
        properties.add(OMapComponent.LAST_RESORT_RECOGNITION_PROPERTIES);
        for (List<String> list : properties) {
            for (String prop : list) {
                String v = mc.getProperty(prop);
                if (v != null)
                    props.setProperty(prop, v);
            }
        }
        properties = findNamingProperties(component.getClass().getName());
        properties.add(OMapComponent.LAST_RESORT_NAMING_PROPERTIES);
        for (List<String> list : properties) {
            for (String prop : list) {
                String v = mc.getProperty(prop);
                if (v != null)
                    props.setProperty(prop, v);
            }
        }
        List<String> list = omapService.getGeneralProperties();
        for (String prop : list) {
            String v = mc.getProperty(prop);
            if (v != null)
                props.setProperty(prop, v);
        }
        return props;
    }
View Full Code Here

    }

    private MComponent findMComponent(Component pcontainer) {
        ComponentFinder finder = JavaRuntime.getInstance().getFinder();
        if (finder == null)
            return new MComponent(pcontainer, getWindowMonitor());
        return finder.getMComponentByComponent(pcontainer, "No Name", null);
    }
View Full Code Here

    private List<Component> findComponent(OMapComponent omapComponent) {
        List<Component> matchedComponents = new ArrayList<Component>();
        Set<Component> set = getAllAWTComponents();
        for (Component c : set) {
            if (omapComponent.isMatched(new MComponent(c, windowMonitor))) {
                matchedComponents.add(c);
            }
        }
        return matchedComponents;
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.marathon.component.MComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.