]> git.argeo.org Git - lgpl/argeo-commons.git/blob - i18n/editors/SimplePage.java
Prepare next development cycle
[lgpl/argeo-commons.git] / i18n / editors / SimplePage.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.demo.i18n.I18nDemoMessages;
19 import org.eclipse.swt.layout.GridLayout;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.ui.forms.AbstractFormPart;
22 import org.eclipse.ui.forms.IManagedForm;
23 import org.eclipse.ui.forms.editor.FormEditor;
24 import org.eclipse.ui.forms.editor.FormPage;
25 import org.eclipse.ui.forms.widgets.FormToolkit;
26 import org.eclipse.ui.forms.widgets.ScrolledForm;
27
28 /**
29 * Main node editor page. Lists all properties of the current node and enable
30 * access and editing for some of them.
31 */
32
33 public class SimplePage extends FormPage {
34 // private final static Log log = LogFactory.getLog(SimplePage.class);
35
36 // Utils
37 // protected DateFormat timeFormatter = new
38 // SimpleDateFormat(DATE_TIME_FORMAT);
39
40 // This page widgets
41 private FormToolkit tk;
42
43 // private List<Control> modifyableProperties = new ArrayList<Control>();
44
45 public SimplePage(FormEditor editor, String title) {
46 super(editor, "id", title);
47 }
48
49 protected void createFormContent(IManagedForm managedForm) {
50 tk = managedForm.getToolkit();
51 ScrolledForm form = managedForm.getForm();
52 GridLayout twt = new GridLayout(3, false);
53 twt.marginWidth = twt.marginHeight = 5;
54
55 form.getBody().setLayout(twt);
56 createPropertiesPart(form.getBody());
57 }
58
59 private void createPropertiesPart(Composite parent) {
60 // Initializes form part
61 tk.createLabel(parent, I18nDemoMessages.get().SimplePage_DescriptionTxt);
62 AbstractFormPart part = new AbstractFormPart() {
63 public void commit(boolean onSave) {
64 if (onSave) {
65
66 // We only commit when onSave = true,
67 // thus it is still possible to save after a tab
68 // change.
69 super.commit(onSave);
70 }
71 }
72 };
73
74 getManagedForm().addPart(part);
75
76 }
77
78 //
79 // LISTENERS
80 //
81 /*
82 * UNUSED FOR THE TIME BEING private class ModifiedFieldListener implements
83 * ModifyListener {
84 *
85 * private AbstractFormPart formPart;
86 *
87 * public ModifiedFieldListener(AbstractFormPart generalPart) {
88 * this.formPart = generalPart; }
89 *
90 * public void modifyText(ModifyEvent e) { formPart.markDirty(); } }
91 */
92 }