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

The following examples show how to use org.eclipse.jface.dialogs.MessageDialog#CONFIRM . 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: DocumentPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private int openOutlineDialog(final IStructuredSelection selection) {
    final StringBuilder sb = new StringBuilder();
    for (final Object selectionElement : selection.toList()) {
        if (selectionElement instanceof Document) {
            sb.append(((Document) selectionElement).getName() + "\n");
        }
    }
    if (sb.length() > 0) {
        sb.delete(sb.length() - 1, sb.length());
    }
    final String[] buttonList = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
    final java.util.List<Object> selectionList = ((IStructuredSelection) documentListViewer.getSelection()).toList();
    final OutlineDialog dialog = new OutlineDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            removalConfirmationDialogTitle, Display
                    .getCurrent().getSystemImage(SWT.ICON_WARNING),
            NLS.bind(Messages.areYouSureMessage, sb.toString()), MessageDialog.CONFIRM, buttonList,
            1, selectionList);
    return dialog.open();
}
 
Example 2
Source File: FileOverrideConfirmDialog.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
public FileOverrideConfirmDialog(final String filePath) {
    super(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ResourceString.getResourceString("dialog.title.confirm"), null, "'" + filePath + "'" + ResourceString.getResourceString("dialog.message.file.exist"), MessageDialog.CONFIRM, BUTTON_LABELS, 0);
}
 
Example 3
Source File: SaveDirtyEditorAbstractHandler.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * @param event
 * @return true iff the dirty editor has been saved, false otherwise
 */
public boolean saveDirtyEditor(final ExecutionEvent event) {
	activeEditor = UIHelper.getActiveEditor();
	if (activeEditor.isDirty()) {
		getPrefs().setDefault(this.getClass() + ".dontBother", false);
		if (getPrefs().getBoolean(this.getClass() + ".dontBother")) {
			// TODO decouple from ui thread
			// Use NullProgressMonitor instead of newly created monitor. The
			// parent ProgressMonitorDialog would need to be properly
			// initialized first.
			// @see Bug #256 in general/bugzilla/index.html
			//
			// Generally though, saving a resource involves I/O which should be
			// decoupled from the UI thread in the first place. Properly doing
			// this, would be from inside a Job which provides a ProgressMonitor
			activeEditor.doSave(new NullProgressMonitor());
		} else {
			final Shell shell = HandlerUtil.getActiveShell(event);
			final MessageDialog dialog = new SaveMessageDialog(shell, getDialogTitle(), getDialogMessage());
			int res = dialog.open();
			if (res == 2) { // 2 is index of button in string[] below
				// User doesn't want to be warned about a dirty editor any longer.
				// Remember it for this handler (this.getClass).
				getPrefs().setValue(this.getClass() + ".dontBother", true);
				res = MessageDialog.OK;
			}
			if (res == MessageDialog.OK || res == MessageDialog.CONFIRM) {
				// TODO decouple from ui thread
				// Use NullProgressMonitor instead of newly created monitor. The
				// parent ProgressMonitorDialog would need to be properly
				// initialized first.
				// @see Bug #256 in general/bugzilla/index.html
				//
				// Generally though, saving a resource involves I/O which should be
				// decoupled from the UI thread in the first place. Properly doing
				// this, would be from inside a Job which provides a ProgressMonitor
				activeEditor.doSave(new NullProgressMonitor());
			} else {
				return false;
			}
		}
	}
	return true;
}
 
Example 4
Source File: PublishTemplateNavigatorAction.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 */
public void run( IAction action )
{
	IFile file = getSelectedFile( );
	if ( file != null )
	{
		String url = file.getLocation( ).toOSString( );
		try
		{
			ModuleHandle handle = SessionHandleAdapter.getInstance( )
					.getSessionHandle( )
					.openDesign( url );

			if ( handle == null )
			{
				action.setEnabled( false );
				return;
			}

			IEditorPart editor = org.eclipse.birt.report.designer.internal.ui.util.UIUtil.findOpenedEditor( url );

			if ( editor != null && editor.isDirty( ) )
			{
				MessageDialog md = new MessageDialog( UIUtil.getDefaultShell( ),
						Messages.getString( "PublishTemplateAction.SaveBeforeGenerating.dialog.title" ), //$NON-NLS-1$
						null,
						Messages.getFormattedString( "PublishTemplateAction.SaveBeforeGenerating.dialog.message", new Object[]{file.getName( )} ), //$NON-NLS-1$
						MessageDialog.CONFIRM,
						new String[]{
								Messages.getString( "PublishTemplateAction.SaveBeforeGenerating.dialog.button.yes" ), //$NON-NLS-1$
								Messages.getString( "PublishTemplateAction.SaveBeforeGenerating.dialog.button.no" ) //$NON-NLS-1$
						},
						0 );
				switch ( md.open( ) )
				{
					case 0 :
						editor.doSave( null );
						break;
					case 1 :
					default :
				}
			}

			WizardDialog dialog = new BaseWizardDialog( UIUtil.getDefaultShell( ),
					new PublishTemplateWizard( (ReportDesignHandle) handle ) );
			dialog.setPageSize( 500, 250 );
			dialog.open( );

			handle.close( );
		}
		catch ( Exception e )
		{
			ExceptionUtil.handle( e );
			return;
		}
	}
	else
	{
		action.setEnabled( false );
	}
}