1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.service.dashboard;
35
36 import fr.paris.lutece.portal.service.i18n.I18nService;
37 import fr.paris.lutece.portal.service.plugin.Plugin;
38 import fr.paris.lutece.portal.service.plugin.PluginService;
39 import fr.paris.lutece.portal.web.l10n.LocaleService;
40 import java.util.Locale;
41
42 import org.apache.commons.lang3.ObjectUtils;
43
44
45
46
47 public abstract class DashboardComponent implements IDashboardComponent
48 {
49 private String _strName;
50 private String _strRight;
51 private int _nZone;
52 private int _nOrder;
53 private Plugin _plugin;
54 private Locale _locale;
55
56
57
58
59
60
61 @Override
62 public String getName( )
63 {
64 return _strName;
65 }
66
67
68
69
70
71
72
73 @Override
74 public void setName( String strName )
75 {
76 _strName = strName;
77 }
78
79
80
81
82
83
84
85
86
87
88
89
90 @Override
91 public String getRight( )
92 {
93 return _strRight;
94 }
95
96
97
98
99
100
101
102 @Override
103 public void setRight( String strRight )
104 {
105 _strRight = strRight;
106 }
107
108
109
110
111
112
113 @Override
114 public int getZone( )
115 {
116 return _nZone;
117 }
118
119
120
121
122
123
124
125 @Override
126 public void setZone( int nZone )
127 {
128 _nZone = nZone;
129 }
130
131
132
133
134
135
136 @Override
137 public int getOrder( )
138 {
139 return _nOrder;
140 }
141
142
143
144
145
146
147
148 @Override
149 public void setOrder( int nOrder )
150 {
151 _nOrder = nOrder;
152 }
153
154
155
156
157
158
159 @Override
160 public Plugin getPlugin( )
161 {
162 return _plugin;
163 }
164
165
166
167
168
169
170
171 @Override
172 public void setPlugin( Plugin plugin )
173 {
174 _plugin = plugin;
175 }
176
177
178
179
180
181
182
183
184 @Override
185 public int compareTo( IDashboardComponent o )
186 {
187 return getOrder( ) - o.getOrder( );
188 }
189
190
191
192
193
194
195 @Override
196 public boolean isEnabled( )
197 {
198 return PluginService.isPluginEnable( _plugin.getName( ) );
199 }
200
201
202
203
204
205 @Override
206 public boolean equals( Object obj )
207 {
208 if ( obj instanceof IDashboardComponent )
209 {
210 IDashboardComponent../../fr/paris/lutece/portal/service/dashboard/IDashboardComponent.html#IDashboardComponent">IDashboardComponent other = (IDashboardComponent) obj;
211
212 return ObjectUtils.equals( this.getName( ), other.getName( ) );
213 }
214
215 return false;
216 }
217
218
219
220
221
222 @Override
223 public int hashCode( )
224 {
225 return ObjectUtils.hashCode( this.getName( ) );
226 }
227
228
229
230
231
232 @Override
233 public String toString( )
234 {
235 return getClass( ).getName( ) + "[name=" + this.getName( ) + ", zone=" + this.getZone( ) + ", order=" + this.getOrder( ) + "]";
236 }
237
238
239
240
241
242 @Override
243 public void setLocale( Locale locale )
244 {
245 _locale = locale;
246 }
247
248 @Override
249 public String getDescription( )
250 {
251 String strKey;
252 Locale locale = ( _locale != null ) ? _locale : LocaleService.getDefault( );
253
254 if ( _plugin == PluginService.getCore( ) )
255 {
256 strKey = "portal.dashboard.dashboardComponent." + _strName + ".description";
257 }
258 else
259 {
260 strKey = _plugin.getName( ) + ".dashboardComponent." + _strName + ".description";
261 }
262 return I18nService.getLocalizedString( strKey, locale );
263 }
264 }