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