• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.hierarchyviewer;
18 
19 import com.android.ddmuilib.ImageLoader;
20 import com.android.hierarchyviewerlib.HierarchyViewerDirector;
21 
22 import org.eclipse.jface.dialogs.Dialog;
23 import org.eclipse.jface.dialogs.IDialogConstants;
24 import org.eclipse.swt.SWT;
25 import org.eclipse.swt.custom.CLabel;
26 import org.eclipse.swt.graphics.Image;
27 import org.eclipse.swt.layout.FillLayout;
28 import org.eclipse.swt.layout.GridData;
29 import org.eclipse.swt.layout.GridLayout;
30 import org.eclipse.swt.widgets.Composite;
31 import org.eclipse.swt.widgets.Control;
32 import org.eclipse.swt.widgets.Display;
33 import org.eclipse.swt.widgets.Label;
34 import org.eclipse.swt.widgets.Shell;
35 
36 public class AboutDialog extends Dialog {
37     private Image mAboutImage;
38 
39     private Image mSmallImage;
40 
AboutDialog(Shell shell)41     public AboutDialog(Shell shell) {
42         super(shell);
43         ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
44         mSmallImage = imageLoader.loadImage("sdk-hierarchyviewer-16.png", Display.getDefault()); //$NON-NLS-1$
45         mAboutImage = imageLoader.loadImage("sdk-hierarchyviewer-128.png", Display.getDefault()); //$NON-NLS-1$
46     }
47 
48     @Override
createButtonsForButtonBar(Composite parent)49     protected void createButtonsForButtonBar(Composite parent) {
50         createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
51     }
52 
53     @Override
createDialogArea(Composite parent)54     protected Control createDialogArea(Composite parent) {
55         Composite control = new Composite(parent, SWT.NONE);
56         control.setLayout(new GridLayout(2, true));
57         Composite imageControl = new Composite(control, SWT.BORDER);
58         imageControl.setLayout(new FillLayout());
59         imageControl.setLayoutData(new GridData(GridData.FILL_VERTICAL));
60         Label imageLabel = new Label(imageControl, SWT.CENTER);
61         imageLabel.setImage(mAboutImage);
62 
63         CLabel textLabel = new CLabel(control, SWT.NONE);
64         textLabel
65                 .setText("Hierarchy Viewer\nCopyright 2010, The Android Open Source Project\nAll Rights Reserved.");
66         textLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, true));
67         getShell().setText("About...");
68         getShell().setImage(mSmallImage);
69         return control;
70 
71     }
72 }
73