Lines 16-21
Link Here
|
16 |
* correcting "Restore Defaults" behavior |
16 |
* correcting "Restore Defaults" behavior |
17 |
* Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874] |
17 |
* Diego Sandin (Motorola) - Use Eclipse Message Bundles [Bug 255874] |
18 |
* Gustavo de Paula (Motorola) - Preverifier api refactoring |
18 |
* Gustavo de Paula (Motorola) - Preverifier api refactoring |
|
|
19 |
* Gustavo de Paula (Motorola) - Change preverification to add proguard support |
20 |
* David Aragao (Motorola) - Preverification type availability |
19 |
*/ |
21 |
*/ |
20 |
package org.eclipse.mtj.internal.ui.preferences; |
22 |
package org.eclipse.mtj.internal.ui.preferences; |
21 |
|
23 |
|
Lines 33-42
Link Here
|
33 |
import org.eclipse.core.runtime.Platform; |
34 |
import org.eclipse.core.runtime.Platform; |
34 |
import org.eclipse.core.runtime.SubProgressMonitor; |
35 |
import org.eclipse.core.runtime.SubProgressMonitor; |
35 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
36 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
|
|
37 |
import org.eclipse.jdt.core.IJavaProject; |
36 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
38 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
|
|
39 |
import org.eclipse.jface.preference.FieldEditorPreferencePage; |
37 |
import org.eclipse.jface.preference.FileFieldEditor; |
40 |
import org.eclipse.jface.preference.FileFieldEditor; |
38 |
import org.eclipse.jface.preference.IPreferenceStore; |
41 |
import org.eclipse.jface.preference.IPreferenceStore; |
39 |
import org.eclipse.jface.preference.PreferencePage; |
42 |
import org.eclipse.jface.preference.RadioGroupFieldEditor; |
|
|
43 |
import org.eclipse.jface.util.IPropertyChangeListener; |
44 |
import org.eclipse.jface.util.PropertyChangeEvent; |
40 |
import org.eclipse.mtj.core.MTJCore; |
45 |
import org.eclipse.mtj.core.MTJCore; |
41 |
import org.eclipse.mtj.core.build.preverifier.IPreverifier; |
46 |
import org.eclipse.mtj.core.build.preverifier.IPreverifier; |
42 |
import org.eclipse.mtj.core.sdk.device.IAPI; |
47 |
import org.eclipse.mtj.core.sdk.device.IAPI; |
Lines 41-46
Link Here
|
41 |
import org.eclipse.mtj.core.build.preverifier.IPreverifier; |
46 |
import org.eclipse.mtj.core.build.preverifier.IPreverifier; |
42 |
import org.eclipse.mtj.core.sdk.device.IAPI; |
47 |
import org.eclipse.mtj.core.sdk.device.IAPI; |
43 |
import org.eclipse.mtj.internal.core.IMTJCoreConstants; |
48 |
import org.eclipse.mtj.internal.core.IMTJCoreConstants; |
|
|
49 |
import org.eclipse.mtj.internal.core.PreferenceAccessor; |
44 |
import org.eclipse.mtj.internal.core.sdk.device.midp.Configuration; |
50 |
import org.eclipse.mtj.internal.core.sdk.device.midp.Configuration; |
45 |
import org.eclipse.mtj.internal.core.util.log.MTJLogger; |
51 |
import org.eclipse.mtj.internal.core.util.log.MTJLogger; |
46 |
import org.eclipse.mtj.internal.ui.IEmbeddableWorkbenchPreferencePage; |
52 |
import org.eclipse.mtj.internal.ui.IEmbeddableWorkbenchPreferencePage; |
Lines 64-479
Link Here
|
64 |
* |
70 |
* |
65 |
* @author Craig Setera |
71 |
* @author Craig Setera |
66 |
*/ |
72 |
*/ |
67 |
public class PreverificationPreferencePage extends PreferencePage implements |
73 |
public class PreverificationPreferencePage extends FieldEditorPreferencePage |
68 |
IEmbeddableWorkbenchPreferencePage { |
74 |
implements IEmbeddableWorkbenchPreferencePage { |
|
|
75 |
|
76 |
private static final String[] BUTTON_TEXTS = new String[] { |
77 |
MTJUIMessages.PreverificationPreferencePage_use_jad_settings_label_text, |
78 |
MTJUIMessages.PreverificationPreferencePage_use_project_settings_label_text, |
79 |
MTJUIMessages.PreverificationPreferencePage_use_specific_config_label_text, }; |
80 |
|
81 |
private static final String[] CONFIG_FILE_LOCATIONS = new String[] { |
82 |
IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION_JAD, |
83 |
IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION_PLATFORM, |
84 |
IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION_SPECIFIED, }; |
85 |
|
86 |
private Combo configCombo; |
87 |
private IAPI[] configSpecs; |
88 |
private FileFieldEditor defaultPreverifierField; |
89 |
private Group defaultPreverifierGroup; |
90 |
private boolean embeddedInProperties; |
69 |
|
91 |
|
70 |
private static final String[] BUTTON_TEXTS = new String[] { |
92 |
// The java project on which this MIDlet suite is based |
71 |
MTJUIMessages.PreverificationPreferencePage_use_jad_settings_label_text, |
93 |
private IJavaProject javaProject; |
72 |
MTJUIMessages.PreverificationPreferencePage_use_project_settings_label_text, |
|
|
73 |
MTJUIMessages.PreverificationPreferencePage_use_specific_config_label_text, }; |
74 |
|
94 |
|
75 |
private static final String[] CONFIG_FILE_LOCATIONS = new String[] { |
95 |
private Button[] preverificationRadios; |
76 |
IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION_JAD, |
|
|
77 |
IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION_PLATFORM, |
78 |
IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION_SPECIFIED, }; |
79 |
|
96 |
|
80 |
private Combo configCombo; |
97 |
private RadioGroupFieldEditor radioGroupFieldEditor; |
81 |
private IAPI[] configSpecs; |
|
|
82 |
private FileFieldEditor defaultPreverifierField; |
83 |
private boolean embeddedInProperties; |
84 |
|
98 |
|
85 |
private Button[] preverificationRadios; |
99 |
/** |
|
|
100 |
* Default constructor. |
101 |
*/ |
102 |
public PreverificationPreferencePage() { |
103 |
this(false, MTJUIPlugin.getDefault().getCorePreferenceStore()); |
104 |
} |
86 |
|
105 |
|
87 |
/** |
106 |
/** |
88 |
* Default constructor. |
107 |
* Constructor for use when embedding the preference page within a |
89 |
*/ |
108 |
* properties page. |
90 |
public PreverificationPreferencePage() { |
109 |
* |
91 |
this(false, MTJUIPlugin.getDefault().getCorePreferenceStore()); |
110 |
* @param embeddedInProperties |
92 |
} |
111 |
* @param preferenceStore |
|
|
112 |
* a table mapping named preferences to values |
113 |
*/ |
114 |
public PreverificationPreferencePage(boolean embeddedInProperties, |
115 |
IPreferenceStore preferenceStore) { |
93 |
|
116 |
|
94 |
/** |
117 |
this.embeddedInProperties = embeddedInProperties; |
95 |
* Constructor for use when embedding the preference page within a |
118 |
setPreferenceStore(preferenceStore); |
96 |
* properties page. |
119 |
configSpecs = Configuration.values(); |
97 |
* |
120 |
} |
98 |
* @param embeddedInProperties |
|
|
99 |
* @param preferenceStore a table mapping named preferences to values |
100 |
*/ |
101 |
public PreverificationPreferencePage(boolean embeddedInProperties, |
102 |
IPreferenceStore preferenceStore) { |
103 |
|
121 |
|
104 |
this.embeddedInProperties = embeddedInProperties; |
122 |
/** |
105 |
setPreferenceStore(preferenceStore); |
123 |
* Launch the build of the MIDlet suites. |
106 |
configSpecs = Configuration.values(); |
124 |
* |
107 |
} |
125 |
* @param toBuild |
|
|
126 |
*/ |
127 |
public void doBuild(final IProject[] toBuild) { |
128 |
// The work to be done. |
129 |
IRunnableWithProgress runnable = new IRunnableWithProgress() { |
130 |
public void run(IProgressMonitor monitor) |
131 |
throws InvocationTargetException { |
132 |
try { |
133 |
for (int i = 0; i < toBuild.length; i++) { |
134 |
SubProgressMonitor subMonitor = new SubProgressMonitor( |
135 |
monitor, IProgressMonitor.UNKNOWN); |
136 |
toBuild[i].build(IncrementalProjectBuilder.FULL_BUILD, |
137 |
subMonitor); |
138 |
subMonitor.done(); |
139 |
} |
140 |
} catch (CoreException e) { |
141 |
throw new InvocationTargetException(e); |
142 |
} |
143 |
} |
144 |
}; |
145 |
try { |
146 |
PlatformUI.getWorkbench().getProgressService().busyCursorWhile( |
147 |
runnable); |
148 |
} catch (InterruptedException e) { |
149 |
} catch (InvocationTargetException e) { |
150 |
MTJLogger |
151 |
.log( |
152 |
IStatus.WARNING, |
153 |
MTJUIMessages.PreverificationPreferencePage_error_build_suite, |
154 |
e.getCause()); |
155 |
} |
156 |
} |
108 |
|
157 |
|
109 |
/** |
158 |
/* |
110 |
* Launch the build of the MIDlet suites. |
159 |
* (non-Javadoc) |
111 |
* |
160 |
* |
112 |
* @param toBuild |
161 |
* @see |
113 |
*/ |
162 |
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) |
114 |
public void doBuild(final IProject[] toBuild) { |
163 |
*/ |
115 |
// The work to be done. |
164 |
public void init(IWorkbench workbench) { |
116 |
IRunnableWithProgress runnable = new IRunnableWithProgress() { |
165 |
} |
117 |
public void run(IProgressMonitor monitor) |
|
|
118 |
throws InvocationTargetException { |
119 |
try { |
120 |
for (int i = 0; i < toBuild.length; i++) { |
121 |
SubProgressMonitor subMonitor = new SubProgressMonitor( |
122 |
monitor, IProgressMonitor.UNKNOWN); |
123 |
toBuild[i].build(IncrementalProjectBuilder.FULL_BUILD, |
124 |
subMonitor); |
125 |
subMonitor.done(); |
126 |
} |
127 |
} catch (CoreException e) { |
128 |
throw new InvocationTargetException(e); |
129 |
} |
130 |
} |
131 |
}; |
132 |
try { |
133 |
PlatformUI.getWorkbench().getProgressService().busyCursorWhile( |
134 |
runnable); |
135 |
} catch (InterruptedException e) { |
136 |
} catch (InvocationTargetException e) { |
137 |
MTJLogger |
138 |
.log( |
139 |
IStatus.WARNING, |
140 |
MTJUIMessages.PreverificationPreferencePage_error_build_suite, |
141 |
e.getCause()); |
142 |
} |
143 |
} |
144 |
|
166 |
|
145 |
/* (non-Javadoc) |
167 |
/* |
146 |
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) |
168 |
* (non-Javadoc) |
147 |
*/ |
169 |
* |
148 |
public void init(IWorkbench workbench) { |
170 |
* @see org.eclipse.jface.preference.PreferencePage#performApply() |
149 |
} |
171 |
*/ |
|
|
172 |
@Override |
173 |
public void performApply() { |
174 |
super.performApply(); |
175 |
} |
150 |
|
176 |
|
151 |
/* (non-Javadoc) |
177 |
/* |
152 |
* @see org.eclipse.jface.preference.PreferencePage#performApply() |
178 |
* (non-Javadoc) |
153 |
*/ |
179 |
* |
154 |
@Override |
180 |
* @see org.eclipse.jface.preference.PreferencePage#performDefaults() |
155 |
public void performApply() { |
181 |
*/ |
156 |
super.performApply(); |
182 |
@Override |
157 |
} |
183 |
public void performDefaults() { |
|
|
184 |
setControlsFromDefaults(); |
185 |
super.performDefaults(); |
186 |
} |
158 |
|
187 |
|
159 |
/* (non-Javadoc) |
188 |
/* |
160 |
* @see org.eclipse.jface.preference.PreferencePage#performDefaults() |
189 |
* (non-Javadoc) |
161 |
*/ |
190 |
* |
162 |
@Override |
191 |
* @see org.eclipse.jface.preference.PreferencePage#performOk() |
163 |
public void performDefaults() { |
192 |
*/ |
164 |
setControlsFromDefaults(); |
193 |
@Override |
165 |
super.performDefaults(); |
194 |
public boolean performOk() { |
166 |
} |
195 |
setPreferencesFromControls(); |
|
|
196 |
if (!embeddedInProperties) { |
197 |
buildSuites(); |
198 |
} |
167 |
|
199 |
|
168 |
/* (non-Javadoc) |
200 |
return super.performOk(); |
169 |
* @see org.eclipse.jface.preference.PreferencePage#performOk() |
201 |
} |
170 |
*/ |
|
|
171 |
@Override |
172 |
public boolean performOk() { |
173 |
setPreferencesFromControls(); |
174 |
if (!embeddedInProperties) { |
175 |
buildSuites(); |
176 |
} |
177 |
|
202 |
|
178 |
return super.performOk(); |
203 |
/** |
179 |
} |
204 |
* Add the controls for choosing the preverification configuration. |
|
|
205 |
* |
206 |
* @param composite |
207 |
*/ |
208 |
private void addConfigurationControls(Composite composite) { |
209 |
Group preverifyConfigGroup = new Group(composite, SWT.NONE); |
210 |
preverifyConfigGroup |
211 |
.setText(MTJUIMessages.PreverificationPreferencePage_preverifyConfigGroup_label_text); |
212 |
preverifyConfigGroup.setLayout(new GridLayout(1, false)); |
213 |
preverifyConfigGroup.setLayoutData(new GridData( |
214 |
GridData.FILL_HORIZONTAL)); |
180 |
|
215 |
|
181 |
/** |
216 |
preverificationRadios = new Button[BUTTON_TEXTS.length]; |
182 |
* Add the controls for choosing the preverification configuration. |
217 |
for (int i = 0; i < BUTTON_TEXTS.length; i++) { |
183 |
* |
218 |
preverificationRadios[i] = new Button(preverifyConfigGroup, |
184 |
* @param composite |
219 |
SWT.RADIO); |
185 |
*/ |
220 |
preverificationRadios[i].setText(BUTTON_TEXTS[i]); |
186 |
private void addConfigurationControls(Composite composite) { |
|
|
187 |
Group preverifyConfigGroup = new Group(composite, SWT.NONE); |
188 |
preverifyConfigGroup |
189 |
.setText(MTJUIMessages.PreverificationPreferencePage_preverifyConfigGroup_label_text); |
190 |
preverifyConfigGroup.setLayout(new GridLayout(1, false)); |
191 |
preverifyConfigGroup.setLayoutData(new GridData( |
192 |
GridData.FILL_HORIZONTAL)); |
193 |
|
221 |
|
194 |
preverificationRadios = new Button[BUTTON_TEXTS.length]; |
222 |
if (CONFIG_FILE_LOCATIONS[i] |
195 |
for (int i = 0; i < BUTTON_TEXTS.length; i++) { |
223 |
.equals(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION_SPECIFIED)) { |
196 |
preverificationRadios[i] = new Button(preverifyConfigGroup, |
224 |
addSpecificConfigurationControls(preverifyConfigGroup); |
197 |
SWT.RADIO); |
225 |
} |
198 |
preverificationRadios[i].setText(BUTTON_TEXTS[i]); |
226 |
} |
|
|
227 |
} |
199 |
|
228 |
|
200 |
if (CONFIG_FILE_LOCATIONS[i] |
229 |
/** |
201 |
.equals(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION_SPECIFIED)) { |
230 |
* Add the controls for setting the default preverifier. |
202 |
addSpecificConfigurationControls(preverifyConfigGroup); |
231 |
* |
203 |
} |
232 |
* @param composite |
204 |
} |
233 |
*/ |
205 |
} |
234 |
private void addDefaultPreverifierControls(Composite composite) { |
|
|
235 |
defaultPreverifierGroup = new Group(composite, SWT.NONE); |
236 |
defaultPreverifierGroup |
237 |
.setText(MTJUIMessages.PreverificationPreferencePage_defaultPreverifierGroup_label_text); |
238 |
defaultPreverifierGroup.setLayout(new GridLayout(3, false)); |
239 |
defaultPreverifierGroup.setLayoutData(new GridData( |
240 |
GridData.FILL_HORIZONTAL)); |
206 |
|
241 |
|
207 |
/** |
242 |
Label tip = new Label(defaultPreverifierGroup, SWT.NONE); |
208 |
* Add the controls for setting the default preverifier. |
243 |
tip |
209 |
* |
244 |
.setText(MTJUIMessages.PreverificationPreferencePage_defaultPreverifierTip_label_text); |
210 |
* @param composite |
245 |
GridData gd = new GridData(); |
211 |
*/ |
246 |
gd.horizontalSpan = 3; |
212 |
private void addDefaultPreverifierControls(Composite composite) { |
247 |
gd.verticalIndent = 10; |
213 |
Group defaultPreverifierGroup = new Group(composite, SWT.NONE); |
248 |
tip.setLayoutData(gd); |
214 |
defaultPreverifierGroup |
|
|
215 |
.setText(MTJUIMessages.PreverificationPreferencePage_defaultPreverifierGroup_label_text); |
216 |
defaultPreverifierGroup.setLayout(new GridLayout(3, false)); |
217 |
defaultPreverifierGroup.setLayoutData(new GridData( |
218 |
GridData.FILL_HORIZONTAL)); |
219 |
|
249 |
|
220 |
Label tip = new Label(defaultPreverifierGroup, SWT.NONE); |
250 |
defaultPreverifierField = new FileFieldEditor( |
221 |
tip |
251 |
IMTJCoreConstants.PREF_DEFAULT_PREVERIFIER, |
222 |
.setText(MTJUIMessages.PreverificationPreferencePage_defaultPreverifierTip_label_text); |
252 |
MTJUIMessages.PreverificationPreferencePage_defaultPreverifierField_label_text, |
223 |
GridData gd = new GridData(); |
253 |
defaultPreverifierGroup); |
224 |
gd.horizontalSpan = 3; |
|
|
225 |
gd.verticalIndent = 10; |
226 |
tip.setLayoutData(gd); |
227 |
|
254 |
|
228 |
defaultPreverifierField = new FileFieldEditor( |
255 |
String[] extensions = null; |
229 |
IMTJCoreConstants.PREF_DEFAULT_PREVERIFIER, |
256 |
if (Platform.getOS().equals(Platform.OS_WIN32)) { |
230 |
MTJUIMessages.PreverificationPreferencePage_defaultPreverifierField_label_text, |
257 |
extensions = new String[] { "*.exe" }; //$NON-NLS-1$ |
231 |
defaultPreverifierGroup); |
258 |
} |
|
|
259 |
defaultPreverifierField.setFileExtensions(extensions); |
260 |
defaultPreverifierField.setPreferenceStore(getPreferenceStore()); |
261 |
} |
232 |
|
262 |
|
233 |
String[] extensions = null; |
263 |
/** |
234 |
if (Platform.getOS().equals(Platform.OS_WIN32)) { |
264 |
* Add the configuration specific controls. |
235 |
extensions = new String[] { "*.exe" }; //$NON-NLS-1$ |
265 |
* |
236 |
} |
266 |
* @param preverifyConfigGroup |
237 |
defaultPreverifierField.setFileExtensions(extensions); |
267 |
* @throws CoreException |
238 |
defaultPreverifierField.setPreferenceStore(getPreferenceStore()); |
268 |
*/ |
239 |
} |
269 |
private void addSpecificConfigurationControls(Group preverifyConfigGroup) { |
|
|
270 |
configCombo = new Combo(preverifyConfigGroup, SWT.READ_ONLY); |
271 |
GridData gridData = new GridData(GridData.FILL_HORIZONTAL); |
272 |
gridData.horizontalIndent = 15; |
273 |
configCombo.setLayoutData(gridData); |
240 |
|
274 |
|
241 |
/** |
275 |
String[] displayValues = new String[configSpecs.length]; |
242 |
* Add the configuration specific controls. |
276 |
for (int i = 0; i < displayValues.length; i++) { |
243 |
* |
277 |
displayValues[i] = configSpecs[i].getName(); |
244 |
* @param preverifyConfigGroup |
278 |
} |
245 |
* @throws CoreException |
|
|
246 |
*/ |
247 |
private void addSpecificConfigurationControls(Group preverifyConfigGroup) { |
248 |
configCombo = new Combo(preverifyConfigGroup, SWT.READ_ONLY); |
249 |
GridData gridData = new GridData(GridData.FILL_HORIZONTAL); |
250 |
gridData.horizontalIndent = 15; |
251 |
configCombo.setLayoutData(gridData); |
252 |
|
279 |
|
253 |
String[] displayValues = new String[configSpecs.length]; |
280 |
configCombo.setItems(displayValues); |
254 |
for (int i = 0; i < displayValues.length; i++) { |
281 |
} |
255 |
displayValues[i] = configSpecs[i].getName(); |
|
|
256 |
} |
257 |
|
282 |
|
258 |
configCombo.setItems(displayValues); |
283 |
/** |
259 |
} |
284 |
* Build the midlet suites in the workspace because preverification settings |
|
|
285 |
* have changed. |
286 |
*/ |
287 |
private void buildSuites() { |
288 |
// TODO Add some more smarts to what needs to get rebuilt. |
289 |
IWorkspaceRoot root = MTJCore.getWorkspace().getRoot(); |
290 |
IProject[] projects = root.getProjects(); |
260 |
|
291 |
|
261 |
/** |
292 |
ArrayList<IProject> toBuild = new ArrayList<IProject>(); |
262 |
* Build the midlet suites in the workspace because preverification settings |
|
|
263 |
* have changed. |
264 |
*/ |
265 |
private void buildSuites() { |
266 |
// TODO Add some more smarts to what needs to get rebuilt. |
267 |
IWorkspaceRoot root = MTJCore.getWorkspace().getRoot(); |
268 |
IProject[] projects = root.getProjects(); |
269 |
|
293 |
|
270 |
ArrayList<IProject> toBuild = new ArrayList<IProject>(); |
294 |
// Collect the projects to be built |
|
|
295 |
for (int i = 0; i < projects.length; i++) { |
296 |
IProject project = projects[i]; |
271 |
|
297 |
|
272 |
// Collect the projects to be built |
298 |
try { |
273 |
for (int i = 0; i < projects.length; i++) { |
299 |
if (project.isOpen() |
274 |
IProject project = projects[i]; |
300 |
&& project.hasNature(IMTJCoreConstants.MTJ_NATURE_ID) |
|
|
301 |
&& !usesProjectSpecificPreverification(project)) { |
302 |
toBuild.add(project); |
303 |
} |
304 |
} catch (CoreException e) { |
305 |
MTJLogger |
306 |
.log( |
307 |
IStatus.ERROR, |
308 |
MTJUIMessages.PreverificationPreferencePage_error_build_midlet_suite, |
309 |
e); |
310 |
} |
311 |
} |
275 |
|
312 |
|
276 |
try { |
313 |
// Do the build of those projects |
277 |
if (project.isOpen() |
314 |
IProject[] projectArray = toBuild.toArray(new IProject[toBuild.size()]); |
278 |
&& project.hasNature(IMTJCoreConstants.MTJ_NATURE_ID) |
315 |
if (projectArray.length > 0) { |
279 |
&& !usesProjectSpecificPreverification(project)) { |
316 |
doBuild(projectArray); |
280 |
toBuild.add(project); |
317 |
} |
281 |
} |
318 |
} |
282 |
} catch (CoreException e) { |
|
|
283 |
MTJLogger |
284 |
.log( |
285 |
IStatus.ERROR, |
286 |
MTJUIMessages.PreverificationPreferencePage_error_build_midlet_suite, |
287 |
e); |
288 |
} |
289 |
} |
290 |
|
319 |
|
291 |
// Do the build of those projects |
320 |
private void setControlsFromDefaults() { |
292 |
IProject[] projectArray = toBuild.toArray(new IProject[toBuild.size()]); |
321 |
if (preverificationRadios != null) { |
293 |
if (projectArray.length > 0) { |
322 |
IPreferenceStore store = getPreferenceStore(); |
294 |
doBuild(projectArray); |
323 |
String location = store |
295 |
} |
324 |
.getDefaultString(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION); |
296 |
} |
325 |
for (int i = 0; i < preverificationRadios.length; i++) { |
|
|
326 |
String fieldValue = CONFIG_FILE_LOCATIONS[i]; |
327 |
preverificationRadios[i].setSelection(fieldValue |
328 |
.equals(location)); |
329 |
} |
330 |
|
331 |
|
332 |
IPreferenceStore preverifierTypestore = radioGroupFieldEditor |
333 |
.getPreferenceStore(); |
334 |
|
335 |
String preverifyType = preverifierTypestore |
336 |
.getString(IMTJCoreConstants.PREF_PREVERIFY_TYPE); |
337 |
if (preverifyType.equals("preverify_default")) { |
338 |
defaultPreverifierField.setEnabled(true, |
339 |
defaultPreverifierGroup); |
340 |
} else { |
341 |
defaultPreverifierField.setEnabled(false, |
342 |
defaultPreverifierGroup); |
343 |
} |
297 |
|
344 |
|
298 |
private void setControlsFromDefaults() { |
345 |
int specIndex = 0; |
299 |
if (preverificationRadios != null) { |
346 |
String config = store |
300 |
IPreferenceStore store = getPreferenceStore(); |
347 |
.getDefaultString(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_VALUE); |
301 |
String location = store |
348 |
for (int i = 0; i < configSpecs.length; i++) { |
302 |
.getDefaultString(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION); |
349 |
IAPI spec = configSpecs[i]; |
303 |
for (int i = 0; i < preverificationRadios.length; i++) { |
350 |
if (spec.getIdentifier().equals(config)) { |
304 |
String fieldValue = CONFIG_FILE_LOCATIONS[i]; |
351 |
specIndex = i; |
305 |
preverificationRadios[i].setSelection(fieldValue |
352 |
break; |
306 |
.equals(location)); |
353 |
} |
307 |
} |
354 |
} |
308 |
|
355 |
|
309 |
int specIndex = 0; |
356 |
configCombo.select(specIndex); |
310 |
String config = store |
357 |
} |
311 |
.getDefaultString(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_VALUE); |
|
|
312 |
for (int i = 0; i < configSpecs.length; i++) { |
313 |
IAPI spec = configSpecs[i]; |
314 |
if (spec.toString().equals(config)) { |
315 |
specIndex = i; |
316 |
break; |
317 |
} |
318 |
} |
319 |
|
358 |
|
320 |
configCombo.select(specIndex); |
359 |
if (defaultPreverifierField != null) { |
321 |
} |
360 |
defaultPreverifierField.loadDefault(); |
|
|
361 |
} |
362 |
} |
322 |
|
363 |
|
323 |
if (defaultPreverifierField != null) { |
364 |
/** |
324 |
defaultPreverifierField.loadDefault(); |
365 |
* Set the state of the controls based on the preferences. |
325 |
} |
366 |
*/ |
326 |
} |
367 |
private void setControlsFromPreferences() { |
|
|
368 |
if (preverificationRadios != null) { |
369 |
IPreferenceStore store = getPreferenceStore(); |
370 |
String location = store |
371 |
.getString(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION); |
372 |
for (int i = 0; i < preverificationRadios.length; i++) { |
373 |
String fieldValue = CONFIG_FILE_LOCATIONS[i]; |
374 |
preverificationRadios[i].setSelection(fieldValue |
375 |
.equals(location)); |
376 |
} |
327 |
|
377 |
|
328 |
/** |
378 |
IPreferenceStore preverifierTypestore = radioGroupFieldEditor |
329 |
* Set the state of the controls based on the preferences. |
379 |
.getPreferenceStore(); |
330 |
*/ |
380 |
String asd = preverifierTypestore |
331 |
private void setControlsFromPreferences() { |
381 |
.getString(IMTJCoreConstants.PREF_PREVERIFY_TYPE); |
332 |
if (preverificationRadios != null) { |
382 |
if (asd.equals("preverify_default")) { |
333 |
IPreferenceStore store = getPreferenceStore(); |
383 |
defaultPreverifierField.setEnabled(true, |
334 |
String location = store |
384 |
defaultPreverifierGroup); |
335 |
.getString(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION); |
385 |
} else { |
336 |
for (int i = 0; i < preverificationRadios.length; i++) { |
386 |
defaultPreverifierField.setEnabled(false, |
337 |
String fieldValue = CONFIG_FILE_LOCATIONS[i]; |
387 |
defaultPreverifierGroup); |
338 |
preverificationRadios[i].setSelection(fieldValue |
388 |
} |
339 |
.equals(location)); |
|
|
340 |
} |
341 |
|
389 |
|
342 |
int specIndex = 0; |
390 |
int specIndex = 0; |
343 |
String config = store |
391 |
String config = store |
344 |
.getString(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_VALUE); |
392 |
.getString(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_VALUE); |
345 |
for (int i = 0; i < configSpecs.length; i++) { |
393 |
for (int i = 0; i < configSpecs.length; i++) { |
346 |
IAPI spec = configSpecs[i]; |
394 |
IAPI spec = configSpecs[i]; |
347 |
if (spec.toString().equals(config)) { |
395 |
if (spec.getIdentifier().equals(config)) { |
348 |
specIndex = i; |
396 |
specIndex = i; |
349 |
break; |
397 |
break; |
350 |
} |
398 |
} |
351 |
} |
399 |
} |
352 |
|
400 |
|
353 |
configCombo.select(specIndex); |
401 |
configCombo.select(specIndex); |
354 |
} |
402 |
} |
355 |
if (defaultPreverifierField != null) { |
403 |
if (defaultPreverifierField != null) { |
356 |
defaultPreverifierField.load(); |
404 |
defaultPreverifierField.load(); |
357 |
} |
405 |
} |
358 |
} |
406 |
} |
359 |
|
407 |
|
360 |
private void setDefaultPreverifier() { |
408 |
private void setDefaultPreverifier() { |
361 |
// if the default preverifier value changed |
409 |
// if the default preverifier value changed |
362 |
if (!defaultPreverifierField.getStringValue().equals( |
410 |
if (!defaultPreverifierField.getStringValue().equals( |
363 |
getPreferenceStore().getString( |
411 |
getPreferenceStore().getString( |
364 |
IMTJCoreConstants.PREF_DEFAULT_PREVERIFIER))) { |
412 |
IMTJCoreConstants.PREF_DEFAULT_PREVERIFIER))) { |
365 |
File preverifierExecutable = new File(defaultPreverifierField |
413 |
File preverifierExecutable = new File(defaultPreverifierField |
366 |
.getStringValue()); |
414 |
.getStringValue()); |
367 |
IPreverifier preverifier = null; |
415 |
IPreverifier preverifier = null; |
368 |
try { |
416 |
try { |
369 |
preverifier = MTJCore.createPreverifier( |
417 |
preverifier = MTJCore.createPreverifier( |
370 |
IPreverifier.PREVERIFIER_STANDARD, |
418 |
IPreverifier.PREVERIFIER_STANDARD, |
371 |
preverifierExecutable); |
419 |
preverifierExecutable); |
372 |
} catch (CoreException e) { |
420 |
} catch (CoreException e) { |
373 |
MTJUIPlugin |
421 |
MTJUIPlugin |
374 |
.displayError( |
422 |
.displayError( |
375 |
getShell(), |
423 |
getShell(), |
376 |
IStatus.ERROR, |
424 |
IStatus.ERROR, |
377 |
-999, |
425 |
-999, |
378 |
MTJUIMessages.PreverificationPreferencePage_invalid_preverifier_dialog_title, |
426 |
MTJUIMessages.PreverificationPreferencePage_invalid_preverifier_dialog_title, |
379 |
MTJUIMessages.PreverificationPreferencePage_invalid_preverifier_dialog_message, |
427 |
MTJUIMessages.PreverificationPreferencePage_invalid_preverifier_dialog_message, |
380 |
e); |
428 |
e); |
381 |
MTJLogger |
429 |
MTJLogger |
382 |
.log( |
430 |
.log( |
383 |
IStatus.ERROR, |
431 |
IStatus.ERROR, |
384 |
NLS |
432 |
NLS |
385 |
.bind( |
433 |
.bind( |
386 |
MTJUIMessages.PreverificationPreferencePage_device_store_error, |
434 |
MTJUIMessages.PreverificationPreferencePage_device_store_error, |
387 |
new String[] { |
435 |
new String[] { |
388 |
e.getClass().getName(), |
436 |
e.getClass().getName(), |
389 |
e.getMessage() }), e); |
437 |
e.getMessage() }), e); |
390 |
} |
438 |
} |
391 |
MTJCore.getDeviceRegistry().setDefaultPreverifer(preverifier); |
439 |
MTJCore.getDeviceRegistry().setDefaultPreverifer(preverifier); |
392 |
|
440 |
|
393 |
try { |
441 |
try { |
394 |
MTJCore.getDeviceRegistry().store(); |
442 |
MTJCore.getDeviceRegistry().store(); |
395 |
} catch (Exception e) { |
443 |
} catch (Exception e) { |
396 |
MTJUIPlugin |
444 |
MTJUIPlugin |
397 |
.displayError( |
445 |
.displayError( |
398 |
getShell(), |
446 |
getShell(), |
399 |
IStatus.ERROR, |
447 |
IStatus.ERROR, |
400 |
-999, |
448 |
-999, |
401 |
MTJUIMessages.PreverificationPreferencePage_error_store_preverifier_dialog_title, |
449 |
MTJUIMessages.PreverificationPreferencePage_error_store_preverifier_dialog_title, |
402 |
MTJUIMessages.PreverificationPreferencePage_error_store_preverifier_dialog_message, |
450 |
MTJUIMessages.PreverificationPreferencePage_error_store_preverifier_dialog_message, |
403 |
e); |
451 |
e); |
404 |
MTJLogger |
452 |
MTJLogger |
405 |
.log( |
453 |
.log( |
406 |
IStatus.ERROR, |
454 |
IStatus.ERROR, |
407 |
NLS |
455 |
NLS |
408 |
.bind( |
456 |
.bind( |
409 |
MTJUIMessages.PreverificationPreferencePage_device_store_error, |
457 |
MTJUIMessages.PreverificationPreferencePage_device_store_error, |
410 |
new String[] { |
458 |
new String[] { |
411 |
e.getClass().getName(), |
459 |
e.getClass().getName(), |
412 |
e.getMessage() }), e); |
460 |
e.getMessage() }), e); |
413 |
} |
461 |
} |
414 |
} |
462 |
} |
415 |
|
463 |
|
416 |
} |
464 |
} |
417 |
|
465 |
|
418 |
/** |
466 |
/** |
419 |
* Set the state of the preferences based on the controls. |
467 |
* Set the state of the preferences based on the controls. |
420 |
*/ |
468 |
*/ |
421 |
private void setPreferencesFromControls() { |
469 |
private void setPreferencesFromControls() { |
422 |
IPreferenceStore store = getPreferenceStore(); |
470 |
IPreferenceStore store = getPreferenceStore(); |
423 |
for (int i = 0; i < preverificationRadios.length; i++) { |
471 |
for (int i = 0; i < preverificationRadios.length; i++) { |
424 |
if (preverificationRadios[i].getSelection()) { |
472 |
if (preverificationRadios[i].getSelection()) { |
425 |
store.setValue( |
473 |
store.setValue( |
426 |
IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION, |
474 |
IMTJCoreConstants.PREF_PREVERIFY_CONFIG_LOCATION, |
427 |
CONFIG_FILE_LOCATIONS[i]); |
475 |
CONFIG_FILE_LOCATIONS[i]); |
428 |
break; |
476 |
break; |
429 |
} |
477 |
} |
430 |
} |
478 |
} |
431 |
|
479 |
|
432 |
int index = configCombo.getSelectionIndex(); |
480 |
int index = configCombo.getSelectionIndex(); |
433 |
store.setValue(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_VALUE, |
481 |
store.setValue(IMTJCoreConstants.PREF_PREVERIFY_CONFIG_VALUE, |
434 |
configSpecs[index].toString()); |
482 |
configSpecs[index].getIdentifier()); |
435 |
if (defaultPreverifierField != null) { |
483 |
if (defaultPreverifierField != null) { |
436 |
setDefaultPreverifier(); |
484 |
setDefaultPreverifier(); |
437 |
defaultPreverifierField.store(); |
485 |
defaultPreverifierField.store(); |
438 |
} |
486 |
} |
439 |
} |
487 |
} |
440 |
|
488 |
|
441 |
/** |
489 |
/** |
442 |
* Return a boolean indicating if the specified project is using |
490 |
* Return a boolean indicating if the specified project is using |
443 |
* project-specific preverification settings. |
491 |
* project-specific preverification settings. |
444 |
* |
492 |
* |
445 |
* @param project |
493 |
* @param project |
446 |
* @return |
494 |
* @return |
447 |
*/ |
495 |
*/ |
448 |
private boolean usesProjectSpecificPreverification(IProject project) { |
496 |
private boolean usesProjectSpecificPreverification(IProject project) { |
449 |
ProjectScope projectScope = new ProjectScope(project); |
497 |
ProjectScope projectScope = new ProjectScope(project); |
450 |
IEclipsePreferences prefNode = projectScope |
498 |
IEclipsePreferences prefNode = projectScope |
451 |
.getNode(IMTJCoreConstants.PLUGIN_ID); |
499 |
.getNode(IMTJCoreConstants.PLUGIN_ID); |
452 |
|
500 |
|
453 |
return prefNode.getBoolean( |
501 |
return prefNode.getBoolean( |
454 |
IMTJCoreConstants.PREF_PREVERIFY_USE_PROJECT, false); |
502 |
IMTJCoreConstants.PREF_PREVERIFY_USE_PROJECT, false); |
455 |
} |
503 |
} |
456 |
|
504 |
|
457 |
/* (non-Javadoc) |
505 |
/** |
458 |
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite) |
506 |
* Add the controls that are for work-in-progress function. |
459 |
*/ |
507 |
* |
460 |
@Override |
508 |
* @param composite |
461 |
protected Control createContents(Composite parent) { |
509 |
*/ |
|
|
510 |
private void addTypeOfPreverifier(final Composite composite) { |
511 |
radioGroupFieldEditor = new RadioGroupFieldEditor( |
512 |
IMTJCoreConstants.PREF_PREVERIFY_TYPE, |
513 |
"Preverifier to use", |
514 |
1, |
515 |
new String[][] { |
516 |
{ "Default Preverifier", |
517 |
IMTJCoreConstants.PREF_DEFAULT_PREVERIFIER }, |
518 |
{ "Emulator Preverifier", |
519 |
IMTJCoreConstants.PREF_PREVERIFY_TYPE_EMULATOR }, |
520 |
{ "Proguard Preverifier", |
521 |
IMTJCoreConstants.PREF_PREVERIFY_TYPE_PROGUARD } }, |
522 |
composite, true); |
523 |
radioGroupFieldEditor.setPreferenceStore(getPreferenceStore()); |
524 |
radioGroupFieldEditor.load(); |
525 |
radioGroupFieldEditor.fillIntoGrid(composite, 1); |
462 |
|
526 |
|
463 |
Composite composite = new Composite(parent, SWT.NONE); |
527 |
radioGroupFieldEditor |
464 |
composite.setLayout(new GridLayout(1, false)); |
528 |
.setPropertyChangeListener(new IPropertyChangeListener() { |
465 |
composite.setLayoutData(new GridData(GridData.FILL_BOTH)); |
529 |
public void propertyChange(PropertyChangeEvent event) { |
|
|
530 |
String newValue = (String) event.getNewValue(); |
531 |
if (!newValue.equals(event.getOldValue())) { |
532 |
if (newValue.equals("default_preverifier")) { |
533 |
defaultPreverifierField.setEnabled(true, |
534 |
defaultPreverifierGroup); |
535 |
} else if (newValue.equals("preverify_proguard") |
536 |
|| newValue.equals("preverify_emulator")) { |
537 |
defaultPreverifierField.setEnabled(false, |
538 |
defaultPreverifierGroup); |
539 |
} |
540 |
} |
541 |
} |
542 |
}); |
466 |
|
543 |
|
467 |
addConfigurationControls(composite); |
544 |
// * "GeneralPage.DoubleClick", resName, 1, |
|
|
545 |
// * new String[][] { |
546 |
// * {"Open Browser", "open"}, |
547 |
// * {"Expand Tree", "expand"} |
548 |
// * }, |
549 |
// * parent |
468 |
|
550 |
|
469 |
if (!embeddedInProperties) { |
551 |
addField(radioGroupFieldEditor); |
470 |
addDefaultPreverifierControls(composite); |
552 |
} |
471 |
} else { |
|
|
472 |
noDefaultAndApplyButton(); |
473 |
} |
474 |
|
553 |
|
475 |
setControlsFromPreferences(); |
554 |
/* |
|
|
555 |
* (non-Javadoc) |
556 |
* |
557 |
* @see |
558 |
* org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse |
559 |
* .swt.widgets.Composite) |
560 |
*/ |
561 |
@Override |
562 |
protected Control createContents(Composite parent) { |
476 |
|
563 |
|
477 |
return composite; |
564 |
Composite composite = new Composite(parent, SWT.NONE); |
478 |
} |
565 |
composite.setLayout(new GridLayout(1, false)); |
|
|
566 |
composite.setLayoutData(new GridData(GridData.FILL_BOTH)); |
567 |
|
568 |
addConfigurationControls(composite); |
569 |
|
570 |
addTypeOfPreverifier(composite); |
571 |
|
572 |
if (!embeddedInProperties) { |
573 |
addDefaultPreverifierControls(composite); |
574 |
} else { |
575 |
noDefaultAndApplyButton(); |
576 |
} |
577 |
|
578 |
setControlsFromPreferences(); |
579 |
|
580 |
return composite; |
581 |
} |
582 |
|
583 |
private String getPreverifierType() { |
584 |
return PreferenceAccessor.instance.getPreverifierType(getProject()); |
585 |
|
586 |
} |
587 |
|
588 |
public IProject getProject() { |
589 |
return javaProject.getProject(); |
590 |
} |
591 |
|
592 |
@Override |
593 |
protected void createFieldEditors() { |
594 |
// TODO Auto-generated method stub |
595 |
|
596 |
} |
479 |
} |
597 |
} |