|
1 /* |
|
2 * Copyright (c) 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 the License "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 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.internal.pi.visual; |
|
19 |
|
20 import java.io.Serializable; |
|
21 import java.util.Enumeration; |
|
22 import java.util.Hashtable; |
|
23 import java.util.Vector; |
|
24 |
|
25 import org.eclipse.swt.graphics.Color; |
|
26 import org.eclipse.swt.graphics.Rectangle; |
|
27 |
|
28 import com.nokia.carbide.cpp.internal.pi.model.ProfiledThread; |
|
29 |
|
30 |
|
31 public class AnalyserVisualState implements Serializable |
|
32 { |
|
33 private static final long serialVersionUID = -826324357879880731L; |
|
34 |
|
35 private Hashtable<Integer,Color> colorInfo; |
|
36 private Hashtable<Integer,Boolean> selectedInfo; |
|
37 private int selectionStart; |
|
38 private int selectionEnd; |
|
39 private double zoomFactor; |
|
40 private transient Rectangle viewRect1; |
|
41 |
|
42 public AnalyserVisualState(Enumeration threads, PICompositePanel bcp) |
|
43 { |
|
44 colorInfo = new Hashtable<Integer,Color>(); |
|
45 selectedInfo = new Hashtable<Integer,Boolean>(); |
|
46 while (threads.hasMoreElements()) |
|
47 { |
|
48 ProfiledThread pt = (ProfiledThread) threads.nextElement(); |
|
49 colorInfo.put(new Integer(pt.getThreadId()), pt.getColor()); |
|
50 // Could instead find pt.isEnabled() for all pages - not just page 0 |
|
51 selectedInfo.put(new Integer(pt.getThreadId()), Boolean.valueOf(pt.isEnabled(0))); |
|
52 } |
|
53 |
|
54 selectionStart = (int) bcp.getSelectionStart(); |
|
55 selectionEnd = (int) bcp.getSelectionEnd(); |
|
56 viewRect1 = bcp.getSashForm().getBounds(); |
|
57 zoomFactor = bcp.getScale(); |
|
58 } |
|
59 |
|
60 public Enumeration<ProfiledThread> resetThreadState(Enumeration<ProfiledThread> threads) |
|
61 { |
|
62 Vector<ProfiledThread> v = new Vector<ProfiledThread>(); |
|
63 Enumeration<ProfiledThread> temp = threads; |
|
64 while (threads.hasMoreElements()) |
|
65 { |
|
66 Object o = threads.nextElement(); |
|
67 if (o instanceof ProfiledThread) |
|
68 { |
|
69 ProfiledThread pt = (ProfiledThread) o; |
|
70 Color c = (Color)colorInfo.get(new Integer(pt.getThreadId())); |
|
71 Boolean b = (Boolean)selectedInfo.get(new Integer(pt.getThreadId())); |
|
72 if ((c != null) && (b != null)) |
|
73 { |
|
74 pt.setColor(c); |
|
75 pt.setEnabled(0, b.booleanValue()); |
|
76 v.addElement(pt); |
|
77 } |
|
78 else |
|
79 { |
|
80 System.out.println(Messages.getString("AnalyserVisualState.noThreadInfo")); //$NON-NLS-1$ |
|
81 return temp; |
|
82 } |
|
83 } |
|
84 } |
|
85 return v.elements(); |
|
86 } |
|
87 |
|
88 public int getSelectionEnd() |
|
89 { |
|
90 return selectionEnd; |
|
91 } |
|
92 |
|
93 public int getSelectionStart() |
|
94 { |
|
95 return selectionStart; |
|
96 } |
|
97 |
|
98 public double getZoomFactor() |
|
99 { |
|
100 return zoomFactor; |
|
101 } |
|
102 |
|
103 public Rectangle getViewRect() |
|
104 { |
|
105 return viewRect1; |
|
106 } |
|
107 } |