Java Code Examples for org.eclipse.jface.dialogs.MessageDialog#QUESTION_WITH_CANCEL

The following examples show how to use org.eclipse.jface.dialogs.MessageDialog#QUESTION_WITH_CANCEL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Question.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
/** Must be called in the UI thread. */
public static int askWithCancel(String title, String message) {
	String[] labels = new String[] { IDialogConstants.YES_LABEL,
			IDialogConstants.NO_LABEL,
			IDialogConstants.CANCEL_LABEL };
	MessageDialog dialog = new MessageDialog(
			UI.shell(), title, null, message,
			MessageDialog.QUESTION_WITH_CANCEL, labels, 0);
	int result = dialog.open();
	if (result == 0)
		return IDialogConstants.YES_ID;
	if (result == 1)
		return IDialogConstants.NO_ID;
	if (result == 2)
		return IDialogConstants.CANCEL_ID;
	return IDialogConstants.CANCEL_ID;
}
 
Example 2
Source File: ConfirmationDialogFuture.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private Boolean showDialog ( final ConfirmationCallback cb, final Display display, final Shell parentShell, final String dialogTitle )
{
    switch ( cb.getConfirmationType () )
    {
        case CONFIRM:
            return MessageDialog.openConfirm ( parentShell, dialogTitle, cb.getLabel () ) ? true : null;
        case ERROR:
            MessageDialog.openError ( parentShell, dialogTitle, cb.getLabel () );
            return true;
        case WARNING:
            MessageDialog.openWarning ( parentShell, dialogTitle, cb.getLabel () );
            return true;
        case INFORMATION:
            MessageDialog.openInformation ( parentShell, dialogTitle, cb.getLabel () );
            return true;
        case QUESTION:
            return MessageDialog.openQuestion ( parentShell, dialogTitle, cb.getLabel () );
        case QUESTION_WITH_CANCEL:
        {
            final MessageDialog dialog = new MessageDialog ( parentShell, dialogTitle, null, cb.getLabel (), MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0 );
            final int result = dialog.open ();
            if ( result == 2 /*CANCEL*/)
            {
                return null;
            }
            else
            {
                return result == Window.OK;
            }
        }
        default:
            throw new IllegalArgumentException ( String.format ( "Unable to process type: %s", cb.getConfirmationType () ) );
    }
}
 
Example 3
Source File: PyDialogHelpers.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @return the index chosen or -1 if it was canceled.
 */
public static int openQuestionWithChoices(String title, String message, String... choices) {
    Shell shell = EditorUtils.getShell();
    MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION_WITH_CANCEL,
            choices, 0);
    return dialog.open();
}
 
Example 4
Source File: LibraryFileChangeResolve.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public boolean reload( ModuleHandle owner )
{
	if ( owner.needsSave( ) )
	{
		MessageDialog md = new MessageDialog( UIUtil.getDefaultShell( ),
				Messages.getString( "MultiPageReportEditor.ConfirmVersion.Dialog.Title" ), //$NON-NLS-1$
				null,
				Messages.getString( "MultiPageReportEditor.ConfirmVersion.Dialog.SaveAndReloadMessage" ), //$NON-NLS-1$
				MessageDialog.QUESTION_WITH_CANCEL,
				new String[]{
						Messages.getString( "MultiPageReportEditor.SaveButton" ), //$NON-NLS-1$
						//Messages.getString( "MultiPageReportEditor.DiscardButton" ), //$NON-NLS-1$
						Messages.getString( "MultiPageReportEditor.CancelButton" ) //$NON-NLS-1$
				},
				0 );

		switch ( md.open( ) )
		{
			case 0 :
				try
				{
					owner.save( );
				}
				catch ( IOException e )
				{
					logger.log( Level.SEVERE, e.getMessage( ), e );
				}
				UIUtil.reloadModuleHandleLibraries( owner );
				return true;
				// case 1 :
				// UIUtil.reloadModuleHandleLibraries( owner );
				// return true;
			default :
				return false;
		}
	}
	else if ( MessageDialog.openConfirm( UIUtil.getDefaultShell( ),
			Messages.getString( "MultiPageReportEditor.ConfirmVersion.Dialog.Title" ), Messages.getString( "MultiPageReportEditor.ConfirmVersion.Dialog.ReloadMessage" ) ) ) //$NON-NLS-1$ //$NON-NLS-2$ 
	{
		UIUtil.reloadModuleHandleLibraries( owner );
		return true;
	}
	return false;
}