|
1 /* |
|
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Definitions for the class ClearAtoolChanges |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.s60tools.analyzetool.ui.actions; |
|
19 |
|
20 import org.eclipse.core.resources.IProject; |
|
21 import org.eclipse.jface.action.IAction; |
|
22 import org.eclipse.jface.viewers.ISelection; |
|
23 import org.eclipse.jface.viewers.IStructuredSelection; |
|
24 import org.eclipse.ui.IObjectActionDelegate; |
|
25 import org.eclipse.ui.IWorkbenchPart; |
|
26 import org.eclipse.ui.PartInitException; |
|
27 |
|
28 import com.nokia.s60tools.analyzetool.Activator; |
|
29 import com.nokia.s60tools.analyzetool.global.Constants; |
|
30 import com.nokia.s60tools.analyzetool.ui.IActionListener; |
|
31 |
|
32 /** |
|
33 * Class to clear atool.exe made changes. |
|
34 * |
|
35 * @author kihe |
|
36 * |
|
37 */ |
|
38 public class ClearAtoolChanges implements IObjectActionDelegate { |
|
39 |
|
40 /** project reference.*/ |
|
41 public IProject project; |
|
42 |
|
43 /** |
|
44 * Constructor. |
|
45 */ |
|
46 public ClearAtoolChanges() { |
|
47 super(); |
|
48 } |
|
49 |
|
50 /** |
|
51 * Opens the AnalyzeTool view and runs clean action. |
|
52 * |
|
53 * @param action User selected action |
|
54 */ |
|
55 public void run(IAction action) { |
|
56 // open AnalyzeTool window |
|
57 try { |
|
58 Activator.getDefault().getWorkbench().getActiveWorkbenchWindow() |
|
59 .getActivePage().showView(Constants.ANALYZE_TOOL_VIEW_ID, |
|
60 null, org.eclipse.ui.IWorkbenchPage.VIEW_CREATE); |
|
61 } catch (PartInitException pie) { |
|
62 pie.printStackTrace(); |
|
63 } |
|
64 |
|
65 IActionListener listener = Activator.getActionListener(); |
|
66 if (listener != null) { |
|
67 listener.runAction(project, Constants.ACTIONS.RUN_CLEAN); |
|
68 } |
|
69 |
|
70 } |
|
71 |
|
72 /** |
|
73 * Listening selection changed events and stores selected project reference. |
|
74 * |
|
75 * @param action User selected action |
|
76 * |
|
77 * @param selection User selection |
|
78 */ |
|
79 public void selectionChanged(IAction action, ISelection selection) { |
|
80 try { |
|
81 project = (IProject) ((IStructuredSelection) selection) |
|
82 .getFirstElement(); |
|
83 |
|
84 } catch (Exception e) { |
|
85 e.printStackTrace(); |
|
86 } |
|
87 } |
|
88 |
|
89 /** |
|
90 * Sets the active part for the delegate. |
|
91 * |
|
92 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) |
|
93 * |
|
94 * @param action User selected action |
|
95 * |
|
96 * @param targetPart Workbench part |
|
97 */ |
|
98 public void setActivePart(IAction action, IWorkbenchPart targetPart) { |
|
99 // MethodDeclaration/Block[count(BlockStatement) = 0 and |
|
100 // @containsComment = 'false'] |
|
101 } |
|
102 } |