InputShellpublic class InputShell extends Object
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.String | getTextValue()
return textValue;
| public boolean | isCanceled()
return bIsCanceled;
| public boolean | isMultiLine()
return bMultiLine;
| public static void | main(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.String | open()
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 void | setLabelParameters(java.lang.String[] p1)
this.p1 = p1;
| public void | setMultiLine(boolean multiLine)
bMultiLine = multiLine;
| public void | setTextValue(java.lang.String textValue)
this.textValue = textValue;
|
|