Changeset 149:80f47186dc48

Show
Ignore:
Timestamp:
08/16/08 16:24:25 (4 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

more dialogs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • jface/user/PopUp.d

    r147 r149  
    77import dwt.layout.GridLayout; 
    88import dwt.layout.GridData; 
     9import dwt.layout.FillLayout; 
    910 
    1011import dwt.graphics.Image; 
     
    1920import dwt.widgets.Event; 
    2021import dwt.widgets.Button; 
     22import dwt.widgets.Label; 
    2123 
    2224import dwtx.jface.dialogs.PopupDialog; 
     25import dwtx.jface.dialogs.ErrorDialog; 
     26import dwtx.jface.dialogs.MessageDialogWithToggle; 
     27import dwtx.jface.dialogs.MessageDialog; 
     28import dwtx.jface.dialogs.IDialogConstants; 
     29import dwtx.jface.dialogs.TitleAreaDialog; 
     30import dwtx.jface.dialogs.InputDialog; 
     31import dwtx.jface.dialogs.IMessageProvider; 
     32import dwtx.jface.dialogs.DialogTray; 
    2333 
    2434import dwtx.jface.window.ApplicationWindow; 
     35import dwtx.core.runtime.IStatus; 
     36import dwtx.core.runtime.Status; 
     37import dwtx.core.runtime.MultiStatus; 
     38 
     39version(JIVE) import jive.stacktrace; 
    2540 
    2641class App : ApplicationWindow { 
     
    3752 
    3853 
    39         auto btn = new Button( comp, DWT.PUSH ); 
    40         btn.addListener( DWT.Selection, dgListener( & doBtn1 )); 
    41         btn.setText( "Btn 1" ); 
     54        with( new Button( comp, DWT.PUSH )){ 
     55            addListener( DWT.Selection, dgListener( & doPopUp )); 
     56            setText( "PopUp" ); 
     57        } 
     58        with( new Button( comp, DWT.PUSH )){ 
     59            addListener( DWT.Selection, dgListener( & doErrorDlg )); 
     60            setText( "Error DLG" ); 
     61        } 
     62        with( new Button( comp, DWT.PUSH )){ 
     63            addListener( DWT.Selection, dgListener( & doInputDlg )); 
     64            setText( "Input DLG" ); 
     65        } 
     66        with( new Button( comp, DWT.PUSH )){ 
     67            addListener( DWT.Selection, dgListener( & doMessageDialogWithToggleDlg )); 
     68            setText( "MessageDialogWithToggle" ); 
     69        } 
     70        with( new Button( comp, DWT.PUSH )){ 
     71            addListener( DWT.Selection, dgListener( & doTitleAreaDialog )); 
     72            setText( "TitleAreaDialog" ); 
     73        } 
    4274        return comp; 
    4375    } 
    44     void doBtn1( Event e ){ 
    45         Trace.formatln( "btn1"); 
     76    void doPopUp( Event e ){ 
    4677        auto pu = new PopupDialog( 
    4778            getShell(), 
     
    5687        pu.open(); 
    5788    } 
    58     void doBtn2( Event e ){ 
    59         Trace.formatln( "btn1"); 
    60         auto pu = new PopupDialog( 
     89    void doErrorDlg( Event e ){ 
     90        auto status = new MultiStatus( "plugin-ID", 0, "MultiStatus message", null ); 
     91        status.add( new Status( Status.ERROR, "plugin-ID", "Status message 'error'"/+, new RuntimeException("bla")+/ ) ); 
     92        status.add( new Status( Status.WARNING, "plugin-ID", "Status message 'warning'" ) ); 
     93        auto dlg = new ErrorDialog( 
    6194            getShell(), 
    62             PopupDialog.HOVER_SHELLSTYLE, 
    63             false, 
    64             true, 
    65             true, 
    66             true, 
    67             true, 
    6895            "Title", 
    69             "Text\non the other line..."); 
    70         pu.open(); 
     96            "Dialog message", 
     97            status, 
     98            IStatus.ERROR|IStatus.WARNING); 
     99        dlg.open(); 
     100    } 
     101    void doMessageDialogWithToggleDlg( Event e ){ 
     102        auto dlg = new MessageDialogWithToggle( 
     103            getShell(), 
     104            "Title", 
     105            null, 
     106            "Dialog message", 
     107            MessageDialog.INFORMATION, 
     108            [ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL ], 
     109            0, 
     110            "Toggle message", 
     111            true); 
     112        dlg.open(); 
     113    } 
     114    void doInputDlg( Event e ){ 
     115        auto dlg = new InputDialog( 
     116            getShell(), 
     117            "Title", 
     118            "Dialog message", 
     119            "42", 
     120            null ); 
     121        dlg.open(); 
     122    } 
     123 
     124    void doTitleAreaDialog( Event e ){ 
     125        auto dlg = new MyTitleAreaDialog( 
     126            getShell()); 
     127        dlg.open(); 
    71128    } 
    72129 
    73130} 
    74131 
     132    class MyTitleAreaDialog : TitleAreaDialog { 
     133        this( Shell shell ){ 
     134            super(shell); 
     135        } 
     136        protected override void configureShell(Shell newShell){ 
     137            super.configureShell(newShell); 
     138            newShell.setText( "Application Name" ); 
     139        } 
     140        protected override bool isResizable(){ 
     141            return true; 
     142        } 
     143        protected override Control createContents(Composite parent) { 
     144            auto comp = cast(Composite) super.createContents(parent); 
     145            openTray( new MyTray() ); 
     146            setTitle( "Title" ); 
     147            setMessage( "A custom message", IMessageProvider.INFORMATION ); 
     148            return comp; 
     149        } 
     150        protected override Control createDialogArea(Composite parent){ 
     151            auto comp = cast(Composite) super.createDialogArea(parent); 
     152            //comp.setLayout( new FillLayout()); 
     153            auto lbl = new Label( comp, DWT.None ); 
     154            lbl.setText( "Dialog Area" ); 
     155            auto gd = new GridData( GridData.FILL, GridData.FILL, true, false ); 
     156            gd.verticalIndent = 5; 
     157            gd.horizontalIndent = 5; 
     158            lbl.setLayoutData( gd ); 
     159            return comp; 
     160        } 
     161    } 
     162    class MyTray : DialogTray { 
     163        protected Control createContents(Composite parent){ 
     164            auto comp = new Composite(parent, DWT.NONE ); 
     165            comp.setLayout( new GridLayout( 1, false )); 
     166            with( new Label( comp, DWT.NONE )){ 
     167                auto gd = new GridData( GridData.FILL, GridData.FILL, true, false ); 
     168                gd.verticalIndent = 5; 
     169                gd.horizontalIndent = 5; 
     170                setLayoutData( gd ); 
     171                setText( "Tray" ); 
     172            } 
     173            return comp; 
     174        } 
     175    } 
    75176 
    76177