Search in sources :

Example 61 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class NumberClass method newProperty.

@Override
public BaseProperty newProperty() {
    String ntype = getNumberType();
    BaseProperty property;
    if (ntype.equals("integer")) {
        property = new IntegerProperty();
    } else if (ntype.equals("float")) {
        property = new FloatProperty();
    } else if (ntype.equals("double")) {
        property = new DoubleProperty();
    } else {
        property = new LongProperty();
    }
    property.setName(getName());
    return property;
}
Also used : IntegerProperty(com.xpn.xwiki.objects.IntegerProperty) LongProperty(com.xpn.xwiki.objects.LongProperty) BaseProperty(com.xpn.xwiki.objects.BaseProperty) FloatProperty(com.xpn.xwiki.objects.FloatProperty) DoubleProperty(com.xpn.xwiki.objects.DoubleProperty)

Example 62 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class PropertyClass method displayEdit.

@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    input input = new input();
    input.setAttributeFilter(new XMLAttributeValueFilter());
    BaseProperty prop = (BaseProperty) object.safeget(name);
    if (prop != null) {
        input.setValue(prop.toText());
    }
    input.setType("text");
    input.setName(prefix + name);
    input.setID(prefix + name);
    input.setDisabled(isDisabled());
    buffer.append(input.toString());
}
Also used : org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) XMLAttributeValueFilter(com.xpn.xwiki.internal.xml.XMLAttributeValueFilter) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 63 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class PropertyClass method toXML.

@Override
public Element toXML() {
    Element pel = new DOMElement(getName());
    // Iterate over values sorted by field name so that the values are
    // exported to XML in a consistent order.
    Iterator it = getSortedIterator();
    while (it.hasNext()) {
        BaseProperty bprop = (BaseProperty) it.next();
        pel.add(bprop.toXML());
    }
    Element el = new DOMElement("classType");
    String classType = getClassType();
    if (this.getClass().getSimpleName().equals(classType + "Class")) {
        // Keep exporting the full Java class name for old/default property types to avoid breaking the XAR format
        // (to allow XClasses created with the current version of XWiki to be imported in an older version).
        classType = this.getClass().getName();
    }
    el.addText(classType);
    pel.add(el);
    return pel;
}
Also used : DOMElement(org.dom4j.dom.DOMElement) Element(org.dom4j.Element) Iterator(java.util.Iterator) DOMElement(org.dom4j.dom.DOMElement) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 64 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class PropertyClass method fromValue.

@Override
public BaseProperty fromValue(Object value) {
    BaseProperty property = newProperty();
    property.setValue(value);
    return property;
}
Also used : BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Example 65 with BaseProperty

use of com.xpn.xwiki.objects.BaseProperty in project xwiki-platform by xwiki.

the class StringClass method newProperty.

@Override
public BaseProperty newProperty() {
    BaseProperty property = new StringProperty();
    property.setName(getName());
    return property;
}
Also used : StringProperty(com.xpn.xwiki.objects.StringProperty) BaseProperty(com.xpn.xwiki.objects.BaseProperty)

Aggregations

BaseProperty (com.xpn.xwiki.objects.BaseProperty)87 BaseObject (com.xpn.xwiki.objects.BaseObject)26 ArrayList (java.util.ArrayList)16 XWikiException (com.xpn.xwiki.XWikiException)14 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)12 XMLAttributeValueFilter (com.xpn.xwiki.internal.xml.XMLAttributeValueFilter)12 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)11 XWikiContext (com.xpn.xwiki.XWikiContext)10 BaseClass (com.xpn.xwiki.objects.classes.BaseClass)9 DocumentReference (org.xwiki.model.reference.DocumentReference)9 StringProperty (com.xpn.xwiki.objects.StringProperty)8 ListProperty (com.xpn.xwiki.objects.ListProperty)7 XWiki (com.xpn.xwiki.XWiki)5 BaseCollection (com.xpn.xwiki.objects.BaseCollection)5 LargeStringProperty (com.xpn.xwiki.objects.LargeStringProperty)5 List (java.util.List)5 Test (org.junit.Test)5 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)5 DBStringListProperty (com.xpn.xwiki.objects.DBStringListProperty)4 PropertyClass (com.xpn.xwiki.objects.classes.PropertyClass)4