changeset 149:80f47186dc48

more dialogs
author Frank Benoit <benoit@tionex.de>
date Sat, 16 Aug 2008 22:24:25 +0200
parents 168b3c176815
children 297120c376f7
files jface/user/PopUp.d
diffstat 1 files changed, 117 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/jface/user/PopUp.d	Sat Aug 16 13:22:20 2008 +0200
+++ b/jface/user/PopUp.d	Sat Aug 16 22:24:25 2008 +0200
@@ -6,6 +6,7 @@
 
 import dwt.layout.GridLayout;
 import dwt.layout.GridData;
+import dwt.layout.FillLayout;
 
 import dwt.graphics.Image;
 
@@ -18,10 +19,24 @@
 import dwt.widgets.Listener;
 import dwt.widgets.Event;
 import dwt.widgets.Button;
+import dwt.widgets.Label;
 
 import dwtx.jface.dialogs.PopupDialog;
+import dwtx.jface.dialogs.ErrorDialog;
+import dwtx.jface.dialogs.MessageDialogWithToggle;
+import dwtx.jface.dialogs.MessageDialog;
+import dwtx.jface.dialogs.IDialogConstants;
+import dwtx.jface.dialogs.TitleAreaDialog;
+import dwtx.jface.dialogs.InputDialog;
+import dwtx.jface.dialogs.IMessageProvider;
+import dwtx.jface.dialogs.DialogTray;
 
 import dwtx.jface.window.ApplicationWindow;
+import dwtx.core.runtime.IStatus;
+import dwtx.core.runtime.Status;
+import dwtx.core.runtime.MultiStatus;
+
+version(JIVE) import jive.stacktrace;
 
 class App : ApplicationWindow {
 
@@ -36,13 +51,29 @@
         comp.setLayout(new GridLayout(1, false));
 
 
-        auto btn = new Button( comp, DWT.PUSH );
-        btn.addListener( DWT.Selection, dgListener( & doBtn1 ));
-        btn.setText( "Btn 1" );
+        with( new Button( comp, DWT.PUSH )){
+            addListener( DWT.Selection, dgListener( & doPopUp ));
+            setText( "PopUp" );
+        }
+        with( new Button( comp, DWT.PUSH )){
+            addListener( DWT.Selection, dgListener( & doErrorDlg ));
+            setText( "Error DLG" );
+        }
+        with( new Button( comp, DWT.PUSH )){
+            addListener( DWT.Selection, dgListener( & doInputDlg ));
+            setText( "Input DLG" );
+        }
+        with( new Button( comp, DWT.PUSH )){
+            addListener( DWT.Selection, dgListener( & doMessageDialogWithToggleDlg ));
+            setText( "MessageDialogWithToggle" );
+        }
+        with( new Button( comp, DWT.PUSH )){
+            addListener( DWT.Selection, dgListener( & doTitleAreaDialog ));
+            setText( "TitleAreaDialog" );
+        }
         return comp;
     }
-    void doBtn1( Event e ){
-        Trace.formatln( "btn1");
+    void doPopUp( Event e ){
         auto pu = new PopupDialog(
             getShell(),
             PopupDialog.HOVER_SHELLSTYLE ,
@@ -55,23 +86,93 @@
             "Info line...");
         pu.open();
     }
-    void doBtn2( Event e ){
-        Trace.formatln( "btn1");
-        auto pu = new PopupDialog(
+    void doErrorDlg( Event e ){
+        auto status = new MultiStatus( "plugin-ID", 0, "MultiStatus message", null );
+        status.add( new Status( Status.ERROR, "plugin-ID", "Status message 'error'"/+, new RuntimeException("bla")+/ ) );
+        status.add( new Status( Status.WARNING, "plugin-ID", "Status message 'warning'" ) );
+        auto dlg = new ErrorDialog(
+            getShell(),
+            "Title",
+            "Dialog message",
+            status,
+            IStatus.ERROR|IStatus.WARNING);
+        dlg.open();
+    }
+    void doMessageDialogWithToggleDlg( Event e ){
+        auto dlg = new MessageDialogWithToggle(
             getShell(),
-            PopupDialog.HOVER_SHELLSTYLE,
-            false,
-            true,
-            true,
-            true,
-            true,
             "Title",
-            "Text\non the other line...");
-        pu.open();
+            null,
+            "Dialog message",
+            MessageDialog.INFORMATION,
+            [ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL ],
+            0,
+            "Toggle message",
+            true);
+        dlg.open();
+    }
+    void doInputDlg( Event e ){
+        auto dlg = new InputDialog(
+            getShell(),
+            "Title",
+            "Dialog message",
+            "42",
+            null );
+        dlg.open();
+    }
+
+    void doTitleAreaDialog( Event e ){
+        auto dlg = new MyTitleAreaDialog(
+            getShell());
+        dlg.open();
     }
 
 }
 
+    class MyTitleAreaDialog : TitleAreaDialog {
+        this( Shell shell ){
+            super(shell);
+        }
+        protected override void configureShell(Shell newShell){
+            super.configureShell(newShell);
+            newShell.setText( "Application Name" );
+        }
+        protected override bool isResizable(){
+            return true;
+        }
+        protected override Control createContents(Composite parent) {
+            auto comp = cast(Composite) super.createContents(parent);
+            openTray( new MyTray() );
+            setTitle( "Title" );
+            setMessage( "A custom message", IMessageProvider.INFORMATION );
+            return comp;
+        }
+        protected override Control createDialogArea(Composite parent){
+            auto comp = cast(Composite) super.createDialogArea(parent);
+            //comp.setLayout( new FillLayout());
+            auto lbl = new Label( comp, DWT.None );
+            lbl.setText( "Dialog Area" );
+            auto gd = new GridData( GridData.FILL, GridData.FILL, true, false );
+            gd.verticalIndent = 5;
+            gd.horizontalIndent = 5;
+            lbl.setLayoutData( gd );
+            return comp;
+        }
+    }
+    class MyTray : DialogTray {
+        protected Control createContents(Composite parent){
+            auto comp = new Composite(parent, DWT.NONE );
+            comp.setLayout( new GridLayout( 1, false ));
+            with( new Label( comp, DWT.NONE )){
+                auto gd = new GridData( GridData.FILL, GridData.FILL, true, false );
+                gd.verticalIndent = 5;
+                gd.horizontalIndent = 5;
+                setLayoutData( gd );
+                setText( "Tray" );
+            }
+            return comp;
+        }
+    }
 
 
 void main(){