]> 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/GenericBundleEditor.java
7429ed0caaa8e9a66defd343ff3573f67bdbfd1d
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui.dist / src / main / java / org / argeo / slc / client / ui / dist / editors / GenericBundleEditor.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 * Expose a bundle and enable its management
30 */
31 public class GenericBundleEditor extends FormEditor {
32 // private final static Log log =
33 // LogFactory.getLog(GenericNodeEditor.class);
34
35 public final static String ID = DistPlugin.ID + ".genericBundleEditor";
36
37 // business objects
38 private Node bundleNode;
39
40 // This Editor widgets
41 private BundleRawPage bundleRawPage;
42 private BundleDetailsPage bundleDetailsPage;
43
44 public void init(IEditorSite site, IEditorInput input)
45 throws PartInitException {
46 super.init(site, input);
47 GenericBundleEditorInput gaei = (GenericBundleEditorInput) getEditorInput();
48 bundleNode = gaei.getArtifactNode();
49 this.setPartName(gaei.getArtifactId());
50 }
51
52 @Override
53 protected void addPages() {
54 try {
55 bundleDetailsPage = new BundleDetailsPage(this, "Main", bundleNode);
56 addPage(bundleDetailsPage);
57 bundleRawPage = new BundleRawPage(this, "Raw info", bundleNode);
58 addPage(bundleRawPage);
59 } catch (PartInitException e) {
60 throw new ArgeoException("Not able to add an empty page ", e);
61 }
62 }
63
64 @Override
65 public void doSave(IProgressMonitor monitor) {
66 try {
67 // Automatically commit all pages of the editor
68 commitPages(true);
69 firePropertyChange(PROP_DIRTY);
70 } catch (Exception e) {
71 throw new ArgeoException("Error while saving node", e);
72 }
73
74 }
75
76 // unused compulsory methods
77 @Override
78 public boolean isSaveAsAllowed() {
79 return false;
80 }
81
82 @Override
83 public void doSaveAs() {
84 }
85
86 }