]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/editors/GenericArtifactEditor.java
Fix commands in dist UI
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / editors / GenericArtifactEditor.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.slc.client.ui.dist.editors;
17
18 import javax.jcr.Node;
19
20 import org.argeo.ArgeoException;
21 import org.argeo.slc.client.ui.dist.DistPlugin;
22 import org.eclipse.core.runtime.IProgressMonitor;
23 import org.eclipse.ui.IEditorInput;
24 import org.eclipse.ui.IEditorSite;
25 import org.eclipse.ui.PartInitException;
26 import org.eclipse.ui.forms.editor.FormEditor;
27
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 */
34 public class GenericArtifactEditor extends FormEditor {
35
36 // private final static Log log =
37 // LogFactory.getLog(GenericNodeEditor.class);
38 public final static String ID = DistPlugin.ID + ".genericArtifactEditor";
39
40 // business objects
41 private Node artifactNode;
42
43 // This Editor widgets
44 private ArtifactDetailsPage artifactDetailsPage;
45
46 public void init(IEditorSite site, IEditorInput input)
47 throws PartInitException {
48 super.init(site, input);
49 GenericArtifactEditorInput gaei = (GenericArtifactEditorInput) getEditorInput();
50 artifactNode = gaei.getArtifactNode();
51 this.setPartName(gaei.getArtifactId());
52 }
53
54 @Override
55 protected void addPages() {
56 try {
57
58 artifactDetailsPage = new ArtifactDetailsPage(this, "Main",
59 artifactNode);
60 addPage(artifactDetailsPage);
61 } catch (PartInitException e) {
62 throw new ArgeoException("Not able to add an empty page ", e);
63 }
64 }
65
66 @Override
67 public void doSaveAs() {
68 // unused compulsory method
69 }
70
71 @Override
72 public void doSave(IProgressMonitor monitor) {
73 try {
74 // Automatically commit all pages of the editor
75 commitPages(true);
76 firePropertyChange(PROP_DIRTY);
77 } catch (Exception e) {
78 throw new ArgeoException("Error while saving node", e);
79 }
80
81 }
82
83 @Override
84 public boolean isSaveAsAllowed() {
85 return true;
86 }
87
88 Node getArtifactNode() {
89 return artifactNode;
90 }
91 }