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 |
package com.symbian.smt.gui.preferences;
|
|
17 |
|
|
18 |
import org.eclipse.core.runtime.preferences.DefaultScope;
|
|
19 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
|
20 |
import org.eclipse.core.runtime.preferences.IScopeContext;
|
|
21 |
import org.eclipse.core.runtime.preferences.InstanceScope;
|
|
22 |
import org.eclipse.jface.preference.PreferencePage;
|
|
23 |
import org.eclipse.jface.resource.ImageDescriptor;
|
|
24 |
import org.eclipse.swt.SWT;
|
|
25 |
import org.eclipse.swt.layout.FillLayout;
|
|
26 |
import org.eclipse.swt.widgets.Composite;
|
|
27 |
import org.eclipse.swt.widgets.Control;
|
|
28 |
import org.eclipse.ui.IWorkbench;
|
|
29 |
import org.eclipse.ui.IWorkbenchPreferencePage;
|
|
30 |
|
|
31 |
import com.symbian.smt.gui.AbstractPersistentDataStore;
|
|
32 |
import com.symbian.smt.gui.Activator;
|
|
33 |
import com.symbian.smt.gui.PersistentDataStore;
|
|
34 |
import com.symbian.smt.gui.smtwidgets.IgnoreWidget;
|
|
35 |
|
|
36 |
public class IgnorePreferences extends PreferencePage implements
|
|
37 |
IWorkbenchPreferencePage {
|
|
38 |
|
|
39 |
private IgnoreWidget ignoreWidget;
|
|
40 |
private AbstractPersistentDataStore instanceStore;
|
|
41 |
private AbstractPersistentDataStore defaultStore;
|
|
42 |
|
|
43 |
public IgnorePreferences() {
|
|
44 |
}
|
|
45 |
|
|
46 |
public IgnorePreferences(String title) {
|
|
47 |
super(title);
|
|
48 |
}
|
|
49 |
|
|
50 |
public IgnorePreferences(String title, ImageDescriptor image) {
|
|
51 |
super(title, image);
|
|
52 |
}
|
|
53 |
|
|
54 |
@Override
|
|
55 |
protected Control createContents(Composite parent) {
|
|
56 |
Composite composite = new Composite(parent, SWT.NONE);
|
|
57 |
composite.setLayout(new FillLayout(SWT.VERTICAL));
|
|
58 |
|
|
59 |
ignoreWidget = new IgnoreWidget(composite, SWT.NONE);
|
|
60 |
|
|
61 |
IScopeContext defaultScope = new DefaultScope();
|
|
62 |
IEclipsePreferences defaultNode = defaultScope
|
|
63 |
.getNode(Activator.PLUGIN_ID);
|
|
64 |
defaultStore = new PersistentDataStore(defaultNode);
|
|
65 |
|
|
66 |
IScopeContext instanceScope = new InstanceScope();
|
|
67 |
IEclipsePreferences instanceNode = instanceScope
|
|
68 |
.getNode(Activator.PLUGIN_ID);
|
|
69 |
instanceStore = new PersistentDataStore(instanceNode, defaultNode);
|
|
70 |
|
|
71 |
ignoreWidget.setIgnoreItems(instanceStore.getIgnoreItems());
|
|
72 |
|
|
73 |
composite.pack();
|
|
74 |
parent.pack();
|
|
75 |
|
|
76 |
return composite;
|
|
77 |
}
|
|
78 |
|
|
79 |
public void init(IWorkbench workbench) {
|
|
80 |
setPreferenceStore(Activator.getDefault().getPreferenceStore());
|
|
81 |
setDescription("List of model entities not to draw when building System Model Diagram.");
|
|
82 |
}
|
|
83 |
|
|
84 |
public void performDefaults() {
|
|
85 |
restoreDefaults();
|
|
86 |
}
|
|
87 |
|
|
88 |
public boolean performOk() {
|
|
89 |
storeValues();
|
|
90 |
return super.performOk();
|
|
91 |
}
|
|
92 |
|
|
93 |
private void restoreDefaults() {
|
|
94 |
ignoreWidget.setIgnoreItems(defaultStore.getIgnoreItems());
|
|
95 |
}
|
|
96 |
|
|
97 |
private void storeValues() {
|
|
98 |
instanceStore.setIgnoreItems(ignoreWidget.getIgnoreItems());
|
|
99 |
}
|
|
100 |
}
|