import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
+import java.util.StringTokenizer;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.argeo.cms.ui.CmsConstants;
import org.argeo.cms.ui.CmsView;
import org.argeo.eclipse.ui.Selected;
+import org.argeo.eclipse.ui.specific.EclipseUiSpecificUtils;
import org.argeo.jcr.JcrUtils;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.service.ResourceManager;
return NodeUtils.getDataPath(cn, node);
}
+ /** Clean reserved URL characters for use in HTTP links. */
+ public static String getDataPathForUrl(Node node) throws RepositoryException {
+ return cleanPathForUrl(getDataPath(node));
+ }
+
+ /** Clean reserved URL characters for use in HTTP links. */
+ public static String cleanPathForUrl(String path) throws RepositoryException {
+ StringTokenizer st = new StringTokenizer(path, "/");
+ StringBuilder sb = new StringBuilder();
+ while (st.hasMoreElements()) {
+ sb.append('/');
+ String encoded = URLEncoder.encode(st.nextToken(), StandardCharsets.UTF_8);
+ encoded = encoded.replace("+", "%20");
+ sb.append(encoded);
+
+ }
+ return sb.toString();
+ }
+
/** @deprecated Use rowData16px() instead. GridData should not be reused. */
@Deprecated
public static RowData ROW_DATA_16px = new RowData(16, 16);
return new GridData(horizontalAlignment, horizontalAlignment, false, true);
}
+ /*
+ * ROW LAYOUT
+ */
public static RowData rowData16px() {
return new RowData(16, 16);
}
* FORM LAYOUT
*/
- public static FormData coversAll() {
+ public static FormData coverAll() {
FormData fdLabel = new FormData();
fdLabel.top = new FormAttachment(0, 0);
fdLabel.left = new FormAttachment(0, 0);
public static <T extends Widget> T style(T widget, String style) {
if (style == null)
return widget;// does nothing
- widget.setData(CmsConstants.STYLE, style);
- if (widget instanceof Control)
- CmsView.getCmsView(((Control) widget).getParent()).applyStyles(widget);
+ EclipseUiSpecificUtils.setStyleData(widget, style);
+ if (widget instanceof Control) {
+ CmsView.getCmsView((Control) widget).applyStyles(widget);
+ }
return widget;
}
/** Enable markups on widget */
public static <T extends Widget> T markup(T widget) {
- if (CmsConstants.MARKUP != null)
- widget.setData(CmsConstants.MARKUP, true);
+ EclipseUiSpecificUtils.setMarkupData(widget);
+ return widget;
+ }
+
+ /** Disable markup validation. */
+ public static <T extends Widget> T disableMarkupValidation(T widget) {
+ EclipseUiSpecificUtils.setMarkupValidationDisabledData(widget);
return widget;
}
/** Dispose all children of a Composite */
public static void clear(Composite composite) {
+ if (composite.isDisposed())
+ return;
for (Control child : composite.getChildren())
child.dispose();
}
}
// IMAGES
+ public static String img(Node fileNode, String width, String height) {
+ return img(null, fileNode, width, height);
+ }
+
+ public static String img(String serverBase, Node fileNode, String width, String height) {
+ String src = (serverBase != null ? serverBase : "") + NodeUtils.getDataPath(fileNode);
+ return imgBuilder(src, width, height).append("/>").toString();
+ }
+
public static String img(String src, String width, String height) {
return imgBuilder(src, width, height).append("/>").toString();
}
/** Singleton. */
private CmsUiUtils() {
}
+
}