1 package org
.argeo
.demo
.i18n
.editors
;
3 import org
.argeo
.demo
.i18n
.I18nDemoMessages
;
4 import org
.argeo
.demo
.i18n
.I18nDemoPlugin
;
5 import org
.eclipse
.swt
.SWT
;
6 import org
.eclipse
.swt
.events
.SelectionAdapter
;
7 import org
.eclipse
.swt
.events
.SelectionEvent
;
8 import org
.eclipse
.swt
.layout
.GridData
;
9 import org
.eclipse
.swt
.layout
.GridLayout
;
10 import org
.eclipse
.swt
.widgets
.Button
;
11 import org
.eclipse
.swt
.widgets
.Composite
;
12 import org
.eclipse
.swt
.widgets
.MessageBox
;
13 import org
.eclipse
.swt
.widgets
.Text
;
14 import org
.eclipse
.ui
.forms
.AbstractFormPart
;
15 import org
.eclipse
.ui
.forms
.IManagedForm
;
16 import org
.eclipse
.ui
.forms
.editor
.FormEditor
;
17 import org
.eclipse
.ui
.forms
.editor
.FormPage
;
18 import org
.eclipse
.ui
.forms
.widgets
.FormToolkit
;
19 import org
.eclipse
.ui
.forms
.widgets
.ScrolledForm
;
20 import org
.eclipse
.ui
.forms
.widgets
.Section
;
21 import org
.eclipse
.ui
.forms
.widgets
.TableWrapData
;
24 * Offers two main sections : one to display a text area with a summary of all
25 * variations between a version and its predecessor and one tree view that
28 public class MultiSectionPage
extends FormPage
{
29 // private final static Log log = LogFactory.getLog(MultiSectionPage.class);
31 // this page UI components
32 private FormToolkit tk
;
34 public MultiSectionPage(FormEditor editor
, String title
) {
35 super(editor
, "MultiSectionPage", title
);
38 protected void createFormContent(IManagedForm managedForm
) {
39 ScrolledForm form
= managedForm
.getForm();
40 tk
= managedForm
.getToolkit();
41 GridLayout twt
= new GridLayout(1, false);
42 twt
.marginWidth
= twt
.marginHeight
= 5;
43 Composite body
= form
.getBody();
46 createDetailsSection(form
.getBody());
47 createDescriptionSection(form
.getBody());
50 protected void createDescriptionSection(Composite parent
) {
51 // Section Layout & MetaData
52 Section section
= tk
.createSection(parent
, Section
.TWISTIE
);
53 section
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
54 section
.setText(I18nDemoMessages
.get().MultiSectionPage_DescriptionSectionTitle
);
57 Composite body
= tk
.createComposite(section
, SWT
.FILL
);
58 // WARNING : 2 following lines are compulsory or body won't be
60 body
.setLayout(new GridLayout());
61 section
.setClient(body
);
63 body
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
64 section
.setExpanded(true);
67 Button b1
= new Button(body
, SWT
.PUSH
| SWT
.FILL
);
68 b1
.setText(I18nDemoMessages
.get().MultiSectionPage_Btn1Lbl
);
69 Button b2
= new Button(body
, SWT
.PUSH
| SWT
.FILL
);
70 b2
.setText(I18nDemoMessages
.get().MultiSectionPage_Btn2Lbl
);
71 Button b3
= new Button(body
, SWT
.PUSH
| SWT
.FILL
);
72 b3
.setText(I18nDemoMessages
.get().MultiSectionPage_Btn3Lbl
);
79 private void addAListener(Button b
) {
80 b
.addSelectionListener(new SelectionAdapter() {
81 public void widgetSelected(SelectionEvent e
) {
82 MessageBox mb
= new MessageBox(I18nDemoPlugin
.getDefault()
83 .getWorkbench().getActiveWorkbenchWindow().getShell(),
86 mb
.setText(I18nDemoMessages
.get().MultiSectionPage_PopupTitle
);
88 mb
.setMessage(I18nDemoMessages
.get().MultiSectionPage_PopupText
);
94 protected void createDetailsSection(Composite parent
) {
97 Section section
= tk
.createSection(parent
, Section
.TWISTIE
);
98 section
.setLayoutData(new GridData(TableWrapData
.FILL_GRAB
));
99 GridLayout gd
= new GridLayout();
100 section
.setLayout(gd
);
102 // Set title of the section
103 section
.setText(I18nDemoMessages
.get().MultiSectionPage_DetailsSectionTitle
);
105 final Text styledText
= tk
.createText(section
, "", SWT
.FULL_SELECTION
106 | SWT
.MULTI
| SWT
.WRAP
| SWT
.V_SCROLL
);
107 styledText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
108 styledText
.setEditable(false);
110 .setText(I18nDemoMessages
.get().MultiSectionPage_DescriptionSectionTxt
);
111 section
.setExpanded(false);
113 section
.setClient(styledText
);
115 AbstractFormPart part
= new AbstractFormPart() {
116 public void commit(boolean onSave
) {
119 public void refresh() {
123 getManagedForm().addPart(part
);
127 public void setActive(boolean active
) {
128 super.setActive(active
);