1
1
/**********************************************************************
2
* Copyright (c) 2005, 2008 IBM Corporation and others.
3
* Copyright (c) 2011, 2012 Ericsson.
2
* Copyright (c) 2005, 2013 IBM Corporation, Ericsson
5
3
* All rights reserved. This program and the accompanying materials
6
4
* are made available under the terms of the Eclipse Public License v1.0
7
5
* which accompanies this distribution, and is available at
8
6
* http://www.eclipse.org/legal/epl-v10.html
11
* IBM - Initial API and implementation
12
* Bernd Hufmann - Updated for TMF
9
* IBM - Initial API and implementation
10
* Bernd Hufmann - Updated for TMF
13
11
**********************************************************************/
14
13
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences;
16
15
import java.util.Iterator;
22
21
import org.eclipse.jface.preference.FontFieldEditor;
23
22
import org.eclipse.jface.preference.IntegerFieldEditor;
24
23
import org.eclipse.jface.preference.PreferencePage;
25
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
24
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.Messages;
26
25
import org.eclipse.swt.SWT;
27
26
import org.eclipse.swt.events.SelectionEvent;
28
27
import org.eclipse.swt.events.SelectionListener;
58
57
* The preference handler used to access the PreferenceStore
60
protected SDViewPref fPreferences = null;
59
private SDViewPref fPreferences = null;
62
61
* BackGround color selector
64
protected ColorFieldEditor fLineColor = null;
63
private ColorFieldEditor fLineColor = null;
66
65
* Foreground color selector
68
protected ColorFieldEditor fBackGroundColor = null;
67
private ColorFieldEditor fBackGroundColor = null;
70
69
* Font color selector
72
protected ColorFieldEditor fTextColor = null;
71
private ColorFieldEditor fTextColor = null;
74
73
* List which display all modifiable sequence Diagram font
76
protected List fClassItemList = null;
75
private List fClassItemList = null;
78
77
* Font selector (The same is used for each modifiable font)
80
protected FontFieldEditor fFont = null;
79
private FontFieldEditor fFont = null;
82
81
* Link font when zooming selector
84
protected BooleanFieldEditor fLink = null;
83
private BooleanFieldEditor fLink = null;
86
85
* Enable tooltip selector
88
protected BooleanFieldEditor fTooltip = null;
87
private BooleanFieldEditor fTooltip = null;
90
89
* Do not take external time into account in the min max computation
92
protected BooleanFieldEditor fNoExternalTime = null;
91
private BooleanFieldEditor fNoExternalTime = null;
94
93
* Use gradient color selector
96
protected BooleanFieldEditor fUseGrad = null;
95
private BooleanFieldEditor fUseGrad = null;
100
protected Composite fButtonArea;
99
private Composite fButtonArea;
102
101
* SwimLane width selector
104
protected IntegerFieldEditor fLifelineWidth = null;
103
private IntegerFieldEditor fLifelineWidth = null;
106
105
// ------------------------------------------------------------------------
108
107
// ------------------------------------------------------------------------
112
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
115
110
protected Control createContents(Composite parent) {
116
111
parent.setLayout(new GridLayout());
121
116
page.setLayoutData(pageLayoutdata);
122
117
page.setLayout(pageLayout);
124
fTooltip = new BooleanFieldEditor(ISDPreferences.PREF_TOOLTIP, SDMessages._97, page);
119
fTooltip = new BooleanFieldEditor(ISDPreferences.PREF_TOOLTIP, Messages.SequenceDiagram_ShowTooltips, page);
125
120
fTooltip.setPreferenceStore(fPreferences.getPreferenceStore());
128
123
// link font with zoom pref
129
fLink = new BooleanFieldEditor(ISDPreferences.PREF_LINK_FONT, SDMessages._82, page);
124
fLink = new BooleanFieldEditor(ISDPreferences.PREF_LINK_FONT, Messages.SequenceDiagram_IncreaseFontSizeWhenZooming, page);
130
125
fLink.setPreferenceStore(fPreferences.getPreferenceStore());
133
fNoExternalTime = new BooleanFieldEditor(ISDPreferences.PREF_EXCLUDE_EXTERNAL_TIME, SDMessages._83, page);
128
fNoExternalTime = new BooleanFieldEditor(ISDPreferences.PREF_EXCLUDE_EXTERNAL_TIME, Messages.SequenceDiagram_ExcludeExternalTime, page);
134
129
fNoExternalTime.setPreferenceStore(fPreferences.getPreferenceStore());
135
130
fNoExternalTime.load();
137
132
// use gradient color pref
138
fUseGrad = new BooleanFieldEditor(ISDPreferences.PREF_USE_GRADIENT, SDMessages._84, page);
133
fUseGrad = new BooleanFieldEditor(ISDPreferences.PREF_USE_GRADIENT, Messages.SequenceDiagram_UseGradientColor, page);
139
134
fUseGrad.setPreferenceStore(fPreferences.getPreferenceStore());
150
145
prefPage.setLayout(prefPageLayout);
152
147
// swimLane width pref
153
fLifelineWidth = new IntegerFieldEditor(ISDPreferences.PREF_LIFELINE_WIDTH, SDMessages._80, prefPage);
148
fLifelineWidth = new IntegerFieldEditor(ISDPreferences.PREF_LIFELINE_WIDTH, Messages.SequenceDiagram_LifelineWidth, prefPage);
154
149
fLifelineWidth.setPreferenceStore(fPreferences.getPreferenceStore());
155
150
fLifelineWidth.setValidRange(119, 500);
156
151
fLifelineWidth.load();
180
175
// font selector initialise for the lifeline font pref
181
176
String[] fontList = SDViewPref.getFontList();
182
177
fFont = new FontFieldEditor(fontList[0], "",//$NON-NLS-1$
183
SDMessages._81, fButtonArea);
178
Messages.SequenceDiagram_AaBbYyZz, fButtonArea);
184
179
fFont.getPreviewControl().setSize(500, 500);
185
180
fFont.setPreferenceStore(fPreferences.getPreferenceStore());
188
fBackGroundColor = new ColorFieldEditor(fontList[0] + SDViewPref.BACK_COLOR_POSTFIX, SDMessages._85, fButtonArea);
183
fBackGroundColor = new ColorFieldEditor(fontList[0] + SDViewPref.BACK_COLOR_POSTFIX, Messages.SequenceDiagram_Background, fButtonArea);
189
184
fBackGroundColor.setPreferenceStore(fPreferences.getPreferenceStore());
190
185
fBackGroundColor.load();
192
fLineColor = new ColorFieldEditor(fontList[0] + SDViewPref.FORE_COLOR_POSTFIX, SDMessages._86, fButtonArea);
187
fLineColor = new ColorFieldEditor(fontList[0] + SDViewPref.FORE_COLOR_POSTFIX, Messages.SequenceDiagram_Lines, fButtonArea);
193
188
fLineColor.setPreferenceStore(fPreferences.getPreferenceStore());
194
189
fLineColor.load();
196
fTextColor = new ColorFieldEditor(fontList[0] + SDViewPref.TEXT_COLOR_POSTFIX, SDMessages._87, fButtonArea);
191
fTextColor = new ColorFieldEditor(fontList[0] + SDViewPref.TEXT_COLOR_POSTFIX, Messages.SequenceDiagram_Text, fButtonArea);
197
192
fTextColor.setPreferenceStore(fPreferences.getPreferenceStore());
198
193
fTextColor.load();
207
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
210
201
public void init(IWorkbench workbench) {
211
202
fPreferences = SDViewPref.getInstance();
216
* @see org.eclipse.jface.preference.PreferencePage#performApply()
219
206
protected void performApply() {
220
207
// Store the prefrences in the PreferenceStore
262
241
// and all the fonts and colors
263
242
// fonts and colors are stored for each time because
264
243
// we are using only one FontFieldEditor
265
Set<String> keySet = SDViewPref.getInstance().fFontPref.keySet();
244
Set<String> keySet = SDViewPref.getInstance().getFontPref().keySet();
266
245
Iterator<String> it = keySet.iterator();
267
246
while (it.hasNext()) {
268
247
Object prefName = it.next();
350
* Swap viewer preferences.
352
* @param toTemp Switch to the temporary preferences
374
354
protected void swapPref(boolean toTemp) {
375
String TAG1 = "";//$NON-NLS-1$
376
String TAG2 = TEMP_TAG;
355
String tag1 = "";//$NON-NLS-1$
356
String tag2 = TEMP_TAG;
379
TAG2 = "";//$NON-NLS-1$
359
tag2 = "";//$NON-NLS-1$
381
Set<String> keySet = SDViewPref.getInstance().fFontPref.keySet();
361
Set<String> keySet = SDViewPref.getInstance().getFontPref().keySet();
382
362
Iterator<String> it = keySet.iterator();
383
363
while (it.hasNext()) {
384
364
Object prefName = it.next();
385
365
if (prefName instanceof String) {
386
fFont.setPreferenceName((String) prefName + TAG1);
366
fFont.setPreferenceName((String) prefName + tag1);
388
fFont.setPreferenceName((String) prefName + TAG2);
368
fFont.setPreferenceName((String) prefName + tag2);
393
keySet = SDViewPref.getInstance().fBackColorPref.keySet();
373
keySet = SDViewPref.getInstance().getBackColorPref().keySet();
394
374
it = keySet.iterator();
395
375
while (it.hasNext()) {
396
376
Object prefName = it.next();
397
377
if (prefName instanceof String) {
398
fBackGroundColor.setPreferenceName((String) prefName + TAG1);
378
fBackGroundColor.setPreferenceName((String) prefName + tag1);
399
379
fBackGroundColor.load();
400
fBackGroundColor.setPreferenceName((String) prefName + TAG2);
380
fBackGroundColor.setPreferenceName((String) prefName + tag2);
401
381
fBackGroundColor.store();
405
keySet = SDViewPref.getInstance().fForeColorPref.keySet();
385
keySet = SDViewPref.getInstance().getForeColorPref().keySet();
406
386
it = keySet.iterator();
407
387
while (it.hasNext()) {
408
388
Object prefName = it.next();
409
389
if (prefName instanceof String) {
410
fLineColor.setPreferenceName((String) prefName + TAG1);
390
fLineColor.setPreferenceName((String) prefName + tag1);
411
391
fLineColor.load();
412
fLineColor.setPreferenceName((String) prefName + TAG2);
392
fLineColor.setPreferenceName((String) prefName + tag2);
413
393
fLineColor.store();
417
keySet = SDViewPref.getInstance().fTextColorPref.keySet();
397
keySet = SDViewPref.getInstance().getTextColorPref().keySet();
418
398
it = keySet.iterator();
419
399
while (it.hasNext()) {
420
400
Object prefName = it.next();
421
401
if (prefName instanceof String) {
422
fTextColor.setPreferenceName((String) prefName + TAG1);
402
fTextColor.setPreferenceName((String) prefName + tag1);
423
403
fTextColor.load();
424
fTextColor.setPreferenceName((String) prefName + TAG2);
404
fTextColor.setPreferenceName((String) prefName + tag2);
425
405
fTextColor.store();