FileDocCategorySizeDatePackage
InputShell.javaAPI DocAzureus 3.0.3.45702Mon Nov 13 15:34:12 GMT 2006org.gudy.azureus2.ui.swt.shells

InputShell

public class InputShell extends Object
author
TuxPaper

Fields Summary
private String
sTitleKey
private String[]
p0
private String
sLabelKey
private String[]
p1
private String
textValue
private boolean
bMultiLine
private boolean
bIsCanceled
Constructors Summary
public InputShell(String sTitleKey, String sLabelKey)

		this(sTitleKey, null, sLabelKey, null, false);
	
public InputShell(String sTitleKey, String sLabelKey, boolean bMultiLine)

		this(sTitleKey, null, sLabelKey, null, bMultiLine);
	
public InputShell(String sTitleKey, String[] p0, String sLabelKey, String[] p1)

		this(sTitleKey, p0, sLabelKey, p1, false);
	
public InputShell(String sTitleKey, String[] p0, String sLabelKey, String[] p1, boolean bMultiLine)

		this.sTitleKey = sTitleKey;
		this.p0 = p0;
		this.sLabelKey = sLabelKey;
		this.p1 = p1;
		this.bMultiLine = bMultiLine;
		this.bIsCanceled = true;

		this.setTextValue("");
	
Methods Summary
public java.lang.StringgetTextValue()

return
Returns the textValue.

		return textValue;
	
public booleanisCanceled()

		return bIsCanceled;
	
public booleanisMultiLine()

		return bMultiLine;
	
public static voidmain(java.lang.String[] args)

		try {
			new Display();
			SWTThread.createInstance(null);
			InputShell shell = new InputShell("MyTorrentsView.dialog.setSpeed.title",
					new String[] { "111111111111"
					}, "MyTorrentsView.dialog.setNumber.text", new String[] {
						"222222",
						"3333333333"
					});
			shell.open();
		} catch (SWTThreadAlreadyInstanciatedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
public java.lang.Stringopen()

		final Display display = SWTThread.getInstance().getDisplay();
		if (display == null)
			return null;

		final Shell shell = ShellFactory.createShell(display.getActiveShell(),
				SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);
		Messages.setLanguageText(shell, sTitleKey, p0);
		Utils.setShellIcon(shell);

		GridLayout layout = new GridLayout();
		shell.setLayout(layout);

		Label label = new Label(shell, SWT.WRAP);
		Messages.setLanguageText(label, sLabelKey, p1);
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
		label.setLayoutData(gridData);

		int style = SWT.BORDER;
		if (bMultiLine) {
			style |= SWT.MULTI;
		}
		final Text text = new Text(shell, style);
		gridData = new GridData(GridData.FILL_HORIZONTAL);
		gridData.widthHint = 300;
		if (bMultiLine) {
			gridData.heightHint = 100;
		}
		text.setLayoutData(gridData);
		text.setText(textValue);
		text.selectAll();

		Composite panel = new Composite(shell, SWT.NULL);
		layout = new GridLayout();
		layout.numColumns = 3;
		panel.setLayout(layout);
		gridData = new GridData(GridData.FILL_HORIZONTAL);
		gridData.horizontalSpan = 2;
		gridData.horizontalAlignment = SWT.CENTER;
		gridData.verticalAlignment = SWT.BOTTOM;
		panel.setLayoutData(gridData);
		Button ok = new Button(panel, SWT.PUSH);
		ok.setText(MessageText.getString("Button.ok"));
		gridData = new GridData();
		gridData.widthHint = 70;
		ok.setLayoutData(gridData);
		shell.setDefaultButton(ok);
		ok.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event event) {
				try {
					setTextValue(text.getText());
					bIsCanceled = false;
					shell.dispose();
				} catch (Exception e) {
					Debug.printStackTrace(e);
				}
			}
		});

		Button cancel = new Button(panel, SWT.PUSH);
		cancel.setText(MessageText.getString("Button.cancel"));
		gridData = new GridData();
		gridData.widthHint = 70;
		cancel.setLayoutData(gridData);
		cancel.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event event) {
				shell.dispose();
			}
		});

		shell.pack();
		Utils.centreWindow(shell);
		Utils.createURLDropTarget(shell, text);
		setTextValue(null);
		shell.open();

		while (!shell.isDisposed())
			if (!display.readAndDispatch())
				display.sleep();

		return getTextValue();
	
public voidsetLabelParameters(java.lang.String[] p1)

		this.p1 = p1;
	
public voidsetMultiLine(boolean multiLine)

		bMultiLine = multiLine;
	
public voidsetTextValue(java.lang.String textValue)

param
textValue The textValue to set.

		this.textValue = textValue;