]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - demo/plugins/org.argeo.demo.i18n/src/main/java/org/argeo/demo/i18n/editors/MultiSectionPage.java
Introduce check-osgi profile
[lgpl/argeo-commons.git] / demo / plugins / org.argeo.demo.i18n / src / main / java / org / argeo / demo / i18n / editors / MultiSectionPage.java
index f641f87bbd6f77c0c45aa424690a31cebb54085b..8f8addf18fb69dc6d7f255f233719541b4b81900 100644 (file)
@@ -1,12 +1,30 @@
+/*
+ * Copyright (C) 2007-2012 Mathieu Baudier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.argeo.demo.i18n.editors;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.argeo.demo.i18n.I18nDemoMessages;
 import org.argeo.demo.i18n.I18nDemoPlugin;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.MessageBox;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.forms.AbstractFormPart;
 import org.eclipse.ui.forms.IManagedForm;
@@ -16,7 +34,6 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.ScrolledForm;
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
 /**
  * Offers two main sections : one to display a text area with a summary of all
@@ -24,8 +41,7 @@ import org.eclipse.ui.forms.widgets.TableWrapLayout;
  * enable browsing
  * */
 public class MultiSectionPage extends FormPage {
-        private final static Log log = LogFactory
-        .getLog(MultiSectionPage.class);
+       // private final static Log log = LogFactory.getLog(MultiSectionPage.class);
 
        // this page UI components
        private FormToolkit tk;
@@ -42,16 +58,15 @@ public class MultiSectionPage extends FormPage {
                Composite body = form.getBody();
                body.setLayout(twt);
 
-
-                               createHistorySection(form.getBody());
-                               createTreeSection(form.getBody());
+               createDetailsSection(form.getBody());
+               createDescriptionSection(form.getBody());
        }
 
-       protected void createTreeSection(Composite parent) {
+       protected void createDescriptionSection(Composite parent) {
                // Section Layout & MetaData
                Section section = tk.createSection(parent, Section.TWISTIE);
                section.setLayoutData(new GridData(GridData.FILL_BOTH));
-               section.setText(I18nDemoPlugin.getMessage("MultiSelectionPage.DescriptionSectionTitle"));
+               section.setText(I18nDemoMessages.get().MultiSectionPage_DescriptionSectionTitle);
 
                // Section Body
                Composite body = tk.createComposite(section, SWT.FILL);
@@ -62,28 +77,56 @@ public class MultiSectionPage extends FormPage {
 
                body.setLayoutData(new GridData(GridData.FILL_BOTH));
                section.setExpanded(true);
+
+               // button line
+               Button b1 = new Button(body, SWT.PUSH | SWT.FILL);
+               b1.setText(I18nDemoMessages.get().MultiSectionPage_Btn1Lbl);
+               Button b2 = new Button(body, SWT.PUSH | SWT.FILL);
+               b2.setText(I18nDemoMessages.get().MultiSectionPage_Btn2Lbl);
+               Button b3 = new Button(body, SWT.PUSH | SWT.FILL);
+               b3.setText(I18nDemoMessages.get().MultiSectionPage_Btn3Lbl);
+
+               addAListener(b1);
+               addAListener(b2);
+               addAListener(b3);
        }
 
+       private void addAListener(Button b) {
+               b.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               MessageBox mb = new MessageBox(I18nDemoPlugin.getDefault()
+                                               .getWorkbench().getActiveWorkbenchWindow().getShell(),
+                                               SWT.OK);
+                               // Title
+                               mb.setText(I18nDemoMessages.get().MultiSectionPage_PopupTitle);
+                               // Message
+                               mb.setMessage(I18nDemoMessages.get().MultiSectionPage_PopupText);
+                               mb.open();
+                       }
+               });
+       }
 
-       protected void createHistorySection(Composite parent) {
+       protected void createDetailsSection(Composite parent) {
 
                // Section Layout
                Section section = tk.createSection(parent, Section.TWISTIE);
                section.setLayoutData(new GridData(TableWrapData.FILL_GRAB));
-               TableWrapLayout twt = new TableWrapLayout();
-               section.setLayout(twt);
+               GridLayout gd = new GridLayout();
+               section.setLayout(gd);
 
                // Set title of the section
-               section.setText(I18nDemoPlugin
-                               .getMessage("MultiSelectionPage.DetailsSectionTitle"));
+               section.setText(I18nDemoMessages.get().MultiSectionPage_DetailsSectionTitle);
 
                final Text styledText = tk.createText(section, "", SWT.FULL_SELECTION
-                               | SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
+                               | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
                styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-               section.setClient(styledText);
                styledText.setEditable(false);
+               styledText
+                               .setText(I18nDemoMessages.get().MultiSectionPage_DescriptionSectionTxt);
                section.setExpanded(false);
 
+               section.setClient(styledText);
+
                AbstractFormPart part = new AbstractFormPart() {
                        public void commit(boolean onSave) {
                        }