/*
- * Copyright (C) 2007-2012 Mathieu Baudier
+ * Copyright (C) 2007-2012 Argeo GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.argeo.jcr.ui.explorer.browser.NodeContentProvider;
import org.argeo.jcr.ui.explorer.browser.NodeLabelProvider;
import org.argeo.jcr.ui.explorer.browser.PropertiesContentProvider;
-import org.argeo.jcr.ui.explorer.model.SingleJcrNode;
+import org.argeo.jcr.ui.explorer.model.SingleJcrNodeElem;
import org.argeo.jcr.ui.explorer.utils.GenericNodeDoubleClickListener;
import org.argeo.jcr.ui.explorer.utils.JcrUiUtils;
import org.argeo.util.security.Keyring;
*/
public class GenericJcrBrowser extends AbstractJcrBrowser {
public final static String ID = JcrExplorerPlugin.ID + ".browserView";
- private boolean sortChildNodes = false;
+ private boolean sortChildNodes = true;
/* DEPENDENCY INJECTION */
private Keyring keyring;
nodesViewer.setComparer(new NodeViewerComparer());
}
+ @Override
+ public void refresh(Object obj) {
+ // Enable full refresh from a command when no element of the tree is
+ // selected
+ if (obj == null) {
+ Object[] elements = nodeContentProvider.getElements(null);
+ for (Object el : elements) {
+ if (el instanceof TreeParent)
+ JcrUiUtils.forceRefreshIfNeeded((TreeParent) el);
+ getNodeViewer().refresh(el);
+ }
+ }
+ super.refresh(obj);
+ }
+
/**
* To be overridden to adapt size of form and result frames.
*/
IStructuredSelection sel = (IStructuredSelection) event
.getSelection();
Object firstItem = sel.getFirstElement();
- if (firstItem instanceof SingleJcrNode)
+ if (firstItem instanceof SingleJcrNodeElem)
propertiesViewer
- .setInput(((SingleJcrNode) firstItem)
+ .setInput(((SingleJcrNodeElem) firstItem)
.getNode());
} else {
propertiesViewer.setInput(getViewSite());
return nodesViewer;
}
+ /**
+ * Resets the tree content provider
+ *
+ * @param sortChildNodes
+ * if true the content provider will use a comparer to sort nodes
+ * that might slow down the display
+ * */
+ public void setSortChildNodes(boolean sortChildNodes) {
+ this.sortChildNodes = sortChildNodes;
+ ((NodeContentProvider) nodesViewer.getContentProvider())
+ .setSortChildren(sortChildNodes);
+ nodesViewer.setInput(getViewSite());
+ }
+
/** Notifies the current view that a node has been added */
public void nodeAdded(TreeParent parentNode) {
// insure that Ui objects have been correctly created:
getNodeViewer().expandToLevel(parentNode, 1);
}
- /** Notifies the current view that a node has been added */
+ /** Notifies the current view that a node has been removed */
public void nodeRemoved(TreeParent parentNode) {
IStructuredSelection newSel = new StructuredSelection(parentNode);
getNodeViewer().setSelection(newSel, true);
}
- public void setSortChildNodes(boolean sortChildNodes) {
- this.sortChildNodes = sortChildNodes;
- }
-
public boolean getSortChildNodes() {
return sortChildNodes;
}