Search in sources :

Example 1 with ISupportName

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

the class ScrollResponseHeaderContainer method getTabSeqComponentNames.

public List<String> getTabSeqComponentNames() {
    // elementTabIndexes is not sorted. We have to sort the indexes of the tabs first.
    SortedMap<Integer, IPersist> sortedTabIndexes = new TreeMap<Integer, IPersist>();
    for (IPersist key : elementTabIndexes.keySet()) {
        sortedTabIndexes.put(elementTabIndexes.get(key), key);
    }
    List<String> tabSeqNames = new ArrayList<String>();
    for (int i : sortedTabIndexes.keySet()) {
        IPersist key = sortedTabIndexes.get(i);
        if (key instanceof ISupportName) {
            String name = ((ISupportName) key).getName();
            if (name != null) {
                tabSeqNames.add(name);
            }
        }
    }
    return tabSeqNames;
}
Also used : IPersist(com.servoy.j2db.persistence.IPersist) ISupportName(com.servoy.j2db.persistence.ISupportName) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) Point(java.awt.Point)

Example 2 with ISupportName

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

the class SortableCellViewHeader method setWidth.

public void setWidth(int width) {
    int borderWidth = 0;
    Iterator<IPersist> it2 = cellview.getAllObjects();
    while (it2.hasNext()) {
        IPersist element = it2.next();
        if (id.equals(ComponentFactory.getWebID(form, element))) {
            GraphicalComponent gc = (GraphicalComponent) view.labelsFor.get(((ISupportName) element).getName());
            if (gc != null) {
                TextualStyle styleObj = new TextualStyle();
                BorderAndPadding ins = TemplateGenerator.applyBaseComponentProperties(gc, view.fc.getForm(), styleObj, (Insets) TemplateGenerator.DEFAULT_LABEL_PADDING.clone(), null, application);
                if (ins.border != null)
                    borderWidth = ins.border.left + ins.border.right;
            }
        }
    }
    int headerPadding = TemplateGenerator.SORTABLE_HEADER_PADDING;
    // If there is no label-for, we leave place for the default border placed at the right of headers.
    if (view.labelsFor.size() == 0) {
        int extraWidth = TemplateGenerator.NO_LABELFOR_DEFAULT_BORDER_WIDTH;
        String headerBorder = view.getHeaderBorder();
        if (headerBorder != null) {
            Properties properties = new Properties();
            Insets borderIns = ComponentFactoryHelper.createBorderCSSProperties(headerBorder, properties);
            extraWidth = borderIns.left + borderIns.right;
            headerPadding = 0;
        }
        borderWidth += extraWidth;
    }
    // we have only left padding
    int clientWidth = width - headerPadding - borderWidth;
    // if we have grid_style for the header, then don't change the header width
    this.width = (view.labelsFor.size() == 0 && view.getHeaderBorder() != null) ? width : clientWidth;
    StyleAppendingModifier widthStyleModifier = new StyleAppendingModifier(new Model<String>() {

        @Override
        public String getObject() {
            // $NON-NLS-1$//$NON-NLS-2$
            return "width: " + SortableCellViewHeader.this.width + "px";
        }
    });
    add(widthStyleModifier);
    headerColumnTable.add(widthStyleModifier);
    labelResolver.setWidth(clientWidth - SortableCellViewHeader.ARROW_WIDTH);
    getStylePropertyChanges().setChanged();
}
Also used : Insets(java.awt.Insets) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) ISupportName(com.servoy.j2db.persistence.ISupportName) BorderAndPadding(com.servoy.j2db.server.headlessclient.dataui.TemplateGenerator.BorderAndPadding) Properties(java.util.Properties) TextualStyle(com.servoy.j2db.server.headlessclient.dataui.TemplateGenerator.TextualStyle) IPersist(com.servoy.j2db.persistence.IPersist)

Example 3 with ISupportName

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

the class ComponentFactory method getWebID.

public static String getWebID(Form form, IPersist meta) {
    StringBuilder prefix = new StringBuilder();
    // to stay javascript id ref compatible
    prefix.append(WEB_ID_PREFIX);
    if (element_name_as_uid_prefix == null) {
        Settings s = Settings.getInstance();
        element_name_as_uid_prefix = Boolean.valueOf(Utils.getAsBoolean(s.getProperty("servoy.webclient.templates.element_name_as_uid_prefix")));
    }
    if (element_name_as_uid_prefix == Boolean.TRUE && meta instanceof ISupportName) {
        String name = ((ISupportName) meta).getName();
        if (name != null && name.trim().length() != 0) {
            prefix.append('_');
            prefix.append(name);
        }
    }
    prefix.append('_');
    String uid = meta.getUUID().toString();
    uid = Utils.stringReplace(uid, "-", "_");
    prefix.append(uid);
    return prefix.toString();
}
Also used : ISupportName(com.servoy.j2db.persistence.ISupportName) ISupportSecuritySettings(com.servoy.j2db.ui.ISupportSecuritySettings) Settings(com.servoy.j2db.util.Settings)

Example 4 with ISupportName

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

the class JSSecurity method hasFormAccess.

private boolean hasFormAccess(String formName, String elementName, int accessType) {
    Form form = application.getFlattenedSolution().getForm(formName);
    int access = 0;
    if (form != null) {
        UUID accesUUID = null;
        if (elementName != null) {
            for (IPersist persist : form.getFlattenedFormElementsAndLayoutContainers()) {
                if (persist instanceof ISupportName && Utils.equalObjects(elementName, ((ISupportName) persist).getName())) {
                    accesUUID = persist.getUUID();
                    break;
                }
            }
        } else {
            accesUUID = form.getUUID();
        }
        if (accesUUID != null) {
            access = application.getFlattenedSolution().getSecurityAccess(accesUUID, form.getImplicitSecurityNoRights() ? IRepository.IMPLICIT_FORM_NO_ACCESS : IRepository.IMPLICIT_FORM_ACCESS);
        }
    }
    return ((access & accessType) != 0);
}
Also used : Form(com.servoy.j2db.persistence.Form) IPersist(com.servoy.j2db.persistence.IPersist) ISupportName(com.servoy.j2db.persistence.ISupportName) UUID(com.servoy.j2db.util.UUID)

Example 5 with ISupportName

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

the class JSSecurity method js_getElementUUIDs.

/**
 * Returns the form elements UUID's as dataset, the one with no name is the form itself.
 *
 * @sample var formElementsUUIDDataSet = security.getElementUUIDs('orders_form');
 *
 * @param formname the formname to retieve the dataset for
 * @return dataset with element info
 */
public // return dataset with name, uuid (note: null name is form uuid)
JSDataSet js_getElementUUIDs(// return dataset with name, uuid (note: null name is form uuid)
String formname) {
    Form f = application.getFlattenedSolution().getForm(formname);
    if (f == null)
        f = application.getFormManager().getPossibleForm(formname);
    if (f != null) {
        List elements = new ArrayList();
        elements.add(new Object[] { null, f.getUUID() });
        Iterator<? extends IPersist> it = f.isResponsiveLayout() ? f.getFlattenedObjects(NameComparator.INSTANCE).iterator() : f.getAllObjects();
        while (it.hasNext()) {
            IPersist elem = it.next();
            int type = elem.getTypeID();
            if (type == IRepository.GRAPHICALCOMPONENTS || type == IRepository.FIELDS || type == IRepository.PORTALS || type == IRepository.RECTSHAPES || type == IRepository.SHAPES || type == IRepository.BEANS || type == IRepository.TABPANELS || type == IRepository.WEBCOMPONENTS) {
                if (elem instanceof ISupportName && ((ISupportName) elem).getName() != null) {
                    elements.add(new Object[] { ((ISupportName) elem).getName(), elem.getUUID() });
                }
            }
        }
        IDataSet set = new BufferedDataSet(new String[] { "name", "uuid" }, elements);
        return new JSDataSet(application, set);
    }
    return new JSDataSet(application);
}
Also used : BufferedDataSet(com.servoy.j2db.dataprocessing.BufferedDataSet) Form(com.servoy.j2db.persistence.Form) IPersist(com.servoy.j2db.persistence.IPersist) ISupportName(com.servoy.j2db.persistence.ISupportName) ArrayList(java.util.ArrayList) JSDataSet(com.servoy.j2db.dataprocessing.JSDataSet) ArrayList(java.util.ArrayList) List(java.util.List) IDataSet(com.servoy.j2db.dataprocessing.IDataSet)

Aggregations

ISupportName (com.servoy.j2db.persistence.ISupportName)10 IPersist (com.servoy.j2db.persistence.IPersist)7 Form (com.servoy.j2db.persistence.Form)5 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)4 Point (java.awt.Point)3 FormController (com.servoy.j2db.FormController)2 Bean (com.servoy.j2db.persistence.Bean)2 Field (com.servoy.j2db.persistence.Field)2 Part (com.servoy.j2db.persistence.Part)2 Portal (com.servoy.j2db.persistence.Portal)2 WebForm (com.servoy.j2db.server.headlessclient.WebForm)2 Dimension (java.awt.Dimension)2 ArrayList (java.util.ArrayList)2 IForm (com.servoy.j2db.IForm)1 IProvideTabSequence (com.servoy.j2db.IProvideTabSequence)1 BufferedDataSet (com.servoy.j2db.dataprocessing.BufferedDataSet)1 FoundSetListWrapper (com.servoy.j2db.dataprocessing.FoundSetListWrapper)1 FoundSetManager (com.servoy.j2db.dataprocessing.FoundSetManager)1 IDataSet (com.servoy.j2db.dataprocessing.IDataSet)1 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)1