|
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 "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 using System; |
|
18 using System.Collections.Generic; |
|
19 using System.Text; |
|
20 using System.IO; |
|
21 using System.Drawing; |
|
22 using SymbianUtils; |
|
23 using SymbianUtils.FileSystem; |
|
24 using SymbianUtils.Settings; |
|
25 using SymbianDebugLib.Engine; |
|
26 using SymbianDebugLib.Entity.Primer; |
|
27 using SymbianDebugLib.PluginAPI; |
|
28 |
|
29 namespace SymbianDebugLib.Entity.Descriptors |
|
30 { |
|
31 public abstract class DbgEntityDescriptor : IComparable<DbgEntityDescriptor> |
|
32 { |
|
33 #region Enumerations |
|
34 public enum TFileSystemBrowserType |
|
35 { |
|
36 EFiles = 0, |
|
37 EDirectories |
|
38 } |
|
39 |
|
40 public enum TUnderlyingType |
|
41 { |
|
42 ETypeUnknown = -1, |
|
43 ETypeSymbols = 0, |
|
44 ETypeCode, |
|
45 ETypeConfigMetaData, |
|
46 ETypeKeyBindings, |
|
47 ETypeTraceDictionaries |
|
48 } |
|
49 #endregion |
|
50 |
|
51 #region Constructors |
|
52 protected DbgEntityDescriptor( DbgEntityDescriptorManager aManager ) |
|
53 { |
|
54 iManager = aManager; |
|
55 } |
|
56 #endregion |
|
57 |
|
58 #region Framework API |
|
59 public abstract DbgEntity Create( FSEntity aEntity ); |
|
60 |
|
61 public abstract DbgEntity Create( XmlSettingCategory aSettingsCategory ); |
|
62 |
|
63 public virtual Image Icon |
|
64 { |
|
65 get { return null; } |
|
66 } |
|
67 |
|
68 public abstract TFileSystemBrowserType FileSystemBrowserType |
|
69 { |
|
70 get; |
|
71 } |
|
72 |
|
73 public abstract string CategoryName |
|
74 { |
|
75 get; |
|
76 } |
|
77 |
|
78 public abstract int DisplayOrder |
|
79 { |
|
80 get; |
|
81 } |
|
82 |
|
83 public virtual FSExtensionList Extensions |
|
84 { |
|
85 get { return new FSExtensionList(); } |
|
86 } |
|
87 |
|
88 public virtual void OnUiModeChanged() |
|
89 { |
|
90 } |
|
91 |
|
92 public virtual TUnderlyingType UnderlyingType |
|
93 { |
|
94 get { return TUnderlyingType.ETypeUnknown; } |
|
95 } |
|
96 |
|
97 public virtual void OnCleared() |
|
98 { |
|
99 } |
|
100 #endregion |
|
101 |
|
102 #region API |
|
103 internal void Prime( DbgEntity aEntity, TSynchronicity aSynchronicity ) |
|
104 { |
|
105 // Make a new result |
|
106 aEntity.PrimerResult = new DbgEntityPrimerResult( aEntity ); |
|
107 |
|
108 // The primer to use |
|
109 IDbgEntityPrimer primer = null; |
|
110 |
|
111 // We can't sensibly prime if we don't have a plugin engine associated with the |
|
112 // entity. |
|
113 DbgPluginEngine plugin = aEntity.PluginEngine; |
|
114 if ( plugin != null ) |
|
115 { |
|
116 // Get primer object |
|
117 switch ( UiMode ) |
|
118 { |
|
119 case TDbgUiMode.EUiDisabled: |
|
120 primer = new DbgEntityPrimerSilent( aEntity, plugin ); |
|
121 break; |
|
122 default: |
|
123 case TDbgUiMode.EUiEnabled: |
|
124 primer = new DbgEntityPrimerUi( aEntity, plugin ); |
|
125 break; |
|
126 } |
|
127 } |
|
128 else |
|
129 { |
|
130 primer = new DbgEntityPrimerNull( aEntity ); |
|
131 Engine.Trace( "WARNING: Entity {0} does not supply plugin engine", aEntity.FullName ); |
|
132 } |
|
133 |
|
134 // Make sure we indicate that we actually atttempted to prime |
|
135 // the entity. |
|
136 aEntity.PrimerResult.PrimeAttempted = true; |
|
137 |
|
138 // And prime away |
|
139 primer.Prime( aSynchronicity ); |
|
140 } |
|
141 #endregion |
|
142 |
|
143 #region Properties |
|
144 public DbgEngine Engine |
|
145 { |
|
146 get { return Manager.Engine; } |
|
147 } |
|
148 |
|
149 public TDbgUiMode UiMode |
|
150 { |
|
151 get { return iManager.UiMode; } |
|
152 } |
|
153 |
|
154 protected DbgEntityDescriptorManager Manager |
|
155 { |
|
156 get { return iManager; } |
|
157 } |
|
158 #endregion |
|
159 |
|
160 #region Internal methods |
|
161 #endregion |
|
162 |
|
163 #region From System.Object |
|
164 public override bool Equals( object aObject ) |
|
165 { |
|
166 if ( aObject != null ) |
|
167 { |
|
168 if ( aObject is DbgEntityDescriptor ) |
|
169 { |
|
170 DbgEntityDescriptor other = (DbgEntityDescriptor) aObject; |
|
171 return other.CategoryName == this.CategoryName; |
|
172 } |
|
173 } |
|
174 // |
|
175 return base.Equals( aObject ); |
|
176 } |
|
177 |
|
178 public override string ToString() |
|
179 { |
|
180 return CategoryName; |
|
181 } |
|
182 |
|
183 public override int GetHashCode() |
|
184 { |
|
185 return CategoryName.GetHashCode(); |
|
186 } |
|
187 #endregion |
|
188 |
|
189 #region From IComparable<DbgEntityDescriptor> |
|
190 public int CompareTo( DbgEntityDescriptor aOther ) |
|
191 { |
|
192 int ret = 1; |
|
193 // |
|
194 if ( aOther != null ) |
|
195 { |
|
196 ret = this.DisplayOrder.CompareTo( aOther.DisplayOrder ); |
|
197 } |
|
198 // |
|
199 return ret; |
|
200 } |
|
201 #endregion |
|
202 |
|
203 #region Data members |
|
204 private readonly DbgEntityDescriptorManager iManager; |
|
205 #endregion |
|
206 } |
|
207 } |