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