]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/forms/EditablePropertyString.java
Merge security.ui bundle in the cms.ui.workbench bundle
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / forms / EditablePropertyString.java
index e8631292240aeba0b779d46f817a6d1a44ac4903..dd3ff29dc50749cba984c34bd086c79656d2d440 100644 (file)
@@ -8,6 +8,7 @@ import javax.jcr.RepositoryException;
 
 import org.argeo.cms.viewers.EditablePart;
 import org.argeo.cms.widgets.EditableText;
+import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Label;
@@ -21,6 +22,10 @@ public class EditablePropertyString extends EditableText implements
        private String propertyName;
        private String message;
 
+       // encode the '&' character in rap
+       private final static String AMPERSAND = "&";
+       private final static String AMPERSAND_REGEX = "&(?![#a-zA-Z0-9]+;)";
+
        public EditablePropertyString(Composite parent, int style, Node node,
                        String propertyName, String message) throws RepositoryException {
                super(parent, style, node, true);
@@ -41,13 +46,14 @@ public class EditablePropertyString extends EditableText implements
                Control child = getControl();
                if (child instanceof Label) {
                        Label lbl = (Label) child;
-                       if (FormUtils.notEmpty(text))
+                       if (EclipseUiUtils.isEmpty(text))
                                lbl.setText(message + "  ");
                        else
-                               lbl.setText(text);
+                               // TODO enhance this
+                               lbl.setText(text.replaceAll(AMPERSAND_REGEX, AMPERSAND));
                } else if (child instanceof Text) {
                        Text txt = (Text) child;
-                       if (FormUtils.notEmpty(text)) {
+                       if (EclipseUiUtils.isEmpty(text)) {
                                txt.setText("");
                                txt.setMessage(message + " ");
                        } else
@@ -61,7 +67,7 @@ public class EditablePropertyString extends EditableText implements
        }
 
        public synchronized void stopEditing() {
-               if (FormUtils.notEmpty(((Text) getControl()).getText()))
+               if (EclipseUiUtils.isEmpty(((Text) getControl()).getText()))
                        getControl().setData(STYLE, propertyMessage.style());
                else
                        getControl().setData(STYLE, propertyText.style());