Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
c8422608 | 2 | * Copyright (c) 2005, 2012 IBM Corporation, Ericsson |
73005152 BH |
3 | * All rights reserved. This program and the accompanying materials |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
a55887ca AM |
7 | * |
8 | * Contributors: | |
c8422608 AM |
9 | * IBM - Initial API and implementation |
10 | * Bernd Hufmann - Updated for TMF | |
73005152 | 11 | **********************************************************************/ |
c8422608 | 12 | |
73005152 BH |
13 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences; |
14 | ||
e6ace8bb | 15 | import java.util.Arrays; |
73005152 | 16 | import java.util.Hashtable; |
eb63f5ff | 17 | import java.util.Map; |
73005152 BH |
18 | |
19 | import org.eclipse.jface.preference.IPreferenceStore; | |
20 | import org.eclipse.jface.preference.PreferenceConverter; | |
21 | import org.eclipse.jface.util.IPropertyChangeListener; | |
22 | import org.eclipse.jface.util.PropertyChangeEvent; | |
8fd82db5 | 23 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; |
73005152 BH |
24 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IColor; |
25 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.IFont; | |
73005152 BH |
26 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl.ColorImpl; |
27 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.impl.FontImpl; | |
28 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages; | |
29 | import org.eclipse.swt.SWT; | |
30 | import org.eclipse.swt.graphics.Color; | |
31 | import org.eclipse.swt.graphics.FontData; | |
32 | import org.eclipse.swt.graphics.RGB; | |
33 | import org.eclipse.swt.widgets.Display; | |
34 | ||
35 | /** | |
df0b8ff4 BH |
36 | * This is the Sequence Diagram preference handler. This class is responsible for accessing the current user preferences |
37 | * selection This class also provider getters for each modifiable preferences. | |
a55887ca | 38 | * |
df0b8ff4 | 39 | * @version 1.0 |
73005152 BH |
40 | * @author sveyrier |
41 | */ | |
42 | public class SDViewPref implements ISDPreferences, IPropertyChangeListener { | |
43 | ||
df0b8ff4 BH |
44 | // ------------------------------------------------------------------------ |
45 | // Constants | |
46 | // ------------------------------------------------------------------------ | |
47 | /** | |
a55887ca | 48 | * Postfix string for background color property |
df0b8ff4 | 49 | */ |
73005152 | 50 | public static final String BACK_COLOR_POSTFIX = "_BACK_COLOR";//$NON-NLS-1$ |
df0b8ff4 | 51 | /** |
a55887ca | 52 | * Postfix string for foreground color property |
df0b8ff4 | 53 | */ |
73005152 | 54 | public static final String FORE_COLOR_POSTFIX = "_FORE_COLOR";//$NON-NLS-1$ |
df0b8ff4 | 55 | /** |
a55887ca | 56 | * Postfix string for text color property |
df0b8ff4 | 57 | */ |
73005152 | 58 | public static final String TEXT_COLOR_POSTFIX = "_TEXT_COLOR";//$NON-NLS-1$ |
df0b8ff4 BH |
59 | /** |
60 | * Array of preference names | |
61 | */ | |
eb63f5ff | 62 | private static final String[] FONT_LIST = { PREF_LIFELINE, PREF_EXEC, PREF_SYNC_MESS, PREF_SYNC_MESS_RET, PREF_ASYNC_MESS, PREF_ASYNC_MESS_RET, PREF_FRAME, PREF_LIFELINE_HEADER, PREF_FRAME_NAME }; |
df0b8ff4 BH |
63 | /** |
64 | * A 2nd array of preference names | |
65 | */ | |
eb63f5ff | 66 | private static final String[] FONT_LIST2 = { SDMessages._88, SDMessages._89, SDMessages._90, SDMessages._91, SDMessages._92, SDMessages._93, SDMessages._94, SDMessages._95, SDMessages._96 }; |
df0b8ff4 BH |
67 | /** |
68 | * Array of background color preference names | |
69 | */ | |
eb63f5ff | 70 | private static final String[] PREF_BACK_COLOR_LIST = { PREF_LIFELINE, PREF_EXEC, PREF_FRAME, PREF_LIFELINE_HEADER, PREF_FRAME_NAME }; |
df0b8ff4 BH |
71 | /** |
72 | * Array of foreground color preference names | |
73 | */ | |
eb63f5ff | 74 | private static final String[] PREF_FORE_COLOR_LIST = { PREF_LIFELINE, PREF_EXEC, PREF_SYNC_MESS, PREF_SYNC_MESS_RET, PREF_ASYNC_MESS, PREF_ASYNC_MESS_RET, PREF_FRAME, PREF_LIFELINE_HEADER, PREF_FRAME_NAME }; |
df0b8ff4 BH |
75 | /** |
76 | * Array of text color preference names | |
77 | */ | |
eb63f5ff | 78 | private static final String[] PREF_TEXT_COLOR_LIST = { PREF_LIFELINE, PREF_SYNC_MESS, PREF_SYNC_MESS_RET, PREF_ASYNC_MESS, PREF_ASYNC_MESS_RET, PREF_LIFELINE_HEADER, PREF_FRAME_NAME }; |
df0b8ff4 | 79 | /** |
a55887ca | 80 | * Temporary tag |
df0b8ff4 BH |
81 | */ |
82 | protected static final String TEMP_TAG = "_TEMP";//$NON-NLS-1$ | |
83 | ||
84 | // ------------------------------------------------------------------------ | |
85 | // Attributes | |
86 | // ------------------------------------------------------------------------ | |
73005152 | 87 | |
df0b8ff4 BH |
88 | /** |
89 | * The sequence diagram preferences singleton instance | |
90 | */ | |
eb63f5ff | 91 | private static SDViewPref fHandle = null; |
df0b8ff4 | 92 | /** |
a55887ca | 93 | * Hashtable for font preferences |
df0b8ff4 | 94 | */ |
eb63f5ff | 95 | protected Map<String, IFont> fFontPref; |
df0b8ff4 | 96 | /** |
a55887ca | 97 | * Hashtable for foreground color preferences |
df0b8ff4 | 98 | */ |
eb63f5ff | 99 | protected Map<String, IColor> fForeColorPref; |
df0b8ff4 | 100 | /** |
a55887ca | 101 | * Hashtable for background color preferences |
df0b8ff4 | 102 | */ |
eb63f5ff | 103 | protected Map<String, IColor> fBackColorPref; |
df0b8ff4 | 104 | /** |
a55887ca | 105 | * Hashtable for text color preferences |
df0b8ff4 | 106 | */ |
eb63f5ff | 107 | protected Map<String, IColor> fTextColorPref; |
df0b8ff4 BH |
108 | /** |
109 | * The reference to the preference store. | |
110 | */ | |
eb63f5ff | 111 | protected IPreferenceStore fPrefStore = null; |
df0b8ff4 BH |
112 | /** |
113 | * Color for the time compression selection | |
114 | */ | |
eb63f5ff | 115 | protected IColor fTimeCompressionSelectionColor = null; |
df0b8ff4 BH |
116 | /** |
117 | * Flag whether no focus selection or not. | |
118 | */ | |
eb63f5ff | 119 | protected boolean fNoFocusSelection = false; |
73005152 | 120 | |
df0b8ff4 BH |
121 | // ------------------------------------------------------------------------ |
122 | // Constructors | |
123 | // ------------------------------------------------------------------------ | |
a55887ca | 124 | |
73005152 BH |
125 | /** |
126 | * Builds the Sequence Diagram preference handler: - Define the preference default values. - Load the currently used | |
127 | * preferences setting | |
73005152 BH |
128 | */ |
129 | protected SDViewPref() { | |
8fd82db5 | 130 | fPrefStore = Activator.getDefault().getPreferenceStore(); |
73005152 | 131 | |
eb63f5ff BH |
132 | fPrefStore.setDefault(PREF_LINK_FONT, true); |
133 | fPrefStore.setDefault(PREF_EXCLUDE_EXTERNAL_TIME, true); | |
134 | fPrefStore.setDefault(PREF_LIFELINE_WIDTH, 200); | |
135 | fPrefStore.setDefault(PREF_USE_GRADIENT, true); | |
136 | fPrefStore.setDefault(PREF_TOOLTIP, true); | |
73005152 | 137 | |
eb63f5ff BH |
138 | fFontPref = new Hashtable<String, IFont>(); |
139 | fForeColorPref = new Hashtable<String, IColor>(); | |
140 | fBackColorPref = new Hashtable<String, IColor>(); | |
141 | fTextColorPref = new Hashtable<String, IColor>(); | |
73005152 | 142 | |
eb63f5ff BH |
143 | for (int i = 0; i < FONT_LIST.length; i++) { |
144 | if (FONT_LIST[i].equals(PREF_FRAME_NAME)) { | |
73005152 BH |
145 | FontData[] data = Display.getDefault().getSystemFont().getFontData(); |
146 | data[0].setStyle(SWT.BOLD); | |
eb63f5ff BH |
147 | PreferenceConverter.setDefault(fPrefStore, FONT_LIST[i], data[0]); |
148 | PreferenceConverter.setDefault(fPrefStore, FONT_LIST[i] + TEMP_TAG, data[0]); | |
73005152 | 149 | } else { |
eb63f5ff BH |
150 | PreferenceConverter.setDefault(fPrefStore, FONT_LIST[i], Display.getDefault().getSystemFont().getFontData()); |
151 | PreferenceConverter.setDefault(fPrefStore, FONT_LIST[i] + TEMP_TAG, Display.getDefault().getSystemFont().getFontData()); | |
73005152 BH |
152 | } |
153 | } | |
154 | ||
eb63f5ff | 155 | for (int i = 0; i < PREF_BACK_COLOR_LIST.length; i++) { |
73005152 | 156 | IColor color; |
eb63f5ff | 157 | if ((PREF_BACK_COLOR_LIST[i].equals(PREF_EXEC)) || PREF_BACK_COLOR_LIST[i].equals(PREF_FRAME_NAME)) { |
73005152 | 158 | color = new ColorImpl(Display.getDefault(), 201, 222, 233); |
eb63f5ff | 159 | } else if (PREF_BACK_COLOR_LIST[i].equals(PREF_LIFELINE)) { |
73005152 | 160 | color = new ColorImpl(Display.getDefault(), 220, 220, 220); |
eb63f5ff | 161 | } else if (PREF_BACK_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) { |
73005152 | 162 | color = new ColorImpl(Display.getDefault(), 245, 244, 244); |
df0b8ff4 | 163 | } else { |
73005152 | 164 | color = new ColorImpl(Display.getDefault(), 255, 255, 255); |
df0b8ff4 | 165 | } |
eb63f5ff BH |
166 | PreferenceConverter.setDefault(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX, ((Color) color.getColor()).getRGB()); |
167 | PreferenceConverter.setDefault(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB()); | |
73005152 BH |
168 | color.dispose(); |
169 | } | |
170 | ||
eb63f5ff | 171 | for (int i = 0; i < PREF_FORE_COLOR_LIST.length; i++) { |
73005152 | 172 | IColor color; |
eb63f5ff | 173 | if (PREF_FORE_COLOR_LIST[i].equals(PREF_LIFELINE)) { |
73005152 | 174 | color = new ColorImpl(Display.getDefault(), 129, 129, 129); |
eb63f5ff | 175 | } else if (PREF_FORE_COLOR_LIST[i].equals(PREF_FRAME_NAME)) { |
73005152 | 176 | color = new ColorImpl(Display.getDefault(), 81, 153, 200); |
eb63f5ff | 177 | } else if (PREF_FORE_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) { |
73005152 | 178 | color = new ColorImpl(Display.getDefault(), 129, 127, 137); |
df0b8ff4 | 179 | } else { |
73005152 | 180 | color = new ColorImpl(Display.getDefault(), 134, 176, 212); |
df0b8ff4 | 181 | } |
eb63f5ff BH |
182 | PreferenceConverter.setDefault(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX, ((Color) color.getColor()).getRGB()); |
183 | PreferenceConverter.setDefault(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB()); | |
73005152 BH |
184 | color.dispose(); |
185 | } | |
186 | ||
eb63f5ff | 187 | for (int i = 0; i < PREF_TEXT_COLOR_LIST.length; i++) { |
73005152 | 188 | IColor color; |
eb63f5ff | 189 | if (PREF_TEXT_COLOR_LIST[i].equals(PREF_LIFELINE)) { |
73005152 | 190 | color = new ColorImpl(Display.getDefault(), 129, 129, 129); |
eb63f5ff | 191 | } else if (PREF_TEXT_COLOR_LIST[i].equals(PREF_FRAME_NAME)) { |
73005152 | 192 | color = new ColorImpl(Display.getDefault(), 0, 0, 0); |
eb63f5ff | 193 | } else if (PREF_TEXT_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) { |
73005152 | 194 | color = new ColorImpl(Display.getDefault(), 129, 127, 137); |
df0b8ff4 | 195 | } else { |
73005152 | 196 | color = new ColorImpl(Display.getDefault(), 134, 176, 212); |
df0b8ff4 | 197 | } |
eb63f5ff BH |
198 | PreferenceConverter.setDefault(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX, ((Color) color.getColor()).getRGB()); |
199 | PreferenceConverter.setDefault(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB()); | |
73005152 BH |
200 | color.dispose(); |
201 | } | |
202 | ||
203 | IColor color = new ColorImpl(Display.getDefault(), 218, 232, 238); | |
eb63f5ff | 204 | PreferenceConverter.setDefault(fPrefStore, PREF_TIME_COMP, ((Color) color.getColor()).getRGB()); |
73005152 BH |
205 | color.dispose(); |
206 | ||
207 | buildFontsAndColors(); | |
208 | ||
eb63f5ff | 209 | fPrefStore.addPropertyChangeListener(this); |
73005152 BH |
210 | } |
211 | ||
212 | /** | |
213 | * Returns the PreferenceStore | |
a55887ca | 214 | * |
73005152 BH |
215 | * @return the PreferenceStore |
216 | */ | |
217 | public IPreferenceStore getPreferenceStore() { | |
eb63f5ff | 218 | return fPrefStore; |
73005152 BH |
219 | } |
220 | ||
221 | /** | |
222 | * Apply the preferences in the preferences handler | |
223 | */ | |
224 | public void apply() { | |
225 | buildFontsAndColors(); | |
eb63f5ff | 226 | fPrefStore.firePropertyChangeEvent("PREFOK", null, null); //$NON-NLS-1$ |
73005152 BH |
227 | } |
228 | ||
229 | /** | |
230 | * Returns an unique instance of the Sequence Diagram preference handler | |
a55887ca | 231 | * |
73005152 BH |
232 | * @return the preference handler instance |
233 | */ | |
df0b8ff4 | 234 | public static synchronized SDViewPref getInstance() { |
eb63f5ff BH |
235 | if (fHandle == null) { |
236 | fHandle = new SDViewPref(); | |
df0b8ff4 | 237 | } |
eb63f5ff | 238 | return fHandle; |
73005152 BH |
239 | } |
240 | ||
df0b8ff4 BH |
241 | /* |
242 | * (non-Javadoc) | |
243 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getForeGroundColor(java.lang.String) | |
73005152 BH |
244 | */ |
245 | @Override | |
246 | public IColor getForeGroundColor(String prefName) { | |
eb63f5ff | 247 | if ((fForeColorPref.get(prefName + FORE_COLOR_POSTFIX) != null) && (fForeColorPref.get(prefName + FORE_COLOR_POSTFIX) instanceof ColorImpl)) { |
abbdd66a | 248 | return fForeColorPref.get(prefName + FORE_COLOR_POSTFIX); |
df0b8ff4 BH |
249 | } |
250 | return ColorImpl.getSystemColor(SWT.COLOR_BLACK); | |
73005152 BH |
251 | } |
252 | ||
df0b8ff4 BH |
253 | /* |
254 | * (non-Javadoc) | |
255 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getBackGroundColor(java.lang.String) | |
73005152 BH |
256 | */ |
257 | @Override | |
258 | public IColor getBackGroundColor(String prefName) { | |
eb63f5ff | 259 | if ((fBackColorPref.get(prefName + BACK_COLOR_POSTFIX) != null) && (fBackColorPref.get(prefName + BACK_COLOR_POSTFIX) instanceof ColorImpl)) { |
abbdd66a | 260 | return fBackColorPref.get(prefName + BACK_COLOR_POSTFIX); |
df0b8ff4 BH |
261 | } |
262 | return ColorImpl.getSystemColor(SWT.COLOR_WHITE); | |
73005152 BH |
263 | } |
264 | ||
df0b8ff4 BH |
265 | /* |
266 | * (non-Javadoc) | |
267 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getFontColor(java.lang.String) | |
73005152 BH |
268 | */ |
269 | @Override | |
270 | public IColor getFontColor(String prefName) { | |
eb63f5ff | 271 | if ((fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX) != null) && (fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX) instanceof ColorImpl)) { |
abbdd66a | 272 | return fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX); |
df0b8ff4 BH |
273 | } |
274 | return ColorImpl.getSystemColor(SWT.COLOR_BLACK); | |
73005152 BH |
275 | } |
276 | ||
df0b8ff4 BH |
277 | /* |
278 | * (non-Javadoc) | |
279 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getForeGroundColorSelection() | |
73005152 BH |
280 | */ |
281 | @Override | |
282 | public IColor getForeGroundColorSelection() { | |
eb63f5ff | 283 | if (fNoFocusSelection) { |
73005152 | 284 | return ColorImpl.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND); |
df0b8ff4 | 285 | } |
73005152 BH |
286 | return ColorImpl.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT); |
287 | } | |
288 | ||
df0b8ff4 BH |
289 | /* |
290 | * (non-Javadoc) | |
291 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getBackGroundColorSelection() | |
73005152 BH |
292 | */ |
293 | @Override | |
294 | public IColor getBackGroundColorSelection() { | |
eb63f5ff | 295 | if (fNoFocusSelection) { |
73005152 | 296 | return ColorImpl.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); |
df0b8ff4 | 297 | } |
73005152 BH |
298 | return ColorImpl.getSystemColor(SWT.COLOR_LIST_SELECTION); |
299 | } | |
300 | ||
df0b8ff4 BH |
301 | /* |
302 | * (non-Javadoc) | |
303 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getFont(java.lang.String) | |
73005152 BH |
304 | */ |
305 | @Override | |
306 | public IFont getFont(String prefName) { | |
abbdd66a AM |
307 | if (fFontPref.get(prefName) != null) { |
308 | return fFontPref.get(prefName); | |
df0b8ff4 BH |
309 | } |
310 | return FontImpl.getSystemFont(); | |
73005152 BH |
311 | } |
312 | ||
313 | /** | |
314 | * Returns the SwimLane width chosen | |
a55887ca | 315 | * |
73005152 BH |
316 | * @return the SwimLane width |
317 | */ | |
318 | public int getLifelineWidth() { | |
eb63f5ff | 319 | return fPrefStore.getInt(PREF_LIFELINE_WIDTH); |
73005152 BH |
320 | } |
321 | ||
322 | /** | |
323 | * Returns if font linkage with zoom has been chosen | |
a55887ca | 324 | * |
73005152 BH |
325 | * @return true if checked false otherwise |
326 | */ | |
327 | public boolean fontLinked() { | |
eb63f5ff | 328 | return fPrefStore.getBoolean(PREF_LINK_FONT); |
73005152 BH |
329 | } |
330 | ||
331 | /** | |
332 | * Returns the tooltip enablement | |
a55887ca | 333 | * |
73005152 BH |
334 | * @return true if checked false otherwise |
335 | */ | |
336 | public boolean tooltipEnabled() { | |
eb63f5ff | 337 | return fPrefStore.getBoolean(PREF_TOOLTIP); |
73005152 BH |
338 | } |
339 | ||
340 | /** | |
341 | * Return true if the user do not want to take external time (basically found and lost messages with time) into | |
342 | * account in the min max computation | |
a55887ca | 343 | * |
73005152 BH |
344 | * @return true if checked false otherwise |
345 | */ | |
346 | public boolean excludeExternalTime() { | |
eb63f5ff | 347 | return fPrefStore.getBoolean(PREF_EXCLUDE_EXTERNAL_TIME); |
73005152 BH |
348 | } |
349 | ||
df0b8ff4 BH |
350 | /* |
351 | * (non-Javadoc) | |
352 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#useGradienColor() | |
73005152 BH |
353 | */ |
354 | @Override | |
355 | public boolean useGradienColor() { | |
eb63f5ff | 356 | return fPrefStore.getBoolean(PREF_USE_GRADIENT); |
73005152 BH |
357 | } |
358 | ||
df0b8ff4 BH |
359 | /* |
360 | * (non-Javadoc) | |
361 | * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.drawings.ISDPreferences#getTimeCompressionSelectionColor() | |
73005152 BH |
362 | */ |
363 | @Override | |
364 | public IColor getTimeCompressionSelectionColor() { | |
eb63f5ff | 365 | return fTimeCompressionSelectionColor; |
73005152 BH |
366 | } |
367 | ||
368 | /** | |
369 | * Builds the new colors and fonts according the current user selection when the OK or Apply button is clicked | |
73005152 | 370 | */ |
eb63f5ff | 371 | private void buildFontsAndColors() { |
73005152 BH |
372 | |
373 | Display display = Display.getDefault(); | |
374 | ||
eb63f5ff BH |
375 | for (int i = 0; i < FONT_LIST.length; i++) { |
376 | FontData fontData = PreferenceConverter.getFontData(fPrefStore, FONT_LIST[i]); | |
abbdd66a AM |
377 | if (fFontPref.get(FONT_LIST[i]) != null) { |
378 | fFontPref.get(FONT_LIST[i]).dispose(); | |
df0b8ff4 | 379 | } |
eb63f5ff | 380 | fFontPref.put(FONT_LIST[i], new FontImpl(display, fontData)); |
73005152 BH |
381 | } |
382 | ||
eb63f5ff BH |
383 | for (int i = 0; i < PREF_BACK_COLOR_LIST.length; i++) { |
384 | RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX); | |
abbdd66a AM |
385 | if (fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) != null) { |
386 | fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX).dispose(); | |
df0b8ff4 | 387 | } |
eb63f5ff | 388 | fBackColorPref.put(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue)); |
73005152 BH |
389 | } |
390 | ||
eb63f5ff BH |
391 | for (int i = 0; i < PREF_FORE_COLOR_LIST.length; i++) { |
392 | RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX); | |
abbdd66a AM |
393 | if (fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) != null) { |
394 | fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX).dispose(); | |
df0b8ff4 | 395 | } |
eb63f5ff | 396 | fForeColorPref.put(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue)); |
73005152 BH |
397 | } |
398 | ||
eb63f5ff BH |
399 | for (int i = 0; i < PREF_TEXT_COLOR_LIST.length; i++) { |
400 | RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX); | |
abbdd66a AM |
401 | if (fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) != null) { |
402 | fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX).dispose(); | |
df0b8ff4 | 403 | } |
eb63f5ff | 404 | fTextColorPref.put(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue)); |
73005152 BH |
405 | } |
406 | ||
eb63f5ff BH |
407 | RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_TIME_COMP); |
408 | if (fTimeCompressionSelectionColor != null) { | |
409 | fTimeCompressionSelectionColor.dispose(); | |
df0b8ff4 | 410 | } |
eb63f5ff | 411 | fTimeCompressionSelectionColor = new ColorImpl(display, rgb.red, rgb.green, rgb.blue); |
73005152 BH |
412 | } |
413 | ||
a55887ca AM |
414 | /** |
415 | * Add a property-change listener | |
416 | * | |
417 | * @param listener | |
418 | * The listener to add | |
419 | */ | |
73005152 | 420 | public void addPropertyChangeListener(IPropertyChangeListener listener) { |
eb63f5ff | 421 | fPrefStore.addPropertyChangeListener(listener); |
73005152 BH |
422 | } |
423 | ||
a55887ca AM |
424 | /** |
425 | * Remove a property-change listener | |
426 | * | |
427 | * @param listener | |
428 | * The listerner to remove | |
429 | */ | |
73005152 | 430 | public void removePropertyChangeListener(IPropertyChangeListener listener) { |
eb63f5ff | 431 | fPrefStore.removePropertyChangeListener(listener); |
73005152 BH |
432 | } |
433 | ||
434 | /* | |
435 | * (non-Javadoc) | |
436 | * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) | |
437 | */ | |
438 | @Override | |
439 | public void propertyChange(PropertyChangeEvent event) { | |
df0b8ff4 | 440 | if (!event.getProperty().equals("PREFOK")) { //$NON-NLS-1$ |
73005152 | 441 | buildFontsAndColors(); |
a55887ca | 442 | fPrefStore.firePropertyChangeEvent("PREFOK", null, null); //$NON-NLS-1$ |
73005152 BH |
443 | } |
444 | } | |
445 | ||
a55887ca AM |
446 | /** |
447 | * Set the "no focus selection" preference | |
448 | * | |
449 | * @param v | |
450 | * New value to use | |
451 | */ | |
73005152 | 452 | public void setNoFocusSelection(boolean v) { |
eb63f5ff | 453 | fNoFocusSelection = v; |
73005152 | 454 | } |
e6ace8bb BH |
455 | |
456 | /** | |
df0b8ff4 | 457 | * Returns the static font list. |
a55887ca | 458 | * |
e6ace8bb BH |
459 | * @return static font list |
460 | */ | |
461 | public static String[] getFontList() { | |
eb63f5ff | 462 | return Arrays.copyOf(FONT_LIST, FONT_LIST.length); |
e6ace8bb | 463 | } |
a55887ca | 464 | |
e6ace8bb | 465 | /** |
df0b8ff4 | 466 | * Returns the 2nd static font list. |
a55887ca | 467 | * |
e6ace8bb BH |
468 | * @return 2nd static font list |
469 | */ | |
470 | public static String[] getFontList2() { | |
eb63f5ff | 471 | return Arrays.copyOf(FONT_LIST2, FONT_LIST2.length); |
e6ace8bb | 472 | } |
a55887ca | 473 | |
e6ace8bb | 474 | /** |
df0b8ff4 | 475 | * Returns the preference background color list. |
a55887ca | 476 | * |
e6ace8bb BH |
477 | * @return preference background color list |
478 | */ | |
479 | public static String[] getPrefBackColorList() { | |
eb63f5ff | 480 | return Arrays.copyOf(PREF_BACK_COLOR_LIST, PREF_BACK_COLOR_LIST.length); |
e6ace8bb | 481 | } |
a55887ca | 482 | |
e6ace8bb | 483 | /** |
df0b8ff4 | 484 | * Returns the preference foreground color list. |
a55887ca | 485 | * |
e6ace8bb BH |
486 | * @return preference foreground color list |
487 | */ | |
488 | public static String[] getPrefForeColorList() { | |
eb63f5ff | 489 | return Arrays.copyOf(PREF_FORE_COLOR_LIST, PREF_FORE_COLOR_LIST.length); |
e6ace8bb | 490 | } |
a55887ca | 491 | |
e6ace8bb | 492 | /** |
df0b8ff4 | 493 | * Returns the preference text color list color list. |
a55887ca | 494 | * |
e6ace8bb BH |
495 | * @return preference text color list color list |
496 | */ | |
497 | public static String[] getPrefTextColorList() { | |
eb63f5ff | 498 | return Arrays.copyOf(PREF_TEXT_COLOR_LIST, PREF_TEXT_COLOR_LIST.length); |
e6ace8bb | 499 | } |
73005152 | 500 | } |