X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Fforms%2FFormPageViewer.java;h=b4d24bf9584d169c8c5674cfa05c2102ce4f354f;hb=c873a0359345503b8e3ca07828bd99d525ec7cc0;hp=71853461bd99f7ab17ac887e4bd48810b78e3471;hpb=a8f81aa9cee36d6fad571023f896c733d257c521;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/forms/FormPageViewer.java b/org.argeo.cms/src/org/argeo/cms/forms/FormPageViewer.java index 71853461b..b4d24bf95 100644 --- a/org.argeo.cms/src/org/argeo/cms/forms/FormPageViewer.java +++ b/org.argeo.cms/src/org/argeo/cms/forms/FormPageViewer.java @@ -16,7 +16,6 @@ import javax.jcr.ValueFormatException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.argeo.ArgeoException; import org.argeo.cms.CmsEditable; import org.argeo.cms.CmsException; import org.argeo.cms.CmsImageManager; @@ -33,11 +32,11 @@ import org.argeo.cms.widgets.StyledControl; import org.argeo.eclipse.ui.EclipseUiUtils; import org.argeo.jcr.JcrUtils; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.rap.addons.fileupload.FileDetails; -import org.eclipse.rap.addons.fileupload.FileUploadEvent; -import org.eclipse.rap.addons.fileupload.FileUploadHandler; -import org.eclipse.rap.addons.fileupload.FileUploadListener; -import org.eclipse.rap.addons.fileupload.FileUploadReceiver; +import org.eclipse.rap.fileupload.FileDetails; +import org.eclipse.rap.fileupload.FileUploadEvent; +import org.eclipse.rap.fileupload.FileUploadHandler; +import org.eclipse.rap.fileupload.FileUploadListener; +import org.eclipse.rap.fileupload.FileUploadReceiver; import org.eclipse.rap.rwt.service.ServerPushSession; import org.eclipse.rap.rwt.widgets.FileUpload; import org.eclipse.swt.SWT; @@ -71,10 +70,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 +120,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 { @@ -413,29 +408,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 { @@ -488,8 +460,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 @@ -499,13 +475,13 @@ public class FormPageViewer extends AbstractPageViewer { section.layout(); section.getParent().layout(); } catch (RepositoryException re) { - throw new ArgeoException("unable to refresh " + throw new CmsException("unable to refresh " + "image section for " + context); } } }); } catch (RepositoryException re) { - throw new ArgeoException("unable to upload image " + name + throw new CmsException("unable to upload image " + name + " at " + context); } } @@ -577,7 +553,7 @@ public class FormPageViewer extends AbstractPageViewer { refresh(parSection); layout(parSection); } catch (RepositoryException re) { - throw new ArgeoException("Unable to delete " + throw new CmsException("Unable to delete " + sessionNode, re); } @@ -627,7 +603,7 @@ public class FormPageViewer extends AbstractPageViewer { edit(emsp, 0); cancelEdit(); } catch (RepositoryException e1) { - throw new ArgeoException( + throw new CmsException( "Unable to remove value " + obj, e1); } layout(emsp);