X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Futil%2FCmsUtils.java;h=743691588f08428a4c27129878081a681c541f17;hb=8018cad996f3a0fd85d7aa2d00f03d0fd622d4af;hp=7864dde8b645999e094529dce4facb70bfdf441e;hpb=7e333073d07b780efe681306a1842a750cbea83c;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms.ui/src/org/argeo/cms/util/CmsUtils.java b/org.argeo.cms.ui/src/org/argeo/cms/util/CmsUtils.java index 7864dde8b..743691588 100644 --- a/org.argeo.cms.ui/src/org/argeo/cms/util/CmsUtils.java +++ b/org.argeo.cms.ui/src/org/argeo/cms/util/CmsUtils.java @@ -16,7 +16,6 @@ import org.argeo.eclipse.ui.specific.UiContext; import org.argeo.jcr.JcrUtils; import org.argeo.node.NodeConstants; import org.argeo.node.NodeUtils; -import org.argeo.node.security.NodeAuthenticated; import org.eclipse.rap.rwt.RWT; import org.eclipse.rap.rwt.service.ResourceManager; import org.eclipse.swt.SWT; @@ -37,11 +36,11 @@ public class CmsUtils implements CmsConstants { // private final static Log log = LogFactory.getLog(CmsUtils.class); /** - * The CMS view related to this display, or null if none is available from - * this call. + * The CMS view related to this display, or null if none is available from this + * call. */ public static CmsView getCmsView() { - return UiContext.getData(NodeAuthenticated.KEY); + return UiContext.getData(CmsView.KEY); } public static StringBuilder getServerBaseUrl(HttpServletRequest request) { @@ -68,10 +67,6 @@ public class CmsUtils implements CmsConstants { } } - // private final static String PATH_DATA = "/data"; - // private final static String WEBDAV_PUBLIC = PATH_DATA + "/public"; - // private final static String WEBDAV_PRIVATE = PATH_DATA + "/files"; - /** A path in the node repository */ public static String getDataPath(Node node) throws RepositoryException { return getDataPath(NodeConstants.NODE, node); @@ -79,43 +74,7 @@ public class CmsUtils implements CmsConstants { public static String getDataPath(String cn, Node node) throws RepositoryException { return NodeUtils.getDataPath(cn, node); - // assert node != null; - // String userId = node.getSession().getUserID(); - // if (log.isTraceEnabled()) - // log.trace(userId + " : " + node.getPath()); - // StringBuilder buf = new StringBuilder(); - // boolean isAnonymous = - // userId.equalsIgnoreCase(NodeConstants.ROLE_ANONYMOUS); - // if (isAnonymous) - // buf.append(WEBDAV_PUBLIC); - // else - // buf.append(WEBDAV_PRIVATE); - // Session session = node.getSession(); - // Repository repository = session.getRepository(); - // String cn; - // if (repository.isSingleValueDescriptor(NodeConstants.CN)) { - // cn = repository.getDescriptor(NodeConstants.CN); - // } else { - // log.warn("No cn defined in repository, using " + NodeConstants.NODE); - // cn = NodeConstants.NODE; - // } - // return - // buf.append('/').append(cn).append('/').append(session.getWorkspace().getName()).append(node.getPath()) - // .toString(); } - // - // public static String getCanonicalUrl(Node node, HttpServletRequest - // request) throws RepositoryException { - // try { - // StringBuilder buf = getServerBaseUrl(request); - // buf.append('/').append('!').append(node.getPath()); - // return new URL(buf.toString()).toString(); - // } catch (MalformedURLException e) { - // throw new CmsException("Cannot build data URL for " + node, e); - // } - // // return request.getRequestURL().append('!').append(node.getPath()) - // // .toString(); - // } /** @deprecated Use rowData16px() instead. GridData should not be reused. */ @Deprecated @@ -125,6 +84,10 @@ public class CmsUtils implements CmsConstants { return noSpaceGridLayout(new GridLayout()); } + public static GridLayout noSpaceGridLayout(int columns) { + return noSpaceGridLayout(new GridLayout(columns, false)); + } + public static GridLayout noSpaceGridLayout(GridLayout layout) { layout.horizontalSpacing = 0; layout.verticalSpacing = 0; @@ -166,28 +129,6 @@ public class CmsUtils implements CmsConstants { table.setData(CmsConstants.ITEM_HEIGHT, height); } - // /** @return the path or null if not instrumented */ - // @Deprecated - // public static String getDataPath(Widget widget) { - // // JCR item - // Object data = widget.getData(); - // if (data != null && data instanceof Item) { - // try { - // return ((Item) data).getPath(); - // } catch (RepositoryException e) { - // throw new CmsException("Cannot find data path of " + data + " for " + - // widget); - // } - // } - // - // // JCR path - // data = widget.getData(Property.JCR_PATH); - // if (data != null) - // return data.toString(); - // - // return null; - // } - /** Dispose all children of a Composite */ public static void clear(Composite composite) { for (Control child : composite.getChildren()) @@ -261,6 +202,18 @@ public class CmsUtils implements CmsConstants { } } + public final static String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." + + " Etiam eleifend hendrerit sem, ac ultricies massa ornare ac." + + " Cras aliquam sodales risus, vitae varius lacus molestie quis." + + " Vivamus consequat, leo id lacinia volutpat, eros diam efficitur urna, finibus interdum risus turpis at nisi." + + " Curabitur vulputate nulla quis scelerisque fringilla. Integer consectetur turpis id lobortis accumsan." + + " Pellentesque commodo turpis ac diam ultricies dignissim." + + " Curabitur sit amet dolor volutpat lacus aliquam ornare quis sed velit." + + " Integer varius quis est et tristique." + + " Suspendisse pharetra porttitor purus, eget condimentum magna." + + " Duis vitae turpis eros. Sed tincidunt lacinia rutrum." + + " Aliquam velit velit, rutrum ut augue sed, condimentum lacinia augue."; + private CmsUtils() { } }