]> git.argeo.org Git - lgpl/argeo-commons.git/blob - i18n/editors/SimpleMultitabEditor.java
Prepare next development cycle
[lgpl/argeo-commons.git] / i18n / editors / SimpleMultitabEditor.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.demo.i18n.editors;
17
18 import org.argeo.ArgeoException;
19 import org.argeo.demo.i18n.I18nDemoMessages;
20 import org.argeo.demo.i18n.I18nDemoPlugin;
21 import org.eclipse.core.runtime.IProgressMonitor;
22 import org.eclipse.ui.IEditorInput;
23 import org.eclipse.ui.IEditorSite;
24 import org.eclipse.ui.PartInitException;
25 import org.eclipse.ui.forms.editor.FormEditor;
26
27 /**
28 *
29 * Container for the node editor page. At creation time, it takes a JCR Node
30 * that cannot be changed afterwards.
31 *
32 */
33 public class SimpleMultitabEditor extends FormEditor {
34
35 // private final static Log log = LogFactory
36 // .getLog(SimpleMultitabEditor.class);
37 public final static String ID = I18nDemoPlugin.ID + ".simpleMultitabEditor";
38
39 private SimplePage simplePage;
40 private MultiSectionPage multiSectionPage;
41
42 public void init(IEditorSite site, IEditorInput input)
43 throws PartInitException {
44 super.init(site, input);
45 // this.setPartName("Internationalized editor part name");
46 }
47
48 @Override
49 protected void addPages() {
50 try {
51 simplePage = new SimplePage(this,
52 I18nDemoMessages.get().SimpleMultitabEditor_SimplePageTitle);
53 addPage(simplePage);
54
55 multiSectionPage = new MultiSectionPage(
56 this,
57 I18nDemoMessages.get().SimpleMultitabEditor_MultiSectionPageTitle);
58 addPage(multiSectionPage);
59
60 } catch (PartInitException e) {
61 throw new ArgeoException("Not able to add an empty page ", e);
62 }
63 }
64
65 @Override
66 public void doSaveAs() {
67 // unused compulsory method
68 }
69
70 @Override
71 public void doSave(IProgressMonitor monitor) {
72 try {
73 // Automatically commit all pages of the editor
74 commitPages(true);
75 firePropertyChange(PROP_DIRTY);
76 } catch (Exception e) {
77 throw new ArgeoException("Error while saving node", e);
78 }
79
80 }
81
82 @Override
83 public boolean isSaveAsAllowed() {
84 return true;
85 }
86 }