LoadAllViewsAction.java revision 99bd6912e7b5b97fc6d4bb787e76b2d9dfffd7ae
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 17package com.android.hierarchyviewer.actions; 18 19import com.android.ddmuilib.ImageLoader; 20import com.android.hierarchyviewerlib.HierarchyViewerDirector; 21import com.android.hierarchyviewerlib.actions.ImageAction; 22import com.android.hierarchyviewerlib.actions.TreeViewEnabledAction; 23 24import org.eclipse.jface.resource.ImageDescriptor; 25import org.eclipse.swt.SWT; 26import org.eclipse.swt.graphics.Image; 27import org.eclipse.swt.widgets.Display; 28 29public class LoadAllViewsAction extends TreeViewEnabledAction implements ImageAction { 30 31 private static LoadAllViewsAction action; 32 33 private Image image; 34 35 private LoadAllViewsAction() { 36 super("Load All &Views"); 37 setAccelerator(SWT.MOD1 + 'V'); 38 ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class); 39 image = imageLoader.loadImage("load-all-views.png", Display.getDefault()); 40 setImageDescriptor(ImageDescriptor.createFromImage(image)); 41 setToolTipText("Load all view images"); 42 } 43 44 public static LoadAllViewsAction getAction() { 45 if (action == null) { 46 action = new LoadAllViewsAction(); 47 } 48 return action; 49 } 50 51 @Override 52 public void run() { 53 HierarchyViewerDirector.getDirector().loadAllViews(); 54 } 55 56 public Image getImage() { 57 return image; 58 } 59} 60