Changeset 55

Show
Ignore:
Timestamp:
05/21/09 17:48:07 (4 years ago)
Author:
frasten
Message:

CLOSED - # 32: Usare la classe MessageBox?
 http://my-trac.assembla.com/oberheditor/ticket/32

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/oberheditor/gui/WinMain.java

    r50 r55  
    183183                                if (listScalette.getSelectionCount() <= 0) return; 
    184184                                // Chiedo conferma con un dialogo 
    185                                 final boolean [] conferma = new boolean [1]; 
    186                                 final Shell dialog = new Shell (win, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 
    187                                 FormLayout form = new FormLayout (); 
    188                                 form.marginWidth = form.marginHeight = 8; 
    189                                 dialog.setLayout (form); 
    190  
    191                                 Label label = new Label (dialog, SWT.NONE); 
    192                                 label.setText ("Vuoi davvero eliminare la scaletta selezionata?"); 
     185                                MessageBox boxChiedi = new MessageBox(win, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); 
     186                                boxChiedi.setText("Conferma"); 
     187                                boxChiedi.setMessage("Vuoi davvero eliminare la scaletta selezionata?"); 
    193188                                 
    194                                 Button cancel = new Button (dialog, SWT.PUSH); 
    195                                 cancel.setText("&Annulla"); 
    196                                 cancel.setImage(new Image(display, "res/cancel.png")); 
    197                                 FormData cancelData = new FormData (); 
    198                                 cancelData.top = new FormAttachment(label, 8); 
    199                                 cancelData.right = new FormAttachment(50, -5); 
    200                                 cancel.setLayoutData(cancelData); 
    201                                  
    202                                  
    203                                 final Button ok = new Button(dialog, SWT.PUSH); 
    204                                 dialog.setDefaultButton(ok); // FIXME: non va 
    205                                 ok.setText("&OK"); 
    206                                 ok.setImage(new Image(display, "res/delete.png")); 
    207                                 FormData okData = new FormData(); 
    208                                 okData.left = new FormAttachment(50, 5); 
    209                                 okData.top = new FormAttachment(cancel, 0, SWT.TOP); 
    210                                 ok.setLayoutData(okData); 
    211  
    212                                 Listener listener = new Listener() { 
    213                                         public void handleEvent (Event event) { 
    214                                                 conferma [0] = event.widget == ok; 
    215                                                 dialog.close(); 
    216                                         } 
    217                                 }; 
    218                                  
    219                                 ok.addListener (SWT.Selection, listener); 
    220                                 cancel.addListener (SWT.Selection, listener); 
    221                                  
    222                                  
    223                                 dialog.pack (); 
    224                                 dialog.open (); 
    225                                 while (!dialog.isDisposed ()) { 
    226                                         if (!display.readAndDispatch ()) display.sleep (); 
    227                                 } 
    228  
    229                                 if (!conferma[0]) return; 
     189                                if (boxChiedi.open() != SWT.OK) return; 
    230190                                 
    231191                                int[] selezione = listScalette.getSelectionIndices(); 
     
    329289                                if (listCanzoni.getSelectionCount() <= 0) return; 
    330290                                // Chiedo conferma con un dialogo 
    331                                 final boolean [] conferma = new boolean [1]; 
    332                                 final Shell dialog = new Shell (win, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); 
    333                                 FormLayout form = new FormLayout (); 
    334                                 form.marginWidth = form.marginHeight = 8; 
    335                                 dialog.setLayout (form); 
    336  
    337                                 Label label = new Label (dialog, SWT.NONE); 
    338                                 label.setText ("Vuoi davvero eliminare la canzone selezionata?\nSara` eliminata da tutte le scalette."); 
    339                                  
    340                                 Button cancel = new Button (dialog, SWT.PUSH); 
    341                                 cancel.setText("&Annulla"); 
    342                                 cancel.setImage(new Image(display, "res/cancel.png")); 
    343                                 FormData cancelData = new FormData (); 
    344                                 cancelData.top = new FormAttachment(label, 8); 
    345                                 cancelData.right = new FormAttachment(50, -5); 
    346                                 cancel.setLayoutData(cancelData); 
    347                                  
    348                                  
    349                                 final Button ok = new Button(dialog, SWT.PUSH); 
    350                                 dialog.setDefaultButton(ok); // FIXME: non va 
    351                                 ok.setText("&OK"); 
    352                                 ok.setImage(new Image(display, "res/delete.png")); 
    353                                 FormData okData = new FormData(); 
    354                                 okData.left = new FormAttachment(50, 5); 
    355                                 okData.top = new FormAttachment(cancel, 0, SWT.TOP); 
    356                                 ok.setLayoutData(okData); 
    357  
    358                                 Listener listener = new Listener() { 
    359                                         public void handleEvent (Event event) { 
    360                                                 conferma [0] = event.widget == ok; 
    361                                                 dialog.close(); 
    362                                         } 
    363                                 }; 
    364                                  
    365                                 ok.addListener (SWT.Selection, listener); 
    366                                 cancel.addListener (SWT.Selection, listener); 
    367                                  
    368                                  
    369                                 dialog.pack (); 
    370                                 dialog.open (); 
    371                                 while (!dialog.isDisposed ()) { 
    372                                         if (!display.readAndDispatch ()) display.sleep (); 
    373                                 } 
    374  
    375                                 if (!conferma[0]) return; 
     291                                MessageBox boxChiedi = new MessageBox(win, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL); 
     292                                boxChiedi.setText("Conferma"); 
     293                                boxChiedi.setMessage("Vuoi davvero eliminare la canzone selezionata?\nSara` eliminata da tutte le scalette."); 
     294                                if (boxChiedi.open() != SWT.OK) return; 
    376295                                 
    377296                                int[] selezione = listCanzoni.getSelectionIndices();