• 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.hierarchyviewerlib.actions;
18 
19 import com.android.ddmuilib.ImageLoader;
20 import com.android.hierarchyviewerlib.HierarchyViewerDirector;
21 
22 import org.eclipse.jface.resource.ImageDescriptor;
23 import org.eclipse.swt.SWT;
24 import org.eclipse.swt.graphics.Image;
25 import org.eclipse.swt.widgets.Display;
26 import org.eclipse.swt.widgets.Shell;
27 
28 public class LoadOverlayAction extends PixelPerfectEnabledAction implements ImageAction {
29 
30     private static LoadOverlayAction sAction;
31 
32     private Image mImage;
33 
34     private Shell mShell;
35 
LoadOverlayAction(Shell shell)36     private LoadOverlayAction(Shell shell) {
37         super("Load &Overlay");
38         this.mShell = shell;
39         setAccelerator(SWT.MOD1 + 'O');
40         ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
41         mImage = imageLoader.loadImage("load-overlay.png", Display.getDefault()); //$NON-NLS-1$
42         setImageDescriptor(ImageDescriptor.createFromImage(mImage));
43         setToolTipText("Load an image to overlay the screenshot");
44     }
45 
getAction(Shell shell)46     public static LoadOverlayAction getAction(Shell shell) {
47         if (sAction == null) {
48             sAction = new LoadOverlayAction(shell);
49         }
50         return sAction;
51     }
52 
53     @Override
run()54     public void run() {
55         HierarchyViewerDirector.getDirector().loadOverlay(mShell);
56     }
57 
58     @Override
getImage()59     public Image getImage() {
60         return mImage;
61     }
62 }
63