AboutDialogpublic class AboutDialog extends org.eclipse.swt.widgets.Dialog
Fields Summary |
---|
private org.eclipse.swt.graphics.Image | logoImage |
Methods Summary |
---|
private void | createContents(org.eclipse.swt.widgets.Shell shell)
GridLayout layout;
GridData data;
Label label;
shell.setLayout(new GridLayout(2, false));
// Fancy logo
Label logo = new Label(shell, SWT.BORDER);
logo.setImage(logoImage);
// Text Area
Composite textArea = new Composite(shell, SWT.NONE);
layout = new GridLayout(1, true);
textArea.setLayout(layout);
// Text lines
label = new Label(textArea, SWT.NONE);
label.setText("Dalvik Debug Monitor v" + Main.VERSION);
label = new Label(textArea, SWT.NONE);
label.setText("Copyright 2007, The Android Open Source Project");
label = new Label(textArea, SWT.NONE);
label.setText("All Rights Reserved.");
// blank spot in grid
label = new Label(shell, SWT.NONE);
// "OK" button
Button ok = new Button(shell, SWT.PUSH);
ok.setText("OK");
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.widthHint = 80;
ok.setLayoutData(data);
ok.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
shell.close();
}
});
shell.pack();
shell.setDefaultButton(ok);
| private org.eclipse.swt.graphics.Image | loadImage(org.eclipse.swt.widgets.Shell shell, java.lang.String fileName)
InputStream imageStream;
String pathName = "/images/" + fileName; // $NON-NLS-1$
imageStream = this.getClass().getResourceAsStream(pathName);
if (imageStream == null) {
//throw new NullPointerException("couldn't find " + pathName);
Log.w("ddms", "Couldn't load " + pathName);
Display display = shell.getDisplay();
return ImageHelper.createPlaceHolderArt(display, 100, 50,
display.getSystemColor(SWT.COLOR_BLUE));
}
Image img = new Image(shell.getDisplay(), imageStream);
if (img == null)
throw new NullPointerException("couldn't load " + pathName);
return img;
| public void | open()Prepare and display the dialog.
Shell parent = getParent();
Shell shell = new Shell(parent, getStyle());
shell.setText("About...");
logoImage = loadImage(shell, "ddms-logo.png"); // $NON-NLS-1$
createContents(shell);
shell.pack();
shell.open();
Display display = parent.getDisplay();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
logoImage.dispose();
|
|