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.ide.eclipse.hierarchyviewer.views;
18 
19 import com.android.hierarchyviewerlib.actions.LoadOverlayAction;
20 import com.android.hierarchyviewerlib.actions.RefreshPixelPerfectAction;
21 import com.android.hierarchyviewerlib.actions.SavePixelPerfectAction;
22 import com.android.hierarchyviewerlib.ui.PixelPerfect;
23 
24 import org.eclipse.jface.action.IMenuManager;
25 import org.eclipse.jface.action.IToolBarManager;
26 import org.eclipse.swt.layout.FillLayout;
27 import org.eclipse.swt.widgets.Composite;
28 import org.eclipse.ui.IActionBars;
29 import org.eclipse.ui.part.ViewPart;
30 
31 public class PixelPerfectView extends ViewPart {
32 
33     public static final String ID =
34             "com.android.ide.eclipse.hierarchyviewer.views.PixelPerfectView"; //$NON-NLS-1$
35 
36     private PixelPerfect mPixelPerfect;
37 
38     @Override
createPartControl(Composite parent)39     public void createPartControl(Composite parent) {
40         parent.setLayout(new FillLayout());
41         mPixelPerfect = new PixelPerfect(parent);
42 
43         placeActions();
44     }
45 
placeActions()46     private void placeActions() {
47         IActionBars actionBars = getViewSite().getActionBars();
48 
49         IMenuManager mm = actionBars.getMenuManager();
50         mm.removeAll();
51         mm.add(SavePixelPerfectAction.getAction(getSite().getShell()));
52         mm.add(RefreshPixelPerfectAction.getAction());
53         mm.add(LoadOverlayAction.getAction(getSite().getShell()));
54 
55         IToolBarManager tm = actionBars.getToolBarManager();
56         tm.removeAll();
57         tm.add(SavePixelPerfectAction.getAction(getSite().getShell()));
58         tm.add(RefreshPixelPerfectAction.getAction());
59         tm.add(LoadOverlayAction.getAction(getSite().getShell()));
60     }
61 
62     @Override
setFocus()63     public void setFocus() {
64         mPixelPerfect.setFocus();
65     }
66 
67 }
68