<commit_before>package org.eclipse.swt.messageBox;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;

import com.xored.q7.quality.mockups.issues.BaseMockupPart;

public class MessageBoxTest extends BaseMockupPart {

	public Control construct(Composite parent) {
		final Composite composite = new Composite(parent, SWT.NONE);
		GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
				.grab(true, true).applyTo(composite);
		GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);

		final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

		Button button = new Button(composite, SWT.PUSH);
		button.setText("Simple Message Box Without Title");
		button.setBounds(2, 30, 100, 30);

		button.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_INFORMATION | SWT.OK);
				mb.setMessage("This MessageBox with simple text");
				mb.open();

			}
		});

		Button button2 = new Button(composite, SWT.PUSH);
		button2.setText("Message With Question");
		button2.setLocation(50, 50);
		button2.setBounds(80, 2, 300, 20);

		final Text t = new Text(composite, SWT.BORDER | SWT.NONE | SWT.MULTI);
		t.setText("Example text");
		t.setBounds(80, 2, 300, 20);

		button2.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
				mb.setText("Question");
				mb.setMessage("This MessageBox with question");
				int response = mb.open();
				if (response == SWT.OK)
					t.setText("Press OK");
				if (response == SWT.CANCEL)
					t.setText("Press Cancel");
			}

		});

		Button button3 = new Button(composite, SWT.PUSH);
		button3.setText("Message Box with RETRY Button");
		button3.setLocation(50, 50);
		button3.setBounds(80, 2, 300, 20);

		button3.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_ERROR | SWT.ABORT | SWT.RETRY | SWT.IGNORE);
				mb.setText("Error");
				mb.setMessage("This MessageBox with error");
				int response = mb.open();
				if (response == SWT.ABORT)
					t.setText("Press ABORT");
				if (response == SWT.RETRY)
					t.setText("Press RETRY");
				if (response == SWT.IGNORE)
					t.setText("Press IGNORE");
			}

		});

		Button button4 = new Button(composite, SWT.PUSH);
		button4.setText("Message Box with YES/NO Buttons");
		button4.setBounds(80, 2, 300, 20);

		button4.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_WARNING | SWT.YES | SWT.NO);
				mb.setText("Warning");
				mb.setMessage("This MessageBox with warning");
				int response = mb.open();
				if (response == SWT.YES)
					t.setText("Press YES");
				if (response == SWT.NO)
					t.setText("Press NO");
			}

		});

		return null;

	}

}<commit_msg>Add a message box from background thread to reproduce bug 483457.<commit_after>package org.eclipse.swt.messageBox;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;

import com.xored.q7.quality.mockups.issues.BaseMockupPart;

public class MessageBoxTest extends BaseMockupPart {

	@Override
	public Control construct(Composite parent) {
		final Composite composite = new Composite(parent, SWT.NONE);
		GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
				.grab(true, true).applyTo(composite);
		GridLayoutFactory.swtDefaults().numColumns(2).applyTo(composite);

		final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();

		Button button = new Button(composite, SWT.PUSH);
		button.setText("Simple Message Box Without Title");
		button.setBounds(2, 30, 100, 30);

		button.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_INFORMATION | SWT.OK);
				mb.setMessage("This MessageBox with simple text");
				mb.open();

			}
		});

		Button button2 = new Button(composite, SWT.PUSH);
		button2.setText("Message With Question");
		button2.setLocation(50, 50);
		button2.setBounds(80, 2, 300, 20);

		final Text t = new Text(composite, SWT.BORDER | SWT.NONE | SWT.MULTI);
		t.setText("Example text");
		t.setBounds(80, 2, 300, 20);

		button2.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
				mb.setText("Question");
				mb.setMessage("This MessageBox with question");
				int response = mb.open();
				if (response == SWT.OK)
					t.setText("Press OK");
				if (response == SWT.CANCEL)
					t.setText("Press Cancel");
			}

		});

		Button button3 = new Button(composite, SWT.PUSH);
		button3.setText("Message Box with RETRY Button");
		button3.setLocation(50, 50);
		button3.setBounds(80, 2, 300, 20);

		button3.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_ERROR | SWT.ABORT | SWT.RETRY | SWT.IGNORE);
				mb.setText("Error");
				mb.setMessage("This MessageBox with error");
				int response = mb.open();
				if (response == SWT.ABORT)
					t.setText("Press ABORT");
				if (response == SWT.RETRY)
					t.setText("Press RETRY");
				if (response == SWT.IGNORE)
					t.setText("Press IGNORE");
			}

		});

		Button button4 = new Button(composite, SWT.PUSH);
		button4.setText("Message Box with YES/NO Buttons");
		button4.setBounds(80, 2, 300, 20);

		button4.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_WARNING | SWT.YES | SWT.NO);
				mb.setText("Warning");
				mb.setMessage("This MessageBox with warning");
				int response = mb.open();
				if (response == SWT.YES)
					t.setText("Press YES");
				if (response == SWT.NO)
					t.setText("Press NO");
			}

		});

		Button button5 = new Button(composite, SWT.PUSH);
		button5.setText("Delayed message from background thread");
		button5.setBounds(80, 2, 300, 20);

		final Display display = Display.getCurrent();
		button5.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				new Thread(new Runnable() {
					@Override
					public void run() {
						try {
							Thread.sleep(2000);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
						display.asyncExec(new Runnable() {
							@Override
							public void run() {
								MessageBox mb = new MessageBox(shell, SWT.NONE | SWT.ICON_WARNING | SWT.YES | SWT.NO);
								mb.setText("Warning");
								mb.setMessage("Will you press the \"No\" button?");
								int response = mb.open();
								if (response == SWT.YES)
									t.setText("Press YES");
								if (response == SWT.NO)
									t.setText("Press NO");
							}
						});
					}
				}).start();
			}

		});

		return null;

	}

}
{'fraction_non_alphanumeric': 0.13295580450572447, 'fraction_numerical': 0.0184660839591284, 'mean_word_length': 3.8675853804673457, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3114739', 'n_tokens_mistral': 3225, 'n_tokens_neox': 2615, 'n_words': 584}