2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.eclipse
.ui
.workbench
.jcr
;
18 import java
.util
.ArrayList
;
19 import java
.util
.List
;
21 import javax
.jcr
.Node
;
22 import javax
.jcr
.RepositoryException
;
23 import javax
.jcr
.nodetype
.NodeType
;
24 import javax
.jcr
.security
.AccessControlManager
;
25 import javax
.jcr
.security
.Privilege
;
27 import org
.argeo
.ArgeoException
;
28 import org
.argeo
.eclipse
.ui
.workbench
.WorkbenchUiPlugin
;
29 import org
.argeo
.eclipse
.ui
.workbench
.internal
.jcr
.parts
.ChildNodesPage
;
30 import org
.argeo
.eclipse
.ui
.workbench
.internal
.jcr
.parts
.GenericNodeEditorInput
;
31 import org
.argeo
.eclipse
.ui
.workbench
.internal
.jcr
.parts
.GenericPropertyPage
;
32 import org
.argeo
.eclipse
.ui
.workbench
.internal
.jcr
.parts
.NodePrivilegesPage
;
33 import org
.argeo
.eclipse
.ui
.workbench
.internal
.jcr
.parts
.NodeVersionHistoryPage
;
34 import org
.argeo
.jcr
.JcrUtils
;
35 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
36 import org
.eclipse
.ui
.IEditorInput
;
37 import org
.eclipse
.ui
.IEditorSite
;
38 import org
.eclipse
.ui
.PartInitException
;
39 import org
.eclipse
.ui
.forms
.editor
.FormEditor
;
41 /** Default form editor for a Jcr {@link Node} */
42 public class DefaultNodeEditor
extends FormEditor
{
43 private static final long serialVersionUID
= 8322127770921612239L;
45 // private final static Log log =
46 // LogFactory.getLog(GenericNodeEditor.class);
47 public final static String ID
= WorkbenchUiPlugin
.ID
+ ".defaultNodeEditor";
49 private Node currentNode
;
51 private GenericPropertyPage genericPropertyPage
;
52 private ChildNodesPage childNodesPage
;
53 private NodePrivilegesPage nodeRightsManagementPage
;
54 private NodeVersionHistoryPage nodeVersionHistoryPage
;
56 public void init(IEditorSite site
, IEditorInput input
)
57 throws PartInitException
{
58 super.init(site
, input
);
59 GenericNodeEditorInput nei
= (GenericNodeEditorInput
) getEditorInput();
60 currentNode
= nei
.getCurrentNode();
61 this.setPartName(JcrUtils
.lastPathElement(nei
.getPath()));
65 protected void addPages() {
67 // genericNodePage = new GenericNodePage(this,
68 // JcrExplorerPlugin.getMessage("genericNodePageTitle"),
70 // addPage(genericNodePage);
72 genericPropertyPage
= new GenericPropertyPage(this,
73 WorkbenchUiPlugin
.getMessage("genericNodePageTitle"),
75 addPage(genericPropertyPage
);
77 childNodesPage
= new ChildNodesPage(this,
78 WorkbenchUiPlugin
.getMessage("childNodesPageTitle"),
80 addPage(childNodesPage
);
82 AccessControlManager accessControlManager
= currentNode
83 .getSession().getAccessControlManager();
84 List
<Privilege
> privileges
= new ArrayList
<Privilege
>();
85 privileges
.add(accessControlManager
86 .privilegeFromName(Privilege
.JCR_READ_ACCESS_CONTROL
));
87 if (accessControlManager
.hasPrivileges(currentNode
.getPath(),
88 privileges
.toArray(new Privilege
[0]))) {
89 nodeRightsManagementPage
= new NodePrivilegesPage(this,
91 .getMessage("nodeRightsManagementPageTitle"),
93 addPage(nodeRightsManagementPage
);
95 if (currentNode
.isNodeType(NodeType
.MIX_VERSIONABLE
)) {
96 nodeVersionHistoryPage
= new NodeVersionHistoryPage(this,
98 .getMessage("nodeVersionHistoryPageTitle"),
100 addPage(nodeVersionHistoryPage
);
103 } catch (RepositoryException e
) {
104 throw new ArgeoException("Cannot get node info for " + currentNode
,
106 } catch (PartInitException e
) {
107 throw new ArgeoException("Cannot add page " + "on node editor for "
113 public void doSaveAs() {
114 // unused compulsory method
118 public void doSave(IProgressMonitor monitor
) {
120 // Automatically commit all pages of the editor
122 firePropertyChange(PROP_DIRTY
);
123 } catch (Exception e
) {
124 throw new ArgeoException("Error while saving node", e
);
130 public boolean isSaveAsAllowed() {
134 Node
getCurrentNode() {