Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
11252342 | 2 | * Copyright (c) 2005, 2013 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; |
cab6c8ff | 16 | import java.util.Collections; |
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; | |
92330441 | 29 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.Messages; |
73005152 BH |
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 | */ | |
92330441 | 67 | private static final String[] FONT_LIST2 = { Messages.SequenceDiagram_Lifeline, Messages.SequenceDiagram_ExecutionOccurrence, Messages.SequenceDiagram_SyncMessage, Messages.SequenceDiagram_SyncMessageReturn, Messages.SequenceDiagram_AsyncMessage, Messages.SequenceDiagram_AsyncMessageReturn, Messages.SequenceDiagram_Frame, Messages.SequenceDiagram_LifelineHeader, Messages.SequenceDiagram_FrameTitle }; |
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 |
cab6c8ff | 82 | * @since 2.0 |
df0b8ff4 | 83 | */ |
cab6c8ff | 84 | public static final String TEMP_TAG = "_TEMP";//$NON-NLS-1$ |
df0b8ff4 BH |
85 | |
86 | // ------------------------------------------------------------------------ | |
87 | // Attributes | |
88 | // ------------------------------------------------------------------------ | |
73005152 | 89 | |
df0b8ff4 BH |
90 | /** |
91 | * The sequence diagram preferences singleton instance | |
92 | */ | |
eb63f5ff | 93 | private static SDViewPref fHandle = null; |
df0b8ff4 | 94 | /** |
a55887ca | 95 | * Hashtable for font preferences |
df0b8ff4 | 96 | */ |
cab6c8ff BH |
97 | private Map<String, IFont> fFontPref; |
98 | ||
df0b8ff4 | 99 | /** |
a55887ca | 100 | * Hashtable for foreground color preferences |
df0b8ff4 | 101 | */ |
cab6c8ff | 102 | private Map<String, IColor> fForeColorPref; |
df0b8ff4 | 103 | /** |
a55887ca | 104 | * Hashtable for background color preferences |
df0b8ff4 | 105 | */ |
cab6c8ff | 106 | private Map<String, IColor> fBackColorPref; |
df0b8ff4 | 107 | /** |
a55887ca | 108 | * Hashtable for text color preferences |
df0b8ff4 | 109 | */ |
cab6c8ff | 110 | private Map<String, IColor> fTextColorPref; |
df0b8ff4 BH |
111 | /** |
112 | * The reference to the preference store. | |
113 | */ | |
cab6c8ff | 114 | private IPreferenceStore fPrefStore = null; |
df0b8ff4 BH |
115 | /** |
116 | * Color for the time compression selection | |
117 | */ | |
cab6c8ff | 118 | private IColor fTimeCompressionSelectionColor = null; |
df0b8ff4 BH |
119 | /** |
120 | * Flag whether no focus selection or not. | |
121 | */ | |
cab6c8ff | 122 | private boolean fNoFocusSelection = false; |
73005152 | 123 | |
df0b8ff4 BH |
124 | // ------------------------------------------------------------------------ |
125 | // Constructors | |
126 | // ------------------------------------------------------------------------ | |
a55887ca | 127 | |
73005152 BH |
128 | /** |
129 | * Builds the Sequence Diagram preference handler: - Define the preference default values. - Load the currently used | |
130 | * preferences setting | |
73005152 BH |
131 | */ |
132 | protected SDViewPref() { | |
8fd82db5 | 133 | fPrefStore = Activator.getDefault().getPreferenceStore(); |
73005152 | 134 | |
eb63f5ff BH |
135 | fPrefStore.setDefault(PREF_LINK_FONT, true); |
136 | fPrefStore.setDefault(PREF_EXCLUDE_EXTERNAL_TIME, true); | |
137 | fPrefStore.setDefault(PREF_LIFELINE_WIDTH, 200); | |
138 | fPrefStore.setDefault(PREF_USE_GRADIENT, true); | |
139 | fPrefStore.setDefault(PREF_TOOLTIP, true); | |
73005152 | 140 | |
507b1336 AM |
141 | fFontPref = new Hashtable<>(); |
142 | fForeColorPref = new Hashtable<>(); | |
143 | fBackColorPref = new Hashtable<>(); | |
144 | fTextColorPref = new Hashtable<>(); | |
73005152 | 145 | |
eb63f5ff BH |
146 | for (int i = 0; i < FONT_LIST.length; i++) { |
147 | if (FONT_LIST[i].equals(PREF_FRAME_NAME)) { | |
73005152 BH |
148 | FontData[] data = Display.getDefault().getSystemFont().getFontData(); |
149 | data[0].setStyle(SWT.BOLD); | |
eb63f5ff BH |
150 | PreferenceConverter.setDefault(fPrefStore, FONT_LIST[i], data[0]); |
151 | PreferenceConverter.setDefault(fPrefStore, FONT_LIST[i] + TEMP_TAG, data[0]); | |
73005152 | 152 | } else { |
eb63f5ff BH |
153 | PreferenceConverter.setDefault(fPrefStore, FONT_LIST[i], Display.getDefault().getSystemFont().getFontData()); |
154 | PreferenceConverter.setDefault(fPrefStore, FONT_LIST[i] + TEMP_TAG, Display.getDefault().getSystemFont().getFontData()); | |
73005152 BH |
155 | } |
156 | } | |
157 | ||
eb63f5ff | 158 | for (int i = 0; i < PREF_BACK_COLOR_LIST.length; i++) { |
73005152 | 159 | IColor color; |
eb63f5ff | 160 | if ((PREF_BACK_COLOR_LIST[i].equals(PREF_EXEC)) || PREF_BACK_COLOR_LIST[i].equals(PREF_FRAME_NAME)) { |
73005152 | 161 | color = new ColorImpl(Display.getDefault(), 201, 222, 233); |
eb63f5ff | 162 | } else if (PREF_BACK_COLOR_LIST[i].equals(PREF_LIFELINE)) { |
73005152 | 163 | color = new ColorImpl(Display.getDefault(), 220, 220, 220); |
eb63f5ff | 164 | } else if (PREF_BACK_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) { |
73005152 | 165 | color = new ColorImpl(Display.getDefault(), 245, 244, 244); |
df0b8ff4 | 166 | } else { |
73005152 | 167 | color = new ColorImpl(Display.getDefault(), 255, 255, 255); |
df0b8ff4 | 168 | } |
eb63f5ff BH |
169 | PreferenceConverter.setDefault(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX, ((Color) color.getColor()).getRGB()); |
170 | PreferenceConverter.setDefault(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB()); | |
73005152 BH |
171 | color.dispose(); |
172 | } | |
173 | ||
eb63f5ff | 174 | for (int i = 0; i < PREF_FORE_COLOR_LIST.length; i++) { |
73005152 | 175 | IColor color; |
eb63f5ff | 176 | if (PREF_FORE_COLOR_LIST[i].equals(PREF_LIFELINE)) { |
73005152 | 177 | color = new ColorImpl(Display.getDefault(), 129, 129, 129); |
eb63f5ff | 178 | } else if (PREF_FORE_COLOR_LIST[i].equals(PREF_FRAME_NAME)) { |
73005152 | 179 | color = new ColorImpl(Display.getDefault(), 81, 153, 200); |
eb63f5ff | 180 | } else if (PREF_FORE_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) { |
73005152 | 181 | color = new ColorImpl(Display.getDefault(), 129, 127, 137); |
df0b8ff4 | 182 | } else { |
73005152 | 183 | color = new ColorImpl(Display.getDefault(), 134, 176, 212); |
df0b8ff4 | 184 | } |
eb63f5ff BH |
185 | PreferenceConverter.setDefault(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX, ((Color) color.getColor()).getRGB()); |
186 | PreferenceConverter.setDefault(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB()); | |
73005152 BH |
187 | color.dispose(); |
188 | } | |
189 | ||
eb63f5ff | 190 | for (int i = 0; i < PREF_TEXT_COLOR_LIST.length; i++) { |
73005152 | 191 | IColor color; |
eb63f5ff | 192 | if (PREF_TEXT_COLOR_LIST[i].equals(PREF_LIFELINE)) { |
73005152 | 193 | color = new ColorImpl(Display.getDefault(), 129, 129, 129); |
eb63f5ff | 194 | } else if (PREF_TEXT_COLOR_LIST[i].equals(PREF_FRAME_NAME)) { |
73005152 | 195 | color = new ColorImpl(Display.getDefault(), 0, 0, 0); |
eb63f5ff | 196 | } else if (PREF_TEXT_COLOR_LIST[i].equals(PREF_LIFELINE_HEADER)) { |
73005152 | 197 | color = new ColorImpl(Display.getDefault(), 129, 127, 137); |
df0b8ff4 | 198 | } else { |
73005152 | 199 | color = new ColorImpl(Display.getDefault(), 134, 176, 212); |
df0b8ff4 | 200 | } |
eb63f5ff BH |
201 | PreferenceConverter.setDefault(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX, ((Color) color.getColor()).getRGB()); |
202 | PreferenceConverter.setDefault(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX + TEMP_TAG, ((Color) color.getColor()).getRGB()); | |
73005152 BH |
203 | color.dispose(); |
204 | } | |
205 | ||
206 | IColor color = new ColorImpl(Display.getDefault(), 218, 232, 238); | |
eb63f5ff | 207 | PreferenceConverter.setDefault(fPrefStore, PREF_TIME_COMP, ((Color) color.getColor()).getRGB()); |
73005152 BH |
208 | color.dispose(); |
209 | ||
210 | buildFontsAndColors(); | |
211 | ||
eb63f5ff | 212 | fPrefStore.addPropertyChangeListener(this); |
73005152 BH |
213 | } |
214 | ||
215 | /** | |
216 | * Returns the PreferenceStore | |
a55887ca | 217 | * |
73005152 BH |
218 | * @return the PreferenceStore |
219 | */ | |
220 | public IPreferenceStore getPreferenceStore() { | |
eb63f5ff | 221 | return fPrefStore; |
73005152 BH |
222 | } |
223 | ||
224 | /** | |
225 | * Apply the preferences in the preferences handler | |
226 | */ | |
227 | public void apply() { | |
228 | buildFontsAndColors(); | |
eb63f5ff | 229 | fPrefStore.firePropertyChangeEvent("PREFOK", null, null); //$NON-NLS-1$ |
73005152 BH |
230 | } |
231 | ||
232 | /** | |
233 | * Returns an unique instance of the Sequence Diagram preference handler | |
a55887ca | 234 | * |
73005152 BH |
235 | * @return the preference handler instance |
236 | */ | |
df0b8ff4 | 237 | public static synchronized SDViewPref getInstance() { |
eb63f5ff BH |
238 | if (fHandle == null) { |
239 | fHandle = new SDViewPref(); | |
df0b8ff4 | 240 | } |
eb63f5ff | 241 | return fHandle; |
73005152 BH |
242 | } |
243 | ||
73005152 BH |
244 | @Override |
245 | public IColor getForeGroundColor(String prefName) { | |
eb63f5ff | 246 | if ((fForeColorPref.get(prefName + FORE_COLOR_POSTFIX) != null) && (fForeColorPref.get(prefName + FORE_COLOR_POSTFIX) instanceof ColorImpl)) { |
abbdd66a | 247 | return fForeColorPref.get(prefName + FORE_COLOR_POSTFIX); |
df0b8ff4 BH |
248 | } |
249 | return ColorImpl.getSystemColor(SWT.COLOR_BLACK); | |
73005152 BH |
250 | } |
251 | ||
73005152 BH |
252 | @Override |
253 | public IColor getBackGroundColor(String prefName) { | |
eb63f5ff | 254 | if ((fBackColorPref.get(prefName + BACK_COLOR_POSTFIX) != null) && (fBackColorPref.get(prefName + BACK_COLOR_POSTFIX) instanceof ColorImpl)) { |
abbdd66a | 255 | return fBackColorPref.get(prefName + BACK_COLOR_POSTFIX); |
df0b8ff4 BH |
256 | } |
257 | return ColorImpl.getSystemColor(SWT.COLOR_WHITE); | |
73005152 BH |
258 | } |
259 | ||
73005152 BH |
260 | @Override |
261 | public IColor getFontColor(String prefName) { | |
eb63f5ff | 262 | if ((fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX) != null) && (fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX) instanceof ColorImpl)) { |
abbdd66a | 263 | return fTextColorPref.get(prefName + TEXT_COLOR_POSTFIX); |
df0b8ff4 BH |
264 | } |
265 | return ColorImpl.getSystemColor(SWT.COLOR_BLACK); | |
73005152 BH |
266 | } |
267 | ||
73005152 BH |
268 | @Override |
269 | public IColor getForeGroundColorSelection() { | |
eb63f5ff | 270 | if (fNoFocusSelection) { |
73005152 | 271 | return ColorImpl.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND); |
df0b8ff4 | 272 | } |
73005152 BH |
273 | return ColorImpl.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT); |
274 | } | |
275 | ||
73005152 BH |
276 | @Override |
277 | public IColor getBackGroundColorSelection() { | |
eb63f5ff | 278 | if (fNoFocusSelection) { |
73005152 | 279 | return ColorImpl.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); |
df0b8ff4 | 280 | } |
73005152 BH |
281 | return ColorImpl.getSystemColor(SWT.COLOR_LIST_SELECTION); |
282 | } | |
283 | ||
73005152 BH |
284 | @Override |
285 | public IFont getFont(String prefName) { | |
abbdd66a AM |
286 | if (fFontPref.get(prefName) != null) { |
287 | return fFontPref.get(prefName); | |
df0b8ff4 BH |
288 | } |
289 | return FontImpl.getSystemFont(); | |
73005152 BH |
290 | } |
291 | ||
292 | /** | |
293 | * Returns the SwimLane width chosen | |
a55887ca | 294 | * |
73005152 BH |
295 | * @return the SwimLane width |
296 | */ | |
297 | public int getLifelineWidth() { | |
eb63f5ff | 298 | return fPrefStore.getInt(PREF_LIFELINE_WIDTH); |
73005152 BH |
299 | } |
300 | ||
301 | /** | |
302 | * Returns if font linkage with zoom has been chosen | |
a55887ca | 303 | * |
73005152 BH |
304 | * @return true if checked false otherwise |
305 | */ | |
306 | public boolean fontLinked() { | |
eb63f5ff | 307 | return fPrefStore.getBoolean(PREF_LINK_FONT); |
73005152 BH |
308 | } |
309 | ||
310 | /** | |
311 | * Returns the tooltip enablement | |
a55887ca | 312 | * |
73005152 BH |
313 | * @return true if checked false otherwise |
314 | */ | |
315 | public boolean tooltipEnabled() { | |
eb63f5ff | 316 | return fPrefStore.getBoolean(PREF_TOOLTIP); |
73005152 BH |
317 | } |
318 | ||
319 | /** | |
320 | * Return true if the user do not want to take external time (basically found and lost messages with time) into | |
321 | * account in the min max computation | |
a55887ca | 322 | * |
73005152 BH |
323 | * @return true if checked false otherwise |
324 | */ | |
325 | public boolean excludeExternalTime() { | |
eb63f5ff | 326 | return fPrefStore.getBoolean(PREF_EXCLUDE_EXTERNAL_TIME); |
73005152 BH |
327 | } |
328 | ||
73005152 BH |
329 | @Override |
330 | public boolean useGradienColor() { | |
eb63f5ff | 331 | return fPrefStore.getBoolean(PREF_USE_GRADIENT); |
73005152 BH |
332 | } |
333 | ||
73005152 BH |
334 | @Override |
335 | public IColor getTimeCompressionSelectionColor() { | |
eb63f5ff | 336 | return fTimeCompressionSelectionColor; |
73005152 BH |
337 | } |
338 | ||
339 | /** | |
340 | * Builds the new colors and fonts according the current user selection when the OK or Apply button is clicked | |
73005152 | 341 | */ |
eb63f5ff | 342 | private void buildFontsAndColors() { |
73005152 BH |
343 | |
344 | Display display = Display.getDefault(); | |
345 | ||
eb63f5ff BH |
346 | for (int i = 0; i < FONT_LIST.length; i++) { |
347 | FontData fontData = PreferenceConverter.getFontData(fPrefStore, FONT_LIST[i]); | |
abbdd66a AM |
348 | if (fFontPref.get(FONT_LIST[i]) != null) { |
349 | fFontPref.get(FONT_LIST[i]).dispose(); | |
df0b8ff4 | 350 | } |
eb63f5ff | 351 | fFontPref.put(FONT_LIST[i], new FontImpl(display, fontData)); |
73005152 BH |
352 | } |
353 | ||
eb63f5ff BH |
354 | for (int i = 0; i < PREF_BACK_COLOR_LIST.length; i++) { |
355 | RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX); | |
abbdd66a AM |
356 | if (fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX) != null) { |
357 | fBackColorPref.get(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX).dispose(); | |
df0b8ff4 | 358 | } |
eb63f5ff | 359 | fBackColorPref.put(PREF_BACK_COLOR_LIST[i] + BACK_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue)); |
73005152 BH |
360 | } |
361 | ||
eb63f5ff BH |
362 | for (int i = 0; i < PREF_FORE_COLOR_LIST.length; i++) { |
363 | RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX); | |
abbdd66a AM |
364 | if (fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX) != null) { |
365 | fForeColorPref.get(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX).dispose(); | |
df0b8ff4 | 366 | } |
eb63f5ff | 367 | fForeColorPref.put(PREF_FORE_COLOR_LIST[i] + FORE_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue)); |
73005152 BH |
368 | } |
369 | ||
eb63f5ff BH |
370 | for (int i = 0; i < PREF_TEXT_COLOR_LIST.length; i++) { |
371 | RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX); | |
abbdd66a AM |
372 | if (fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX) != null) { |
373 | fTextColorPref.get(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX).dispose(); | |
df0b8ff4 | 374 | } |
eb63f5ff | 375 | fTextColorPref.put(PREF_TEXT_COLOR_LIST[i] + TEXT_COLOR_POSTFIX, new ColorImpl(display, rgb.red, rgb.green, rgb.blue)); |
73005152 BH |
376 | } |
377 | ||
eb63f5ff BH |
378 | RGB rgb = PreferenceConverter.getColor(fPrefStore, PREF_TIME_COMP); |
379 | if (fTimeCompressionSelectionColor != null) { | |
380 | fTimeCompressionSelectionColor.dispose(); | |
df0b8ff4 | 381 | } |
eb63f5ff | 382 | fTimeCompressionSelectionColor = new ColorImpl(display, rgb.red, rgb.green, rgb.blue); |
73005152 BH |
383 | } |
384 | ||
a55887ca AM |
385 | /** |
386 | * Add a property-change listener | |
387 | * | |
388 | * @param listener | |
389 | * The listener to add | |
390 | */ | |
73005152 | 391 | public void addPropertyChangeListener(IPropertyChangeListener listener) { |
eb63f5ff | 392 | fPrefStore.addPropertyChangeListener(listener); |
73005152 BH |
393 | } |
394 | ||
a55887ca AM |
395 | /** |
396 | * Remove a property-change listener | |
397 | * | |
398 | * @param listener | |
399 | * The listerner to remove | |
400 | */ | |
73005152 | 401 | public void removePropertyChangeListener(IPropertyChangeListener listener) { |
eb63f5ff | 402 | fPrefStore.removePropertyChangeListener(listener); |
73005152 BH |
403 | } |
404 | ||
73005152 BH |
405 | @Override |
406 | public void propertyChange(PropertyChangeEvent event) { | |
df0b8ff4 | 407 | if (!event.getProperty().equals("PREFOK")) { //$NON-NLS-1$ |
73005152 | 408 | buildFontsAndColors(); |
a55887ca | 409 | fPrefStore.firePropertyChangeEvent("PREFOK", null, null); //$NON-NLS-1$ |
73005152 BH |
410 | } |
411 | } | |
412 | ||
a55887ca AM |
413 | /** |
414 | * Set the "no focus selection" preference | |
415 | * | |
416 | * @param v | |
417 | * New value to use | |
418 | */ | |
73005152 | 419 | public void setNoFocusSelection(boolean v) { |
eb63f5ff | 420 | fNoFocusSelection = v; |
73005152 | 421 | } |
e6ace8bb | 422 | |
cab6c8ff BH |
423 | /** |
424 | * Returns a unmodifiable map with font preferences. | |
425 | * | |
426 | * @return map with font preferences | |
427 | * @since 2.0 | |
428 | */ | |
429 | protected Map<String, IFont> getFontPref() { | |
430 | return Collections.unmodifiableMap(fFontPref); | |
431 | } | |
432 | ||
433 | /** | |
434 | * Returns a unmodifiable map with foreground color preferences | |
435 | * | |
436 | * @return map with foreground color preferences | |
437 | * @since 2.0 | |
438 | */ | |
439 | public Map<String, IColor> getForeColorPref() { | |
440 | return Collections.unmodifiableMap(fForeColorPref); | |
441 | } | |
442 | ||
443 | /** | |
444 | * Returns a unmodifiable map with background color preferences | |
445 | * | |
446 | * @return map with background color preferences | |
447 | * @since 2.0 | |
448 | */ | |
449 | public Map<String, IColor> getBackColorPref() { | |
450 | return Collections.unmodifiableMap(fBackColorPref); | |
451 | } | |
452 | ||
453 | /** | |
454 | * Returns a unmodifiable map with text color preferences | |
455 | * | |
456 | * @return map with text color preferences | |
457 | * @since 2.0 | |
458 | */ | |
459 | public Map<String, IColor> getTextColorPref() { | |
460 | return Collections.unmodifiableMap(fTextColorPref); | |
461 | } | |
462 | ||
463 | /** | |
464 | * Returns the preference store. | |
465 | * | |
466 | * @return the preference store | |
467 | * @since 2.0 | |
468 | */ | |
469 | public IPreferenceStore getPrefStore() { | |
470 | return fPrefStore; | |
471 | } | |
472 | ||
473 | /** | |
474 | * Returns flag about focus selection | |
475 | * | |
476 | * @return flag about focus selection | |
477 | * @since 2.0 | |
478 | */ | |
479 | public boolean isNoFocusSelection() { | |
480 | return fNoFocusSelection; | |
481 | } | |
482 | ||
e6ace8bb | 483 | /** |
df0b8ff4 | 484 | * Returns the static font list. |
a55887ca | 485 | * |
e6ace8bb BH |
486 | * @return static font list |
487 | */ | |
488 | public static String[] getFontList() { | |
eb63f5ff | 489 | return Arrays.copyOf(FONT_LIST, FONT_LIST.length); |
e6ace8bb | 490 | } |
a55887ca | 491 | |
e6ace8bb | 492 | /** |
df0b8ff4 | 493 | * Returns the 2nd static font list. |
a55887ca | 494 | * |
e6ace8bb BH |
495 | * @return 2nd static font list |
496 | */ | |
497 | public static String[] getFontList2() { | |
eb63f5ff | 498 | return Arrays.copyOf(FONT_LIST2, FONT_LIST2.length); |
e6ace8bb | 499 | } |
a55887ca | 500 | |
e6ace8bb | 501 | /** |
df0b8ff4 | 502 | * Returns the preference background color list. |
a55887ca | 503 | * |
e6ace8bb BH |
504 | * @return preference background color list |
505 | */ | |
506 | public static String[] getPrefBackColorList() { | |
eb63f5ff | 507 | return Arrays.copyOf(PREF_BACK_COLOR_LIST, PREF_BACK_COLOR_LIST.length); |
e6ace8bb | 508 | } |
a55887ca | 509 | |
e6ace8bb | 510 | /** |
df0b8ff4 | 511 | * Returns the preference foreground color list. |
a55887ca | 512 | * |
e6ace8bb BH |
513 | * @return preference foreground color list |
514 | */ | |
515 | public static String[] getPrefForeColorList() { | |
eb63f5ff | 516 | return Arrays.copyOf(PREF_FORE_COLOR_LIST, PREF_FORE_COLOR_LIST.length); |
e6ace8bb | 517 | } |
a55887ca | 518 | |
e6ace8bb | 519 | /** |
df0b8ff4 | 520 | * Returns the preference text color list color list. |
a55887ca | 521 | * |
e6ace8bb BH |
522 | * @return preference text color list color list |
523 | */ | |
524 | public static String[] getPrefTextColorList() { | |
eb63f5ff | 525 | return Arrays.copyOf(PREF_TEXT_COLOR_LIST, PREF_TEXT_COLOR_LIST.length); |
e6ace8bb | 526 | } |
73005152 | 527 | } |