]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/jcr/DefaultNodeEditor.java
Revert hack that was necessary before Rap 2.3.x
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui.workbench / src / org / argeo / eclipse / ui / workbench / jcr / DefaultNodeEditor.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16 package org.argeo.eclipse.ui.workbench.jcr;
17
18 import javax.jcr.Node;
19
20 import org.argeo.ArgeoException;
21 import org.argeo.eclipse.ui.workbench.WorkbenchUiPlugin;
22 import org.argeo.eclipse.ui.workbench.jcr.internal.parts.ChildNodesPage;
23 import org.argeo.eclipse.ui.workbench.jcr.internal.parts.GenericNodeEditorInput;
24 import org.argeo.eclipse.ui.workbench.jcr.internal.parts.GenericPropertyPage;
25 import org.argeo.eclipse.ui.workbench.jcr.internal.parts.NodeRightsManagementPage;
26 import org.argeo.eclipse.ui.workbench.jcr.internal.parts.NodeVersionHistoryPage;
27 import org.argeo.jcr.JcrUtils;
28 import org.eclipse.core.runtime.IProgressMonitor;
29 import org.eclipse.ui.IEditorInput;
30 import org.eclipse.ui.IEditorSite;
31 import org.eclipse.ui.PartInitException;
32 import org.eclipse.ui.forms.editor.FormEditor;
33
34 /**
35 * Container for the node editor page. At creation time, it takes a JCR Node
36 * that cannot be changed afterwards.
37 */
38 public class DefaultNodeEditor extends FormEditor {
39 private static final long serialVersionUID = -5397680152514917137L;
40
41 // private final static Log log =
42 // LogFactory.getLog(GenericNodeEditor.class);
43 public final static String ID = WorkbenchUiPlugin.ID + ".defaultNodeEditor";
44
45 private Node currentNode;
46
47 private GenericPropertyPage genericPropertyPage;
48 private ChildNodesPage childNodesPage;
49 private NodeRightsManagementPage nodeRightsManagementPage;
50 private NodeVersionHistoryPage nodeVersionHistoryPage;
51
52 public void init(IEditorSite site, IEditorInput input)
53 throws PartInitException {
54 super.init(site, input);
55 GenericNodeEditorInput nei = (GenericNodeEditorInput) getEditorInput();
56 currentNode = nei.getCurrentNode();
57 this.setPartName(JcrUtils.lastPathElement(nei.getPath()));
58 }
59
60 @Override
61 protected void addPages() {
62 try {
63 // genericNodePage = new GenericNodePage(this,
64 // JcrExplorerPlugin.getMessage("genericNodePageTitle"),
65 // currentNode);
66 // addPage(genericNodePage);
67
68 genericPropertyPage = new GenericPropertyPage(this,
69 WorkbenchUiPlugin.getMessage("genericNodePageTitle"),
70 currentNode);
71 addPage(genericPropertyPage);
72
73 childNodesPage = new ChildNodesPage(this,
74 WorkbenchUiPlugin.getMessage("childNodesPageTitle"),
75 currentNode);
76 addPage(childNodesPage);
77
78 nodeRightsManagementPage = new NodeRightsManagementPage(this,
79 WorkbenchUiPlugin
80 .getMessage("nodeRightsManagementPageTitle"),
81 currentNode);
82 addPage(nodeRightsManagementPage);
83
84 nodeVersionHistoryPage = new NodeVersionHistoryPage(
85 this,
86 WorkbenchUiPlugin.getMessage("nodeVersionHistoryPageTitle"),
87 currentNode);
88 addPage(nodeVersionHistoryPage);
89 } catch (PartInitException e) {
90 throw new ArgeoException("Not able to add an empty page ", e);
91 }
92 }
93
94 @Override
95 public void doSaveAs() {
96 // unused compulsory method
97 }
98
99 @Override
100 public void doSave(IProgressMonitor monitor) {
101 try {
102 // Automatically commit all pages of the editor
103 commitPages(true);
104 firePropertyChange(PROP_DIRTY);
105 } catch (Exception e) {
106 throw new ArgeoException("Error while saving node", e);
107 }
108
109 }
110
111 @Override
112 public boolean isSaveAsAllowed() {
113 return true;
114 }
115
116 Node getCurrentNode() {
117 return currentNode;
118 }
119 }