--- /dev/null
+package org.argeo.jcr.ui.explorer.editors;
+
+import javax.jcr.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * List all childs of the current node and brings some browsing capabilities
+ * accross the repository
+ */
+public class ChildNodesPage extends FormPage {
+ private final static Log log = LogFactory.getLog(ChildNodesPage.class);
+
+ private Node currentNode;
+
+ public ChildNodesPage(FormEditor editor, String title, Node currentNode) {
+ super(editor, "ChildNodesPage", title);
+ this.currentNode = currentNode;
+ }
+
+ protected void createFormContent(IManagedForm managedForm) {
+ try {
+ ScrolledForm form = managedForm.getForm();
+ GridLayout twt = new GridLayout(1, false);
+ twt.marginWidth = twt.marginHeight = 0;
+ form.getBody().setLayout(twt);
+ Label lbl = new Label(form.getBody(), SWT.NONE);
+ lbl.setText("Implement this");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
-/** Executes any JCR query. */
+/** Enables end user to type and execute any JCR query. */
public class GenericJcrQueryEditor extends AbstractJcrQueryEditor {
public final static String ID = "org.argeo.jcr.ui.explorer.genericJcrQueryEditor";
import org.eclipse.ui.forms.editor.FormEditor;
/**
- * Parent Abstract GR multitab editor. Insure the presence of a GrBackend
+ *
+ * Container for the node editor page. At creation time, it takes a JCR Node
+ * that cannot be changed afterwards.
+ *
*/
public class GenericNodeEditor extends FormEditor {
private Node currentNode;
private GenericNodePage networkDetailsPage;
+ private ChildNodesPage childNodesPage;
+ private NodeRightsManagementPage nodeRightsManagementPage;
+ private NodeVersionHistoryPage nodeVersionHistoryPage;
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
super.init(site, input);
GenericNodeEditorInput nei = (GenericNodeEditorInput) getEditorInput();
+ currentNode = nei.getCurrentNode();
this.setPartName(JcrUtils.lastPathElement(nei.getPath()));
}
@Override
protected void addPages() {
- EmptyNodePage enp = new EmptyNodePage(this, "Empty node page");
- try {
- addPage(enp);
- } catch (PartInitException e) {
- throw new ArgeoException("Not able to add an empty page ", e);
- }
- }
-
- private void addPagesAfterNodeSet() {
try {
networkDetailsPage = new GenericNodePage(this,
JcrExplorerPlugin.getMessage("genericNodePageTitle"),
currentNode);
addPage(networkDetailsPage);
- this.setActivePage(networkDetailsPage.getIndex());
+
+ childNodesPage = new ChildNodesPage(this,
+ JcrExplorerPlugin.getMessage("childNodesPageTitle"),
+ currentNode);
+ addPage(childNodesPage);
+
+ nodeRightsManagementPage = new NodeRightsManagementPage(this,
+ JcrExplorerPlugin
+ .getMessage("nodeRightsManagementPageTitle"),
+ currentNode);
+ addPage(nodeRightsManagementPage);
+
+ nodeVersionHistoryPage = new NodeVersionHistoryPage(
+ this,
+ JcrExplorerPlugin.getMessage("nodeVersionHistoryPageTitle"),
+ currentNode);
+ addPage(nodeVersionHistoryPage);
} catch (PartInitException e) {
- throw new ArgeoException("Not able to add page ", e);
+ throw new ArgeoException("Not able to add an empty page ", e);
}
}
Node getCurrentNode() {
return currentNode;
}
-
- public void setCurrentNode(Node currentNode) {
- boolean nodeWasNull = this.currentNode == null;
- this.currentNode = currentNode;
- if (nodeWasNull) {
- this.removePage(0);
- addPagesAfterNodeSet();
- }
- }
}
package org.argeo.jcr.ui.explorer.editors;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+import org.argeo.ArgeoException;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;
/**
- * An editor input based on a path to a node plus workspace name and repository
- * alias. In a multirepository environment, path can be enriched with Repository
- * Alias and workspace
- */
+ * An editor input based the JCR node object.
+ * */
public class GenericNodeEditorInput implements IEditorInput {
- private final String path;
- private final String repositoryAlias;
- private final String workspaceName;
+ private final Node currentNode;
- /**
- * In order to implement a generic explorer that supports remote and multi
- * workspaces repositories, node path can be detailed by these strings.
- *
- * @param repositoryAlias
- * : can be null
- * @param workspaceName
- * : can be null
- * @param path
- */
- public GenericNodeEditorInput(String repositoryAlias, String workspaceName,
- String path) {
- this.path = path;
- this.repositoryAlias = repositoryAlias;
- this.workspaceName = workspaceName;
+ public GenericNodeEditorInput(Node currentNode) {
+ this.currentNode = currentNode;
+ }
+
+ public Node getCurrentNode() {
+ return currentNode;
}
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
}
public String getName() {
- return path;
+ try {
+ return currentNode.getName();
+ } catch (RepositoryException re) {
+ throw new ArgeoException(
+ "unexpected error while getting node name", re);
+ }
}
- public String getRepositoryAlias() {
- return repositoryAlias;
- }
-
- public String getWorkspaceName() {
- return workspaceName;
- }
-
- public IPersistableElement getPersistable() {
- return null;
+ public String getUid() {
+ try {
+ return currentNode.getIdentifier();
+ } catch (RepositoryException re) {
+ throw new ArgeoException("unexpected error while getting node uid",
+ re);
+ }
}
public String getToolTipText() {
- return path;
+ try {
+ return currentNode.getPath();
+ } catch (RepositoryException re) {
+ throw new ArgeoException(
+ "unexpected error while getting node path", re);
+ }
}
public String getPath() {
- return path;
+ try {
+ return currentNode.getPath();
+ } catch (RepositoryException re) {
+ throw new ArgeoException(
+ "unexpected error while getting node path", re);
+ }
}
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ /**
+ * equals method based on UID that is unique within a workspace and path of
+ * the node, thus 2 shared node that have same UID as defined in the spec
+ * but 2 different pathes will open two distinct editors.
+ *
+ * TODO enhance this method to support multirepository and multiworkspace
+ * environments
+ */
public boolean equals(Object obj) {
if (this == obj)
return true;
return false;
GenericNodeEditorInput other = (GenericNodeEditorInput) obj;
-
- if (!path.equals(other.getPath()))
- return false;
-
- String own = other.getWorkspaceName();
- if ((workspaceName == null && own != null)
- || (workspaceName != null && (own == null || !workspaceName
- .equals(own))))
+ if (!getUid().equals(other.getUid()))
return false;
-
- String ora = other.getRepositoryAlias();
- if ((repositoryAlias == null && ora != null)
- || (repositoryAlias != null && (ora == null || !repositoryAlias
- .equals(ora))))
+ if (!getPath().equals(other.getPath()))
return false;
-
return true;
}
}
--- /dev/null
+package org.argeo.jcr.ui.explorer.editors;
+
+import javax.jcr.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * This page is only used at editor's creation time when current node has not
+ * yet been set
+ */
+public class NodeRightsManagementPage extends FormPage {
+ private final static Log log = LogFactory.getLog(NodeRightsManagementPage.class);
+
+
+ private Node currentNode;
+ public NodeRightsManagementPage(FormEditor editor, String title, Node currentNode) {
+ super(editor, "NodeRightsManagementPage", title);
+ this.currentNode = currentNode;
+ }
+
+ protected void createFormContent(IManagedForm managedForm) {
+ try {
+ ScrolledForm form = managedForm.getForm();
+ GridLayout twt = new GridLayout(1, false);
+ twt.marginWidth = twt.marginHeight = 0;
+ form.getBody().setLayout(twt);
+ Label lbl = new Label(form.getBody(), SWT.NONE);
+ lbl.setText("Implement this");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+package org.argeo.jcr.ui.explorer.editors;
+
+import javax.jcr.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * This page is only used at editor's creation time when current node has not
+ * yet been set
+ */
+public class NodeVersionHistoryPage extends FormPage {
+ private final static Log log = LogFactory
+ .getLog(NodeVersionHistoryPage.class);
+
+ private Node currentNode;
+
+ public NodeVersionHistoryPage(FormEditor editor, String title,
+ Node currentNode) {
+ super(editor, "NodeVersionHistoryPage", title);
+ this.currentNode = currentNode;
+ }
+
+ protected void createFormContent(IManagedForm managedForm) {
+ try {
+ ScrolledForm form = managedForm.getForm();
+ GridLayout twt = new GridLayout(1, false);
+ twt.marginWidth = twt.marginHeight = 0;
+ form.getBody().setLayout(twt);
+ Label lbl = new Label(form.getBody(), SWT.NONE);
+ lbl.setText("Implement this");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
--- /dev/null
+package org.argeo.jcr.ui.explorer.editors;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPersistableElement;
+
+/**
+ * An editor input based on three strings define a node :
+ * <ul>
+ * <li>complete path to the node</li>
+ * <li>the workspace name</li>
+ * <li>the repository alias</li>
+ * </ul>
+ * In a single workspace and/or repository environment, name and alias can be
+ * null.
+ *
+ * Note : unused for the time being.
+ */
+
+public class StringNodeEditorInput implements IEditorInput {
+ private final String path;
+ private final String repositoryAlias;
+ private final String workspaceName;
+
+ /**
+ * In order to implement a generic explorer that supports remote and multi
+ * workspaces repositories, node path can be detailed by these strings.
+ *
+ * @param repositoryAlias
+ * : can be null
+ * @param workspaceName
+ * : can be null
+ * @param path
+ */
+ public StringNodeEditorInput(String repositoryAlias, String workspaceName,
+ String path) {
+ this.path = path;
+ this.repositoryAlias = repositoryAlias;
+ this.workspaceName = workspaceName;
+ }
+
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+ return null;
+ }
+
+ public boolean exists() {
+ return true;
+ }
+
+ public ImageDescriptor getImageDescriptor() {
+ return null;
+ }
+
+ public String getName() {
+ return path;
+ }
+
+ public String getRepositoryAlias() {
+ return repositoryAlias;
+ }
+
+ public String getWorkspaceName() {
+ return workspaceName;
+ }
+
+ public IPersistableElement getPersistable() {
+ return null;
+ }
+
+ public String getToolTipText() {
+ return path;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+
+ StringNodeEditorInput other = (StringNodeEditorInput) obj;
+
+ if (!path.equals(other.getPath()))
+ return false;
+
+ String own = other.getWorkspaceName();
+ if ((workspaceName == null && own != null)
+ || (workspaceName != null && (own == null || !workspaceName
+ .equals(own))))
+ return false;
+
+ String ora = other.getRepositoryAlias();
+ if ((repositoryAlias == null && ora != null)
+ || (repositoryAlias != null && (ora == null || !repositoryAlias
+ .equals(ora))))
+ return false;
+
+ return true;
+ }
+}
jfp.setRootNodes((Object[]) itcp.getElements(null));
fileHandler.openFile(name, id);
}
- // File or not, we always open the corresponding node Editor.
- String repositoryAlias = getRepositoryAlias(obj);
- String workspaceName = node.getSession().getWorkspace()
- .getName();
- String path = node.getPath();
-
- if (log.isDebugEnabled()) {
- log.debug("RepoAlias: " + repositoryAlias + " - WS Name: "
- + workspaceName + " - path:" + path);
- }
- GenericNodeEditorInput gnei = new GenericNodeEditorInput(
- repositoryAlias, workspaceName, path);
-
- GenericNodeEditor gne = (GenericNodeEditor) JcrExplorerPlugin
- .getDefault().getWorkbench().getActiveWorkbenchWindow()
- .getActivePage().openEditor(gnei, GenericNodeEditor.ID);
- gne.setCurrentNode(node);
-
+ GenericNodeEditorInput gnei = new GenericNodeEditorInput(node);
+ JcrExplorerPlugin.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .openEditor(gnei, GenericNodeEditor.ID);
} catch (RepositoryException re) {
throw new ArgeoException(
"Repository error while getting node info", re);
## Generic labels
nodeEditorLbl=Generic node editor
genericNodePageTitle=Edit Node properties
+childNodesPageTitle=Children
+nodeRightsManagementPageTitle=Permissions
+nodeVersionHistoryPageTitle=Node history
## Dummy ones
testLbl=Internationalizations of messages seems to work properly.