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.properties;
|
|
17 |
|
|
18 |
import org.eclipse.core.resources.IProject;
|
|
19 |
import org.eclipse.core.resources.ProjectScope;
|
|
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.swt.SWT;
|
|
25 |
import org.eclipse.swt.custom.BusyIndicator;
|
|
26 |
import org.eclipse.swt.layout.FillLayout;
|
|
27 |
import org.eclipse.swt.widgets.Composite;
|
|
28 |
import org.eclipse.swt.widgets.Control;
|
|
29 |
import org.eclipse.ui.IWorkbenchPropertyPage;
|
|
30 |
import org.eclipse.ui.dialogs.PropertyPage;
|
|
31 |
|
|
32 |
import com.symbian.smt.gui.AbstractPersistentDataStore;
|
|
33 |
import com.symbian.smt.gui.Activator;
|
|
34 |
import com.symbian.smt.gui.ManageResources;
|
|
35 |
import com.symbian.smt.gui.NodeListener;
|
|
36 |
import com.symbian.smt.gui.PersistentDataStore;
|
|
37 |
import com.symbian.smt.gui.preferences.SmmPreferencesInitializer;
|
|
38 |
import com.symbian.smt.gui.smtwidgets.resources.ResourcesWidget;
|
|
39 |
|
|
40 |
public class ResourceProperties extends PropertyPage implements
|
|
41 |
IWorkbenchPropertyPage {
|
|
42 |
|
|
43 |
private ResourcesWidget resourcesWidget;
|
|
44 |
private AbstractPersistentDataStore projectStore;
|
|
45 |
private AbstractPersistentDataStore instanceStore;
|
|
46 |
|
|
47 |
@Override
|
|
48 |
protected Control createContents(Composite parent) {
|
|
49 |
new NodeListener(getProject());
|
|
50 |
|
|
51 |
// Initialise the default values
|
|
52 |
SmmPreferencesInitializer initialiser = new SmmPreferencesInitializer();
|
|
53 |
initialiser.initializeDefaultPreferences();
|
|
54 |
|
|
55 |
// Create the project scope data store
|
|
56 |
IScopeContext projectScope = new ProjectScope(this.getProject());
|
|
57 |
projectStore = new PersistentDataStore(projectScope
|
|
58 |
.getNode(Activator.PLUGIN_ID));
|
|
59 |
|
|
60 |
// Create the default scope data store
|
|
61 |
IScopeContext defaultScope = new DefaultScope();
|
|
62 |
IEclipsePreferences defaultNode = defaultScope
|
|
63 |
.getNode(Activator.PLUGIN_ID);
|
|
64 |
|
|
65 |
IScopeContext instanceScope = new InstanceScope();
|
|
66 |
IEclipsePreferences instanceNode = instanceScope
|
|
67 |
.getNode(Activator.PLUGIN_ID);
|
|
68 |
instanceStore = new PersistentDataStore(instanceNode, defaultNode);
|
|
69 |
|
|
70 |
// Create the widget
|
|
71 |
Composite composite = new Composite(parent, SWT.NONE);
|
|
72 |
composite.setLayout(new FillLayout(SWT.VERTICAL));
|
|
73 |
resourcesWidget = new ResourcesWidget(composite, SWT.NONE);
|
|
74 |
|
|
75 |
// Set required values
|
|
76 |
populate(projectStore);
|
|
77 |
|
|
78 |
return composite;
|
|
79 |
}
|
|
80 |
|
|
81 |
private IProject getProject() {
|
|
82 |
return (IProject) getElement();
|
|
83 |
}
|
|
84 |
|
|
85 |
@Override
|
|
86 |
protected void performApply() {
|
|
87 |
saveChanges();
|
|
88 |
}
|
|
89 |
|
|
90 |
@Override
|
|
91 |
protected void performDefaults() {
|
|
92 |
populate(instanceStore);
|
|
93 |
}
|
|
94 |
|
|
95 |
@Override
|
|
96 |
public boolean performOk() {
|
|
97 |
saveChanges();
|
|
98 |
return super.performOk();
|
|
99 |
}
|
|
100 |
|
|
101 |
private void populate(AbstractPersistentDataStore dataStore) {
|
|
102 |
|
|
103 |
// All files
|
|
104 |
resourcesWidget.setBorderShapesFiles(dataStore.getBorderShapesFiles());
|
|
105 |
resourcesWidget.setBorderStylesFiles(dataStore.getBorderStylesFiles());
|
|
106 |
resourcesWidget.setColoursFiles(dataStore.getColoursFiles());
|
|
107 |
resourcesWidget.setDependenciesFiles(dataStore.getDependenciesFiles());
|
|
108 |
resourcesWidget.setLevelsFiles(dataStore.getLevelsFiles());
|
|
109 |
resourcesWidget.setLocalisationFiles(dataStore.getLocalisationFiles());
|
|
110 |
resourcesWidget.setPatternsFiles(dataStore.getPatternsFiles());
|
|
111 |
resourcesWidget.setShapesFiles(dataStore.getShapesFiles());
|
|
112 |
resourcesWidget.setSystemInfoFiles(dataStore.getSystemInfoFiles());
|
|
113 |
resourcesWidget.setS12XmlFiles(dataStore.getS12XmlFiles());
|
|
114 |
|
|
115 |
// Selected files
|
|
116 |
resourcesWidget.setSelectedBorderShapesFiles(dataStore
|
|
117 |
.getSelectedBorderShapesFiles());
|
|
118 |
resourcesWidget.setSelectedBorderStylesFiles(dataStore
|
|
119 |
.getSelectedBorderStylesFiles());
|
|
120 |
resourcesWidget.setSelectedColoursFiles(dataStore
|
|
121 |
.getSelectedColoursFiles());
|
|
122 |
resourcesWidget.setSelectedDependenciesFiles(dataStore
|
|
123 |
.getSelectedDependenciesFiles());
|
|
124 |
resourcesWidget.setSelectedLevelsFiles(dataStore
|
|
125 |
.getSelectedLevelsFiles());
|
|
126 |
resourcesWidget.setSelectedLocalisationFiles(dataStore
|
|
127 |
.getSelectedLocalisationFiles());
|
|
128 |
resourcesWidget.setSelectedPatternsFiles(dataStore
|
|
129 |
.getSelectedPatternsFiles());
|
|
130 |
resourcesWidget.setSelectedShapesFiles(dataStore
|
|
131 |
.getSelectedShapesFiles());
|
|
132 |
resourcesWidget.setSelectedSystemInfoFiles(dataStore
|
|
133 |
.getSelectedSystemInfoFiles());
|
|
134 |
resourcesWidget.setSelectedS12XmlFiles(dataStore
|
|
135 |
.getSelectedS12XmlFiles());
|
|
136 |
}
|
|
137 |
|
|
138 |
private void saveChanges() {
|
|
139 |
Runnable runnable = new Runnable() {
|
|
140 |
public void run() {
|
|
141 |
// All files
|
|
142 |
projectStore.setBorderShapesFiles(resourcesWidget
|
|
143 |
.getBorderShapesFiles());
|
|
144 |
projectStore.setBorderStylesFiles(resourcesWidget
|
|
145 |
.getBorderStylesFiles());
|
|
146 |
projectStore.setColoursFiles(resourcesWidget.getColoursFiles());
|
|
147 |
projectStore.setDependenciesFiles(resourcesWidget
|
|
148 |
.getDependenciesFiles());
|
|
149 |
projectStore.setLevelsFiles(resourcesWidget.getLevelsFiles());
|
|
150 |
projectStore.setLocalisationFiles(resourcesWidget
|
|
151 |
.getLocalisationFiles());
|
|
152 |
projectStore.setPatternsFiles(resourcesWidget.getPatternsFiles());
|
|
153 |
projectStore.setShapesFiles(resourcesWidget.getShapesFiles());
|
|
154 |
projectStore.setSystemInfoFiles(resourcesWidget.getSystemInfoFiles());
|
|
155 |
projectStore.setS12XmlFiles(resourcesWidget.getS12XmlFiles());
|
|
156 |
|
|
157 |
// Add the folders and files to the project
|
|
158 |
ManageResources.updateShapesFiles(getProject(), resourcesWidget
|
|
159 |
.getSelectedShapesFiles());
|
|
160 |
ManageResources.updateLevelsFiles(getProject(), resourcesWidget
|
|
161 |
.getSelectedLevelsFiles());
|
|
162 |
ManageResources.updateLocalisationFiles(getProject(), resourcesWidget
|
|
163 |
.getSelectedLocalisationFiles());
|
|
164 |
ManageResources.updateDependenciesFiles(getProject(), resourcesWidget
|
|
165 |
.getSelectedDependenciesFiles());
|
|
166 |
ManageResources.updateSystemInfoFiles(getProject(), resourcesWidget
|
|
167 |
.getSelectedSystemInfoFiles());
|
|
168 |
ManageResources.updateColoursFiles(getProject(), resourcesWidget
|
|
169 |
.getSelectedColoursFiles());
|
|
170 |
ManageResources.updateBorderStylesFiles(getProject(), resourcesWidget
|
|
171 |
.getSelectedBorderStylesFiles());
|
|
172 |
ManageResources.updateBorderShapesFiles(getProject(), resourcesWidget
|
|
173 |
.getSelectedBorderShapesFiles());
|
|
174 |
ManageResources.updatePatternsFiles(getProject(), resourcesWidget
|
|
175 |
.getSelectedPatternsFiles());
|
|
176 |
ManageResources.updateS12XmlFiles(getProject(), resourcesWidget
|
|
177 |
.getSelectedS12XmlFiles());
|
|
178 |
}
|
|
179 |
};
|
|
180 |
|
|
181 |
BusyIndicator.showWhile(getShell().getDisplay(), runnable);
|
|
182 |
}
|
|
183 |
|
|
184 |
} |