~ubuntu-branches/ubuntu/utopic/eclipse-linuxtools/utopic

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/preferences/SDViewerPage.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2014-05-12 18:11:40 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140512181140-w237r3vsah1tmybz
Tags: 2.2.1-1
* New upstream release.
* Refreshed d/patches.
* Removed eclipse-cdt-valgrind-remote package, all its functionality
  is now provided by eclipse-cdt-profiling-framework-remote.
* Added remove-license-feature.patch.
* Bump Standards-Version to 3.9.5.
* Enable eclipse-changelog package.
* Enable eclipse-rpm-editor package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**********************************************************************
2
 
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 
 * Copyright (c) 2011, 2012 Ericsson.
4
 
 *
 
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
9
7
 *
10
8
 * Contributors:
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
 **********************************************************************/
 
12
 
14
13
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences;
15
14
 
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;
49
48
    /**
50
49
     * Temporary preferences tag
51
50
     */
52
 
    protected static final String TEMP_TAG = SDViewPref.TEMP_TAG;
 
51
    private static final String TEMP_TAG = SDViewPref.TEMP_TAG;
53
52
 
54
53
    // ------------------------------------------------------------------------
55
54
    // Attributes
57
56
    /**
58
57
     * The preference handler used to access the PreferenceStore
59
58
     */
60
 
    protected SDViewPref fPreferences = null;
 
59
    private SDViewPref fPreferences = null;
61
60
    /**
62
61
     * BackGround color selector
63
62
     */
64
 
    protected ColorFieldEditor fLineColor = null;
 
63
    private ColorFieldEditor fLineColor = null;
65
64
    /**
66
65
     * Foreground color selector
67
66
     */
68
 
    protected ColorFieldEditor fBackGroundColor = null;
 
67
    private ColorFieldEditor fBackGroundColor = null;
69
68
    /**
70
69
     * Font color selector
71
70
     */
72
 
    protected ColorFieldEditor fTextColor = null;
 
71
    private ColorFieldEditor fTextColor = null;
73
72
    /**
74
73
     * List which display all modifiable sequence Diagram font
75
74
     */
76
 
    protected List fClassItemList = null;
 
75
    private List fClassItemList = null;
77
76
    /**
78
77
     * Font selector (The same is used for each modifiable font)
79
78
     */
80
 
    protected FontFieldEditor fFont = null;
 
79
    private FontFieldEditor fFont = null;
81
80
    /**
82
81
     * Link font when zooming selector
83
82
     */
84
 
    protected BooleanFieldEditor fLink = null;
 
83
    private BooleanFieldEditor fLink = null;
85
84
    /**
86
85
     * Enable tooltip selector
87
86
     */
88
 
    protected BooleanFieldEditor fTooltip = null;
 
87
    private BooleanFieldEditor fTooltip = null;
89
88
    /**
90
89
     * Do not take external time into account in the min max computation
91
90
     */
92
 
    protected BooleanFieldEditor fNoExternalTime = null;
 
91
    private BooleanFieldEditor fNoExternalTime = null;
93
92
    /**
94
93
     * Use gradient color selector
95
94
     */
96
 
    protected BooleanFieldEditor fUseGrad = null;
 
95
    private BooleanFieldEditor fUseGrad = null;
97
96
    /**
98
97
     * A button area.
99
98
     */
100
 
    protected Composite fButtonArea;
 
99
    private Composite fButtonArea;
101
100
    /**
102
101
     * SwimLane width selector
103
102
     */
104
 
    protected IntegerFieldEditor fLifelineWidth = null;
 
103
    private IntegerFieldEditor fLifelineWidth = null;
105
104
 
106
105
    // ------------------------------------------------------------------------
107
106
    // Methods
108
107
    // ------------------------------------------------------------------------
109
108
 
110
 
    /*
111
 
     * (non-Javadoc)
112
 
     * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
113
 
     */
114
109
    @Override
115
110
    protected Control createContents(Composite parent) {
116
111
        parent.setLayout(new GridLayout());
121
116
        page.setLayoutData(pageLayoutdata);
122
117
        page.setLayout(pageLayout);
123
118
 
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());
126
121
        fTooltip.load();
127
122
 
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());
131
126
        fLink.load();
132
127
 
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();
136
131
 
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());
140
135
        fUseGrad.load();
141
136
 
150
145
        prefPage.setLayout(prefPageLayout);
151
146
 
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());
186
181
        fFont.load();
187
182
 
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();
191
186
 
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();
195
190
 
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();
199
194
        swapPref(true);
202
197
        return page;
203
198
    }
204
199
 
205
 
    /*
206
 
     * (non-Javadoc)
207
 
     * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
208
 
     */
209
200
    @Override
210
201
    public void init(IWorkbench workbench) {
211
202
        fPreferences = SDViewPref.getInstance();
212
203
    }
213
204
 
214
 
    /*
215
 
     * (non-Javadoc)
216
 
     * @see org.eclipse.jface.preference.PreferencePage#performApply()
217
 
     */
218
205
    @Override
219
206
    protected void performApply() {
220
207
        // Store the prefrences in the PreferenceStore
237
224
        swapPref(true);
238
225
    }
239
226
 
240
 
    /*
241
 
     * (non-Javadoc)
242
 
     * @see org.eclipse.jface.preference.PreferencePage#performOk()
243
 
     */
244
227
    @Override
245
228
    public boolean performOk() {
246
229
        performApply();
247
230
        return true;
248
231
    }
249
232
 
250
 
    /*
251
 
     * (non-Javadoc)
252
 
     * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
253
 
     */
254
233
    @Override
255
234
    protected void performDefaults() {
256
235
        fLink.loadDefault();
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();
274
253
            }
275
254
        }
276
255
 
277
 
        keySet = SDViewPref.getInstance().fBackColorPref.keySet();
 
256
        keySet = SDViewPref.getInstance().getBackColorPref().keySet();
278
257
        it = keySet.iterator();
279
258
        while (it.hasNext()) {
280
259
            Object prefName = it.next();
291
270
        fBackGroundColor.setPreferenceName(fontList[fClassItemList.getSelectionIndex()] + SDViewPref.BACK_COLOR_POSTFIX + TEMP_TAG);
292
271
        fBackGroundColor.load();
293
272
 
294
 
        keySet = SDViewPref.getInstance().fForeColorPref.keySet();
 
273
        keySet = SDViewPref.getInstance().getForeColorPref().keySet();
295
274
        it = keySet.iterator();
296
275
        while (it.hasNext()) {
297
276
            Object prefName = it.next();
306
285
        fLineColor.setPreferenceName(fontList[fClassItemList.getSelectionIndex()] + SDViewPref.FORE_COLOR_POSTFIX + TEMP_TAG);
307
286
        fLineColor.load();
308
287
 
309
 
        keySet = SDViewPref.getInstance().fTextColorPref.keySet();
 
288
        keySet = SDViewPref.getInstance().getTextColorPref().keySet();
310
289
        it = keySet.iterator();
311
290
        while (it.hasNext()) {
312
291
            Object prefName = it.next();
321
300
        fTextColor.load();
322
301
    }
323
302
 
324
 
    /*
325
 
     * (non-Javadoc)
326
 
     * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
327
 
     */
328
303
    @Override
329
304
    public void widgetSelected(SelectionEvent e) {
330
305
        // Store the past set font preference or else the
371
346
        }
372
347
    }
373
348
 
 
349
    /**
 
350
     * Swap viewer preferences.
 
351
     *
 
352
     * @param toTemp Switch to the temporary preferences
 
353
     */
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;
377
357
        if (!toTemp) {
378
 
            TAG1 = TEMP_TAG;
379
 
            TAG2 = "";//$NON-NLS-1$
 
358
            tag1 = TEMP_TAG;
 
359
            tag2 = "";//$NON-NLS-1$
380
360
        }
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);
387
367
                fFont.load();
388
 
                fFont.setPreferenceName((String) prefName + TAG2);
 
368
                fFont.setPreferenceName((String) prefName + tag2);
389
369
                fFont.store();
390
370
            }
391
371
        }
392
372
 
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();
402
382
            }
403
383
        }
404
384
 
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();
414
394
            }
415
395
        }
416
396
 
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();
426
406
            }
427
407
        }
442
422
        }
443
423
    }
444
424
 
445
 
    /*
446
 
     * (non-Javadoc)
447
 
     * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
448
 
     */
449
425
    @Override
450
426
    public void widgetDefaultSelected(SelectionEvent e) {
451
427
    }