changeset 171:0a21c7cabc16

presentation windows
author Frank Benoit <benoit@tionex.de>
date Sun, 26 Oct 2008 14:07:11 +0100
parents b5ce05a02738
children d36bf485a753
files jface/ActionAndStatusbar.d jface/user/PopUp.d
diffstat 2 files changed, 228 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/jface/ActionAndStatusbar.d	Sun Oct 26 14:05:37 2008 +0100
+++ b/jface/ActionAndStatusbar.d	Sun Oct 26 14:07:11 2008 +0100
@@ -19,6 +19,7 @@
 import dwtx.jface.action.MenuManager;
 import dwtx.jface.action.StatusLineManager;
 import dwtx.jface.action.ToolBarManager;
+import dwtx.jface.action.Separator;
 import dwtx.jface.resource.ImageDescriptor;
 import dwtx.jface.window.ApplicationWindow;
 import dwtx.core.runtime.IProgressMonitor;
@@ -26,6 +27,13 @@
 import dwt.widgets.Composite;
 import dwt.widgets.Control;
 import dwt.widgets.Display;
+import dwt.widgets.Group;
+import dwt.widgets.Button;
+import dwt.widgets.Event;
+import dwt.widgets.Listener;
+import dwt.widgets.Text;
+import dwt.layout.GridData;
+import dwt.layout.GridLayout;
 
 import tango.text.convert.Format;
 version(JIVE) import jive.stacktrace;
@@ -58,22 +66,46 @@
 
     protected Control createContents(Composite parent) {
         getShell().setText("Action/Contribution Example");
-        parent.setSize(290, 150);
-        aci.fill(parent);
-        return parent;
+        //parent.setSize(290, 150);
+        //aci.fill(parent);
+        Composite comp = cast(Composite) super.createContents(parent);
+        comp.setLayout( new GridLayout());
+        new Text( comp, DWT.BORDER );
+        auto grp = new Group(comp, DWT.None);
+        grp.setLayoutData( new GridData( GridData.FILL_BOTH ));
+        //grp.setSize( 200, 200 );
+        grp.setText("Action enable" );
+        grp.setLayout(new GridLayout( 1, true ));
+        with( new Button( grp, DWT.RADIO )){
+            setText( "On" );
+            addListener( DWT.Selection, dgListener( &doEnable, true ));
+        }
+        with( new Button( grp, DWT.RADIO )){
+            setText( "Off" );
+            addListener( DWT.Selection, dgListener( &doEnable, false ));
+        }
+        return comp;
+    }
+    void doEnable( Event e, bool state ){
+        status_action.setEnabled( state );
     }
 
     protected MenuManager createMenuManager() {
         MenuManager main_menu = new MenuManager(null);
+        MenuManager file_menu = new MenuManager("File");
         MenuManager action_menu = new MenuManager("Menu");
+        main_menu.add(file_menu);
         main_menu.add(action_menu);
         action_menu.add(status_action);
+        file_menu.add(status_action);
         return main_menu;
     }
 
     protected ToolBarManager createToolBarManager(int style) {
         ToolBarManager tool_bar_manager = new ToolBarManager(style);
         tool_bar_manager.add(status_action);
+        tool_bar_manager.add(new Separator());
+        tool_bar_manager.add(status_action);
         return tool_bar_manager;
     }
 
--- a/jface/user/PopUp.d	Sun Oct 26 14:05:37 2008 +0100
+++ b/jface/user/PopUp.d	Sun Oct 26 14:07:11 2008 +0100
@@ -1,7 +1,11 @@
 module user.PopUp;
 import tango.util.log.Trace;
+import tango.io.FileConduit;
+import tango.io.Stdout;
+import tango.core.Thread;
 
 import dwt.dwthelper.utils;
+import dwt.dwthelper.FileOutputStream;
 import dwt.DWT;
 
 import dwt.layout.GridLayout;
@@ -21,6 +25,9 @@
 import dwt.widgets.Button;
 import dwt.widgets.Label;
 
+import dwtx.core.runtime.IProgressMonitor;
+import dwtx.jface.operation.IRunnableWithProgress;
+import dwtx.jface.preference.PreferenceStore;
 import dwtx.jface.dialogs.PopupDialog;
 import dwtx.jface.dialogs.ErrorDialog;
 import dwtx.jface.dialogs.MessageDialogWithToggle;
@@ -31,6 +38,14 @@
 import dwtx.jface.dialogs.IMessageProvider;
 import dwtx.jface.dialogs.DialogTray;
 import dwtx.jface.dialogs.IInputValidator;
+import dwtx.jface.dialogs.DialogSettings;
+import dwtx.jface.dialogs.IDialogSettings;
+import dwtx.jface.dialogs.StatusDialog;
+
+import dwtx.jface.wizard.Wizard;
+import dwtx.jface.wizard.WizardPage;
+import dwtx.jface.wizard.WizardSelectionPage;
+import dwtx.jface.wizard.WizardDialog;
 
 import dwtx.jface.window.ApplicationWindow;
 import dwtx.core.runtime.IStatus;
@@ -57,6 +72,10 @@
             setText( "PopUp" );
         }
         with( new Button( comp, DWT.PUSH )){
+            addListener( DWT.Selection, dgListener( & doMessageDlg ));
+            setText( "Message DLG" );
+        }
+        with( new Button( comp, DWT.PUSH )){
             addListener( DWT.Selection, dgListener( & doErrorDlg ));
             setText( "Error DLG" );
         }
@@ -72,6 +91,14 @@
             addListener( DWT.Selection, dgListener( & doTitleAreaDialog ));
             setText( "TitleAreaDialog" );
         }
+        with( new Button( comp, DWT.PUSH )){
+            addListener( DWT.Selection, dgListener( & doWizard ));
+            setText( "Wizard" );
+        }
+        with( new Button( comp, DWT.PUSH )){
+            addListener( DWT.Selection, dgListener( & doStatusDialog ));
+            setText( "StatusDialog" );
+        }
         return comp;
     }
     void doPopUp( Event e ){
@@ -87,19 +114,35 @@
             "Info line...");
         pu.open();
     }
+    void doMessageDlg( Event e ){
+    }
     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 status = new MultiStatus( "plugin-ID", 0, "Message text of the MultiStatus", null );
+        status.add( new Status( Status.ERROR, "plugin-ID", "message of an example 'error' status"/+, new RuntimeException("bla")+/ ) );
+        status.add( new Status( Status.WARNING, "plugin-ID", "message of an example 'warning' status" ) );
         auto dlg = new ErrorDialog(
             getShell(),
-            "Title",
+            "ErrorDialog",
             "Dialog message",
             status,
             IStatus.ERROR|IStatus.WARNING);
         dlg.open();
     }
     void doMessageDialogWithToggleDlg( Event e ){
+        auto ps = new PreferenceStore( "ps.txt" );
+        auto dlg = MessageDialogWithToggle.openYesNoCancelQuestion(
+                getShell(),
+                "MessageDialogWithToggle",
+                "MessageDialogWithToggle with additional toggle message. "
+                "A preference can be controlled by this that is set to 'always' if check and 'YES' or is set to 'never' if check and NO is selected. ",
+                "Toggle message (e.g. Remember my decision)",
+                false,
+                ps,
+                "key" );
+        ps.save();
+        Stdout.formatln("list:" );
+        ps.list(Stdout);
+/+
         auto dlg = new MessageDialogWithToggle(
             getShell(),
             "Title",
@@ -111,11 +154,17 @@
             "Toggle message",
             true);
         dlg.open();
++/
+    }
+    void doStatusDialog( Event e ){
+        auto dlg = new MyStatusDialog( getShell() );
+        dlg.setTitle( "StatusDialog" );
+        dlg.open();
     }
     void doInputDlg( Event e ){
         auto dlg = new InputDialog(
             getShell(),
-            "Title",
+            "InputDialog",
             "Enter a positive number",
             "42",
             new class() IInputValidator{
@@ -125,50 +174,127 @@
                         return null;
                     }
                     catch( Exception e ){
-                        return "Not a valid number";
+                        return "\"" ~ newText ~ "\" is not a valid number";
                     }
                 }
             } );
         dlg.open();
     }
 
+    DialogSettings dlgsettings;
     void doTitleAreaDialog( Event e ){
+        if( dlgsettings is null ){
+            dlgsettings = new DialogSettings("TitleAreaDialog");
+
+            try{
+                dlgsettings.load( "dlgsettings.txt" );
+            }
+            catch( IOException e ){
+
+            }
+        }
         auto dlg = new MyTitleAreaDialog(
-            getShell());
+            getShell(), dlgsettings );
         dlg.open();
+        dlgsettings.save( "dlgsettings.txt" );
     }
 
+    void doWizard( Event e ){
+        auto myWizard = new MyWizard();
+        auto w = new WizardDialog( getShell(), myWizard );
+        w.open();
+    }
 }
-
+    class MyStatusDialog : StatusDialog {
+        this( Shell parent ) {
+            super(parent );
+        }
+        override void create(){
+            super.create();
+            updateStatus( new Status( IStatus.ERROR, "id", "the error message" ) );
+        }
+    }
     class MyTitleAreaDialog : TitleAreaDialog {
-        this( Shell shell ){
+        IDialogSettings settings;
+        this( Shell shell, IDialogSettings settings ){
+            this.settings = settings;
             super(shell);
         }
         protected override void configureShell(Shell newShell){
             super.configureShell(newShell);
             newShell.setText( "Application Name" );
         }
+        protected override IDialogSettings getDialogBoundsSettings(){
+            return settings;
+        }
         protected override bool isResizable(){
             return true;
         }
+        protected override int getDialogBoundsStrategy(){
+            //return DIALOG_PERSISTLOCATION;
+            //return DIALOG_PERSISTSIZE;
+            return DIALOG_PERSISTLOCATION | DIALOG_PERSISTSIZE;
+            //return 0;
+        }
         protected override Control createContents(Composite parent) {
             auto comp = cast(Composite) super.createContents(parent);
-            openTray( new MyTray() );
+            //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 );
+
+            Group grp = new Group( comp, DWT.NONE );
+            grp.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, false ));
+            grp.setLayout( new GridLayout( 2, true ));
+            grp.setText( "Select" );
+
+            with( new Button( grp, DWT.RADIO )){
+                addListener( DWT.Selection, dgListener( &selNone ));
+                setText( "None" );
+            }
+            with( new Button( grp, DWT.RADIO )){
+                addListener( DWT.Selection, dgListener( &selDescription ));
+                setText( "Description" );
+            }
+            with( new Button( grp, DWT.RADIO )){
+                addListener( DWT.Selection, dgListener( &selInfo ));
+                setText( "Info" );
+            }
+            with( new Button( grp, DWT.RADIO )){
+                addListener( DWT.Selection, dgListener( &selWarning ));
+                setText( "Warning" );
+            }
+            with( new Button( grp, DWT.RADIO )){
+                addListener( DWT.Selection, dgListener( &selError ));
+                setText( "Error" );
+            }
+
             return comp;
         }
+        private void selNone( Event e ){
+            setMessage(null);
+        }
+        private void selDescription( Event e ){
+            setMessage("Description which can also be a bit\nlonger.", IMessageProvider.NONE );
+        }
+        private void selInfo( Event e ){
+            setMessage("Information", IMessageProvider.INFORMATION );
+        }
+        private void selWarning( Event e ){
+            setMessage("Warning", IMessageProvider.WARNING );
+        }
+        private void selError( Event e ){
+            setMessage("Error", IMessageProvider.ERROR );
+        }
     }
     class MyTray : DialogTray {
         protected Control createContents(Composite parent){
@@ -185,6 +311,62 @@
         }
     }
 
+    class Page1 : WizardPage {
+        this( char[] title ){
+            super(title);
+            setTitle( title );
+            setMessage( "A description of the wizard page", IMessageProvider.NONE );
+        }
+        public void createControl( Composite parent ){
+            Composite comp = new Composite( parent, DWT.NONE );
+            comp.setLayout( new FillLayout() );
+            with( new Label( comp, DWT.NONE )){
+                setText( "content" );
+            }
+            setControl( comp );
+            return comp;
+        }
+    }
+    class Page2 : WizardSelectionPage {
+        this( char[] title ){
+            super(title);
+        }
+        public void createControl( Composite parent ){
+            Composite comp = new Composite( parent, DWT.NONE );
+            comp.setLayout( new FillLayout() );
+            with( new Label( comp, DWT.NONE )){
+                setText( "content" );
+            }
+            setControl( comp );
+
+            return comp;
+        }
+    }
+    class MyWizard : Wizard {
+        this(){
+            addPage( new Page1( "First Wizard Page") );
+            addPage( new Page1( "Second Wizard Page") );
+            setNeedsProgressMonitor(true);
+            setWindowTitle( "Wizard" );
+        }
+        public override bool performFinish(){
+            // puts the data into a database ...
+            getContainer().run(true, true, new class IRunnableWithProgress {
+                public void run(IProgressMonitor monitor) {
+                    monitor.beginTask("Store data", 100);
+
+                    monitor.worked(40);
+
+                    // store data here ...
+                    //System.out.println(data);
+
+                    Thread.sleep(5.200);
+                    monitor.done();
+                }
+            });
+            return true;
+        }
+    }
 
 void main(){
     auto d = new Display();