0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
package com.symbian.smt.gui.preferences;
|
|
19 |
|
|
20 |
import org.eclipse.core.runtime.preferences.DefaultScope;
|
|
21 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
|
22 |
import org.eclipse.core.runtime.preferences.IScopeContext;
|
|
23 |
import org.eclipse.core.runtime.preferences.InstanceScope;
|
|
24 |
import org.eclipse.jface.preference.PreferencePage;
|
|
25 |
import org.eclipse.jface.resource.ImageDescriptor;
|
|
26 |
import org.eclipse.swt.SWT;
|
|
27 |
import org.eclipse.swt.layout.FillLayout;
|
|
28 |
import org.eclipse.swt.widgets.Composite;
|
|
29 |
import org.eclipse.swt.widgets.Control;
|
|
30 |
import org.eclipse.ui.IWorkbench;
|
|
31 |
import org.eclipse.ui.IWorkbenchPreferencePage;
|
|
32 |
|
|
33 |
import com.symbian.smt.gui.AbstractPersistentDataStore;
|
|
34 |
import com.symbian.smt.gui.Activator;
|
|
35 |
import com.symbian.smt.gui.PersistentDataStore;
|
|
36 |
import com.symbian.smt.gui.smtwidgets.AdvancedOptionsWidget;
|
|
37 |
|
|
38 |
/**
|
|
39 |
* This is the Preference page for the Advanced Options. It utilises the
|
|
40 |
* <code>AdvancedOptionsWidget</code>.
|
|
41 |
* <p>
|
|
42 |
* By default, there are no advanced options defined.
|
|
43 |
* </p>
|
|
44 |
*
|
|
45 |
* @author barbararosi-schwartz
|
|
46 |
*/
|
|
47 |
public class AdvancedOptionsPreferences extends PreferencePage implements
|
|
48 |
IWorkbenchPreferencePage {
|
|
49 |
|
|
50 |
private AdvancedOptionsWidget advancedOptionsWidget;
|
|
51 |
private AbstractPersistentDataStore instanceStore;
|
|
52 |
private AbstractPersistentDataStore defaultStore;
|
|
53 |
|
|
54 |
public AdvancedOptionsPreferences() {
|
|
55 |
}
|
|
56 |
|
|
57 |
public AdvancedOptionsPreferences(String title) {
|
|
58 |
super(title);
|
|
59 |
}
|
|
60 |
|
|
61 |
public AdvancedOptionsPreferences(String title, ImageDescriptor image) {
|
|
62 |
super(title, image);
|
|
63 |
}
|
|
64 |
|
|
65 |
@Override
|
|
66 |
protected Control createContents(Composite parent) {
|
|
67 |
Composite composite = new Composite(parent, SWT.NONE);
|
|
68 |
composite.setLayout(new FillLayout(SWT.VERTICAL));
|
|
69 |
|
|
70 |
advancedOptionsWidget = new AdvancedOptionsWidget(composite, SWT.NONE);
|
|
71 |
|
|
72 |
IScopeContext defaultScope = new DefaultScope();
|
|
73 |
IEclipsePreferences defaultNode = defaultScope
|
|
74 |
.getNode(Activator.PLUGIN_ID);
|
|
75 |
defaultStore = new PersistentDataStore(defaultNode);
|
|
76 |
|
|
77 |
IScopeContext instanceScope = new InstanceScope();
|
|
78 |
IEclipsePreferences instanceNode = instanceScope
|
|
79 |
.getNode(Activator.PLUGIN_ID);
|
|
80 |
instanceStore = new PersistentDataStore(instanceNode, defaultNode);
|
|
81 |
|
|
82 |
advancedOptionsWidget.setAdvancedOptions(instanceStore
|
|
83 |
.getAdvancedOptions());
|
|
84 |
|
|
85 |
composite.pack();
|
|
86 |
parent.pack();
|
|
87 |
|
|
88 |
return composite;
|
|
89 |
}
|
|
90 |
|
|
91 |
public void init(IWorkbench workbench) {
|
|
92 |
setPreferenceStore(Activator.getDefault().getPreferenceStore());
|
|
93 |
setDescription("System Model Diagram advanced options.\n"
|
|
94 |
+ "These must be defined in their entirety. "
|
|
95 |
+ "Their order is also user defined.");
|
|
96 |
}
|
|
97 |
|
|
98 |
public void performDefaults() {
|
|
99 |
restoreDefaults();
|
|
100 |
}
|
|
101 |
|
|
102 |
public boolean performOk() {
|
|
103 |
storeValues();
|
|
104 |
return super.performOk();
|
|
105 |
}
|
|
106 |
|
|
107 |
private void restoreDefaults() {
|
|
108 |
advancedOptionsWidget.setAdvancedOptions(defaultStore
|
|
109 |
.getAdvancedOptions());
|
|
110 |
}
|
|
111 |
|
|
112 |
private void storeValues() {
|
|
113 |
instanceStore.setAdvancedOptions(advancedOptionsWidget
|
|
114 |
.getAdvancedOptions());
|
|
115 |
}
|
|
116 |
}
|