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