Search in sources :

Example 6 with IRuntimeComponent

use of com.servoy.j2db.ui.runtime.IRuntimeComponent in project servoy-client by Servoy.

the class RuntimeGroup method setLocation.

/*
	 * Move contained objects relative to location change.
	 *
	 * @see com.servoy.j2db.ui.runtime.IRuntimeComponent#setLocation(int, int)
	 */
public void setLocation(int x, int y) {
    Rectangle bounds = getBounds();
    int dx = x - bounds.x;
    int dy = y - bounds.y;
    for (IRuntimeComponent obj : scriptBaseObjects) {
        obj.setLocation(obj.getLocationX() + dx, obj.getLocationY() + dy);
    }
}
Also used : Rectangle(java.awt.Rectangle) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent)

Example 7 with IRuntimeComponent

use of com.servoy.j2db.ui.runtime.IRuntimeComponent in project servoy-client by Servoy.

the class RuntimeGroup method getBounds.

protected Rectangle getBounds() {
    Rectangle bounds = null;
    for (IRuntimeComponent obj : scriptBaseObjects) {
        int x = obj.getLocationX();
        int y = obj.getLocationY();
        int width = obj.getWidth();
        int height = obj.getHeight();
        Rectangle rect = new Rectangle(x, y, width, height);
        if (bounds == null) {
            bounds = rect;
        } else {
            bounds = bounds.union(rect);
        }
    }
    return bounds == null ? NO_BOUNDS : bounds;
}
Also used : Rectangle(java.awt.Rectangle) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent)

Example 8 with IRuntimeComponent

use of com.servoy.j2db.ui.runtime.IRuntimeComponent in project servoy-client by Servoy.

the class SwingForm method registerComponentsToScope.

private int registerComponentsToScope(Scriptable fs, ElementScope es, int counter, Object[] comps, Object[] compsRenderer, Component controller, Map<String, Object[]> hmChildrenJavaMembers) {
    if (comps != null) {
        for (int j = 0; j < comps.length; j++) {
            Object comp = comps[j];
            if (comp instanceof PortalComponent) {
                PortalComponent portal = (PortalComponent) comp;
                counter = registerComponentsToScope(fs, es, counter, portal.getEditorComponents(), portal.getRendererComponents(), portal, hmChildrenJavaMembers);
            }
            String name = null;
            if (comp instanceof IComponent) {
                name = ((IComponent) comp).getName();
            } else if (comp instanceof Component) {
                name = ((Component) comp).getName();
            }
            Object obj = comp;
            if (comp instanceof InvisibleBean) {
                obj = ((InvisibleBean) comp).getDelegate();
            } else if (comp instanceof VisibleBean) {
                obj = ((VisibleBean) comp).getDelegate();
            }
            String groupName = FormElementGroup.getName((String) formController.getComponentProperty(comp, ComponentFactory.GROUPID_COMPONENT_PROPERTY));
            if (obj instanceof IScriptableProvider)
                obj = ((IScriptableProvider) obj).getScriptObject();
            IRuntimeComponent baseMethodsObj = null;
            if (obj instanceof IRuntimeComponent) {
                baseMethodsObj = (IRuntimeComponent) obj;
            }
            JavaMembers jm = ScriptObjectRegistry.getJavaMembers(obj.getClass(), ScriptableObject.getTopLevelScope(fs));
            // $NON-NLS-1$
            boolean named = name != null && !name.equals("") && !name.startsWith(ComponentFactory.WEB_ID_PREFIX);
            if (groupName != null || named) {
                Object obj2 = null;
                if (compsRenderer != null) {
                    obj2 = compsRenderer[j];
                    if (obj2 instanceof InvisibleBean) {
                        obj2 = ((InvisibleBean) obj2).getDelegate();
                    }
                }
                try {
                    Scriptable s = null;
                    if (obj2 != null) {
                        if (obj2 instanceof IScriptableProvider)
                            obj2 = ((IScriptableProvider) obj2).getScriptObject();
                        NativeJavaObject s2 = new NativeJavaObject(fs, obj2, jm);
                        s = new TwoNativeJavaObject(fs, obj, s2, jm, controller);
                        // group properties have to be set to both
                        if (groupName != null && obj2 instanceof IRuntimeComponent) {
                            if (baseMethodsObj == null) {
                                baseMethodsObj = (IRuntimeComponent) obj2;
                            } else {
                                RuntimeGroup runtimeGroup = new RuntimeGroup(baseMethodsObj.getName());
                                runtimeGroup.addScriptBaseMethodsObj(baseMethodsObj);
                                runtimeGroup.addScriptBaseMethodsObj((IRuntimeComponent) obj2);
                                baseMethodsObj = runtimeGroup;
                            }
                        }
                    } else {
                        s = new NativeJavaObject(fs, obj, jm);
                    }
                    if (named) {
                        es.put(name, fs, s);
                        es.put(counter++, fs, s);
                        hmChildrenJavaMembers.put(name, new Object[] { jm, obj });
                    }
                    if (groupName != null) {
                        Object group = es.get(groupName, fs);
                        if (group == Scriptable.NOT_FOUND) {
                            group = new NativeJavaObject(fs, new RuntimeGroup(groupName), ScriptObjectRegistry.getJavaMembers(RuntimeGroup.class, ScriptableObject.getTopLevelScope(fs)));
                            es.put(groupName, fs, group);
                            es.put(counter++, fs, group);
                        }
                        if (baseMethodsObj != null && group instanceof NativeJavaObject && ((NativeJavaObject) group).unwrap() instanceof RuntimeGroup) {
                            ((RuntimeGroup) (((NativeJavaObject) group).unwrap())).addScriptBaseMethodsObj(baseMethodsObj);
                        }
                    }
                } catch (Throwable ex) {
                    // incase classdefnot founds are thrown for beans,applets/plugins
                    Debug.error(ex);
                }
            }
        }
    }
    return counter;
}
Also used : JavaMembers(org.mozilla.javascript.JavaMembers) IComponent(com.servoy.j2db.ui.IComponent) TwoNativeJavaObject(com.servoy.j2db.smart.scripting.TwoNativeJavaObject) PortalComponent(com.servoy.j2db.smart.dataui.PortalComponent) VisibleBean(com.servoy.j2db.smart.dataui.VisibleBean) InvisibleBean(com.servoy.j2db.smart.dataui.InvisibleBean) Scriptable(org.mozilla.javascript.Scriptable) IScriptable(com.servoy.j2db.scripting.IScriptable) Point(java.awt.Point) RuntimeGroup(com.servoy.j2db.scripting.RuntimeGroup) TwoNativeJavaObject(com.servoy.j2db.smart.scripting.TwoNativeJavaObject) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) PortalComponent(com.servoy.j2db.smart.dataui.PortalComponent) JComponent(javax.swing.JComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) TwoNativeJavaObject(com.servoy.j2db.smart.scripting.TwoNativeJavaObject) NativeJavaObject(org.mozilla.javascript.NativeJavaObject)

Example 9 with IRuntimeComponent

use of com.servoy.j2db.ui.runtime.IRuntimeComponent in project servoy-client by Servoy.

the class TableView method updateComponentBounds.

protected void updateComponentBounds(Component component, Rectangle cellRect, boolean sizeChanged, boolean locationChanged) {
    int height;
    int y;
    if (component instanceof ISupportCachedLocationAndSize) {
        Dimension cachedSize = ((ISupportCachedLocationAndSize) component).getCachedSize();
        height = ((cachedSize != null) ? cachedSize.height : 0);
        Point cachedLocation = ((ISupportCachedLocationAndSize) component).getCachedLocation();
        y = ((cachedLocation != null) ? cachedLocation.y : 0);
    } else {
        height = component.getHeight();
        y = component.getY();
    }
    if (sizeChanged) {
        if (component instanceof IScriptableProvider && ((IScriptableProvider) component).getScriptObject() instanceof IRuntimeComponent) {
            ((IRuntimeComponent) ((IScriptableProvider) component).getScriptObject()).setSize(cellRect.width, height);
        } else {
            component.setSize(cellRect.width, height);
        }
    }
    if (locationChanged) {
        if (component instanceof IScriptableProvider && ((IScriptableProvider) component).getScriptObject() instanceof IRuntimeComponent) {
            ((IRuntimeComponent) ((IScriptableProvider) component).getScriptObject()).setLocation(cellRect.x, y);
        } else {
            component.setLocation(cellRect.x, y);
        }
    }
}
Also used : IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) Dimension(java.awt.Dimension) Point(java.awt.Point) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) ISupportCachedLocationAndSize(com.servoy.j2db.ui.ISupportCachedLocationAndSize) Point(java.awt.Point)

Example 10 with IRuntimeComponent

use of com.servoy.j2db.ui.runtime.IRuntimeComponent in project servoy-client by Servoy.

the class RuntimeGroup method setSize.

/*
	 * Resize contained objects relative to size change.
	 *
	 * @see com.servoy.j2db.ui.runtime.IRuntimeComponent#setSize(int, int)
	 */
public void setSize(int width, int height) {
    Rectangle bounds = getBounds();
    float scalew = ((float) width) / bounds.width;
    float scaleh = ((float) height) / bounds.height;
    for (IRuntimeComponent obj : scriptBaseObjects) {
        int x = obj.getLocationX();
        int y = obj.getLocationY();
        obj.setLocation(bounds.x + (int) Math.floor(scalew * (x - bounds.x)), bounds.y + (int) Math.floor(scaleh * (y - bounds.y)));
        int w = obj.getWidth();
        int h = obj.getHeight();
        obj.setSize((int) Math.floor(scalew * w), (int) Math.floor(scaleh * h));
    }
}
Also used : Rectangle(java.awt.Rectangle) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent)

Aggregations

IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)20 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)15 IComponent (com.servoy.j2db.ui.IComponent)10 Point (java.awt.Point)10 Component (org.apache.wicket.Component)9 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)6 BaseComponent (com.servoy.j2db.persistence.BaseComponent)5 IScriptable (com.servoy.j2db.scripting.IScriptable)5 AbstractRuntimeBaseComponent (com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent)5 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)4 IPortalComponent (com.servoy.j2db.ui.IPortalComponent)4 IPersist (com.servoy.j2db.persistence.IPersist)3 IProviderStylePropertyChanges (com.servoy.j2db.ui.IProviderStylePropertyChanges)3 IRuntimeInputComponent (com.servoy.j2db.ui.runtime.IRuntimeInputComponent)3 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)2 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)2 ISupportAnchors (com.servoy.j2db.persistence.ISupportAnchors)2 RuntimeGroup (com.servoy.j2db.scripting.RuntimeGroup)2 ILabel (com.servoy.j2db.ui.ILabel)2 ISupportWebBounds (com.servoy.j2db.ui.ISupportWebBounds)2