|
1 /* |
|
2 * Copyright (c) 2007-2010 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: |
|
15 * |
|
16 * Handler for deactivating line count rule command |
|
17 * |
|
18 */ |
|
19 package com.nokia.traceviewer.action; |
|
20 |
|
21 import java.net.URL; |
|
22 import java.util.List; |
|
23 |
|
24 import org.eclipse.jface.resource.ImageDescriptor; |
|
25 import org.eclipse.swt.widgets.Table; |
|
26 import org.eclipse.ui.PlatformUI; |
|
27 |
|
28 import com.nokia.traceviewer.TraceViewerHelpContextIDs; |
|
29 import com.nokia.traceviewer.TraceViewerPlugin; |
|
30 import com.nokia.traceviewer.dialog.treeitem.LineCountTreeComponentItem; |
|
31 import com.nokia.traceviewer.dialog.treeitem.LineCountTreeTextItem; |
|
32 import com.nokia.traceviewer.engine.TraceViewerGlobals; |
|
33 import com.nokia.traceviewer.engine.dataprocessor.LineCountItem; |
|
34 |
|
35 /** |
|
36 * Handler for deactivating line count rule command |
|
37 */ |
|
38 public final class DeactivateLineCountRuleAction extends TraceViewerAction { |
|
39 |
|
40 /** |
|
41 * Image for this Action |
|
42 */ |
|
43 private static ImageDescriptor image; |
|
44 |
|
45 /** |
|
46 * Item index in TracePropertyView to be deactivated |
|
47 */ |
|
48 private int itemIndex; |
|
49 |
|
50 /** |
|
51 * Line counting table |
|
52 */ |
|
53 private final Table lineCountingTable; |
|
54 |
|
55 static { |
|
56 URL url = null; |
|
57 url = TraceViewerPlugin.getDefault().getBundle().getEntry( |
|
58 "/icons/count.gif"); //$NON-NLS-1$ |
|
59 image = ImageDescriptor.createFromURL(url); |
|
60 } |
|
61 |
|
62 /** |
|
63 * Constructor |
|
64 * |
|
65 * @param itemIndex |
|
66 * item index to be edited |
|
67 * @param lineCountingTable |
|
68 */ |
|
69 public DeactivateLineCountRuleAction(int itemIndex, Table lineCountingTable) { |
|
70 setText(Messages |
|
71 .getString("DeactivateLineCountRuleAction.DeactivateRuleText")); //$NON-NLS-1$ |
|
72 setToolTipText(Messages |
|
73 .getString("DeactivateLineCountRuleAction.DeactivateRuleToolTip")); //$NON-NLS-1$ |
|
74 setImageDescriptor(image); |
|
75 |
|
76 this.itemIndex = itemIndex; |
|
77 this.lineCountingTable = lineCountingTable; |
|
78 |
|
79 // Set help |
|
80 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, |
|
81 TraceViewerHelpContextIDs.ACTIONS); |
|
82 } |
|
83 |
|
84 /* |
|
85 * (non-Javadoc) |
|
86 * |
|
87 * @see com.nokia.traceviewer.action.TraceViewerAction#doRun() |
|
88 */ |
|
89 @Override |
|
90 protected void doRun() { |
|
91 // Remove the item from the property view items |
|
92 List<LineCountItem> items = TraceViewerGlobals.getTraceViewer() |
|
93 .getDataProcessorAccess().getLineCountProcessor() |
|
94 .getLineCountItems(); |
|
95 items.remove(itemIndex); |
|
96 |
|
97 // Remove from the actual table |
|
98 lineCountingTable.remove(itemIndex); |
|
99 |
|
100 // Get rule arrays |
|
101 List<LineCountTreeTextItem> textRules = TraceViewerGlobals |
|
102 .getTraceViewer().getDataProcessorAccess() |
|
103 .getLineCountProcessor().getTextRules(); |
|
104 List<LineCountTreeComponentItem> componentRules = TraceViewerGlobals |
|
105 .getTraceViewer().getDataProcessorAccess() |
|
106 .getLineCountProcessor().getComponentRules(); |
|
107 |
|
108 // Remove from the rule lists |
|
109 if (itemIndex < componentRules.size()) { |
|
110 componentRules.remove(itemIndex); |
|
111 } else { |
|
112 itemIndex -= componentRules.size(); |
|
113 textRules.remove(itemIndex); |
|
114 } |
|
115 } |
|
116 } |