public int show( String fileName ) { XulMessageBox msgBox = null; try { msgBox = runXulChangedWarningDialog( fileName ); if ( fileName != null ) { msgBox.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.PromptToSave.Fail.Message.WithParam", fileName ) ); //$NON-NLS-1$ } else { msgBox.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.PromptToSave.Fail.Message" ) ); //$NON-NLS-1$ } msgBox.setButtons( new Integer[] { SWT.YES | SWT.NO } ); } catch ( Exception e ) { e.printStackTrace(); throw new RuntimeException( e ); } int retVal = msgBox.open(); // Map from this question to make sense in the original context // (Yes = save, No = no-save , Cancel = do not disconnect) if ( retVal == SWT.YES ) { return SWT.NO; } else { return SWT.CANCEL; } } } );
public int showPromptMessage( final String message, final String title, Object[] buttons ) { try { final XulMessageBox msg = (XulMessageBox) document.createElement( "messagebox" ); msg.setModalParent( modalParent ); msg.setTitle( title ); msg.setMessage( message ); msg.setButtons( buttons ); return msg.open(); } catch ( XulException e ) { log.logError( "Error displaying message: {0}", message ); } return -1; }
protected XulMessageBox runXulChangedWarningDialog( String fileName ) throws IllegalArgumentException, XulException { container = Spoon.getInstance().getMainSpoonContainer(); XulMessageBox messageBox = (XulMessageBox) container.getDocumentRoot().createElement( "messagebox" ); messageBox.setTitle( BaseMessages.getString( PKG, "Spoon.Dialog.PromptSave.Title" ) ); if ( fileName != null ) { messageBox.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.PromptToSave.Message", fileName ) ); } else { messageBox.setMessage( BaseMessages.getString( PKG, "Spoon.Dialog.PromptSave.Message" ) ); } messageBox.setButtons( new Integer[] { SWT.YES, SWT.NO, SWT.CANCEL } ); return messageBox; } }