Search in sources :

Example 1 with ICouchParametersExtra

use of com.twinsoft.convertigo.beans.transactions.couchdb.ICouchParametersExtra in project convertigo by convertigo.

the class CouchVariablesComposite method setPropertyDescriptor.

public void setPropertyDescriptor(AbstractCouchDbTransaction couchDbTransaction, PropertyDescriptor[] propertyDescriptors, DatabaseObject parentObject) {
    cleanGroups();
    /* Fill the Group widget */
    for (PropertyDescriptor property : propertyDescriptors) {
        String name = property.getName();
        String description = property.getShortDescription();
        if (!parametersCouch.contains(name)) {
            if ((name.startsWith("q_") || name.startsWith("p_"))) {
                if (!parentObject.getClass().getCanonicalName().equals(property.getValue(MySimpleBeanInfo.BLACK_LIST_PARENT_CLASS))) {
                    Group choosenGroup = name.startsWith("q_") ? groupQueries : groupParameters;
                    description = description.replaceFirst("\\|", "<br/>\n");
                    addToComposite(choosenGroup, name, description, false);
                }
            }
        }
    }
    Collection<CouchExtraVariable> extraVariables = null;
    if (couchDbTransaction instanceof ICouchParametersExtra) {
        extraVariables = ((ICouchParametersExtra) couchDbTransaction).getCouchParametersExtra();
    }
    if (extraVariables != null) {
        for (CouchExtraVariable extraVariable : extraVariables) {
            String name = extraVariable.getVariableName();
            Group group = name.startsWith("q_") ? groupQueries : groupData;
            addToComposite(group, name, extraVariable.getVariableDescription(), extraVariable.isMultiValued());
        }
    }
    if (groupQueries.getChildren().length == 1) {
        groupQueries.dispose();
    }
    if (groupParameters.getChildren().length == 1) {
        groupParameters.dispose();
    }
    if (groupData.getChildren().length == 1) {
        groupData.dispose();
    }
    setContent(globalComposite);
    globalComposite.pack(true);
    // Fix text no displayed in C8oBrowser
    LinkedList<Control> controls = new LinkedList<>();
    controls.add(globalComposite);
    Control c;
    while ((c = controls.pollFirst()) != null) {
        if (c instanceof C8oBrowser) {
            ((C8oBrowser) c).reloadText();
        } else if (c instanceof Composite) {
            controls.addAll(Arrays.asList(((Composite) c).getChildren()));
        }
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) CouchExtraVariable(com.twinsoft.convertigo.engine.enums.CouchExtraVariable) Control(org.eclipse.swt.widgets.Control) PropertyDescriptor(java.beans.PropertyDescriptor) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) C8oBrowser(com.twinsoft.convertigo.eclipse.swt.C8oBrowser) ICouchParametersExtra(com.twinsoft.convertigo.beans.transactions.couchdb.ICouchParametersExtra) LinkedList(java.util.LinkedList)

Aggregations

ICouchParametersExtra (com.twinsoft.convertigo.beans.transactions.couchdb.ICouchParametersExtra)1 C8oBrowser (com.twinsoft.convertigo.eclipse.swt.C8oBrowser)1 CouchExtraVariable (com.twinsoft.convertigo.engine.enums.CouchExtraVariable)1 PropertyDescriptor (java.beans.PropertyDescriptor)1 LinkedList (java.util.LinkedList)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Group (org.eclipse.swt.widgets.Group)1