]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/forms/FormPageViewer.java
Fix glitches
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / forms / FormPageViewer.java
index 7eddbbc2e6e38aed8f1afaaf20edc419fed31c40..98566485963e8231e6fac23e5caed93b46f40640 100644 (file)
@@ -71,10 +71,6 @@ public class FormPageViewer extends AbstractPageViewer {
 
        // TODO manage within the CSS
        private int labelColWidth = 150;
-       private int sectionSeparatorHeight = 10;
-       private int sectionBodyVIndent = 30;
-       private int sectionBodyHSpacing = 15;
-       private int sectionBodyVSpacing = 15;
        private int rowLayoutHSpacing = 8;
 
        // Context cached in the viewer
@@ -125,7 +121,7 @@ public class FormPageViewer extends AbstractPageViewer {
                        // JCR : Model
                        node = ept.getNode();
                        String propName = ept.getPropertyName();
-                       if (FormUtils.notEmpty(txt)) {
+                       if (EclipseUiUtils.isEmpty(txt)) {
                                if (node.hasProperty(propName))
                                        node.getProperty(propName).remove();
                        } else {
@@ -381,10 +377,13 @@ public class FormPageViewer extends AbstractPageViewer {
        }
 
        protected Label createPropertyLbl(Composite parent, String value, int vAlign) {
-               Label label = new Label(parent, SWT.RIGHT | SWT.WRAP);
+               boolean isSmall = CmsUtils.getCmsView().getUxContext().isSmall();
+               Label label = new Label(parent, isSmall ? SWT.LEFT : SWT.RIGHT
+                               | SWT.WRAP);
                label.setText(value + " ");
                CmsUtils.style(label, FormStyle.propertyLabel.style());
-               GridData gd = new GridData(SWT.RIGHT, vAlign, false, false);
+               GridData gd = new GridData(isSmall ? SWT.LEFT : SWT.RIGHT, vAlign,
+                               false, false);
                gd.widthHint = labelColWidth;
                label.setLayoutData(gd);
                return label;
@@ -410,29 +409,6 @@ public class FormPageViewer extends AbstractPageViewer {
                return bodyRow;
        }
 
-       protected Composite createSectionBody(Composite parent, int nbOfCol) {
-               // The separator line. Ugly workaround that should be better managed via
-               // css
-               Composite header = new Composite(parent, SWT.NO_FOCUS);
-               CmsUtils.style(header, FormStyle.sectionHeader.style());
-               GridData gd = CmsUtils.fillWidth();
-               gd.verticalIndent = sectionSeparatorHeight;
-               gd.heightHint = 0;
-               header.setLayoutData(gd);
-
-               Composite bodyRow = new Composite(parent, SWT.NO_FOCUS);
-               gd = CmsUtils.fillWidth();
-               gd.verticalIndent = sectionBodyVIndent;
-               bodyRow.setLayoutData(gd);
-               GridLayout gl = new GridLayout(nbOfCol, false);
-               gl.horizontalSpacing = sectionBodyHSpacing;
-               gl.verticalSpacing = sectionBodyVSpacing;
-               bodyRow.setLayout(gl);
-               CmsUtils.style(bodyRow, FormStyle.section.style());
-
-               return bodyRow;
-       }
-
        protected Composite createAddImgComposite(final Section section,
                        Composite parent, final Node parentNode) throws RepositoryException {
 
@@ -485,8 +461,12 @@ public class FormPageViewer extends AbstractPageViewer {
 
                        if (name == null)
                                name = details.getFileName();
+
+                       // TODO clean image name more carefully
+                       String cleanedName = name.replaceAll("[^a-zA-Z0-9-.]", "_");
+
                        try {
-                               imageManager().uploadImage(context, name, stream);
+                               imageManager().uploadImage(context, cleanedName, stream);
                                // TODO clean refresh strategy
                                section.getDisplay().asyncExec(new Runnable() {
                                        @Override