]> git.argeo.org Git - lgpl/argeo-commons.git/blob - demo/plugins/org.argeo.demo.i18n/src/main/java/org/argeo/demo/i18n/editors/MultiSectionPage.java
Improve CSV and tabular
[lgpl/argeo-commons.git] / demo / plugins / org.argeo.demo.i18n / src / main / java / org / argeo / demo / i18n / editors / MultiSectionPage.java
1 package org.argeo.demo.i18n.editors;
2
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
5 import org.argeo.demo.i18n.I18nDemoMessages;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.layout.GridData;
8 import org.eclipse.swt.layout.GridLayout;
9 import org.eclipse.swt.widgets.Composite;
10 import org.eclipse.swt.widgets.Text;
11 import org.eclipse.ui.forms.AbstractFormPart;
12 import org.eclipse.ui.forms.IManagedForm;
13 import org.eclipse.ui.forms.editor.FormEditor;
14 import org.eclipse.ui.forms.editor.FormPage;
15 import org.eclipse.ui.forms.widgets.FormToolkit;
16 import org.eclipse.ui.forms.widgets.ScrolledForm;
17 import org.eclipse.ui.forms.widgets.Section;
18 import org.eclipse.ui.forms.widgets.TableWrapData;
19 import org.eclipse.ui.forms.widgets.TableWrapLayout;
20
21 /**
22 * Offers two main sections : one to display a text area with a summary of all
23 * variations between a version and its predecessor and one tree view that
24 * enable browsing
25 * */
26 public class MultiSectionPage extends FormPage {
27 private final static Log log = LogFactory.getLog(MultiSectionPage.class);
28
29 // this page UI components
30 private FormToolkit tk;
31
32 public MultiSectionPage(FormEditor editor, String title) {
33 super(editor, "MultiSectionPage", title);
34 }
35
36 protected void createFormContent(IManagedForm managedForm) {
37 ScrolledForm form = managedForm.getForm();
38 tk = managedForm.getToolkit();
39 GridLayout twt = new GridLayout(1, false);
40 twt.marginWidth = twt.marginHeight = 5;
41 Composite body = form.getBody();
42 body.setLayout(twt);
43
44 createHistorySection(form.getBody());
45 createTreeSection(form.getBody());
46 }
47
48 protected void createTreeSection(Composite parent) {
49 // Section Layout & MetaData
50 Section section = tk.createSection(parent, Section.TWISTIE);
51 section.setLayoutData(new GridData(GridData.FILL_BOTH));
52 section.setText(I18nDemoMessages.get().MultiSelectionPage_DescriptionSectionTitle);
53
54 // Section Body
55 Composite body = tk.createComposite(section, SWT.FILL);
56 // WARNING : 2 following lines are compulsory or body won't be
57 // displayed.
58 body.setLayout(new GridLayout());
59 section.setClient(body);
60
61 body.setLayoutData(new GridData(GridData.FILL_BOTH));
62 section.setExpanded(true);
63 }
64
65 protected void createHistorySection(Composite parent) {
66
67 // Section Layout
68 Section section = tk.createSection(parent, Section.TWISTIE);
69 section.setLayoutData(new GridData(TableWrapData.FILL_GRAB));
70 TableWrapLayout twt = new TableWrapLayout();
71 section.setLayout(twt);
72
73 // Set title of the section
74 section.setText(I18nDemoMessages.get().MultiSelectionPage_DetailsSectionTitle);
75
76 final Text styledText = tk.createText(section, "", SWT.FULL_SELECTION
77 | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
78 styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
79 section.setClient(styledText);
80 styledText.setEditable(false);
81 section.setExpanded(false);
82
83 AbstractFormPart part = new AbstractFormPart() {
84 public void commit(boolean onSave) {
85 }
86
87 public void refresh() {
88 super.refresh();
89 }
90 };
91 getManagedForm().addPart(part);
92 }
93
94 @Override
95 public void setActive(boolean active) {
96 super.setActive(active);
97 }
98 }