Search in sources :

Example 1 with WebComponent

use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.

the class ContainersScope method findFormComponentContainers.

private static void findFormComponentContainers(Iterator<WebComponent> components, Map<String, List<String>> namesToLayout, FlattenedSolution fs) {
    while (components.hasNext()) {
        WebComponent component = components.next();
        String typeName = (String) component.getProperty(IContentSpecConstants.PROPERTY_TYPENAME);
        WebComponentSpecProvider.getInstance();
        WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(typeName);
        if (spec != null) {
            Collection<PropertyDescription> pd = spec.getProperties(FormComponentPropertyType.INSTANCE);
            if (pd != null && !pd.isEmpty()) {
                PropertyDescription prop = pd.iterator().next();
                Object val = component.getProperty(prop.getName());
                Form fcomp = FormComponentPropertyType.INSTANCE.getForm(val, fs);
                if (fcomp != null && fcomp.isResponsiveLayout()) {
                    fillNames(fcomp.getLayoutContainers(), namesToLayout, fs);
                }
            }
        }
    }
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) WebComponent(com.servoy.j2db.persistence.WebComponent) WebObjectSpecification(org.sablo.specification.WebObjectSpecification) Form(com.servoy.j2db.persistence.Form)

Example 2 with WebComponent

use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.

the class ComponentFactory method createComponentEx.

protected static IComponent createComponentEx(IApplication application, Form form, IPersist meta, IDataProviderLookup dataProviderLookup, IScriptExecuter el, boolean printing) {
    IComponent comp = null;
    switch(meta.getTypeID()) {
        case IRepository.FIELDS:
            comp = createField(application, form, (Field) meta, dataProviderLookup, el, printing);
            break;
        case IRepository.GRAPHICALCOMPONENTS:
            comp = createGraphicalComponent(application, form, (GraphicalComponent) meta, el, dataProviderLookup);
            break;
        case IRepository.RECTSHAPES:
            comp = createRectangle(application, form, (RectShape) meta);
            break;
        case IRepository.PORTALS:
            comp = createPortal(application, form, (Portal) meta, dataProviderLookup, el, printing);
            break;
        case IRepository.PARTS:
            comp = createPart(application, (Part) meta);
            break;
        case IRepository.TABPANELS:
            TabPanel tabPanelMeta = (TabPanel) meta;
            int orient = tabPanelMeta.getTabOrientation();
            if (orient == TabPanel.SPLIT_HORIZONTAL || orient == TabPanel.SPLIT_VERTICAL)
                comp = createSplitPane(application, form, tabPanelMeta, el);
            else
                comp = createTabPanel(application, form, tabPanelMeta, el);
            break;
        case IRepository.BEANS:
            comp = createBean(application, form, (Bean) meta, null);
            break;
        case IRepository.WEBCOMPONENTS:
            comp = createWebComponentPlaceholder(application, form, (WebComponent) meta);
            break;
        default:
            Debug.error("ComponentFactory:unkown type " + meta.getTypeID() + ", uuid: " + meta.getUUID() + ", parent:" + meta.getParent());
            IStandardLabel label = application.getItemFactory().createLabel(getWebID(form, meta), "ComponentFactory:unkown type " + meta.getTypeID());
            label.setSize(new Dimension(200, 20));
            comp = label;
    }
    if (comp instanceof JComponent) {
        ((JComponent) comp).putClientProperty("Id", ComponentFactory.getWebID(form, meta));
    }
    return comp;
}
Also used : ITabPanel(com.servoy.j2db.ui.ITabPanel) TabPanel(com.servoy.j2db.persistence.TabPanel) RuntimeTabPanel(com.servoy.j2db.ui.scripting.RuntimeTabPanel) RectShape(com.servoy.j2db.persistence.RectShape) IComponent(com.servoy.j2db.ui.IComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) JComponent(javax.swing.JComponent) Dimension(java.awt.Dimension) IStandardLabel(com.servoy.j2db.ui.IStandardLabel) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) Bean(com.servoy.j2db.persistence.Bean) RuntimeMediaField(com.servoy.j2db.ui.scripting.RuntimeMediaField) RuntimeDataLookupField(com.servoy.j2db.ui.scripting.RuntimeDataLookupField) Field(com.servoy.j2db.persistence.Field) RuntimeDataField(com.servoy.j2db.ui.scripting.RuntimeDataField) AbstractRuntimeField(com.servoy.j2db.ui.scripting.AbstractRuntimeField) WebComponent(com.servoy.j2db.persistence.WebComponent) Part(com.servoy.j2db.persistence.Part) Portal(com.servoy.j2db.persistence.Portal) RuntimePortal(com.servoy.j2db.ui.scripting.RuntimePortal)

Example 3 with WebComponent

use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.

the class JSNGWebComponent method setHandler.

@Override
public void setHandler(String handlerName, JSMethod value) {
    WebComponent webComponent = getBaseComponent(false);
    WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(webComponent.getTypeName());
    if (spec != null) {
        String name = handlerName;
        if (spec.getHandler(name) == null) {
            name = name + "MethodID";
        }
        if (spec.getHandler(name) != null) {
            setJSONProperty(name, value);
            getBaseComponent(true).putMethodParameters(name, new ArrayList(), value instanceof JSMethodWithArguments ? Arrays.asList(((JSMethodWithArguments) value).getArguments()) : null);
        } else {
            int i = name.indexOf('.');
            if (i > 0) {
                String firstPart = name.substring(0, i);
                PropertyDescription property = spec.getProperty(firstPart);
                if (property != null && property.getType() instanceof IFormComponentType) {
                    // undefined means remove the property
                    Object convertedValue = fromRhinoToDesignValue(value, property, application, this, handlerName);
                    webComponent.setProperty(firstPart, convertedValue);
                    // TODO store the method parameters/arguments..
                    return;
                }
            }
            Debug.log("Error: component " + webComponent.getTypeName() + " does not declare a handler named " + handlerName + ".");
        }
    }
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) WebComponent(com.servoy.j2db.persistence.WebComponent) WebObjectSpecification(org.sablo.specification.WebObjectSpecification) ArrayList(java.util.ArrayList) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) IFormComponentType(com.servoy.j2db.util.IFormComponentType)

Example 4 with WebComponent

use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.

the class JSNGWebComponent method resetJSONProperty.

@Override
public void resetJSONProperty(String propertyName) {
    try {
        WebComponent webComponent = getBaseComponent(true);
        WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(webComponent.getTypeName());
        Pair<PropertyDescription, String> propAndName = getPropertyDescriptionAndName(propertyName, spec);
        PropertyDescription pd = propAndName.getLeft();
        if (pd != null && pd.getType() instanceof IFormComponentType) {
            IFormComponentRhinoConverter converter = ((IFormComponentType) pd.getType()).getFormComponentRhinoConverter(pd.getName(), webComponent.getProperty(pd.getName()), application, this);
            // undefined means remove the property
            Object convertedValue = fromRhinoToDesignValue(Context.getUndefinedValue(), propAndName.getLeft(), application, this, propertyName);
            webComponent.setProperty(propAndName.getRight(), convertedValue);
        } else if (pd != null)
            webComponent.clearProperty(propertyName);
    } catch (JSONException e) {
        Debug.error(e);
    }
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) WebComponent(com.servoy.j2db.persistence.WebComponent) WebObjectSpecification(org.sablo.specification.WebObjectSpecification) IFormComponentRhinoConverter(com.servoy.j2db.util.IFormComponentRhinoConverter) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject) IFormComponentType(com.servoy.j2db.util.IFormComponentType)

Example 5 with WebComponent

use of com.servoy.j2db.persistence.WebComponent in project servoy-client by Servoy.

the class JSNGWebComponent method setJSONProperty.

@Override
public void setJSONProperty(String propertyName, Object value) {
    try {
        WebComponent webComponent = getBaseComponent(true);
        WebObjectSpecification spec = WebComponentSpecProvider.getSpecProviderState().getWebComponentSpecification(webComponent.getTypeName());
        Pair<PropertyDescription, String> propAndName = getPropertyDescriptionAndName(propertyName, spec);
        if (propAndName.getLeft() == null) {
            Debug.warn("Property '" + propertyName + "' not found in spec file of: " + webComponent.getTypeName() + ". It was set using JSWebComponent.setJSONProperty API.");
        }
        Object convertedValue = fromRhinoToDesignValue(value, propAndName.getLeft(), application, this, propertyName);
        webComponent.setProperty(propAndName.getRight(), convertedValue);
    } catch (JSONException e) {
        Debug.error(e);
    }
}
Also used : PropertyDescription(org.sablo.specification.PropertyDescription) WebComponent(com.servoy.j2db.persistence.WebComponent) WebObjectSpecification(org.sablo.specification.WebObjectSpecification) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) ServoyJSONObject(com.servoy.j2db.util.ServoyJSONObject)

Aggregations

WebComponent (com.servoy.j2db.persistence.WebComponent)17 ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)9 PropertyDescription (org.sablo.specification.PropertyDescription)9 WebObjectSpecification (org.sablo.specification.WebObjectSpecification)9 Form (com.servoy.j2db.persistence.Form)8 JSONObject (org.json.JSONObject)7 ArrayList (java.util.ArrayList)4 ServoyClientSupport (com.servoy.base.scripting.annotations.ServoyClientSupport)3 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)3 Dimension (java.awt.Dimension)3 JSFunction (org.mozilla.javascript.annotations.JSFunction)3 AbstractContainer (com.servoy.j2db.persistence.AbstractContainer)2 Field (com.servoy.j2db.persistence.Field)2 IPersist (com.servoy.j2db.persistence.IPersist)2 IPersistVisitor (com.servoy.j2db.persistence.IPersistVisitor)2 DataAdapterList (com.servoy.j2db.server.ngclient.DataAdapterList)2 FormElement (com.servoy.j2db.server.ngclient.FormElement)2 IDataAdapterList (com.servoy.j2db.server.ngclient.IDataAdapterList)2 ServoyDataConverterContext (com.servoy.j2db.server.ngclient.ServoyDataConverterContext)2 WebFormComponent (com.servoy.j2db.server.ngclient.WebFormComponent)2