Re: Questions about xforms editor
Hi,
I made some change to the core/ui to add the Hint Control has an object
rather than an attribute.
I corrected some bugs in ArrayMap and AttributesMap too.
Cheers,
Stéphane.
Bogdan Stefanescu a écrit :
> Stéphane Bouchet wrote:
>
>> Bogdan Stefanescu a écrit :
>>
>>> Stéphane Bouchet wrote:
>>>
>>> Hi Stephane,
>>>
>>> If I remember well the "Hint" is mapped to an attribute to ease the
>>> generation of the SWT form
>>> because usually a xforms control element is mapped to an eclipse control
>>> (like XFInput to a text widget)
>>> And the hint element is mapped to a tooltip which is not a swt controlb
>>> but a widget property.
>>>
>>>
>> ok, i understand that.
>>
>>
>>> The same is used to store the label of a xform component by setting the
>>> mLabel member of the parent control (XFLabeledControl)
>>> instead of mapping it into a SWT label - this way we can easily put the
>>> label widget before widget corresponding to the parent element in the
>>> SWT form.
>>>
>>>
>> ok, iunderstand too, but the mLabel member is atype of XFLabel, not
>> an attribute.
>>
>> My question is : why not having a mHint member for each Control, that
>> will be mapped into a tooltiptext ?
>>
> Indeed, we can do that since all controls may have tooltips.
> Initially the AttributeMap was added to store custom properties on
> controls, but since the hint is valid for any control we may
> put it directly in the control as a member.
>
>
>> i understand that the swt tooltip is a property, but in the XForm
>> Model, it is specified that the hint element is not an attribute.
>> Then, it is the job of the SWTBuilder to set the property if the hint
>> element is set or not.
>>
>> This could be cdone via XFControlElement, that holds the actions and
>> style of every control.
>>
>>
>>
>>> There are many things to be implemented and fix. (like the AttributeMap
>>> bug you mention)
>>>
>>> Unfortunately, I had no time to continue development on the XForms
>>> engine these months - I hope this will change in the near future - when
>>> the core part of Apogee will be done so that we can integrate the engine
>>> into Apogee.
>>>
>>> Anyway, anyone is welcome to contribute with fixes or new features.
>>>
>>>
>> Ok, i'll try to do some changes and send the patches.
>>
> Thank you
>
> Bogdan
>
>
>>> A first change in the engine implementation I see is to integrate the
>>> XSD engine from https://xsom.dev.java.net/
>>> This is fully supporting XSD specs so the xforms engine may benefit
>>> of them.
>>>
>>> Regards,
>>> Bogdan
>>>
>>>
>>>
>> Cheers,
>>
>> Stéphane
>>
>>
>>>> Hi,
>>>>
>>>> I am looking a bit around the XForms editor in eclipse.
>>>>
>>>> I checked out from svn and installed it. it's working very good.
>>>>
>>>> But after looking a bit more inside, i have a question :
>>>> Why the <Hint> element is mapped into an attribute of the parent
>>>> element ?
>>>> it seems also that the mapping from <hint> element to swt tooltiptext
>>>> is not working ?
>>>> this is due to the AttributeMap class that is not setting new values
>>>> correctly....
>>>>
>>>>
>>>> finally, i am very interresed to the edit part of the editor also. (
>>>> add elements to the xform... )
>>>>
>>>>
>>>
>>>
>>>> Cheers,
>>>>
>>>> Stéphane
>>>>
>>>> _______________________________________________
>>>> Apogee mailing list
>>>> Apogee@...
>>>> http://lists.nuxeo.com/mailman/listinfo/apogee
>>>>
>>>>
>>>
>>>
>
>
>
Property changes on: D:\workspace\org.nuxeo.xforms.core
___________________________________________________________________
Name: svn:ignore
+ bin
Index: D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xml/ArrayMap.java
===================================================================
--- D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xml/ArrayMap.java (revision 47548)
+++ D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xml/ArrayMap.java (working copy)
@@ -43,7 +43,7 @@
}
public int size() {
- return count<<1;
+ return count;
}
public void add(String key, Object value){
Index: D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xml/AttributesMap.java
===================================================================
---
D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xml/AttributesMap.java (revision 48407)
+++ D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xml/AttributesMap.java (working copy)
@@ -130,11 +130,13 @@
public void set(String uri, String name, String value) {
int i = indexOf(uri, name);
if (i > -1) setValue(i, value);
+ else put(uri, name, value);
}
public void set(String name, String value) {
int i = indexOf(name);
if (i > -1) setValue(i, value);
+ else put(name, value);
}
public int size() {
Index: D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/factories/HintXFactory.java
===================================================================
---
D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/factories/HintXFactory.java (revision 47548)
+++
D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/factories/HintXFactory.java (working copy)
@@ -15,11 +15,15 @@
package org.nuxeo.xforms.xforms.factories;
+import org.nuxeo.xforms.xforms.model.XForm;
import org.nuxeo.xforms.xforms.model.controls.XFControlElement;
+import org.nuxeo.xforms.xforms.model.controls.XFHint;
+import org.nuxeo.xforms.xml.AttributesMap;
import org.nuxeo.xforms.xml.DefaultXFactory;
import org.nuxeo.xforms.xml.XParserGlobalContext;
import org.xml.sax.Attributes;
+
/**
* @author <a href="mailto:bstefanescu@...">Bogdan Stefanescu</a>
*
@@ -32,7 +36,9 @@
* @see org.nuxeo.xf4e.xml.DefaultXFactory#create(org.nuxeo.xf4e.xml.XParserGlobalContext,
java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
public Object create(XParserGlobalContext context, String uri, String localName, String qname,
Attributes attrs) {
- return null;
+ XForm form = (XForm) context.document;
+ XFHint element = new XFHint(form, new AttributesMap(attrs));
+ return element;
}
/* (non-Javadoc)
@@ -40,8 +46,10 @@
*/
public void setContent(XParserGlobalContext context, Object object, String text) {
Object parent = context.peekObject();
- if (parent instanceof XFControlElement) {
- ((XFControlElement)parent).setHint(text);
+ XFHint hint = (XFHint)object;
+ hint.setText(text);
+ if (parent instanceof XFControlElement) {
+ ((XFControlElement)parent).setHint(hint);
} else {
System.out.println("Parse error: hint element out of it's scope"); // TODO
}
Index: D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/model/controls/XFHint.java
===================================================================
---
D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/model/controls/XFHint.java (revision 0)
+++
D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/model/controls/XFHint.java (revision 0)
@@ -0,0 +1,40 @@
+package org.nuxeo.xforms.xforms.model.controls;
+
+import org.nuxeo.xforms.xforms.XFormsControlVisitor;
+import org.nuxeo.xforms.xforms.model.XForm;
+import org.nuxeo.xforms.xml.AttributesMap;
+
+public class XFHint extends XFControlElement {
+
+ public final static String TYPE = TAG_HINT;
+
+ protected String mText;
+
+ public String getText() {
+ return this.mText;
+ }
+
+ public void setText(String text) {
+ this.mText = text;
+ }
+
+ public XFHint(XForm form) {
+ super(form);
+ }
+
+ public XFHint(XForm form, AttributesMap map) {
+ super(form, map);
+ }
+
+ @Override
+ public Object accept(XFormsControlVisitor visitor, Object arg) {
+ return arg;
+ }
+
+ @Override
+ public String type() {
+ return TYPE;
+ }
+
+
+}
Index: D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/model/controls/XFControlElement.java
===================================================================
---
D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/model/controls/XFControlElement.java (revision 47548)
+++
D:/workspace/org.nuxeo.xforms.core/src/org/nuxeo/xforms/xforms/model/controls/XFControlElement.java (working copy)
@@ -46,6 +46,8 @@
* corresponding action
*/
protected ArrayMap mEventMap;
+
+ protected XFHint mHint;
public XFControlElement() {
@@ -94,12 +96,12 @@
}
- public String getHint() {
- return getAttribute("hint");
+ public XFHint getHint() {
+ return this.mHint;
}
- public void setHint(String hint) {
- setAttribute("hint", hint);
+ public void setHint(XFHint hint) {
+ this.mHint = hint;
}
/**
Property changes on: D:\workspace\org.nuxeo.xforms.ui
___________________________________________________________________
Name: svn:ignore
+ bin
Index: D:/workspace/org.nuxeo.xforms.ui/src/org/nuxeo/xforms/ui/swt/SWTBuilder.java
===================================================================
--- D:/workspace/org.nuxeo.xforms.ui/src/org/nuxeo/xforms/ui/swt/SWTBuilder.java (revision 47548)
+++ D:/workspace/org.nuxeo.xforms.ui/src/org/nuxeo/xforms/ui/swt/SWTBuilder.java (working copy)
@@ -45,6 +45,7 @@
import org.nuxeo.xforms.xforms.model.controls.XFBody;
import org.nuxeo.xforms.xforms.model.controls.XFControlElement;
import org.nuxeo.xforms.xforms.model.controls.XFGroup;
+import org.nuxeo.xforms.xforms.model.controls.XFHint;
import org.nuxeo.xforms.xforms.model.controls.XFInput;
import org.nuxeo.xforms.xforms.model.controls.XFItem;
import org.nuxeo.xforms.xforms.model.controls.XFLabel;
@@ -59,6 +60,7 @@
+
/**
*
* @author <a href="mailto:bstefanescu@...">Bogdan Stefanescu</a>
@@ -487,10 +489,10 @@
//String value = element.getValue();
//if (value != null) mContext.proxy.setXMLValue(mContext.control, value);
// setting tooltip if any
- String value = element.getHint();
- if (value != null) {
- mContext.proxy.setToolTipText(value);
- }
+ XFHint hint = element.getHint();
+ if (hint != null) {
+ mContext.proxy.setToolTipText(hint.getText());
+ }
// third processing step
_______________________________________________
Apogee mailing list
Apogee@...
http://lists.nuxeo.com/mailman/listinfo/apogee