public
TextViewerWindow(
String sTitleID, String sMessageID, String sText, boolean modal )
{
final Display display = SWTThread.getInstance().getDisplay();
if ( modal ){
shell = org.gudy.azureus2.ui.swt.components.shell.ShellFactory.createShell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE );
}else{
shell = ShellFactory.createMainShell(SWT.DIALOG_TRIM | SWT.RESIZE );
}
if (sTitleID != null) shell.setText(MessageText.keyExists(sTitleID)?MessageText.getString(sTitleID):sTitleID);
Utils.setShellIcon(shell);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
shell.setLayout(layout);
Label label = new Label(shell, SWT.NONE);
if (sMessageID != null) label.setText(MessageText.keyExists(sMessageID)?MessageText.getString(sMessageID):sMessageID);
GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
gridData.widthHint = 200;
gridData.horizontalSpan = 2;
label.setLayoutData(gridData);
txtInfo = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
gridData = new GridData( GridData.FILL_BOTH );
gridData.widthHint = 500;
gridData.heightHint = 400;
gridData.horizontalSpan = 2;
txtInfo.setLayoutData(gridData);
txtInfo.setText(sText);
label = new Label(shell, SWT.NONE);
gridData = new GridData( GridData.FILL_HORIZONTAL );
label.setLayoutData(gridData);
Button ok = new Button(shell, 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 {
shell.dispose();
}
catch (Exception e) {
Debug.printStackTrace( e );
}
}
});
shell.addListener(SWT.Traverse, new Listener() {
public void handleEvent(Event e) {
if ( e.character == SWT.ESC){
shell.dispose();
}
}
});
shell.addDisposeListener(
new DisposeListener()
{
public void
widgetDisposed(
DisposeEvent arg0)
{
for ( TextViewerWindowListener l: listeners ){
l.closed();
}
}
});
shell.pack();
Utils.centreWindow( shell );
shell.open();
if ( modal ){
while (!shell.isDisposed())
if (!display.readAndDispatch()) display.sleep();
}
}