Search in sources :

Example 6 with RuntimeWebComponent

use of com.servoy.j2db.server.ngclient.component.RuntimeWebComponent in project servoy-client by Servoy.

the class WebFormUI method getScriptableComponents.

public Collection<WebComponent> getScriptableComponents() {
    List<WebComponent> components = new ArrayList<WebComponent>();
    Object[] names = getElementsScope().getIds();
    if (names != null) {
        for (Object componentName : names) {
            Object component = getElementsScope().get((String) componentName, null);
            if (component instanceof RuntimeWebComponent) {
                components.add(((RuntimeWebComponent) component).getComponent());
            }
        }
    }
    return components;
}
Also used : WebComponent(org.sablo.WebComponent) RuntimeWebComponent(com.servoy.j2db.server.ngclient.component.RuntimeWebComponent) ArrayList(java.util.ArrayList) JSONObject(org.json.JSONObject) RuntimeWebComponent(com.servoy.j2db.server.ngclient.component.RuntimeWebComponent)

Example 7 with RuntimeWebComponent

use of com.servoy.j2db.server.ngclient.component.RuntimeWebComponent in project servoy-client by Servoy.

the class WebFormUI method removeComponentFromElementsScope.

// this should be the opposite of formUI.contributeComponentToElementsScope(...)
public void removeComponentFromElementsScope(FormElement fe, WebObjectSpecification componentSpec, WebFormComponent component) {
    ElementScope elementsScope = getElementsScope();
    if (elementsScope != null) {
        if (!FormElement.ERROR_BEAN.equals(componentSpec.getName()) && (!fe.getName().startsWith("svy_") || ((fe.getPersistIfAvailable() instanceof IFormElement) && ((IFormElement) fe.getPersistIfAvailable()).getGroupID() != null))) {
            if (!fe.getName().startsWith("svy_")) {
                RuntimeWebComponent runtimeComponent = (RuntimeWebComponent) elementsScope.remove(fe.getRawName());
                elementsScope.removeIndexByValue(runtimeComponent);
            }
            String groupID = fe.getPersistIfAvailable() instanceof IFormElement ? ((IFormElement) fe.getPersistIfAvailable()).getGroupID() : null;
            if (groupID != null) {
                if (groups == null)
                    groups = new HashMap<String, RuntimeWebGroup>(4);
                RuntimeWebGroup group = groups.get(groupID);
                if (group != null) {
                    String groupName = FormElementGroup.getName(groupID);
                    group.remove(component);
                    if (group.getComponentCount() == 0)
                        elementsScope.remove(groupName);
                    groups.remove(groupID);
                }
            }
        }
    } else {
        Debug.error(new RuntimeException("Trying to remove component from a non-existent elements scope for form: " + getName()));
    }
}
Also used : IFormElement(com.servoy.j2db.persistence.IFormElement) RuntimeWebGroup(com.servoy.j2db.server.ngclient.component.RuntimeWebGroup) HashMap(java.util.HashMap) ElementScope(com.servoy.j2db.scripting.ElementScope) RuntimeWebComponent(com.servoy.j2db.server.ngclient.component.RuntimeWebComponent)

Aggregations

RuntimeWebComponent (com.servoy.j2db.server.ngclient.component.RuntimeWebComponent)7 JSONObject (org.json.JSONObject)6 IFormElement (com.servoy.j2db.persistence.IFormElement)3 WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)3 RuntimeLegacyComponent (com.servoy.j2db.server.ngclient.component.RuntimeLegacyComponent)3 Point (java.awt.Point)3 ElementScope (com.servoy.j2db.scripting.ElementScope)2 FormElement (com.servoy.j2db.server.ngclient.FormElement)2 RuntimeWebGroup (com.servoy.j2db.server.ngclient.component.RuntimeWebGroup)2 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 IJSEvent (com.servoy.base.scripting.api.IJSEvent)1 FlattenedSolution (com.servoy.j2db.FlattenedSolution)1 Form (com.servoy.j2db.persistence.Form)1 FormScope (com.servoy.j2db.scripting.FormScope)1 JSEvent (com.servoy.j2db.scripting.JSEvent)1 JSForm (com.servoy.j2db.scripting.solutionmodel.JSForm)1 FormComponentCache (com.servoy.j2db.server.ngclient.FormElementHelper.FormComponentCache)1