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