Search in sources :

Example 41 with IFormElement

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

the class WebFormController method getTabSequence.

@Override
public String[] getTabSequence() {
    if (tabSequence == null) {
        Map<Integer, String> map = new TreeMap<Integer, String>();
        boolean defaultTabSequence = true;
        for (WebComponent component : formUI.getScriptableComponents()) {
            WebObjectSpecification spec = component.getSpecification();
            Collection<PropertyDescription> properties = spec.getProperties(NGTabSeqPropertyType.NG_INSTANCE);
            if (properties.size() == 1) {
                PropertyDescription pd = properties.iterator().next();
                Integer value = (Integer) component.getProperty(pd.getName());
                defaultTabSequence = defaultTabSequence && value.intValue() == 0;
                if (!component.getName().startsWith(FormElement.SVY_NAME_PREFIX) && value.intValue() > 0) {
                    map.put(value, component.getName());
                }
            }
        }
        if (defaultTabSequence) {
            ArrayList<String> sequence = new ArrayList<String>();
            Iterator<IFormElement> it = form.getFormElementsSortedByFormIndex();
            while (it.hasNext()) {
                IFormElement element = it.next();
                if (element.getName() != null)
                    sequence.add(element.getName());
            }
            tabSequence = sequence.toArray(new String[sequence.size()]);
        } else {
            tabSequence = map.values().toArray(new String[map.size()]);
        }
    }
    return tabSequence;
}
Also used : WebObjectSpecification(org.sablo.specification.WebObjectSpecification) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) PropertyDescription(org.sablo.specification.PropertyDescription) WebComponent(org.sablo.WebComponent) IFormElement(com.servoy.j2db.persistence.IFormElement)

Example 42 with IFormElement

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

the class ComponentFactory method createComponent.

/**
 * Create a component
 *
 * @param meta the definition
 * @param el the event listener such as action,mouse event listeners, can be null (Example:makes possible for button to call script)
 */
public static IComponent createComponent(IApplication application, Form form, IPersist meta, IDataProviderLookup dataProviderLookup, IScriptExecuter el, boolean printing) {
    IComponent c = createComponentEx(application, form, meta, dataProviderLookup, el, printing);
    // set groupID property
    if (meta instanceof IFormElement && ((IFormElement) meta).getGroupID() != null) {
        String groupId = ((IFormElement) meta).getGroupID();
        if (groupId != null) {
            setComponentProperty(application, c, GROUPID_COMPONENT_PROPERTY, groupId);
        }
    }
    // Extra call so that focusable is user set...
    if (c instanceof Component) {
        Component comp = (Component) c;
        if (comp.isFocusable())
            comp.setFocusable(true);
        OrientationApplier.setOrientationToAWTComponent(comp, application.getLocale(), application.getSolution().getTextOrientation());
    }
    int access = application.getFlattenedSolution().getSecurityAccess(meta.getUUID(), form.getImplicitSecurityNoRights() ? IRepository.IMPLICIT_FORM_NO_ACCESS : IRepository.IMPLICIT_FORM_ACCESS);
    if (access != -1) {
        boolean b_visible = ((access & IRepository.VIEWABLE) != 0);
        if (!b_visible) {
            if (c instanceof ISupportSecuritySettings) {
                ((ISupportSecuritySettings) c).setViewable(false);
            } else {
                c.setComponentVisible(false);
            }
        }
        if (c instanceof ISupportSecuritySettings) {
            boolean b_accessible = ((access & IRepository.ACCESSIBLE) != 0);
            if (!b_accessible)
                ((ISupportSecuritySettings) c).setAccessible(false);
        }
    }
    // special case requested by ayton (have own security interface)
    if (c instanceof ITabPanel && meta instanceof TabPanel) {
        try {
            int i = 0;
            Iterator<IPersist> it = ((TabPanel) meta).getTabs();
            while (it.hasNext()) {
                Tab t = (Tab) it.next();
                int access1 = application.getFlattenedSolution().getSecurityAccess(t.getUUID(), form.getImplicitSecurityNoRights() ? IRepository.IMPLICIT_FORM_NO_ACCESS : IRepository.IMPLICIT_FORM_ACCESS);
                if (access1 != -1) {
                    boolean b_accessible = ((access1 & IRepository.ACCESSIBLE) != 0);
                    boolean b_visible = ((access & IRepository.VIEWABLE) != 0);
                    if (!b_accessible || !b_visible)
                        ((ITabPanel) c).setTabEnabledAt(i, false);
                }
                i++;
            }
        } catch (Exception e) {
            Debug.error(e);
        }
    }
    return c;
}
Also used : ITabPanel(com.servoy.j2db.ui.ITabPanel) TabPanel(com.servoy.j2db.persistence.TabPanel) RuntimeTabPanel(com.servoy.j2db.ui.scripting.RuntimeTabPanel) IComponent(com.servoy.j2db.ui.IComponent) ITabPanel(com.servoy.j2db.ui.ITabPanel) JSONException(org.json.JSONException) IOException(java.io.IOException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) IFormElement(com.servoy.j2db.persistence.IFormElement) Tab(com.servoy.j2db.persistence.Tab) IPersist(com.servoy.j2db.persistence.IPersist) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) AbstractRuntimeValuelistComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeValuelistComponent) BaseComponent(com.servoy.j2db.persistence.BaseComponent) IFormatScriptComponent(com.servoy.j2db.ui.scripting.IFormatScriptComponent) IAnchoredComponent(com.servoy.j2db.ui.IAnchoredComponent) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) WebComponent(com.servoy.j2db.persistence.WebComponent) IPortalComponent(com.servoy.j2db.ui.IPortalComponent) JComponent(javax.swing.JComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) ISupportSecuritySettings(com.servoy.j2db.ui.ISupportSecuritySettings)

Aggregations

IFormElement (com.servoy.j2db.persistence.IFormElement)42 IPersist (com.servoy.j2db.persistence.IPersist)20 ArrayList (java.util.ArrayList)15 Point (java.awt.Point)14 HashMap (java.util.HashMap)12 JSONObject (org.json.JSONObject)12 PropertyDescription (org.sablo.specification.PropertyDescription)11 Form (com.servoy.j2db.persistence.Form)8 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)8 Part (com.servoy.j2db.persistence.Part)8 FormElement (com.servoy.j2db.server.ngclient.FormElement)8 WebObjectSpecification (org.sablo.specification.WebObjectSpecification)8 Dimension (java.awt.Dimension)7 AbstractBase (com.servoy.j2db.persistence.AbstractBase)6 PropertyPath (com.servoy.j2db.server.ngclient.property.types.PropertyPath)6 BaseComponent (com.servoy.j2db.persistence.BaseComponent)5 LayoutContainer (com.servoy.j2db.persistence.LayoutContainer)5 Portal (com.servoy.j2db.persistence.Portal)4 ServoyJSONObject (com.servoy.j2db.util.ServoyJSONObject)4 IBasicWebObject (com.servoy.j2db.persistence.IBasicWebObject)3