FileDocCategorySizeDatePackage
AboutDialog.javaAPI DocAndroid 1.5 API4620Wed May 06 22:41:08 BST 2009com.android.ddms

AboutDialog

public class AboutDialog extends org.eclipse.swt.widgets.Dialog
Our "about" box.

Fields Summary
private org.eclipse.swt.graphics.Image
logoImage
Constructors Summary
public AboutDialog(org.eclipse.swt.widgets.Shell parent)
Create with default style.

        this(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    
public AboutDialog(org.eclipse.swt.widgets.Shell parent, int style)
Create with app-defined style.

        super(parent, style);
    
Methods Summary
private voidcreateContents(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.ImageloadImage(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 voidopen()
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();