X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.suite.ui%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fui%2FRecentItems.java;h=66f2dc5b05e1d169fb17c11c5163458ca05b5c04;hp=e0415a0304baf8473adf5d74f0e4bd9ef3413cf3;hb=3cf66bc01bb8ad4c55139ae01be5a5bdb3759e2c;hpb=5f3933c6262a3f45212299f6f0ec3c29a2e411bf diff --git a/org.argeo.suite.ui/src/org/argeo/suite/ui/RecentItems.java b/org.argeo.suite.ui/src/org/argeo/suite/ui/RecentItems.java index e0415a0..66f2dc5 100644 --- a/org.argeo.suite.ui/src/org/argeo/suite/ui/RecentItems.java +++ b/org.argeo.suite.ui/src/org/argeo/suite/ui/RecentItems.java @@ -15,12 +15,11 @@ import javax.jcr.observation.EventListener; import javax.jcr.query.Query; import javax.jcr.query.QueryResult; -import org.argeo.cms.ui.CmsTheme; +import org.argeo.api.cms.CmsTheme; +import org.argeo.cms.swt.CmsSwtUtils; import org.argeo.cms.ui.CmsUiProvider; -import org.argeo.cms.ui.CmsView; -import org.argeo.cms.ui.util.CmsUiUtils; import org.argeo.eclipse.ui.EclipseUiUtils; -import org.argeo.entity.EntityTypes; +import org.argeo.entity.EntityType; import org.argeo.jcr.Jcr; import org.argeo.jcr.JcrUtils; import org.argeo.suite.ui.widgets.DelayedText; @@ -56,17 +55,17 @@ public class RecentItems implements CmsUiProvider { private final static int SEARCH_TEXT_DELAY = 800; private final static int SEARCH_DEFAULT_LIMIT = 100; - public static enum Property { - entityTypes; - } - private CmsTheme theme; private String entityType; + static enum Property { + entityTypes; + } + @Override public Control createUi(Composite parent, Node context) throws RepositoryException { - theme = CmsTheme.getCmsTheme(parent); + theme = CmsSwtUtils.getCmsTheme(parent); parent.setLayout(new GridLayout()); // parent.setLayout(CmsUiUtils.noSpaceGridLayout()); parent.setLayout(new GridLayout()); @@ -89,11 +88,11 @@ public class RecentItems implements CmsUiProvider { return null; SingleEntityViewer entityViewer = new SingleEntityViewer(parent, SWT.NONE, context.getSession()); entityViewer.createUi(); - entityViewer.getViewer().getTable().setLayoutData(CmsUiUtils.fillAll()); + entityViewer.getViewer().getTable().setLayoutData(CmsSwtUtils.fillAll()); Composite bottom = new Composite(parent, SWT.NONE); - bottom.setLayoutData(CmsUiUtils.fillWidth()); - bottom.setLayout(CmsUiUtils.noSpaceGridLayout()); + bottom.setLayoutData(CmsSwtUtils.fillWidth()); + bottom.setLayout(CmsSwtUtils.noSpaceGridLayout()); ToolBar bottomToolBar = new ToolBar(bottom, SWT.NONE); bottomToolBar.setLayoutData(new GridData(SWT.END, SWT.FILL, true, false)); ToolItem deleteItem = new ToolItem(bottomToolBar, SWT.FLAT); @@ -108,7 +107,7 @@ public class RecentItems implements CmsUiProvider { public void doubleClick(DoubleClickEvent event) { Node node = (Node) entityViewer.getViewer().getStructuredSelection().getFirstElement(); if (node != null) - CmsView.getCmsView(parent).sendEvent(SuiteEvent.openNewPart.topic(), + CmsSwtUtils.getCmsView(parent).sendEvent(SuiteEvent.openNewPart.topic(), SuiteEvent.eventProperties(node)); } @@ -117,7 +116,7 @@ public class RecentItems implements CmsUiProvider { public void selectionChanged(SelectionChangedEvent event) { Node node = (Node) entityViewer.getViewer().getStructuredSelection().getFirstElement(); if (node != null) { - CmsView.getCmsView(parent).sendEvent(SuiteEvent.refreshPart.topic(), + CmsSwtUtils.getCmsView(parent).sendEvent(SuiteEvent.refreshPart.topic(), SuiteEvent.eventProperties(node)); deleteItem.setEnabled(true); } else { @@ -294,11 +293,17 @@ public class RecentItems implements CmsUiProvider { // XPATH Query String xpathQueryStr; - if (entityType != null) - xpathQueryStr = entityType.contains(":") ? "//element(*, " + entityType + ")" - : "//element(*, " + EntityTypes.ENTITY_ENTITY + ")[@entity:type='" + entityType + "']"; - else - xpathQueryStr = "//element(*, " + EntityTypes.ENTITY_ENTITY + ")"; + if (entityType != null) { + int indexColumn = entityType.indexOf(':'); + if (indexColumn > 0) {// JCR node type + xpathQueryStr = "//element(*, " + entityType + ") order by @jcr:created descending"; + } else { + xpathQueryStr = entityType.contains(":") ? "//element(*, " + entityType + ")" + : "//element(*, " + EntityType.entity.get() + ")[@entity:type='" + entityType + "']"; + } + } else { + xpathQueryStr = "//element(*, " + EntityType.entity.get() + ")"; + } // String xpathQueryStr = "//element(*, " + ConnectTypes.CONNECT_ENTITY + ")"; String xpathFilter = XPathUtils.getFreeTextConstraint(filter); if (notEmpty(xpathFilter))