Changeset 149:80f47186dc48
- 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
| r147 |
r149 |
|
| 7 | 7 | import dwt.layout.GridLayout; |
|---|
| 8 | 8 | import dwt.layout.GridData; |
|---|
| | 9 | import dwt.layout.FillLayout; |
|---|
| 9 | 10 | |
|---|
| 10 | 11 | import dwt.graphics.Image; |
|---|
| … | … | |
| 19 | 20 | import dwt.widgets.Event; |
|---|
| 20 | 21 | import dwt.widgets.Button; |
|---|
| | 22 | import dwt.widgets.Label; |
|---|
| 21 | 23 | |
|---|
| 22 | 24 | import dwtx.jface.dialogs.PopupDialog; |
|---|
| | 25 | import dwtx.jface.dialogs.ErrorDialog; |
|---|
| | 26 | import dwtx.jface.dialogs.MessageDialogWithToggle; |
|---|
| | 27 | import dwtx.jface.dialogs.MessageDialog; |
|---|
| | 28 | import dwtx.jface.dialogs.IDialogConstants; |
|---|
| | 29 | import dwtx.jface.dialogs.TitleAreaDialog; |
|---|
| | 30 | import dwtx.jface.dialogs.InputDialog; |
|---|
| | 31 | import dwtx.jface.dialogs.IMessageProvider; |
|---|
| | 32 | import dwtx.jface.dialogs.DialogTray; |
|---|
| 23 | 33 | |
|---|
| 24 | 34 | import dwtx.jface.window.ApplicationWindow; |
|---|
| | 35 | import dwtx.core.runtime.IStatus; |
|---|
| | 36 | import dwtx.core.runtime.Status; |
|---|
| | 37 | import dwtx.core.runtime.MultiStatus; |
|---|
| | 38 | |
|---|
| | 39 | version(JIVE) import jive.stacktrace; |
|---|
| 25 | 40 | |
|---|
| 26 | 41 | class App : ApplicationWindow { |
|---|
| … | … | |
| 37 | 52 | |
|---|
| 38 | 53 | |
|---|
| 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 | } |
|---|
| 42 | 74 | return comp; |
|---|
| 43 | 75 | } |
|---|
| 44 | | void doBtn1( Event e ){ |
|---|
| 45 | | Trace.formatln( "btn1"); |
|---|
| | 76 | void doPopUp( Event e ){ |
|---|
| 46 | 77 | auto pu = new PopupDialog( |
|---|
| 47 | 78 | getShell(), |
|---|
| … | … | |
| 56 | 87 | pu.open(); |
|---|
| 57 | 88 | } |
|---|
| 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( |
|---|
| 61 | 94 | getShell(), |
|---|
| 62 | | PopupDialog.HOVER_SHELLSTYLE, |
|---|
| 63 | | false, |
|---|
| 64 | | true, |
|---|
| 65 | | true, |
|---|
| 66 | | true, |
|---|
| 67 | | true, |
|---|
| 68 | 95 | "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(); |
|---|
| 71 | 128 | } |
|---|
| 72 | 129 | |
|---|
| 73 | 130 | } |
|---|
| 74 | 131 | |
|---|
| | 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 | } |
|---|
| 75 | 176 | |
|---|
| 76 | 177 | |
|---|