0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.s60tools.imaker.internal.viewers;
|
|
19 |
|
|
20 |
import java.lang.reflect.InvocationTargetException;
|
|
21 |
import java.util.ArrayList;
|
|
22 |
import java.util.Arrays;
|
|
23 |
import java.util.List;
|
|
24 |
import java.util.Properties;
|
|
25 |
|
|
26 |
import org.eclipse.core.resources.IFile;
|
1
|
27 |
import org.eclipse.core.resources.IResource;
|
0
|
28 |
import org.eclipse.core.runtime.CoreException;
|
|
29 |
import org.eclipse.core.runtime.IProgressMonitor;
|
|
30 |
import org.eclipse.core.runtime.IStatus;
|
|
31 |
import org.eclipse.core.runtime.Path;
|
|
32 |
import org.eclipse.core.runtime.Platform;
|
1
|
33 |
import org.eclipse.core.runtime.Status;
|
0
|
34 |
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
|
35 |
import org.eclipse.jface.operation.IRunnableWithProgress;
|
|
36 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
37 |
import org.eclipse.jface.viewers.StructuredSelection;
|
|
38 |
import org.eclipse.jface.wizard.WizardDialog;
|
|
39 |
import org.eclipse.swt.SWT;
|
|
40 |
import org.eclipse.swt.custom.CTabFolder;
|
|
41 |
import org.eclipse.swt.custom.CTabItem;
|
|
42 |
import org.eclipse.swt.events.SelectionAdapter;
|
|
43 |
import org.eclipse.swt.events.SelectionEvent;
|
|
44 |
import org.eclipse.swt.events.SelectionListener;
|
|
45 |
import org.eclipse.swt.layout.GridData;
|
|
46 |
import org.eclipse.swt.layout.GridLayout;
|
|
47 |
import org.eclipse.swt.layout.RowData;
|
|
48 |
import org.eclipse.swt.layout.RowLayout;
|
|
49 |
import org.eclipse.swt.widgets.Button;
|
|
50 |
import org.eclipse.swt.widgets.Composite;
|
|
51 |
import org.eclipse.swt.widgets.Control;
|
|
52 |
import org.eclipse.swt.widgets.Label;
|
|
53 |
import org.eclipse.swt.widgets.Shell;
|
|
54 |
import org.eclipse.swt.widgets.Text;
|
|
55 |
import org.eclipse.swt.widgets.Widget;
|
|
56 |
import org.eclipse.ui.IWorkbench;
|
|
57 |
import org.eclipse.ui.IWorkbenchWindow;
|
|
58 |
import org.eclipse.ui.PlatformUI;
|
|
59 |
|
|
60 |
import com.nokia.s60tools.imaker.IEnvironment;
|
|
61 |
import com.nokia.s60tools.imaker.IEnvironmentManager;
|
|
62 |
import com.nokia.s60tools.imaker.IIMakerWrapper;
|
1
|
63 |
import com.nokia.s60tools.imaker.IMakerKeyConstants;
|
0
|
64 |
import com.nokia.s60tools.imaker.IMakerPlugin;
|
|
65 |
import com.nokia.s60tools.imaker.IMakerUtils;
|
|
66 |
import com.nokia.s60tools.imaker.ImageFlasherHelpContextIDs;
|
|
67 |
import com.nokia.s60tools.imaker.Messages;
|
|
68 |
import com.nokia.s60tools.imaker.StatusHandler;
|
|
69 |
import com.nokia.s60tools.imaker.UIConfiguration;
|
|
70 |
import com.nokia.s60tools.imaker.UITarget;
|
|
71 |
import com.nokia.s60tools.imaker.UIVariable;
|
|
72 |
import com.nokia.s60tools.imaker.exceptions.IMakerCoreExecutionException;
|
|
73 |
import com.nokia.s60tools.imaker.exceptions.IMakerCoreNotFoundException;
|
|
74 |
import com.nokia.s60tools.imaker.internal.dialogs.ProductSelectionDialog;
|
|
75 |
import com.nokia.s60tools.imaker.internal.managers.ProjectManager;
|
|
76 |
import com.nokia.s60tools.imaker.internal.model.ImakerProperties;
|
|
77 |
import com.nokia.s60tools.imaker.internal.wizards.NewImakerFileWizard;
|
|
78 |
import com.nokia.s60tools.imaker.internal.wrapper.IMakerWrapperPreferences;
|
|
79 |
|
|
80 |
public class PreferencesTab extends CTabItem {
|
|
81 |
public static PreferencesTab currentPreferencesTab = null;
|
|
82 |
|
|
83 |
// private enum EDIT_STATE {EMPTY,EDITED,SAVED};
|
|
84 |
// private enum NAME_STATE {UNNAMED,NAMED};
|
|
85 |
// private EDIT_STATE editState = EDIT_STATE.EMPTY;
|
|
86 |
// private NAME_STATE nameState = NAME_STATE.UNNAMED;
|
|
87 |
|
|
88 |
private Label labelVersion;
|
|
89 |
private Text textUserDefinedParameters;
|
|
90 |
private Button buttonSymbolFiles;
|
|
91 |
private Button buttonVerbose;
|
|
92 |
private Button buttonImageTypeRnd;
|
|
93 |
private Button buttonImageTypePrd;
|
|
94 |
private Button buttonImageTypeSubcon;
|
|
95 |
private Text textProduct;
|
|
96 |
private org.eclipse.swt.widgets.List listTarget;
|
|
97 |
private Button buttonSave;
|
|
98 |
private Button buttonSaveAs;
|
|
99 |
private IEnvironmentManager environmentManager = null;
|
|
100 |
private IEnvironment activeEnvironment = null;
|
|
101 |
private PreferenceSelectionListener pListener;
|
|
102 |
private String iMakerCoreVersion;
|
|
103 |
private String pluginVersion;
|
|
104 |
private String pluginDate;
|
|
105 |
private IMakerTabsViewer tabsViewer;
|
|
106 |
private org.eclipse.swt.widgets.List listSource;
|
|
107 |
|
|
108 |
private IPropertyViewer tabDebug;
|
|
109 |
private SettingsTab settingsTab;
|
|
110 |
private PlatsimTab platsimTab;
|
|
111 |
|
|
112 |
private ProjectManager projectManager;
|
|
113 |
|
|
114 |
/**
|
|
115 |
* The only constructor
|
|
116 |
* @param parent
|
|
117 |
* @param style
|
|
118 |
* @param tabsViewer
|
|
119 |
*/
|
|
120 |
public PreferencesTab(CTabFolder parent, int style, IMakerTabsViewer tabsViewer) {
|
|
121 |
super(parent, style);
|
|
122 |
this.tabsViewer = tabsViewer;
|
|
123 |
environmentManager = tabsViewer.getEnvironmentManager();
|
|
124 |
this.activeEnvironment = environmentManager.getActiveEnvironment();
|
|
125 |
this.projectManager = tabsViewer.getProjectManager();
|
|
126 |
|
|
127 |
pListener = new PreferenceSelectionListener();
|
|
128 |
iMakerCoreVersion = Messages.getString("PreferencesTab.32"); //$NON-NLS-1$
|
|
129 |
|
|
130 |
pluginVersion =
|
|
131 |
(String)Platform.getBundle(IMakerPlugin.PLUGIN_ID) //$NON-NLS-1$
|
|
132 |
.getHeaders()
|
|
133 |
.get("Bundle-Version"); //$NON-NLS-1$
|
|
134 |
pluginDate =
|
|
135 |
(String)Platform.getBundle(IMakerPlugin.PLUGIN_ID) //$NON-NLS-1$
|
|
136 |
.getHeaders()
|
|
137 |
.get("Bundle-Date"); //$NON-NLS-1$
|
|
138 |
|
|
139 |
setControl(createControl(parent));
|
|
140 |
}
|
|
141 |
|
|
142 |
|
|
143 |
private Control createControl(CTabFolder parent) {
|
|
144 |
// Create Top composite in top of the parent composite
|
|
145 |
Composite container = new Composite(parent, SWT.FLAT);
|
|
146 |
|
|
147 |
GridData topCompositeGridData = new GridData(SWT.FILL, SWT.FILL, true,false);
|
|
148 |
container.setLayoutData(topCompositeGridData);
|
|
149 |
GridLayout topCompositeGridLayout = createLayout();
|
|
150 |
container.setLayout(topCompositeGridLayout);
|
|
151 |
|
|
152 |
setHelpForControl(container,ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP);
|
|
153 |
|
|
154 |
try {
|
|
155 |
addConfigurationControls(container);
|
|
156 |
addImageTypeSelectionControls(container);
|
|
157 |
addFlagSelectionControls(container);
|
|
158 |
addAdditionalParametersControl(container);
|
|
159 |
|
|
160 |
addPreferencesControls(container);
|
|
161 |
addVersionInfoControls(container);
|
|
162 |
|
|
163 |
// // Set up context help ids
|
|
164 |
setHelpForControl(textProduct, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_PRODUCT);
|
|
165 |
setHelpForControl(listSource, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_TARGETS);
|
|
166 |
setHelpForControl(listTarget, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_SELECTED_TARGETS);
|
|
167 |
setHelpForControl(buttonImageTypeRnd, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_IMAGE_TYPE);
|
|
168 |
setHelpForControl(buttonImageTypePrd, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_IMAGE_TYPE);
|
|
169 |
setHelpForControl(buttonImageTypeSubcon, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_IMAGE_TYPE);
|
|
170 |
setHelpForControl(buttonSymbolFiles, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_FLAGS);
|
|
171 |
setHelpForControl(buttonVerbose, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_FLAGS);
|
|
172 |
setHelpForControl(textUserDefinedParameters, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_ADDITIONAL_PARAMS);
|
|
173 |
} catch( Exception e ) {
|
|
174 |
//Creating preferences dialog caused an exception
|
|
175 |
e.printStackTrace();
|
|
176 |
}
|
|
177 |
return container;
|
|
178 |
}
|
|
179 |
|
|
180 |
private GridLayout createLayout() {
|
|
181 |
GridLayout topCompositeGridLayout = new GridLayout(2, false);
|
|
182 |
topCompositeGridLayout.horizontalSpacing = 5; // CodForChk_Dis_Magic
|
|
183 |
topCompositeGridLayout.verticalSpacing = 5; // CodForChk_Dis_Magic
|
|
184 |
topCompositeGridLayout.marginWidth = 3;
|
|
185 |
topCompositeGridLayout.marginHeight = 3;
|
|
186 |
return topCompositeGridLayout;
|
|
187 |
}
|
|
188 |
|
|
189 |
private void addVersionInfoControls(Composite container) {
|
|
190 |
labelVersion = new Label(container, SWT.NONE);
|
|
191 |
labelVersion.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
|
|
192 |
|
|
193 |
String versionText = getVersionText();
|
|
194 |
|
|
195 |
labelVersion.setText(versionText + "\n" + iMakerCoreVersion); //$NON-NLS-1$
|
|
196 |
labelVersion.setToolTipText(Messages.getString("PreferencesTab.20"));
|
|
197 |
}
|
|
198 |
|
|
199 |
private String getVersionText() {
|
|
200 |
String versionText = "iMaker Extension: " + pluginVersion + ", " + pluginDate;
|
|
201 |
return versionText;
|
|
202 |
}
|
|
203 |
|
|
204 |
/**
|
|
205 |
* @param container
|
|
206 |
*/
|
|
207 |
private void addPreferencesControls(Composite container) {
|
|
208 |
Composite controlGroup = new Composite(container, SWT.NONE);
|
|
209 |
GridLayout layoutAdditionalParameters = new GridLayout(4, true);
|
|
210 |
controlGroup.setLayout(layoutAdditionalParameters);
|
|
211 |
controlGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false,
|
|
212 |
2, 1));
|
|
213 |
|
|
214 |
buttonSave = new Button(controlGroup, SWT.PUSH);
|
|
215 |
buttonSave.setEnabled(true);
|
|
216 |
buttonSave.setText(Messages.getString("PreferencesTab.16")); //$NON-NLS-1$
|
|
217 |
buttonSave.setToolTipText(Messages.getString("PreferencesTab.17")); //$NON-NLS-1$
|
|
218 |
buttonSave.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
|
|
219 |
buttonSave.addSelectionListener(pListener);
|
|
220 |
|
|
221 |
buttonSaveAs = new Button(controlGroup, SWT.PUSH);
|
|
222 |
buttonSaveAs.setText(Messages.getString("PreferencesTab.18")); //$NON-NLS-1$
|
|
223 |
buttonSaveAs.setToolTipText(Messages.getString("PreferencesTab.19")); //$NON-NLS-1$
|
|
224 |
buttonSaveAs.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
|
|
225 |
buttonSaveAs.addSelectionListener(pListener);
|
|
226 |
}
|
|
227 |
|
|
228 |
private void addAdditionalParametersControl(Composite container) {
|
|
229 |
Label label = new Label(container, SWT.NONE);
|
|
230 |
label.setText(Messages.getString("PreferencesTab.14")); //$NON-NLS-1$
|
|
231 |
|
|
232 |
label.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false,
|
|
233 |
1, 1));
|
|
234 |
|
|
235 |
Composite comp = new Composite(container,SWT.NONE);
|
|
236 |
RowLayout layout = new RowLayout();
|
|
237 |
layout.type = SWT.HORIZONTAL;
|
|
238 |
layout.marginLeft = 0;
|
|
239 |
comp.setLayout(layout);
|
|
240 |
comp
|
|
241 |
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false,
|
|
242 |
1, 1));
|
|
243 |
|
|
244 |
// User defined parameters text
|
|
245 |
textUserDefinedParameters = new Text(comp, SWT.BORDER);
|
|
246 |
textUserDefinedParameters.setText("");
|
|
247 |
textUserDefinedParameters.setToolTipText(Messages.getString("PreferencesTab.15"));
|
|
248 |
RowData rData = new RowData();
|
|
249 |
rData.width = 335;
|
|
250 |
textUserDefinedParameters.setLayoutData(rData);
|
|
251 |
}
|
|
252 |
|
|
253 |
private void addFlagSelectionControls(Composite container) {
|
|
254 |
Label label = new Label(container, SWT.NONE);
|
|
255 |
label.setText(Messages.getString("PreferencesTab.9")); //$NON-NLS-1$
|
|
256 |
|
|
257 |
label.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false,
|
|
258 |
1, 1));
|
|
259 |
Composite comp = new Composite(container,SWT.NONE);
|
|
260 |
RowLayout layout = new RowLayout();
|
|
261 |
layout.type = SWT.VERTICAL;
|
|
262 |
layout.spacing = 2;
|
|
263 |
layout.marginLeft = 0;
|
|
264 |
comp.setLayout(layout);
|
|
265 |
comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false,
|
|
266 |
1, 1));
|
|
267 |
|
|
268 |
buttonSymbolFiles = new Button(comp, SWT.CHECK);
|
|
269 |
buttonSymbolFiles.setText(Messages.getString("PreferencesTab.10"));
|
|
270 |
buttonSymbolFiles.setToolTipText(Messages.getString("PreferencesTab.11"));
|
|
271 |
buttonVerbose = new Button(comp, SWT.CHECK);
|
|
272 |
buttonVerbose.setText(Messages.getString("PreferencesTab.12"));
|
|
273 |
buttonVerbose.setToolTipText(Messages.getString("PreferencesTab.13"));
|
|
274 |
}
|
|
275 |
|
|
276 |
/**
|
|
277 |
* Adds image selection user interface components
|
|
278 |
* @param container
|
|
279 |
*/
|
|
280 |
private void addImageTypeSelectionControls(Composite container) {
|
|
281 |
Label label = new Label(container, SWT.NONE);
|
|
282 |
label.setText(Messages.getString("PreferencesTab.2")); //$NON-NLS-1$
|
|
283 |
label.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false,
|
|
284 |
1, 1));
|
|
285 |
Composite comp = new Composite(container,SWT.NONE);
|
|
286 |
RowLayout layout = new RowLayout();
|
|
287 |
layout.type = SWT.VERTICAL;
|
|
288 |
layout.spacing = 2;
|
|
289 |
layout.marginLeft = 0;
|
|
290 |
comp.setLayout(layout);
|
|
291 |
comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false,
|
|
292 |
1, 1));
|
|
293 |
|
|
294 |
// Rnd/Prd/Subcon
|
|
295 |
buttonImageTypeRnd = new Button(comp,SWT.RADIO);
|
|
296 |
buttonImageTypeRnd.setText(Messages.getString("PreferencesTab.3"));
|
|
297 |
buttonImageTypeRnd.setToolTipText(Messages.getString("PreferencesTab.4"));
|
|
298 |
buttonImageTypeRnd.setSelection(true);
|
|
299 |
buttonImageTypePrd = new Button(comp,SWT.RADIO);
|
|
300 |
buttonImageTypePrd.setText(Messages.getString("PreferencesTab.5"));
|
|
301 |
buttonImageTypePrd.setToolTipText(Messages.getString("PreferencesTab.6"));
|
|
302 |
buttonImageTypeSubcon = new Button(comp,SWT.RADIO);
|
|
303 |
buttonImageTypeSubcon.setText(Messages.getString("PreferencesTab.7"));
|
|
304 |
buttonImageTypeSubcon.setToolTipText(Messages.getString("PreferencesTab.8"));
|
|
305 |
}
|
|
306 |
|
|
307 |
|
|
308 |
/**
|
|
309 |
* Add configuration user interface components
|
|
310 |
* @param container
|
|
311 |
*/
|
|
312 |
private void addConfigurationControls(Composite container) {
|
|
313 |
Label label = null;
|
|
314 |
|
|
315 |
label = new Label(container, SWT.NONE);
|
|
316 |
label.setText(Messages.getString("PreferencesTab.0")); //$NON-NLS-1$
|
|
317 |
|
|
318 |
// Product combo
|
|
319 |
createProductWidgets(container);
|
|
320 |
|
|
321 |
// Target selection label
|
|
322 |
label = new Label(container, SWT.NONE);
|
|
323 |
label.setText(Messages.getString("PreferencesTab.1"));
|
|
324 |
label.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false,
|
|
325 |
1, 1));
|
|
326 |
|
|
327 |
addTargetLists(container);
|
|
328 |
}
|
|
329 |
/**
|
|
330 |
* @param container
|
|
331 |
*/
|
|
332 |
private void createProductWidgets(Composite container) {
|
|
333 |
Composite product = new Composite(container,SWT.NONE);
|
|
334 |
product.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
|
|
335 |
product.setLayout(new GridLayout(2, false));
|
|
336 |
textProduct = new Text(product, SWT.BORDER);
|
|
337 |
textProduct.setText("");
|
|
338 |
textProduct.setEditable(false);
|
|
339 |
GridData layoutData = new GridData(SWT.BEGINNING, SWT.CENTER, true, true, 1, 1);
|
|
340 |
layoutData.widthHint = 280;
|
|
341 |
textProduct.setLayoutData(layoutData);
|
|
342 |
|
|
343 |
Button select = new Button(product,SWT.PUSH);
|
|
344 |
select.setText("&Change...");
|
|
345 |
select.addSelectionListener(new SelectionListener() {
|
|
346 |
|
|
347 |
// @Override
|
|
348 |
public void widgetSelected(SelectionEvent se) {
|
|
349 |
ProductSelectionDialog selectDialog = new ProductSelectionDialog(getControl().getShell(),
|
|
350 |
activeEnvironment);
|
|
351 |
boolean ret = selectDialog.displayDialog();
|
|
352 |
if(ret) {
|
|
353 |
UIConfiguration config = selectDialog.getSelectedConfiguration();
|
|
354 |
refreshProduct(config);
|
|
355 |
}
|
|
356 |
}
|
|
357 |
|
|
358 |
// @Override
|
|
359 |
public void widgetDefaultSelected(SelectionEvent se) {
|
|
360 |
widgetSelected(se);
|
|
361 |
}
|
|
362 |
});
|
|
363 |
select.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
364 |
}
|
|
365 |
|
|
366 |
private void addTargetLists(Composite parent) {
|
|
367 |
Composite top = new Composite(parent,SWT.NONE);
|
|
368 |
GridLayout layout = new GridLayout(3, false);
|
|
369 |
layout.horizontalSpacing = 6;
|
|
370 |
layout.verticalSpacing = 1;
|
|
371 |
layout.marginWidth = 0;
|
|
372 |
layout.marginHeight = 0;
|
|
373 |
top.setLayout(layout);
|
|
374 |
top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
|
|
375 |
|
|
376 |
listSource = createListComponent(top, "&All");
|
|
377 |
listSource.addSelectionListener(new SelectionListener() {
|
|
378 |
|
|
379 |
// @Override
|
|
380 |
public void widgetSelected(SelectionEvent se) {
|
|
381 |
String item = listSource.getItem(listSource.getSelectionIndex());
|
|
382 |
UIConfiguration p = activeEnvironment.getCurrentProduct();
|
|
383 |
listSource.setToolTipText(p.getTarget(item).getDescription());
|
|
384 |
}
|
|
385 |
|
|
386 |
// @Override
|
|
387 |
public void widgetDefaultSelected(SelectionEvent arg0) {
|
|
388 |
}
|
|
389 |
});
|
|
390 |
createListButtons(top);
|
|
391 |
listTarget = createListComponent(top, "&Selected");
|
|
392 |
listTarget.addSelectionListener(new SelectionListener() {
|
|
393 |
|
|
394 |
// @Override
|
|
395 |
public void widgetSelected(SelectionEvent se) {
|
|
396 |
String item = listTarget.getItem(listTarget.getSelectionIndex());
|
|
397 |
UIConfiguration p = activeEnvironment.getCurrentProduct();
|
|
398 |
listTarget.setToolTipText(p.getTarget(item).getDescription());
|
|
399 |
}
|
|
400 |
|
|
401 |
// @Override
|
|
402 |
public void widgetDefaultSelected(SelectionEvent arg0) {
|
|
403 |
}
|
|
404 |
});
|
|
405 |
}
|
|
406 |
|
|
407 |
|
|
408 |
private org.eclipse.swt.widgets.List createListComponent(Composite top,
|
|
409 |
String txt) {
|
|
410 |
Composite comp = new Composite(top,SWT.NONE);
|
|
411 |
GridLayout layout = new GridLayout(1, true);
|
|
412 |
layout.verticalSpacing = 1;
|
|
413 |
layout.marginWidth = 0;
|
|
414 |
layout.marginHeight = 0;
|
|
415 |
comp.setLayout(layout);
|
|
416 |
comp
|
|
417 |
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false,
|
|
418 |
1, 1));
|
|
419 |
GridData gData;
|
|
420 |
Label label = new Label(comp,SWT.NONE);
|
|
421 |
label.setText(txt);
|
|
422 |
org.eclipse.swt.widgets.List list;
|
|
423 |
list = new org.eclipse.swt.widgets.List(comp, SWT.MULTI | SWT.V_SCROLL
|
|
424 |
| SWT.BORDER);
|
|
425 |
gData = new GridData();
|
|
426 |
gData.widthHint = 132;
|
|
427 |
gData.heightHint = 132;
|
|
428 |
list.setLayoutData(gData);
|
|
429 |
return list;
|
|
430 |
}
|
|
431 |
|
|
432 |
private void createListButtons(Composite top) {
|
|
433 |
Composite bComp = new Composite(top,SWT.NONE);
|
|
434 |
GridLayout layout = new GridLayout(1, true);
|
|
435 |
layout.marginWidth = 1;
|
|
436 |
layout.verticalSpacing = 1;
|
|
437 |
bComp.setLayout(layout);
|
|
438 |
bComp.setLayoutData(new GridData(SWT.NONE, SWT.CENTER, false, false, 1,
|
|
439 |
1));
|
|
440 |
Button button = new Button(bComp,SWT.PUSH);
|
|
441 |
button.setText(">");
|
|
442 |
button.addSelectionListener(new SelectionAdapter() {
|
|
443 |
public void widgetSelected(SelectionEvent e) {
|
|
444 |
String[] selections = listSource.getSelection();
|
|
445 |
addToListTarget(selections);
|
|
446 |
listSource.setToolTipText("");
|
|
447 |
}
|
|
448 |
});
|
|
449 |
|
|
450 |
GridData gData = new GridData();
|
|
451 |
gData.verticalAlignment = SWT.END;
|
|
452 |
button.setLayoutData(gData);
|
|
453 |
button = new Button(bComp,SWT.PUSH);
|
|
454 |
button.setText("<");
|
|
455 |
button.addSelectionListener(new SelectionAdapter() {
|
|
456 |
public void widgetSelected(SelectionEvent e) {
|
|
457 |
String[] selections = listTarget.getSelection();
|
|
458 |
addToListSource(selections);
|
|
459 |
listTarget.setToolTipText("");
|
|
460 |
}
|
|
461 |
});
|
|
462 |
gData = new GridData();
|
|
463 |
gData.verticalAlignment = SWT.CENTER;
|
|
464 |
button.setLayoutData(gData);
|
|
465 |
}
|
|
466 |
|
|
467 |
|
|
468 |
private void moveItemsInList(org.eclipse.swt.widgets.List source,
|
|
469 |
org.eclipse.swt.widgets.List target, String[] items) {
|
|
470 |
List<String> sourceItems = Arrays.asList(source.getItems());
|
|
471 |
for (int i = 0; i < items.length; i++) {
|
|
472 |
String item = items[i];
|
|
473 |
if(sourceItems.contains(item)) {
|
|
474 |
source.remove(item);
|
|
475 |
target.add(item);
|
|
476 |
}
|
|
477 |
}
|
|
478 |
}
|
|
479 |
|
|
480 |
protected void addToListSource(String[] selections) {
|
|
481 |
moveItemsInList(listTarget, listSource, selections);
|
|
482 |
String[] items = listSource.getItems();
|
|
483 |
Arrays.sort(items);
|
|
484 |
listSource.removeAll();
|
|
485 |
listSource.setItems(items);
|
|
486 |
}
|
|
487 |
|
|
488 |
protected void addToListTarget(String[] selections) {
|
|
489 |
UIConfiguration pr = activeEnvironment.getCurrentProduct();
|
|
490 |
moveItemsInList(listSource, listTarget, selections);
|
|
491 |
for (int i = 0; i < selections.length; i++) {
|
|
492 |
String target = selections[i];
|
|
493 |
UITarget tr = pr.getTarget(target);
|
|
494 |
if(tr.getSteps()==null) {
|
|
495 |
String targetSteps = activeEnvironment.getTargetSteps(target);
|
|
496 |
tr.setSteps(targetSteps);
|
|
497 |
}
|
|
498 |
}
|
|
499 |
}
|
|
500 |
|
|
501 |
|
|
502 |
private void setHelpForControl(Control container, String id) {
|
|
503 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(container, id);
|
|
504 |
}
|
|
505 |
|
|
506 |
private void resetAdditionalFields() {
|
|
507 |
buttonImageTypeRnd.setSelection(true);
|
|
508 |
buttonImageTypePrd.setSelection(false);
|
|
509 |
buttonImageTypeSubcon.setSelection(false);
|
|
510 |
buttonSymbolFiles.setSelection(false);
|
|
511 |
buttonVerbose.setSelection(false);
|
|
512 |
textUserDefinedParameters.setText("");
|
|
513 |
}
|
|
514 |
|
|
515 |
|
|
516 |
private void loadConfigurations() throws InvocationTargetException {
|
|
517 |
try {
|
|
518 |
iMakerCoreVersion = activeEnvironment.getIMakerCoreVersion();
|
|
519 |
|
|
520 |
fixVersionText();
|
|
521 |
activeEnvironment.load();
|
|
522 |
if(activeEnvironment.isLoaded()) {
|
|
523 |
UIConfiguration def = getDefaultConfig();
|
|
524 |
if(def==null) {
|
|
525 |
def = activeEnvironment.getConfigurations().get(0);
|
|
526 |
}
|
|
527 |
refreshProduct(def);
|
|
528 |
}
|
|
529 |
} catch (IMakerCoreNotFoundException e) {
|
|
530 |
StatusHandler.handle(IStatus.ERROR,"iMaker Core was not found.",e); //$NON-NLS-1$
|
|
531 |
return;
|
|
532 |
} catch (IMakerCoreExecutionException e) {
|
|
533 |
StatusHandler.handle(IStatus.ERROR,"An error has occurred while executing iMaker Core. The selected environment cannot be used with iMaker extension.",e); //$NON-NLS-1$
|
|
534 |
return;
|
|
535 |
}
|
|
536 |
}
|
|
537 |
|
|
538 |
/**
|
|
539 |
* @param environment
|
|
540 |
* @return
|
|
541 |
*/
|
|
542 |
private UIConfiguration getDefaultConfig() {
|
|
543 |
List<UIConfiguration> configs;
|
|
544 |
try {
|
|
545 |
configs = activeEnvironment.getConfigurations();
|
|
546 |
UIConfiguration ret = null;
|
|
547 |
for (UIConfiguration config : configs) {
|
|
548 |
if(config.isDefaultConfig()) {
|
|
549 |
ret = config;
|
|
550 |
break;
|
|
551 |
}
|
|
552 |
}
|
|
553 |
return ret;
|
|
554 |
} catch (InvocationTargetException e) {
|
|
555 |
return null;
|
|
556 |
}
|
|
557 |
}
|
|
558 |
|
|
559 |
private void refreshProduct(UIConfiguration product) {
|
|
560 |
if(product==null) return;
|
2
|
561 |
clearWidgets();
|
|
562 |
try {
|
|
563 |
product.load();
|
|
564 |
} catch (Throwable e) {
|
|
565 |
StatusHandler.handle(IStatus.ERROR,"An error has occurred while executing iMaker Core.",e);
|
|
566 |
return;
|
|
567 |
}
|
0
|
568 |
textProduct.setText(product.getConfigurationName());
|
|
569 |
textProduct.setData(product);
|
|
570 |
activeEnvironment.setCurrentProduct(product);
|
|
571 |
|
|
572 |
List<UITarget> targets = product.getFilteredTargets();
|
|
573 |
if(targets!=null) {
|
|
574 |
for(UITarget target: targets) {
|
|
575 |
listSource.add(target.getName());
|
|
576 |
}
|
|
577 |
}
|
|
578 |
settingsTab.setInput(product);
|
|
579 |
textProduct.setToolTipText(product.getFilePath());
|
|
580 |
platsimTab.activate(product.isPlatsimConfiguration());
|
|
581 |
}
|
|
582 |
|
|
583 |
/**
|
|
584 |
*
|
|
585 |
*/
|
|
586 |
private void clearWidgets() {
|
|
587 |
listSource.removeAll();
|
|
588 |
listTarget.removeAll();
|
|
589 |
resetAdditionalFields();
|
2
|
590 |
settingsTab.setInput(null);
|
|
591 |
tabDebug.clear();
|
|
592 |
platsimTab.clear();
|
0
|
593 |
}
|
|
594 |
|
|
595 |
private void fixVersionText() {
|
|
596 |
StringBuilder version = new StringBuilder(labelVersion.getText());
|
|
597 |
int index = version.indexOf(Messages.getString("PreferencesTab.32")); //$NON-NLS-1$
|
|
598 |
if(index != -1) {
|
|
599 |
version.replace(index, version.length(), Messages.getString("PreferencesTab.32") + " " + iMakerCoreVersion);
|
|
600 |
labelVersion.setText(version.toString());
|
|
601 |
}
|
|
602 |
}
|
|
603 |
|
|
604 |
|
|
605 |
private void savePreferencesToFile(String filePath) {
|
|
606 |
ImakerProperties uiValues = new ImakerProperties();
|
|
607 |
uiValues.putAll(getUIValues());
|
|
608 |
|
|
609 |
UIConfiguration current = null;
|
|
610 |
current = activeEnvironment.getCurrentProduct();
|
|
611 |
|
|
612 |
if (filePath == null||filePath.equals(ProjectManager.NEW_ITEM)) {
|
|
613 |
IStructuredSelection selection = new StructuredSelection(tabsViewer
|
|
614 |
.getProjectManager().getProject());
|
|
615 |
IWorkbench workbench = PlatformUI.getWorkbench();
|
|
616 |
|
|
617 |
NewImakerFileWizard wizard = new NewImakerFileWizard(uiValues, current,
|
|
618 |
this);
|
|
619 |
wizard.init(workbench, selection);
|
|
620 |
|
|
621 |
WizardDialog dialog = new WizardDialog(workbench
|
|
622 |
.getActiveWorkbenchWindow().getShell(), wizard);
|
|
623 |
dialog.open();
|
|
624 |
|
|
625 |
if (wizard.isSaved()) {
|
|
626 |
IFile file = wizard.getFile();
|
|
627 |
String loc = file.getLocation().toString();
|
|
628 |
tabsViewer.populateConfigurations(loc);
|
|
629 |
}
|
|
630 |
} else {
|
|
631 |
IFile file = (IFile)projectManager.getImakerFile(new Path(filePath));
|
1
|
632 |
uiValues.saveToFile(file.getLocation().toFile());
|
|
633 |
try {
|
|
634 |
file.refreshLocal(IResource.DEPTH_ZERO, null);
|
|
635 |
} catch (CoreException e) {
|
|
636 |
IStatus status = new Status(Status.WARNING,IMakerPlugin.PLUGIN_ID,"Refreshing file ("+file.getLocation().toOSString()+")failled!",e);
|
|
637 |
IMakerPlugin.getDefault().getLog().log(status);
|
|
638 |
e.printStackTrace();
|
|
639 |
}
|
0
|
640 |
}
|
|
641 |
}
|
|
642 |
|
|
643 |
private Properties getUIValues() {
|
|
644 |
ImakerProperties prop = new ImakerProperties();
|
|
645 |
try {
|
|
646 |
UIConfiguration config = (UIConfiguration) textProduct.getData();
|
|
647 |
if(config!=null) {
|
1
|
648 |
addField(prop,IMakerKeyConstants.PRODUCT,config.getConfigurationName());
|
0
|
649 |
}
|
|
650 |
StringBuilder sb = new StringBuilder();
|
|
651 |
for (int i = 0; i < listTarget.getItemCount(); i++) {
|
|
652 |
sb.append(listTarget.getItem(i));
|
|
653 |
if(i<listTarget.getItemCount()-1) {
|
|
654 |
sb.append(" ");
|
|
655 |
}
|
|
656 |
}
|
|
657 |
if(sb.length()>0) {
|
|
658 |
addField(prop,IMakerKeyConstants.TARGET_LIST,sb.toString());
|
|
659 |
}
|
|
660 |
if(buttonImageTypePrd.getSelection()) {
|
|
661 |
addField(prop,IMakerKeyConstants.TYPE,Messages.getString("PreferencesTab.23")); //$NON-NLS-1$
|
|
662 |
} else if(buttonImageTypeSubcon.getSelection()) {
|
|
663 |
addField(prop,IMakerKeyConstants.TYPE,Messages.getString("PreferencesTab.24")); //$NON-NLS-1$
|
|
664 |
} else {
|
|
665 |
addField(prop,IMakerKeyConstants.TYPE,Messages.getString("PreferencesTab.25")); //$NON-NLS-1$
|
|
666 |
}
|
|
667 |
if(buttonVerbose.getSelection()) {
|
|
668 |
addField(prop,IMakerKeyConstants.VERBOSE,Messages.getString("PreferencesTab.26")); //$NON-NLS-1$
|
|
669 |
}
|
|
670 |
if(buttonSymbolFiles.getSelection()) {
|
|
671 |
addField(prop,IMakerKeyConstants.SYMBOLFILES,Messages.getString("PreferencesTab.27")); //$NON-NLS-1$
|
|
672 |
}
|
|
673 |
addField(prop, IMakerKeyConstants.ADDITIONAL_PARAMETERS,
|
|
674 |
textUserDefinedParameters.getText());
|
|
675 |
platsimTab.addToProperties(prop);
|
|
676 |
tabDebug.addToProperties(prop);
|
1
|
677 |
} catch(Exception e) {}
|
0
|
678 |
return prop;
|
|
679 |
}
|
|
680 |
|
|
681 |
private void addField(Properties properties, String name, String value) {
|
|
682 |
if((name==null)||(name.equals(""))||(value==null)||(value.equals(""))) { //$NON-NLS-1$ //$NON-NLS-2$
|
|
683 |
return;
|
|
684 |
}
|
|
685 |
properties.setProperty(name, value);
|
|
686 |
}
|
|
687 |
|
|
688 |
private void fillUIForm(ImakerProperties prop) throws InvocationTargetException {
|
1
|
689 |
String targetProduct = (String) prop.remove(IMakerKeyConstants.PRODUCT);
|
|
690 |
if(targetProduct==null) return;
|
|
691 |
boolean found = false;
|
0
|
692 |
List<UIConfiguration> configs = activeEnvironment.getConfigurations();
|
|
693 |
for (UIConfiguration config : configs) {
|
1
|
694 |
if(config.getConfigurationName().equals(targetProduct)) {
|
0
|
695 |
refreshProduct(config);
|
1
|
696 |
found = true;
|
0
|
697 |
break;
|
|
698 |
}
|
|
699 |
}
|
|
700 |
|
1
|
701 |
if (!found) {
|
|
702 |
IStatus status = new Status(Status.WARNING,IMakerPlugin.PLUGIN_ID,"Unable to fill dialog ui, because product: "+targetProduct+" not found!");
|
|
703 |
IMakerPlugin.getDefault().getLog().log(status);
|
|
704 |
return;
|
|
705 |
}
|
|
706 |
|
0
|
707 |
String targets = (String) prop.remove(IMakerKeyConstants.TARGET_LIST);
|
|
708 |
if((targets!=null)&&!(targets.equals(""))) { //$NON-NLS-1$
|
|
709 |
String[] tars = targets.split(" "); //$NON-NLS-1$
|
|
710 |
addToListTarget(tars);
|
|
711 |
}
|
|
712 |
|
|
713 |
String str = (String)prop.remove(IMakerKeyConstants.TYPE);
|
|
714 |
if(str!=null){
|
|
715 |
buttonImageTypeRnd.setSelection(false);
|
|
716 |
if(str.equals(Messages.getString("PreferencesTab.24"))) { //$NON-NLS-1$
|
|
717 |
buttonImageTypeSubcon.setSelection(true);
|
|
718 |
} else if(str.equals(Messages.getString("PreferencesTab.23"))) { //$NON-NLS-1$
|
|
719 |
buttonImageTypePrd.setSelection(true);
|
|
720 |
} else {
|
|
721 |
buttonImageTypeRnd.setSelection(true);
|
|
722 |
}
|
|
723 |
}
|
|
724 |
|
|
725 |
str = (String)prop.remove(IMakerKeyConstants.VERBOSE);
|
|
726 |
if((str!=null)&&!(str.equals(""))) { //$NON-NLS-1$
|
|
727 |
buttonVerbose.setSelection(true);
|
|
728 |
}
|
|
729 |
str = (String)prop.remove(IMakerKeyConstants.SYMBOLFILES);
|
|
730 |
if((str!=null)&&!(str.equals(""))) { //$NON-NLS-1$
|
|
731 |
buttonSymbolFiles.setSelection(true);
|
|
732 |
}
|
|
733 |
String adds = (String)prop.remove(IMakerKeyConstants.ADDITIONAL_PARAMETERS);
|
|
734 |
if(adds!=null) {
|
|
735 |
textUserDefinedParameters.setText(adds);
|
|
736 |
}
|
|
737 |
updateSettings(prop);
|
|
738 |
tabDebug.restoreFromProperties(prop);
|
|
739 |
platsimTab.restoreFromProperties(prop);
|
|
740 |
}
|
|
741 |
|
|
742 |
public void setSettings(SettingsTab tabSettings) {
|
|
743 |
this.settingsTab = tabSettings;
|
|
744 |
}
|
|
745 |
|
|
746 |
/**
|
|
747 |
*
|
|
748 |
*/
|
|
749 |
private class PreferenceSelectionListener implements SelectionListener {
|
|
750 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
751 |
widgetSelected(e);
|
|
752 |
}
|
|
753 |
|
|
754 |
public void widgetSelected(SelectionEvent e) {
|
|
755 |
Widget source = e.widget;
|
|
756 |
if(source==buttonSave) {
|
|
757 |
savePreferencesToFile(tabsViewer.getSelectedItem());
|
|
758 |
} else if(source==buttonSaveAs) {
|
|
759 |
savePreferencesToFile(null);
|
|
760 |
} else {}
|
|
761 |
}
|
|
762 |
}
|
|
763 |
|
|
764 |
public void revertSettingsTab() {
|
|
765 |
|
|
766 |
}
|
|
767 |
|
|
768 |
/**
|
|
769 |
* Called when something changed in the settingsTab.
|
1
|
770 |
* @param modVariable
|
0
|
771 |
*/
|
1
|
772 |
public void refreshSettingsTab(UIVariable modVariable) {
|
0
|
773 |
if(!settingsTab.isDirty()) {
|
|
774 |
return;
|
|
775 |
}
|
|
776 |
String drive = activeEnvironment.getDrive();
|
|
777 |
IRunnableWithProgress op = new IMakerSettingsUpdater(null,drive);
|
|
778 |
executeRunnable(op);
|
1
|
779 |
if (modVariable!=null) {
|
|
780 |
String text = textUserDefinedParameters.getText();
|
|
781 |
if(text!=null) {
|
|
782 |
text = text.trim();
|
|
783 |
if(!"".equals(text)) {
|
|
784 |
text = text +" " + getVariableString(modVariable);
|
|
785 |
} else {
|
|
786 |
text = getVariableString(modVariable);
|
|
787 |
}
|
|
788 |
} else {
|
|
789 |
text = getVariableString(modVariable);
|
|
790 |
}
|
|
791 |
textUserDefinedParameters.setText(text);
|
|
792 |
}
|
|
793 |
}
|
|
794 |
|
|
795 |
private String getVariableString(UIVariable variable) {
|
|
796 |
String value = variable.getValue();
|
|
797 |
if(value.contains(" ")) {
|
|
798 |
return variable.getName()+"=\""+value+"\"";
|
|
799 |
} else {
|
|
800 |
return variable.getName()+"="+value;
|
|
801 |
}
|
0
|
802 |
}
|
|
803 |
|
|
804 |
private void executeRunnable(IRunnableWithProgress op) {
|
|
805 |
IWorkbench wb = PlatformUI.getWorkbench();
|
|
806 |
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
|
|
807 |
Shell shell = win != null ? win.getShell() : null;
|
|
808 |
try {
|
|
809 |
ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell);
|
|
810 |
progressMonitorDialog.run(true, false, op);
|
|
811 |
settingsTab.getTableViewer().refresh();
|
|
812 |
} catch (InvocationTargetException e) {
|
|
813 |
StatusHandler.handle(IStatus.ERROR,Messages.getString("Error.1"),e.getTargetException()); //$NON-NLS-1$
|
|
814 |
e.printStackTrace();
|
|
815 |
} catch (InterruptedException e) {
|
|
816 |
e.printStackTrace();
|
|
817 |
}
|
|
818 |
}
|
|
819 |
|
|
820 |
private class IMakerSettingsUpdater implements IRunnableWithProgress {
|
|
821 |
private List<String> modifiedVariables=null;
|
|
822 |
private String environment;
|
|
823 |
|
|
824 |
public IMakerSettingsUpdater(List<String> modifiedVariables, String env) {
|
|
825 |
this.modifiedVariables = modifiedVariables;
|
|
826 |
this.environment = env;
|
|
827 |
}
|
|
828 |
|
|
829 |
public void run(IProgressMonitor monitor)
|
|
830 |
throws InvocationTargetException, InterruptedException {
|
|
831 |
try {
|
|
832 |
IIMakerWrapper wrapper = activeEnvironment.getImakerWrapper();
|
|
833 |
ArrayList<String> parameters = new ArrayList<String>();
|
|
834 |
UIConfiguration currentConfiguration = activeEnvironment.getCurrentProduct();
|
|
835 |
parameters.add(environment +
|
|
836 |
IMakerWrapperPreferences.DEFAULT_COMMAND);
|
|
837 |
parameters.add(currentConfiguration.getFilePath());
|
|
838 |
UIConfiguration configuration=null;
|
|
839 |
List<UIVariable> incVars = null;
|
|
840 |
if(modifiedVariables==null) {
|
|
841 |
incVars = IMakerUtils.getCommandlineIncludeVariables(currentConfiguration.getVariables());
|
|
842 |
List<String> varList = IMakerUtils.convertVariablesToStrings(incVars);
|
|
843 |
parameters.addAll(varList);
|
|
844 |
configuration = wrapper.getConfiguration(parameters, monitor);
|
|
845 |
} else {
|
|
846 |
incVars = IMakerUtils.convertStringsToVariables(modifiedVariables);
|
|
847 |
parameters.addAll(modifiedVariables);
|
|
848 |
configuration = wrapper.getConfiguration(parameters, monitor);
|
|
849 |
}
|
|
850 |
for (UIVariable variable : incVars) {
|
|
851 |
UIVariable v = findVariable(configuration,variable);
|
|
852 |
if(v!=null) {
|
|
853 |
v.setInclude(true);
|
|
854 |
}
|
|
855 |
}
|
|
856 |
currentConfiguration.setVariables(configuration.getVariables());
|
|
857 |
} catch (Exception e) {
|
|
858 |
throw new InvocationTargetException(e);
|
|
859 |
}
|
|
860 |
monitor.worked(100);
|
|
861 |
monitor.done();
|
|
862 |
}
|
|
863 |
private UIVariable findVariable(UIConfiguration configuration,
|
|
864 |
UIVariable var) {
|
|
865 |
List<UIVariable> variables = configuration.getVariables();
|
|
866 |
for (UIVariable variable : variables) {
|
|
867 |
if(var.equals(variable)) {
|
|
868 |
return variable;
|
|
869 |
}
|
|
870 |
}
|
|
871 |
return null;
|
|
872 |
}
|
|
873 |
}
|
|
874 |
|
|
875 |
public void runPressed(String item) {
|
|
876 |
if(item.equals(ProjectManager.NEW_ITEM)) {
|
|
877 |
ImakerProperties run = activeEnvironment.getRunProperties();
|
|
878 |
run.clear();
|
|
879 |
Properties uiValues = getUIValues();
|
|
880 |
run.putAll(uiValues);
|
|
881 |
run.setActiveFile(null);
|
|
882 |
} else {
|
|
883 |
savePreferencesToFile(item);
|
|
884 |
ImakerProperties run = activeEnvironment.getRunProperties();
|
|
885 |
run.setActiveFile(item);
|
|
886 |
}
|
|
887 |
}
|
|
888 |
|
|
889 |
public void setDebug(IPropertyViewer debug) {
|
|
890 |
tabDebug = debug;
|
|
891 |
}
|
|
892 |
|
|
893 |
/**get
|
|
894 |
* @param item
|
|
895 |
* @throws InterruptedException
|
|
896 |
*/
|
|
897 |
public void loadImakerFile(String item) throws InvocationTargetException {
|
|
898 |
if(!item.equals(ProjectManager.NEW_ITEM)) {
|
|
899 |
IFile file = (IFile)projectManager.getImakerFile(new Path(item));
|
1
|
900 |
if(file!=null) {
|
|
901 |
ImakerProperties prop = null;
|
|
902 |
prop = ImakerProperties.createFromFile(file);
|
|
903 |
fillUIForm(prop);
|
|
904 |
}
|
0
|
905 |
} else {
|
|
906 |
loadDefaults();
|
|
907 |
fillUIForm(activeEnvironment.getRunProperties());
|
|
908 |
}
|
|
909 |
}
|
|
910 |
|
|
911 |
|
|
912 |
private void updateSettings(Properties content) {
|
|
913 |
List<String> modified = new ArrayList<String>();
|
|
914 |
|
|
915 |
String mods = (String)content.get(IMakerKeyConstants.MODIFIED_SETTINGS);
|
|
916 |
if(mods==null) return;
|
|
917 |
String[] parts;
|
|
918 |
if(mods!=null) {
|
|
919 |
parts = mods.split(ImakerProperties.SEPARATOR);
|
|
920 |
for (int i = 0; i < parts.length; i++) {
|
|
921 |
modified.add(parts[i]);
|
|
922 |
}
|
|
923 |
}
|
|
924 |
mods = (String) content.get(IMakerKeyConstants.ADDITIONAL_PARAMETERS);
|
|
925 |
if(mods!=null) {
|
|
926 |
parts = mods.split(ImakerProperties.SEPARATOR);
|
|
927 |
for (int i = 0; i < parts.length; i++) {
|
|
928 |
modified.add(parts[i]);
|
|
929 |
}
|
|
930 |
}
|
|
931 |
String drive = activeEnvironment.getDrive();
|
|
932 |
IRunnableWithProgress op = new IMakerSettingsUpdater(modified,drive);
|
|
933 |
executeRunnable(op);
|
|
934 |
}
|
|
935 |
|
|
936 |
|
|
937 |
/**
|
|
938 |
* @throws InterruptedException
|
|
939 |
*
|
|
940 |
*/
|
|
941 |
private void loadDefaults() throws InvocationTargetException {
|
|
942 |
loadConfigurations();
|
|
943 |
tabDebug.clear();
|
|
944 |
platsimTab.clear();
|
|
945 |
updateDefaultTarget(getDefaultConfig());
|
|
946 |
}
|
|
947 |
|
|
948 |
/**
|
|
949 |
*
|
|
950 |
*/
|
|
951 |
public void restore() {
|
|
952 |
UIConfiguration def = getDefaultConfig();
|
|
953 |
refreshProduct(def);
|
|
954 |
updateDefaultTarget(def);
|
|
955 |
}
|
|
956 |
|
|
957 |
/**
|
|
958 |
* @param def
|
|
959 |
*
|
|
960 |
*/
|
|
961 |
private void updateDefaultTarget(UIConfiguration def) {
|
|
962 |
if(def==null) return;
|
|
963 |
String target = "default";
|
|
964 |
addToListTarget(new String[]{target});
|
|
965 |
}
|
|
966 |
|
|
967 |
public void setPlatsim(PlatsimTab tabPlatsim) {
|
|
968 |
this.platsimTab = tabPlatsim;
|
|
969 |
}
|
|
970 |
|
|
971 |
public String[] getSelectedTargets() {
|
|
972 |
return listTarget.getItems();
|
|
973 |
}
|
|
974 |
|
|
975 |
public UIConfiguration getSelectedProduct() {
|
|
976 |
return activeEnvironment.getCurrentProduct();
|
|
977 |
}
|
|
978 |
}
|