|
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 * Select all action |
|
17 * |
|
18 */ |
|
19 package com.nokia.traceviewer.action; |
|
20 |
|
21 import java.util.List; |
|
22 |
|
23 import org.eclipse.swt.custom.StyledText; |
|
24 |
|
25 import com.nokia.traceviewer.engine.TraceProperties; |
|
26 import com.nokia.traceviewer.engine.TraceViewerGlobals; |
|
27 import com.nokia.traceviewer.view.listener.SelectionProperties; |
|
28 import com.nokia.traceviewer.view.listener.ViewerSelectionChangedListener; |
|
29 |
|
30 /** |
|
31 * Select all action |
|
32 */ |
|
33 final class SelectAllAction extends TraceViewerAction { |
|
34 |
|
35 /* |
|
36 * (non-Javadoc) |
|
37 * |
|
38 * @see com.nokia.traceviewer.action.TraceViewerAction#doRun() |
|
39 */ |
|
40 @Override |
|
41 protected void doRun() { |
|
42 StyledText widget = TraceViewerGlobals.getTraceViewer().getView() |
|
43 .getViewer().getTextWidget(); |
|
44 |
|
45 int totalTraceCount = TraceViewerGlobals.getTraceViewer() |
|
46 .getDataReaderAccess().getCurrentDataReader().getTraceCount(); |
|
47 |
|
48 // Set selection properties |
|
49 SelectionProperties.firstClickedLine = 0; |
|
50 SelectionProperties.firstClickedLineCaretOffset = 0; |
|
51 SelectionProperties.lastClickedLine = totalTraceCount; |
|
52 |
|
53 // Save current top index |
|
54 int topIndex = widget.getTopIndex(); |
|
55 |
|
56 // Select everything from the current showing text widget |
|
57 int endOffset = widget.getOffsetAtLine(widget.getLineCount() - 1); |
|
58 SelectionProperties.lastClickedLineCaretOffset = 0; |
|
59 widget.setSelection(0, endOffset); |
|
60 |
|
61 // Return old top index |
|
62 widget.setTopIndex(topIndex); |
|
63 |
|
64 // Get first trace |
|
65 List<TraceProperties> firstTraceArr = TraceViewerGlobals |
|
66 .getTraceViewer().getTraces(0, 0); |
|
67 if (!firstTraceArr.isEmpty()) { |
|
68 TraceProperties firstTrace = firstTraceArr.get(0); |
|
69 |
|
70 // Process timestamp |
|
71 TraceViewerGlobals.getTraceViewer().getDataProcessorAccess() |
|
72 .getTimestampParser().processData(firstTrace); |
|
73 |
|
74 if (firstTrace.timestampString != null) { |
|
75 SelectionProperties.firstClickedTimestamp = firstTrace.timestampString; |
|
76 } |
|
77 |
|
78 } |
|
79 |
|
80 // Get last trace |
|
81 List<TraceProperties> lastTraceArr = TraceViewerGlobals |
|
82 .getTraceViewer().getTraces(totalTraceCount - 1, |
|
83 totalTraceCount - 1); |
|
84 if (!lastTraceArr.isEmpty()) { |
|
85 TraceProperties lastTrace = lastTraceArr.get(0); |
|
86 |
|
87 // Process timestamp |
|
88 TraceViewerGlobals.getTraceViewer().getDataProcessorAccess() |
|
89 .getTimestampParser().processData(lastTrace); |
|
90 |
|
91 if (lastTrace.timestampString != null) { |
|
92 SelectionProperties.lastClickedTimestamp = lastTrace.timestampString; |
|
93 } |
|
94 |
|
95 } |
|
96 ViewerSelectionChangedListener.handleTrimInformationUpdate(); |
|
97 } |
|
98 } |