Changeset 171:0a21c7cabc16
- Timestamp:
- 10/26/08 09:07:11 (3 years ago)
- Files:
-
- jface/ActionAndStatusbar.d (modified) (4 diffs)
- jface/user/PopUp.d (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
jface/ActionAndStatusbar.d
r60 r171 20 20 import dwtx.jface.action.StatusLineManager; 21 21 import dwtx.jface.action.ToolBarManager; 22 import dwtx.jface.action.Separator; 22 23 import dwtx.jface.resource.ImageDescriptor; 23 24 import dwtx.jface.window.ApplicationWindow; … … 27 28 import dwt.widgets.Control; 28 29 import dwt.widgets.Display; 30 import dwt.widgets.Group; 31 import dwt.widgets.Button; 32 import dwt.widgets.Event; 33 import dwt.widgets.Listener; 34 import dwt.widgets.Text; 35 import dwt.layout.GridData; 36 import dwt.layout.GridLayout; 29 37 30 38 import tango.text.convert.Format; … … 59 67 protected Control createContents(Composite parent) { 60 68 getShell().setText("Action/Contribution Example"); 61 parent.setSize(290, 150); 62 aci.fill(parent); 63 return parent; 69 //parent.setSize(290, 150); 70 //aci.fill(parent); 71 Composite comp = cast(Composite) super.createContents(parent); 72 comp.setLayout( new GridLayout()); 73 new Text( comp, DWT.BORDER ); 74 auto grp = new Group(comp, DWT.None); 75 grp.setLayoutData( new GridData( GridData.FILL_BOTH )); 76 //grp.setSize( 200, 200 ); 77 grp.setText("Action enable" ); 78 grp.setLayout(new GridLayout( 1, true )); 79 with( new Button( grp, DWT.RADIO )){ 80 setText( "On" ); 81 addListener( DWT.Selection, dgListener( &doEnable, true )); 82 } 83 with( new Button( grp, DWT.RADIO )){ 84 setText( "Off" ); 85 addListener( DWT.Selection, dgListener( &doEnable, false )); 86 } 87 return comp; 88 } 89 void doEnable( Event e, bool state ){ 90 status_action.setEnabled( state ); 64 91 } 65 92 66 93 protected MenuManager createMenuManager() { 67 94 MenuManager main_menu = new MenuManager(null); 95 MenuManager file_menu = new MenuManager("File"); 68 96 MenuManager action_menu = new MenuManager("Menu"); 97 main_menu.add(file_menu); 69 98 main_menu.add(action_menu); 70 99 action_menu.add(status_action); 100 file_menu.add(status_action); 71 101 return main_menu; 72 102 } … … 74 104 protected ToolBarManager createToolBarManager(int style) { 75 105 ToolBarManager tool_bar_manager = new ToolBarManager(style); 106 tool_bar_manager.add(status_action); 107 tool_bar_manager.add(new Separator()); 76 108 tool_bar_manager.add(status_action); 77 109 return tool_bar_manager; jface/user/PopUp.d
r162 r171 1 1 module user.PopUp; 2 2 import tango.util.log.Trace; 3 import tango.io.FileConduit; 4 import tango.io.Stdout; 5 import tango.core.Thread; 3 6 4 7 import dwt.dwthelper.utils; 8 import dwt.dwthelper.FileOutputStream; 5 9 import dwt.DWT; 6 10 … … 22 26 import dwt.widgets.Label; 23 27 28 import dwtx.core.runtime.IProgressMonitor; 29 import dwtx.jface.operation.IRunnableWithProgress; 30 import dwtx.jface.preference.PreferenceStore; 24 31 import dwtx.jface.dialogs.PopupDialog; 25 32 import dwtx.jface.dialogs.ErrorDialog; … … 32 39 import dwtx.jface.dialogs.DialogTray; 33 40 import dwtx.jface.dialogs.IInputValidator; 41 import dwtx.jface.dialogs.DialogSettings; 42 import dwtx.jface.dialogs.IDialogSettings; 43 import dwtx.jface.dialogs.StatusDialog; 44 45 import dwtx.jface.wizard.Wizard; 46 import dwtx.jface.wizard.WizardPage; 47 import dwtx.jface.wizard.WizardSelectionPage; 48 import dwtx.jface.wizard.WizardDialog; 34 49 35 50 import dwtx.jface.window.ApplicationWindow; … … 58 73 } 59 74 with( new Button( comp, DWT.PUSH )){ 75 addListener( DWT.Selection, dgListener( & doMessageDlg )); 76 setText( "Message DLG" ); 77 } 78 with( new Button( comp, DWT.PUSH )){ 60 79 addListener( DWT.Selection, dgListener( & doErrorDlg )); 61 80 setText( "Error DLG" ); … … 72 91 addListener( DWT.Selection, dgListener( & doTitleAreaDialog )); 73 92 setText( "TitleAreaDialog" ); 93 } 94 with( new Button( comp, DWT.PUSH )){ 95 addListener( DWT.Selection, dgListener( & doWizard )); 96 setText( "Wizard" ); 97 } 98 with( new Button( comp, DWT.PUSH )){ 99 addListener( DWT.Selection, dgListener( & doStatusDialog )); 100 setText( "StatusDialog" ); 74 101 } 75 102 return comp; … … 88 115 pu.open(); 89 116 } 117 void doMessageDlg( Event e ){ 118 } 90 119 void doErrorDlg( Event e ){ 91 auto status = new MultiStatus( "plugin-ID", 0, "M ultiStatus message", null );92 status.add( new Status( Status.ERROR, "plugin-ID", " Status message 'error'"/+, new RuntimeException("bla")+/ ) );93 status.add( new Status( Status.WARNING, "plugin-ID", " Status message 'warning'" ) );120 auto status = new MultiStatus( "plugin-ID", 0, "Message text of the MultiStatus", null ); 121 status.add( new Status( Status.ERROR, "plugin-ID", "message of an example 'error' status"/+, new RuntimeException("bla")+/ ) ); 122 status.add( new Status( Status.WARNING, "plugin-ID", "message of an example 'warning' status" ) ); 94 123 auto dlg = new ErrorDialog( 95 124 getShell(), 96 " Title",125 "ErrorDialog", 97 126 "Dialog message", 98 127 status, … … 101 130 } 102 131 void doMessageDialogWithToggleDlg( Event e ){ 132 auto ps = new PreferenceStore( "ps.txt" ); 133 auto dlg = MessageDialogWithToggle.openYesNoCancelQuestion( 134 getShell(), 135 "MessageDialogWithToggle", 136 "MessageDialogWithToggle with additional toggle message. " 137 "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. ", 138 "Toggle message (e.g. Remember my decision)", 139 false, 140 ps, 141 "key" ); 142 ps.save(); 143 Stdout.formatln("list:" ); 144 ps.list(Stdout); 145 /+ 103 146 auto dlg = new MessageDialogWithToggle( 104 147 getShell(), … … 112 155 true); 113 156 dlg.open(); 157 +/ 158 } 159 void doStatusDialog( Event e ){ 160 auto dlg = new MyStatusDialog( getShell() ); 161 dlg.setTitle( "StatusDialog" ); 162 dlg.open(); 114 163 } 115 164 void doInputDlg( Event e ){ 116 165 auto dlg = new InputDialog( 117 166 getShell(), 118 " Title",167 "InputDialog", 119 168 "Enter a positive number", 120 169 "42", … … 126 175 } 127 176 catch( Exception e ){ 128 return " Not a valid number";177 return "\"" ~ newText ~ "\" is not a valid number"; 129 178 } 130 179 } … … 133 182 } 134 183 184 DialogSettings dlgsettings; 135 185 void doTitleAreaDialog( Event e ){ 186 if( dlgsettings is null ){ 187 dlgsettings = new DialogSettings("TitleAreaDialog"); 188 189 try{ 190 dlgsettings.load( "dlgsettings.txt" ); 191 } 192 catch( IOException e ){ 193 194 } 195 } 136 196 auto dlg = new MyTitleAreaDialog( 137 getShell()); 138 dlg.open(); 139 } 140 197 getShell(), dlgsettings ); 198 dlg.open(); 199 dlgsettings.save( "dlgsettings.txt" ); 200 } 201 202 void doWizard( Event e ){ 203 auto myWizard = new MyWizard(); 204 auto w = new WizardDialog( getShell(), myWizard ); 205 w.open(); 206 } 141 207 } 142 208 class MyStatusDialog : StatusDialog { 209 this( Shell parent ) { 210 super(parent ); 211 } 212 override void create(){ 213 super.create(); 214 updateStatus( new Status( IStatus.ERROR, "id", "the error message" ) ); 215 } 216 } 143 217 class MyTitleAreaDialog : TitleAreaDialog { 144 this( Shell shell ){ 218 IDialogSettings settings; 219 this( Shell shell, IDialogSettings settings ){ 220 this.settings = settings; 145 221 super(shell); 146 222 } … … 149 225 newShell.setText( "Application Name" ); 150 226 } 227 protected override IDialogSettings getDialogBoundsSettings(){ 228 return settings; 229 } 151 230 protected override bool isResizable(){ 152 231 return true; 153 232 } 233 protected override int getDialogBoundsStrategy(){ 234 //return DIALOG_PERSISTLOCATION; 235 //return DIALOG_PERSISTSIZE; 236 return DIALOG_PERSISTLOCATION | DIALOG_PERSISTSIZE; 237 //return 0; 238 } 154 239 protected override Control createContents(Composite parent) { 155 240 auto comp = cast(Composite) super.createContents(parent); 156 openTray( new MyTray() );241 //openTray( new MyTray() ); 157 242 setTitle( "Title" ); 158 243 setMessage( "A custom message", IMessageProvider.INFORMATION ); … … 161 246 protected override Control createDialogArea(Composite parent){ 162 247 auto comp = cast(Composite) super.createDialogArea(parent); 163 //comp.setLayout( new FillLayout());164 248 auto lbl = new Label( comp, DWT.None ); 165 249 lbl.setText( "Dialog Area" ); … … 168 252 gd.horizontalIndent = 5; 169 253 lbl.setLayoutData( gd ); 170 return comp; 254 255 Group grp = new Group( comp, DWT.NONE ); 256 grp.setLayoutData( new GridData( GridData.FILL, GridData.FILL, true, false )); 257 grp.setLayout( new GridLayout( 2, true )); 258 grp.setText( "Select" ); 259 260 with( new Button( grp, DWT.RADIO )){ 261 addListener( DWT.Selection, dgListener( &selNone )); 262 setText( "None" ); 263 } 264 with( new Button( grp, DWT.RADIO )){ 265 addListener( DWT.Selection, dgListener( &selDescription )); 266 setText( "Description" ); 267 } 268 with( new Button( grp, DWT.RADIO )){ 269 addListener( DWT.Selection, dgListener( &selInfo )); 270 setText( "Info" ); 271 } 272 with( new Button( grp, DWT.RADIO )){ 273 addListener( DWT.Selection, dgListener( &selWarning )); 274 setText( "Warning" ); 275 } 276 with( new Button( grp, DWT.RADIO )){ 277 addListener( DWT.Selection, dgListener( &selError )); 278 setText( "Error" ); 279 } 280 281 return comp; 282 } 283 private void selNone( Event e ){ 284 setMessage(null); 285 } 286 private void selDescription( Event e ){ 287 setMessage("Description which can also be a bit\nlonger.", IMessageProvider.NONE ); 288 } 289 private void selInfo( Event e ){ 290 setMessage("Information", IMessageProvider.INFORMATION ); 291 } 292 private void selWarning( Event e ){ 293 setMessage("Warning", IMessageProvider.WARNING ); 294 } 295 private void selError( Event e ){ 296 setMessage("Error", IMessageProvider.ERROR ); 171 297 } 172 298 } … … 186 312 } 187 313 314 class Page1 : WizardPage { 315 this( char[] title ){ 316 super(title); 317 setTitle( title ); 318 setMessage( "A description of the wizard page", IMessageProvider.NONE ); 319 } 320 public void createControl( Composite parent ){ 321 Composite comp = new Composite( parent, DWT.NONE ); 322 comp.setLayout( new FillLayout() ); 323 with( new Label( comp, DWT.NONE )){ 324 setText( "content" ); 325 } 326 setControl( comp ); 327 return comp; 328 } 329 } 330 class Page2 : WizardSelectionPage { 331 this( char[] title ){ 332 super(title); 333 } 334 public void createControl( Composite parent ){ 335 Composite comp = new Composite( parent, DWT.NONE ); 336 comp.setLayout( new FillLayout() ); 337 with( new Label( comp, DWT.NONE )){ 338 setText( "content" ); 339 } 340 setControl( comp ); 341 342 return comp; 343 } 344 } 345 class MyWizard : Wizard { 346 this(){ 347 addPage( new Page1( "First Wizard Page") ); 348 addPage( new Page1( "Second Wizard Page") ); 349 setNeedsProgressMonitor(true); 350 setWindowTitle( "Wizard" ); 351 } 352 public override bool performFinish(){ 353 // puts the data into a database ... 354 getContainer().run(true, true, new class IRunnableWithProgress { 355 public void run(IProgressMonitor monitor) { 356 monitor.beginTask("Store data", 100); 357 358 monitor.worked(40); 359 360 // store data here ... 361 //System.out.println(data); 362 363 Thread.sleep(5.200); 364 monitor.done(); 365 } 366 }); 367 return true; 368 } 369 } 188 370 189 371 void main(){
