0
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 |
|
|
19 |
|
|
20 |
package com.nokia.s60tools.ui.wizards;
|
|
21 |
|
|
22 |
import java.io.File;
|
|
23 |
import org.eclipse.swt.widgets.DirectoryDialog;
|
|
24 |
import org.eclipse.swt.SWT;
|
|
25 |
import org.eclipse.swt.dnd.DND;
|
|
26 |
import org.eclipse.swt.dnd.DropTarget;
|
|
27 |
import org.eclipse.swt.dnd.DropTargetEvent;
|
|
28 |
import org.eclipse.swt.dnd.DropTargetListener;
|
|
29 |
import org.eclipse.swt.dnd.FileTransfer;
|
|
30 |
import org.eclipse.swt.dnd.Transfer;
|
|
31 |
import org.eclipse.swt.events.ModifyEvent;
|
|
32 |
import org.eclipse.swt.events.ModifyListener;
|
|
33 |
import org.eclipse.swt.events.SelectionEvent;
|
|
34 |
import org.eclipse.swt.events.SelectionListener;
|
|
35 |
import org.eclipse.swt.layout.GridData;
|
|
36 |
import org.eclipse.swt.layout.GridLayout;
|
|
37 |
import org.eclipse.swt.widgets.Button;
|
|
38 |
import org.eclipse.swt.widgets.List;
|
|
39 |
import org.eclipse.swt.widgets.Combo;
|
|
40 |
import org.eclipse.swt.widgets.Composite;
|
|
41 |
import org.eclipse.swt.widgets.FileDialog;
|
|
42 |
import org.eclipse.swt.widgets.Group;
|
|
43 |
import org.eclipse.swt.widgets.Label;
|
|
44 |
import org.eclipse.swt.widgets.Text;
|
|
45 |
import org.eclipse.ui.PlatformUI;
|
|
46 |
import org.eclipse.jface.dialogs.IDialogSettings;
|
|
47 |
|
|
48 |
import com.nokia.s60tools.ui.internal.resources.Messages;
|
|
49 |
|
|
50 |
import java.util.*;
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Wizard page for querying user for: Symbol, map and image files.
|
|
54 |
*
|
|
55 |
* This page can also be used to query selge.ini location, but this
|
|
56 |
* functionality is hidden from the user at the moment. It might
|
|
57 |
* be restored in the future.
|
|
58 |
*
|
|
59 |
*/
|
|
60 |
public abstract class DebugMetadataWizardPage extends S60ToolsWizardPage implements
|
|
61 |
SelectionListener, ModifyListener, DropTargetListener {
|
|
62 |
|
|
63 |
// defines for map file radio buttons
|
|
64 |
final int NO_MAP_FILES_RADIO = 0;
|
|
65 |
final int SDK_MAP_FILES_FOLDER_RADIO = 1;
|
|
66 |
final int MAP_FILES_ZIP_RADIO = 2;
|
|
67 |
final int MAP_FILES_FOLDER_RADIO = 3;
|
|
68 |
|
|
69 |
// width hint for all buttons in the page
|
|
70 |
final int BUTTON_WIDTH = 60;
|
|
71 |
// height hint for all lists in the page
|
|
72 |
final int LIST_HEIGHT = 50;
|
|
73 |
|
|
74 |
// filters for file selection dialogs
|
|
75 |
static final String SELGE_INI_FILTER = "selge.ini";
|
|
76 |
static final String SYMBOL_FILTER = "*.symbol";
|
|
77 |
static final String ZIP_FILTER = "*.zip";
|
|
78 |
static final String[] IMAGE_FILTER = {"*.fpsx", "*.img", "*.v??", ".c??", "*.*"};
|
|
79 |
|
|
80 |
// wizard saves last entered values to these tags in dialog_settings.xml
|
|
81 |
static final String LAST_USED_SELGE_INI_FILES = "SelgeIniFiles"; //$NON-NLS-1$
|
|
82 |
static final String LAST_USED_SYMBOL_FILES = "SymbolFiles"; //$NON-NLS-1$
|
|
83 |
static final String LAST_USED_DECODING_STYLE = "SymbolFileWasUsedLast"; //$NON-NLS-1$
|
|
84 |
static final String LAST_USED_MAPFILES_FOLDER = "MapFilesFolder"; //$NON-NLS-1$
|
|
85 |
static final String LAST_USED_MAPZIP_FILES = "MapZipFiles"; //$NON-NLS-1$
|
|
86 |
static final String LAST_USED_IMAGE_FILES = "ImageFiles"; //$NON-NLS-1$
|
|
87 |
static final String LAST_USED_MAPFILE_TYPE = "LastUsedMapFileType"; //$NON-NLS-1$
|
|
88 |
static final String LAST_USED_SDK = "LastUsedSdk"; //$NON-NLS-1$
|
|
89 |
|
|
90 |
// top level containers
|
|
91 |
protected Composite composite;
|
|
92 |
protected Group groupSelge; // selge group is hidden at all times. Might be restored in the future
|
|
93 |
|
|
94 |
// selge.ini page items. Page cannot be show at the moment. Might be restored in the future.
|
|
95 |
protected Button buttonSelgeRadio;
|
|
96 |
protected Button buttonSelgeBrowse;
|
|
97 |
protected Button buttonShowSelgeDetails;
|
|
98 |
protected Text textSelgeDetails;
|
|
99 |
protected Combo comboSelge;
|
|
100 |
protected Label labelSelge;
|
|
101 |
|
|
102 |
// symbol page items
|
|
103 |
protected Button buttonSymbolRadio = null;
|
|
104 |
protected Button buttonMapFolderBrowse;
|
|
105 |
protected Button buttonZipBrowse;
|
|
106 |
protected Button buttonMapFilesZipRadio;
|
|
107 |
protected Button buttonMapFilesFolderRadio;
|
|
108 |
protected Button buttonSdkFolderRadio;
|
|
109 |
protected Button buttonNoMapFilesRadio;
|
|
110 |
protected Button buttonAddSymbol;
|
|
111 |
protected Button buttonRemoveSymbol;
|
|
112 |
protected Button buttonAddImageFile;
|
|
113 |
protected Button buttonRemoveImageFile;
|
|
114 |
protected Combo comboMapFilesFolder;
|
|
115 |
protected Combo comboMapFilesZip;
|
|
116 |
protected Combo comboSdkFolder;
|
|
117 |
protected Group groupSymbolFiles;
|
|
118 |
protected Group groupMapFiles;
|
|
119 |
protected Group groupImageFiles;
|
|
120 |
protected Group groupSelgeSymbolRadios;
|
|
121 |
protected Label labelMapFilesFolder;
|
|
122 |
protected Label labelZip;
|
|
123 |
protected Label labelSdkFolder;
|
|
124 |
protected Label labelNoMapFiles;
|
|
125 |
protected List listSymbols;
|
|
126 |
protected List listImageFiles;
|
|
127 |
|
|
128 |
// owner can pass in ROM IDs so that we can check that correct symbol is selected
|
|
129 |
protected String[] romIds = null;
|
|
130 |
|
|
131 |
// holds SDK names and their folders
|
|
132 |
protected HashMap<String, String> sdkFolders = null;
|
|
133 |
|
|
134 |
// default location of selge.ini.
|
|
135 |
protected String defaultSelgeIniFile = "\\\\Vagrp014\\groups4\\Builds\\S60RnD\\S60_5_0\\SelgeIniFile\\selge.ini"; //$NON-NLS-1$
|
|
136 |
|
|
137 |
// defines whether image files selection should be visible in the page
|
|
138 |
boolean showImageFilesGroup = false;
|
|
139 |
|
|
140 |
// section where this wizard pages data is saved
|
|
141 |
IDialogSettings previousValuesSection;
|
|
142 |
|
|
143 |
// defines how many previous user entered values are saved
|
|
144 |
final int MAX_SAVED_VALUES;
|
|
145 |
|
|
146 |
/**
|
|
147 |
* Constructor.
|
|
148 |
*
|
|
149 |
* @param pageName name of the page
|
|
150 |
* @param title page title
|
|
151 |
* @param imageFilesGroup if true, image files are queried from user. If false, image file are not queried
|
|
152 |
* @param section section where wizard reads/saves previously entered values
|
|
153 |
* @param maxSavedValues how many previously entered values are saved
|
|
154 |
*/
|
|
155 |
public DebugMetadataWizardPage(String pageName,
|
|
156 |
String title,
|
|
157 |
boolean imageFilesGroup,
|
|
158 |
IDialogSettings section,
|
|
159 |
int maxSavedValues){
|
|
160 |
super(pageName);
|
|
161 |
MAX_SAVED_VALUES = maxSavedValues;
|
|
162 |
showImageFilesGroup = imageFilesGroup;
|
|
163 |
previousValuesSection = section;
|
|
164 |
|
|
165 |
setTitle(title);
|
|
166 |
|
|
167 |
setDescription(Messages.getString("DebugMetadataWizardPage.SelgeIniDescription")); //$NON-NLS-1$
|
|
168 |
|
|
169 |
setPageComplete(true);
|
|
170 |
}
|
|
171 |
|
|
172 |
public abstract String getHelpContext();
|
|
173 |
public abstract boolean canFinish();
|
|
174 |
public abstract HashMap<String, String> getSdkMapFolders();
|
|
175 |
public abstract boolean folderContainsMapFiles(String folder);
|
|
176 |
public abstract boolean zipContainsMapFiles(String path);
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
@Override
|
|
181 |
public void recalculateButtonStates() {
|
|
182 |
}
|
|
183 |
|
|
184 |
@Override
|
|
185 |
public void setInitialFocus() {
|
|
186 |
if (buttonSelgeRadio.getSelection())
|
|
187 |
comboSelge.setFocus();
|
|
188 |
else
|
|
189 |
listSymbols.setFocus();
|
|
190 |
}
|
|
191 |
|
|
192 |
/**
|
|
193 |
* @see org.eclipse.jface.wizard.WizardPage
|
|
194 |
*/
|
|
195 |
public void createControl(Composite parent) {
|
|
196 |
composite = new Composite(parent, SWT.NULL);
|
|
197 |
GridLayout gl = new GridLayout();
|
|
198 |
gl.numColumns = 1;
|
|
199 |
composite.setLayout(gl);
|
|
200 |
|
|
201 |
groupSelgeSymbolRadios = new Group(composite, SWT.NONE);
|
|
202 |
groupSelgeSymbolRadios.setLayout(gl);
|
|
203 |
groupSelgeSymbolRadios.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
204 |
|
|
205 |
// Selge.ini radio button
|
|
206 |
buttonSelgeRadio = new Button(groupSelgeSymbolRadios, SWT.RADIO);
|
|
207 |
buttonSelgeRadio.setText(Messages.getString("DebugMetadataWizardPage.UseSelgeIni")); //$NON-NLS-1$
|
|
208 |
buttonSelgeRadio.setSelection(!symbolFileWasUsedPreviously());
|
|
209 |
buttonSelgeRadio.addSelectionListener(this);
|
|
210 |
|
|
211 |
// symbol & map files radio button
|
|
212 |
buttonSymbolRadio = new Button(groupSelgeSymbolRadios, SWT.RADIO);
|
|
213 |
buttonSymbolRadio.setText(Messages.getString("DebugMetadataWizardPage.DefinePathsManually")); //$NON-NLS-1$
|
|
214 |
buttonSymbolRadio.setSelection(symbolFileWasUsedPreviously());
|
|
215 |
|
|
216 |
createSelgeGroup();
|
|
217 |
|
|
218 |
createSymbolGroup();
|
|
219 |
|
|
220 |
setHelps();
|
|
221 |
|
|
222 |
setInitialFocus();
|
|
223 |
|
|
224 |
// selge.ini is not used at the moment, but it might be restored later
|
|
225 |
hideSelgeIniSelection();
|
|
226 |
|
|
227 |
Transfer[] types = new Transfer[] { FileTransfer.getInstance() };
|
|
228 |
DropTarget dropTarget = new DropTarget(composite, DND.DROP_COPY);
|
|
229 |
dropTarget.setTransfer(types);
|
|
230 |
dropTarget.addDropListener(this);
|
|
231 |
|
|
232 |
setControl(composite);
|
|
233 |
}
|
|
234 |
|
|
235 |
/**
|
|
236 |
* Creates UI controls for selge.ini usage
|
|
237 |
*
|
|
238 |
*/
|
|
239 |
void createSelgeGroup() {
|
|
240 |
// Selge.ini group
|
|
241 |
groupSelge = new Group(composite, SWT.NONE);
|
|
242 |
GridLayout gl = new GridLayout();
|
|
243 |
GridData selgeGd = new GridData(GridData.FILL_BOTH);
|
|
244 |
gl.numColumns = 2;
|
|
245 |
groupSelge.setLayout(gl);
|
|
246 |
|
|
247 |
// show selge group if user used selge.ini last time, hide if symbol & map files was used
|
|
248 |
groupSelge.setVisible(!symbolFileWasUsedPreviously());
|
|
249 |
selgeGd.exclude = symbolFileWasUsedPreviously();
|
|
250 |
groupSelge.setLayoutData(selgeGd);
|
|
251 |
|
|
252 |
// Selge.ini label
|
|
253 |
labelSelge = new Label(groupSelge, SWT.LEFT);
|
|
254 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
|
255 |
gd.horizontalSpan = 2;
|
|
256 |
labelSelge.setLayoutData(gd);
|
|
257 |
labelSelge.setText(Messages.getString("DebugMetadataWizardPage.SelgeIniFile")); //$NON-NLS-1$
|
|
258 |
|
|
259 |
// Selge.ini combo
|
|
260 |
comboSelge = new Combo(groupSelge, SWT.BORDER);
|
|
261 |
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
|
|
262 |
comboSelge.setLayoutData(gd);
|
|
263 |
comboSelge.addModifyListener(this);
|
|
264 |
|
|
265 |
String[] lastUsed = getPreviousPaths(LAST_USED_SELGE_INI_FILES);
|
|
266 |
// set the previous selge.ini file as default
|
|
267 |
if (lastUsed != null) {
|
|
268 |
comboSelge.setItems(lastUsed);
|
|
269 |
comboSelge.select(0);
|
|
270 |
// user has not defined selge.ini previously, show default location
|
|
271 |
} else {
|
|
272 |
comboSelge.setText(defaultSelgeIniFile);
|
|
273 |
}
|
|
274 |
|
|
275 |
// Selge.ini browse button
|
|
276 |
buttonSelgeBrowse = new Button(groupSelge, SWT.PUSH);
|
|
277 |
buttonSelgeBrowse.setText(Messages.getString("DebugMetadataWizardPage.Browse")); //$NON-NLS-1$
|
|
278 |
buttonSelgeBrowse.addSelectionListener(this);
|
|
279 |
|
|
280 |
// Show selge.ini details button is not yet used i.e. shown to user
|
|
281 |
GridData gdDetailsButton = new GridData();
|
|
282 |
gdDetailsButton.horizontalSpan = 2;
|
|
283 |
buttonShowSelgeDetails = new Button(groupSelge, SWT.PUSH);
|
|
284 |
buttonShowSelgeDetails.setText(Messages.getString("DebugMetadataWizardPage.ShowDetails")); //$NON-NLS-1$
|
|
285 |
buttonShowSelgeDetails.setLayoutData(gdDetailsButton);
|
|
286 |
buttonShowSelgeDetails.addSelectionListener(this);
|
|
287 |
buttonShowSelgeDetails.setVisible(false);
|
|
288 |
|
|
289 |
// textbox for selge.ini details. Not yet used.
|
|
290 |
textSelgeDetails = new Text(groupSelge, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
|
|
291 |
textSelgeDetails.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
292 |
}
|
|
293 |
|
|
294 |
/**
|
|
295 |
* Creates UI controls for symbol & map & image files usage.
|
|
296 |
*
|
|
297 |
*/
|
|
298 |
void createSymbolGroup() {
|
|
299 |
// Symbol group
|
|
300 |
GridLayout gl = new GridLayout();
|
|
301 |
gl.numColumns = 2;
|
|
302 |
GridData gd = new GridData(GridData.FILL_BOTH);
|
|
303 |
|
|
304 |
boolean visible = symbolFileWasUsedPreviously();
|
|
305 |
// show symbol group if user used symbol & map files last time, hide if selge.ini was used
|
|
306 |
gd.exclude = !visible;
|
|
307 |
if (visible)
|
|
308 |
setDescription(Messages.getString("DebugMetadataWizardPage.SymbolDescription")); //$NON-NLS-1$
|
|
309 |
|
|
310 |
// Symbol files group
|
|
311 |
groupSymbolFiles = new Group(composite, SWT.LEFT);
|
|
312 |
groupSymbolFiles.setLayout(gl);
|
|
313 |
groupSymbolFiles.setLayoutData(new GridData(GridData.FILL_BOTH));
|
|
314 |
GridData gdTwoSpan = new GridData(GridData.FILL_HORIZONTAL);
|
|
315 |
gdTwoSpan.horizontalSpan = 2;
|
|
316 |
groupSymbolFiles.setText(Messages.getString("DebugMetadataWizardPage.SymbolFiles")); //$NON-NLS-1$
|
|
317 |
|
|
318 |
// Symbol file list
|
|
319 |
listSymbols = new List(groupSymbolFiles, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
|
|
320 |
GridData gdHorizontalTop = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
|
|
321 |
gdHorizontalTop.verticalSpan = 2;
|
|
322 |
gdHorizontalTop.heightHint = LIST_HEIGHT;
|
|
323 |
listSymbols.setLayoutData(gdHorizontalTop);
|
|
324 |
|
|
325 |
// read last used symbol files to combo
|
|
326 |
String[] lastUsed = getPreviousPaths(LAST_USED_SYMBOL_FILES);
|
|
327 |
if (lastUsed != null) {
|
|
328 |
listSymbols.setItems(lastUsed);
|
|
329 |
}
|
|
330 |
|
|
331 |
GridData gdButtons = new GridData();
|
|
332 |
gdButtons.widthHint = BUTTON_WIDTH;
|
|
333 |
|
|
334 |
// Add Symbol file button
|
|
335 |
buttonAddSymbol = new Button(groupSymbolFiles, SWT.PUSH);
|
|
336 |
buttonAddSymbol.setText(Messages.getString("DebugMetadataWizardPage.Add")); //$NON-NLS-1$
|
|
337 |
buttonAddSymbol.setLayoutData(gdButtons);
|
|
338 |
buttonAddSymbol.addSelectionListener(this);
|
|
339 |
|
|
340 |
// Remove Symbol file button
|
|
341 |
buttonRemoveSymbol = new Button(groupSymbolFiles, SWT.PUSH);
|
|
342 |
buttonRemoveSymbol.setText(Messages.getString("DebugMetadataWizardPage.Remove")); //$NON-NLS-1$
|
|
343 |
buttonRemoveSymbol.setLayoutData(gdButtons);
|
|
344 |
buttonRemoveSymbol.addSelectionListener(this);
|
|
345 |
|
|
346 |
createMapFilesGroup(composite);
|
|
347 |
|
|
348 |
// if image files UI is wanted, create it
|
|
349 |
if (showImageFilesGroup)
|
|
350 |
createImageFilesGroup(composite);
|
|
351 |
}
|
|
352 |
|
|
353 |
/**
|
|
354 |
* Creates UI controls for map files usage.
|
|
355 |
*
|
|
356 |
*/
|
|
357 |
void createMapFilesGroup(Composite parent) {
|
|
358 |
// Map Files group
|
|
359 |
groupMapFiles = new Group(parent, SWT.NONE);
|
|
360 |
GridData gd = new GridData(GridData.FILL_BOTH);
|
|
361 |
gd.horizontalSpan = 2;
|
|
362 |
gd.verticalIndent = 10;
|
|
363 |
GridLayout gl = new GridLayout();
|
|
364 |
gl.numColumns = 3;
|
|
365 |
groupMapFiles.setLayout(gl);
|
|
366 |
groupMapFiles.setText(Messages.getString("DebugMetadataWizardPage.MapFiles")); //$NON-NLS-1$
|
|
367 |
groupMapFiles.setLayoutData(gd);
|
|
368 |
|
|
369 |
// empty label to make layout correct
|
|
370 |
new Label(groupMapFiles, SWT.LEFT);
|
|
371 |
|
|
372 |
// Map files folder label
|
|
373 |
labelMapFilesFolder = new Label(groupMapFiles, SWT.LEFT);
|
|
374 |
GridData gdTwoSpanWithIndent = new GridData(GridData.FILL_HORIZONTAL);
|
|
375 |
gdTwoSpanWithIndent.horizontalSpan = 2;
|
|
376 |
gdTwoSpanWithIndent.verticalIndent = 10;
|
|
377 |
labelMapFilesFolder.setLayoutData(gdTwoSpanWithIndent);
|
|
378 |
labelMapFilesFolder.setText(Messages.getString("DebugMetadataWizardPage.MapFilesFolder")); //$NON-NLS-1$
|
|
379 |
|
|
380 |
// Map files folder radio button
|
|
381 |
buttonMapFilesFolderRadio = new Button(groupMapFiles, SWT.RADIO);
|
|
382 |
buttonMapFilesFolderRadio.addSelectionListener(this);
|
|
383 |
|
|
384 |
// Map files folder combo
|
|
385 |
comboMapFilesFolder = new Combo(groupMapFiles, SWT.BORDER);
|
|
386 |
GridData gdHorizontal = new GridData(GridData.FILL_HORIZONTAL);
|
|
387 |
comboMapFilesFolder.setLayoutData(gdHorizontal);
|
|
388 |
comboMapFilesFolder.addModifyListener(this);
|
|
389 |
|
|
390 |
// read last used map file folders to combo
|
|
391 |
String[] lastUsed = getPreviousPaths(LAST_USED_MAPFILES_FOLDER);
|
|
392 |
if (lastUsed != null) {
|
|
393 |
comboMapFilesFolder.setItems(lastUsed);
|
|
394 |
comboMapFilesFolder.select(0);
|
|
395 |
}
|
|
396 |
|
|
397 |
// Map files folder browse button
|
|
398 |
buttonMapFolderBrowse = new Button(groupMapFiles, SWT.PUSH);
|
|
399 |
buttonMapFolderBrowse.setText(Messages.getString("DebugMetadataWizardPage.Browse")); //$NON-NLS-1$
|
|
400 |
buttonMapFolderBrowse.addSelectionListener(this);
|
|
401 |
|
|
402 |
// empty label to make layout correct
|
|
403 |
new Label(groupMapFiles, SWT.LEFT);
|
|
404 |
|
|
405 |
// MapFiles.zip label
|
|
406 |
labelZip = new Label(groupMapFiles, SWT.LEFT);
|
|
407 |
GridData gdTwoSpan = new GridData(GridData.FILL_HORIZONTAL);
|
|
408 |
gdTwoSpan.horizontalSpan = 2;
|
|
409 |
labelZip.setLayoutData(gdTwoSpan);
|
|
410 |
labelZip.setText(Messages.getString("DebugMetadataWizardPage.MapFilesZip")); //$NON-NLS-1$
|
|
411 |
|
|
412 |
// MapFiles.zip radio button
|
|
413 |
buttonMapFilesZipRadio = new Button(groupMapFiles, SWT.RADIO);
|
|
414 |
buttonMapFilesZipRadio.addSelectionListener(this);
|
|
415 |
|
|
416 |
// MapFiles.zip combo
|
|
417 |
comboMapFilesZip = new Combo(groupMapFiles, SWT.BORDER);
|
|
418 |
comboMapFilesZip.setLayoutData(gdHorizontal);
|
|
419 |
comboMapFilesZip.addModifyListener(this);
|
|
420 |
|
|
421 |
// read last used mapfiles.zip file paths to combo
|
|
422 |
lastUsed = getPreviousPaths(LAST_USED_MAPZIP_FILES);
|
|
423 |
if (lastUsed != null) {
|
|
424 |
comboMapFilesZip.setItems(lastUsed);
|
|
425 |
comboMapFilesZip.select(0);
|
|
426 |
}
|
|
427 |
|
|
428 |
// MapFiles.zip browse button
|
|
429 |
buttonZipBrowse = new Button(groupMapFiles, SWT.PUSH);
|
|
430 |
buttonZipBrowse.setText(Messages.getString("DebugMetadataWizardPage.Browse")); //$NON-NLS-1$
|
|
431 |
buttonZipBrowse.addSelectionListener(this);
|
|
432 |
|
|
433 |
// empty label to make layout correct
|
|
434 |
new Label(groupMapFiles, SWT.LEFT);
|
|
435 |
|
|
436 |
// SDK folder label
|
|
437 |
labelSdkFolder = new Label(groupMapFiles, SWT.LEFT);
|
|
438 |
labelSdkFolder.setLayoutData(gdTwoSpan);
|
|
439 |
labelSdkFolder.setText(Messages.getString("DebugMetadataWizardPage.SdkMapFilesFolder")); //$NON-NLS-1$
|
|
440 |
|
|
441 |
// SDK folder radio button
|
|
442 |
buttonSdkFolderRadio = new Button(groupMapFiles, SWT.RADIO);
|
|
443 |
buttonSdkFolderRadio.addSelectionListener(this);
|
|
444 |
|
|
445 |
// SDK folder combo
|
|
446 |
comboSdkFolder = new Combo(groupMapFiles, SWT.BORDER | SWT.READ_ONLY);
|
|
447 |
comboSdkFolder.setLayoutData(gdHorizontal);
|
|
448 |
comboSdkFolder.addModifyListener(this);
|
|
449 |
comboSdkFolder.setVisibleItemCount(50);
|
|
450 |
|
|
451 |
sdkFolders = getSdkMapFolders();
|
|
452 |
|
|
453 |
// if no SDK folders were found disable SDK combo
|
|
454 |
if (sdkFolders == null || sdkFolders.size() < 1) {
|
|
455 |
disableSdkSelection();
|
|
456 |
// SDK folders were found, fill SDK combo with those values
|
|
457 |
} else {
|
|
458 |
Set<String> keySet = sdkFolders.keySet();
|
|
459 |
String[] keys = keySet.toArray(new String[keySet.size()]);
|
|
460 |
Arrays.sort(keys);
|
|
461 |
comboSdkFolder.setItems(keys);
|
|
462 |
}
|
|
463 |
|
|
464 |
// read which SDK folder was used last, and select it in SDK combo if possible
|
|
465 |
lastUsed = getPreviousPaths(LAST_USED_SDK);
|
|
466 |
if (lastUsed != null && sdkFolders != null && buttonSdkFolderRadio.getEnabled()) {
|
|
467 |
String[] items = comboSdkFolder.getItems();
|
|
468 |
for (int i = 0; i < items.length; i++) {
|
|
469 |
if (items[i].equalsIgnoreCase(lastUsed[0])) {
|
|
470 |
comboSdkFolder.select(i);
|
|
471 |
break;
|
|
472 |
}
|
|
473 |
}
|
|
474 |
}
|
|
475 |
|
|
476 |
// empty label to make layout correct
|
|
477 |
new Label(groupMapFiles, SWT.LEFT);
|
|
478 |
|
|
479 |
// No map files radio button
|
|
480 |
buttonNoMapFilesRadio = new Button(groupMapFiles, SWT.RADIO);
|
|
481 |
buttonNoMapFilesRadio.addSelectionListener(this);
|
|
482 |
|
|
483 |
// No map files label
|
|
484 |
labelNoMapFiles = new Label(groupMapFiles, SWT.LEFT);
|
|
485 |
labelNoMapFiles.setText(Messages.getString("DebugMetadataWizardPage.NoMapFiles")); //$NON-NLS-1$
|
|
486 |
labelNoMapFiles.setLayoutData(gdTwoSpan);
|
|
487 |
|
|
488 |
// read how map files were used last time (i.e. which radio button
|
|
489 |
// was selected) and select the same radio button this time.
|
|
490 |
int lastUsedMapRadio = lastUsedMapFileType();
|
|
491 |
switch (lastUsedMapRadio) {
|
|
492 |
case MAP_FILES_FOLDER_RADIO:
|
|
493 |
buttonMapFilesFolderRadio.setSelection(true);
|
|
494 |
break;
|
|
495 |
case MAP_FILES_ZIP_RADIO:
|
|
496 |
buttonMapFilesZipRadio.setSelection(true);
|
|
497 |
break;
|
|
498 |
case SDK_MAP_FILES_FOLDER_RADIO:
|
|
499 |
buttonSdkFolderRadio.setSelection(true);
|
|
500 |
break;
|
|
501 |
default:
|
|
502 |
buttonNoMapFilesRadio.setSelection(true);
|
|
503 |
break;
|
|
504 |
}
|
|
505 |
|
|
506 |
enableMapSelections();
|
|
507 |
}
|
|
508 |
|
|
509 |
/**
|
|
510 |
* Creates UI controls for image files usage.
|
|
511 |
*
|
|
512 |
*/
|
|
513 |
void createImageFilesGroup(Composite parent) {
|
|
514 |
// Image files group
|
|
515 |
groupImageFiles = new Group(parent, SWT.NONE);
|
|
516 |
GridData gd = new GridData(GridData.FILL_BOTH);
|
|
517 |
gd.horizontalSpan = 2;
|
|
518 |
gd.verticalIndent = 10;
|
|
519 |
GridLayout gl = new GridLayout();
|
|
520 |
gl.numColumns = 2;
|
|
521 |
groupImageFiles.setLayout(gl);
|
|
522 |
groupImageFiles.setText(Messages.getString("DebugMetadataWizardPage.ImageFiles")); //$NON-NLS-1$
|
|
523 |
groupImageFiles.setLayoutData(gd);
|
|
524 |
|
|
525 |
// Image file list
|
|
526 |
listImageFiles = new List(groupImageFiles, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
|
|
527 |
GridData gdHorizontalTop = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
|
|
528 |
gdHorizontalTop.verticalSpan = 2;
|
|
529 |
gdHorizontalTop.heightHint = LIST_HEIGHT;
|
|
530 |
listImageFiles.setLayoutData(gdHorizontalTop);
|
|
531 |
|
|
532 |
// read last used image files and fill them into the list
|
|
533 |
String[] lastUsed = getPreviousPaths(LAST_USED_IMAGE_FILES);
|
|
534 |
if (lastUsed != null) {
|
|
535 |
listImageFiles.setItems(lastUsed);
|
|
536 |
}
|
|
537 |
|
|
538 |
GridData gdButtons = new GridData();
|
|
539 |
gdButtons.widthHint = BUTTON_WIDTH;
|
|
540 |
|
|
541 |
// Add image file button
|
|
542 |
buttonAddImageFile = new Button(groupImageFiles, SWT.PUSH);
|
|
543 |
buttonAddImageFile.setText(Messages.getString("DebugMetadataWizardPage.Add")); //$NON-NLS-1$
|
|
544 |
buttonAddImageFile.setLayoutData(gdButtons);
|
|
545 |
buttonAddImageFile.addSelectionListener(this);
|
|
546 |
|
|
547 |
// Remove image file button
|
|
548 |
buttonRemoveImageFile = new Button(groupImageFiles, SWT.PUSH);
|
|
549 |
buttonRemoveImageFile.setText(Messages.getString("DebugMetadataWizardPage.Remove")); //$NON-NLS-1$
|
|
550 |
buttonRemoveImageFile.setLayoutData(gdButtons);
|
|
551 |
buttonRemoveImageFile.addSelectionListener(this);
|
|
552 |
}
|
|
553 |
|
|
554 |
/**
|
|
555 |
* This'll disable selge.ini selection from user
|
|
556 |
*/
|
|
557 |
void hideSelgeIniSelection() {
|
|
558 |
// hide radios group
|
|
559 |
GridData gd = (GridData)groupSelgeSymbolRadios.getLayoutData();
|
|
560 |
gd.exclude = true;
|
|
561 |
groupSelgeSymbolRadios.setVisible(false);
|
|
562 |
buttonSymbolRadio.setSelection(true);
|
|
563 |
|
|
564 |
// show symbol group
|
|
565 |
// ROWS COMMENTED SO THAT THEY CAN BE RESTORED INCASE SELGE.INI USAGE IS RESTORED
|
|
566 |
/* gd = (GridData)groupSymbol.getLayoutData();
|
|
567 |
groupSymbol.setVisible(true);
|
|
568 |
gd.exclude = false;
|
|
569 |
*/
|
|
570 |
// hide selge group
|
|
571 |
gd = (GridData)groupSelge.getLayoutData();
|
|
572 |
gd.exclude = true;
|
|
573 |
groupSelge.setVisible(false);
|
|
574 |
buttonSelgeRadio.setSelection(false);
|
|
575 |
|
|
576 |
setDescription(Messages.getString("DebugMetadataWizardPage.SymbolDescription")); //$NON-NLS-1$
|
|
577 |
|
|
578 |
composite.layout();
|
|
579 |
}
|
|
580 |
|
|
581 |
/**
|
|
582 |
* Return the default selge.ini file
|
|
583 |
*/
|
|
584 |
public String getDefaultSelgeIniFile() {
|
|
585 |
return defaultSelgeIniFile;
|
|
586 |
}
|
|
587 |
|
|
588 |
/**
|
|
589 |
* Returns the selected selge.ini file. Returns empty if symbol group
|
|
590 |
* is visible.
|
|
591 |
*/
|
|
592 |
public String getSelgeIniFile() {
|
|
593 |
if (buttonSymbolRadio.getSelection()) {
|
|
594 |
return ""; //$NON-NLS-1$
|
|
595 |
} else {
|
|
596 |
return comboSelge.getText();
|
|
597 |
}
|
|
598 |
}
|
|
599 |
|
|
600 |
/**
|
|
601 |
* Returns symbols files selected by user. If selge.ini group is visible,
|
|
602 |
* null is returned.
|
|
603 |
*/
|
|
604 |
public String[] getSymbolFiles() {
|
|
605 |
if (buttonSelgeRadio.getSelection()) {
|
|
606 |
return null;
|
|
607 |
}
|
|
608 |
|
|
609 |
return listSymbols.getItems();
|
|
610 |
}
|
|
611 |
|
|
612 |
/**
|
|
613 |
* Returns the selected map files folder. Return value depends on which
|
|
614 |
* map files radio button is selected. Returns empty if MapFiles.zip radio
|
|
615 |
* button is selected.
|
|
616 |
*/
|
|
617 |
public String getMapFilesFolder() {
|
|
618 |
// if selge.ini group is visible, return empty
|
|
619 |
if (buttonSelgeRadio.getSelection()) {
|
|
620 |
return ""; //$NON-NLS-1$
|
|
621 |
// MapFiles.zip radio is selected, return empty
|
|
622 |
}else if (buttonMapFilesZipRadio.getSelection()) {
|
|
623 |
return ""; //$NON-NLS-1$
|
|
624 |
// Map Files folder radio button is selected
|
|
625 |
} else if (buttonMapFilesFolderRadio.getSelection()) {
|
|
626 |
return comboMapFilesFolder.getText();
|
|
627 |
// "SDK Map files folder" radio button is selected, return correct sdk folder
|
|
628 |
} else if (buttonSdkFolderRadio.getSelection() &&
|
|
629 |
buttonSdkFolderRadio.getEnabled() &&
|
|
630 |
sdkFolders != null && sdkFolders.size() > 0 &&
|
|
631 |
comboSdkFolder.getSelectionIndex() >= 0) {
|
|
632 |
return sdkFolders.get(comboSdkFolder.getText());
|
|
633 |
// otherwise return empty
|
|
634 |
} else {
|
|
635 |
return ""; //$NON-NLS-1$
|
|
636 |
}
|
|
637 |
}
|
|
638 |
|
|
639 |
/**
|
|
640 |
* Returns the MapFiles.zip location user has provided. If MapFiles.zip radio button
|
|
641 |
* is not selected, this will return empty.
|
|
642 |
*/
|
|
643 |
public String getMapFilesZip() {
|
|
644 |
// if selge.ini group is visible, return empty
|
|
645 |
if (buttonSelgeRadio.getSelection()) {
|
|
646 |
return ""; //$NON-NLS-1$
|
|
647 |
// return empty if MapFiles.zip radio button is not selected
|
|
648 |
} else if (!buttonMapFilesZipRadio.getSelection()) {
|
|
649 |
return ""; //$NON-NLS-1$
|
|
650 |
}
|
|
651 |
|
|
652 |
return comboMapFilesZip.getText();
|
|
653 |
}
|
|
654 |
|
|
655 |
/**
|
|
656 |
* Returns image files selected by user. If selge.ini group is visible,
|
|
657 |
* null is returned.
|
|
658 |
*/
|
|
659 |
public String[] getImageFiles() {
|
|
660 |
if (buttonSelgeRadio.getSelection()) {
|
|
661 |
return null;
|
|
662 |
}
|
|
663 |
|
|
664 |
return listImageFiles.getItems();
|
|
665 |
}
|
|
666 |
|
|
667 |
/**
|
|
668 |
* Returns the provided ROM IDs
|
|
669 |
*/
|
|
670 |
public String[] getRomIds() {
|
|
671 |
return romIds;
|
|
672 |
}
|
|
673 |
|
|
674 |
|
|
675 |
/**
|
|
676 |
* Disables "SDK Map files folder" radio button & combo & label
|
|
677 |
*/
|
|
678 |
void disableSdkSelection() {
|
|
679 |
if (buttonSdkFolderRadio.getSelection())
|
|
680 |
buttonNoMapFilesRadio.setSelection(true);
|
|
681 |
buttonSdkFolderRadio.setEnabled(false);
|
|
682 |
comboSdkFolder.setEnabled(false);
|
|
683 |
}
|
|
684 |
|
|
685 |
public void widgetDefaultSelected(SelectionEvent arg0) {
|
|
686 |
}
|
|
687 |
|
|
688 |
public void widgetSelected(SelectionEvent event) {
|
|
689 |
// change between selge.ini "view" and symbol&map files "view"
|
|
690 |
if (event.widget == buttonSelgeRadio || event.widget == buttonSymbolRadio) {
|
|
691 |
this.setErrorMessage(null);
|
|
692 |
// ROWS COMMENTED SO THAT THEY CAN BE RESTORED INCASE SELGE.INI USAGE IS RESTORED
|
|
693 |
/* boolean selgeButtonSelected = buttonSelgeRadio.getSelection();
|
|
694 |
GridData gd = (GridData)groupSymbol.getLayoutData();
|
|
695 |
boolean visible = !(gd.exclude = selgeButtonSelected);
|
|
696 |
groupSymbol.setVisible(visible);
|
|
697 |
|
|
698 |
gd = (GridData)groupSelge.getLayoutData();
|
|
699 |
visible = !(gd.exclude = !selgeButtonSelected);
|
|
700 |
groupSelge.setVisible(visible);
|
|
701 |
if (visible) {
|
|
702 |
setDescription(Messages.getString("DebugMetadataWizardPage.SelgeIniDescription")); //$NON-NLS-1$
|
|
703 |
} else {
|
|
704 |
*/ setDescription(Messages.getString("DebugMetadataWizardPage.SymbolDescription")); //$NON-NLS-1$
|
|
705 |
// }
|
|
706 |
|
|
707 |
try {
|
|
708 |
getWizard().getContainer().updateButtons();
|
|
709 |
} catch (Exception E) {}
|
|
710 |
|
|
711 |
composite.layout();
|
|
712 |
|
|
713 |
// selge.ini browse button pressed
|
|
714 |
} else if (event.widget == buttonSelgeBrowse) {
|
|
715 |
FileDialog dialog = new FileDialog(this.getShell(), SWT.OPEN);
|
|
716 |
dialog.setText(Messages.getString("DebugMetadataWizardPage.SelectSelgeIniFile")); //$NON-NLS-1$
|
|
717 |
String[] filterExt = {SELGE_INI_FILTER};
|
|
718 |
dialog.setFilterExtensions(filterExt);
|
|
719 |
dialog.setFilterPath(comboSelge.getText());
|
|
720 |
String result = dialog.open();
|
|
721 |
comboSelge.setText(result);
|
|
722 |
|
|
723 |
// show selge.ini details button pressed
|
|
724 |
} else if (event.widget == buttonShowSelgeDetails) {
|
|
725 |
|
|
726 |
// Add symbol file button pressed
|
|
727 |
} else if (event.widget == buttonAddSymbol) {
|
|
728 |
FileDialog dialog = new FileDialog(this.getShell(), SWT.OPEN | SWT.MULTI);
|
|
729 |
dialog.setText(Messages.getString("DebugMetadataWizardPage.SelectSymbolFile")); //$NON-NLS-1$
|
|
730 |
String[] filterExt = {SYMBOL_FILTER};
|
|
731 |
dialog.setFilterExtensions(filterExt);
|
|
732 |
String result = dialog.open();
|
|
733 |
// if user selected files, check that files don't already exist in the list
|
|
734 |
// and add them if they don't already exist.
|
|
735 |
if (result != null) {
|
|
736 |
String[] fileNames = dialog.getFileNames();
|
|
737 |
if (fileNames != null) {
|
|
738 |
String path = dialog.getFilterPath() + File.separator;
|
|
739 |
for (int j = 0; j < fileNames.length; j++) {
|
|
740 |
String filePath = path + fileNames[j];
|
|
741 |
String[] listItems = listSymbols.getItems();
|
|
742 |
if (listItems != null && listItems.length > 0) {
|
|
743 |
boolean found = false;
|
|
744 |
for (int i = 0; i < listItems.length; i++) {
|
|
745 |
String listItem = listItems[i];
|
|
746 |
if (listItem.compareToIgnoreCase(filePath) == 0) {
|
|
747 |
found = true;
|
|
748 |
break;
|
|
749 |
}
|
|
750 |
}
|
|
751 |
if (!found)
|
|
752 |
listSymbols.add(filePath);
|
|
753 |
} else {
|
|
754 |
listSymbols.add(filePath);
|
|
755 |
}
|
|
756 |
}
|
|
757 |
}
|
|
758 |
}
|
|
759 |
|
|
760 |
// Remove symbol file button pressed
|
|
761 |
} else if (event.widget == buttonRemoveSymbol) {
|
|
762 |
int[] selectedItems = listSymbols.getSelectionIndices();
|
|
763 |
if (selectedItems != null && selectedItems.length > 0) {
|
|
764 |
listSymbols.remove(selectedItems);
|
|
765 |
}
|
|
766 |
|
|
767 |
// Add image file button pressed
|
|
768 |
} else if (event.widget == buttonAddImageFile) {
|
|
769 |
FileDialog dialog = new FileDialog(this.getShell(), SWT.OPEN | SWT.MULTI);
|
|
770 |
dialog.setText(Messages.getString("DebugMetadataWizardPage.SelectImageFile")); //$NON-NLS-1$
|
|
771 |
String[] filterExt = IMAGE_FILTER;
|
|
772 |
dialog.setFilterExtensions(filterExt);
|
|
773 |
String result = dialog.open();
|
|
774 |
// if user selected files, check that files don't already exist in the list
|
|
775 |
// and add them if they don't already exist.
|
|
776 |
if (result != null) {
|
|
777 |
String[] fileNames = dialog.getFileNames();
|
|
778 |
if (fileNames != null) {
|
|
779 |
String path = dialog.getFilterPath() + File.separator;
|
|
780 |
for (int j = 0; j < fileNames.length; j++) {
|
|
781 |
String filePath = path + fileNames[j];
|
|
782 |
String[] listItems = listImageFiles.getItems();
|
|
783 |
if (listItems != null && listItems.length > 0) {
|
|
784 |
boolean found = false;
|
|
785 |
for (int i = 0; i < listItems.length; i++) {
|
|
786 |
String listItem = listItems[i];
|
|
787 |
if (listItem.compareToIgnoreCase(filePath) == 0) {
|
|
788 |
found = true;
|
|
789 |
break;
|
|
790 |
}
|
|
791 |
}
|
|
792 |
if (!found)
|
|
793 |
listImageFiles.add(filePath);
|
|
794 |
} else {
|
|
795 |
listImageFiles.add(filePath);
|
|
796 |
}
|
|
797 |
}
|
|
798 |
}
|
|
799 |
}
|
|
800 |
|
|
801 |
// Remove image file button pressed
|
|
802 |
} else if (event.widget == buttonRemoveImageFile) {
|
|
803 |
int[] selectedItems = listImageFiles.getSelectionIndices();
|
|
804 |
if (selectedItems != null && selectedItems.length > 0) {
|
|
805 |
listImageFiles.remove(selectedItems);
|
|
806 |
}
|
|
807 |
|
|
808 |
// Map files folder browse button pressed
|
|
809 |
} else if (event.widget == buttonMapFolderBrowse) {
|
|
810 |
DirectoryDialog dialog = new DirectoryDialog(getShell());
|
|
811 |
dialog.setText(Messages.getString("DebugMetadataWizardPage.MapFilesFolder")); //$NON-NLS-1$
|
|
812 |
String result = dialog.open();
|
|
813 |
comboMapFilesFolder.setText(result);
|
|
814 |
|
|
815 |
// MapFiles.zip browse button pressed
|
|
816 |
} else if (event.widget == buttonZipBrowse) {
|
|
817 |
FileDialog dialog = new FileDialog(this.getShell(), SWT.OPEN);
|
|
818 |
dialog.setText(Messages.getString("DebugMetadataWizardPage.SelectMapFilesZip")); //$NON-NLS-1$
|
|
819 |
String[] filterExt = {ZIP_FILTER};
|
|
820 |
dialog.setFilterExtensions(filterExt);
|
|
821 |
String result = dialog.open();
|
|
822 |
comboMapFilesZip.setText(result);
|
|
823 |
|
|
824 |
// map files radio selection changed
|
|
825 |
} else if (event.widget == buttonMapFilesFolderRadio || event.widget == buttonMapFilesZipRadio ||
|
|
826 |
event.widget == buttonSdkFolderRadio || event.widget == buttonNoMapFilesRadio || event.widget == comboSdkFolder) {
|
|
827 |
enableMapSelections();
|
|
828 |
}
|
|
829 |
|
|
830 |
updateButtons();
|
|
831 |
}
|
|
832 |
|
|
833 |
/**
|
|
834 |
* Disables/Enables map file labels & combos & buttons accordingly to which
|
|
835 |
* Map Files radio button is selected.
|
|
836 |
*/
|
|
837 |
void enableMapSelections() {
|
|
838 |
comboMapFilesFolder.setEnabled(false);
|
|
839 |
buttonMapFolderBrowse.setEnabled(false);
|
|
840 |
comboMapFilesZip.setEnabled(false);
|
|
841 |
buttonZipBrowse.setEnabled(false);
|
|
842 |
comboSdkFolder.setEnabled(false);
|
|
843 |
|
|
844 |
// Map Files folder radio button is selected
|
|
845 |
if (buttonMapFilesFolderRadio.getSelection()) {
|
|
846 |
comboMapFilesFolder.setEnabled(true);
|
|
847 |
buttonMapFolderBrowse.setEnabled(true);
|
|
848 |
// MapFiles.zip radio button is selected
|
|
849 |
} else if (buttonMapFilesZipRadio.getSelection()) {
|
|
850 |
comboMapFilesZip.setEnabled(true);
|
|
851 |
buttonZipBrowse.setEnabled(true);
|
|
852 |
// SDK map files radio button is selected
|
|
853 |
} else if (buttonSdkFolderRadio.getSelection()) {
|
|
854 |
comboSdkFolder.setEnabled(true);
|
|
855 |
}
|
|
856 |
}
|
|
857 |
|
|
858 |
public void modifyText(ModifyEvent event) {
|
|
859 |
this.setErrorMessage(null);
|
|
860 |
updateButtons();
|
|
861 |
}
|
|
862 |
|
|
863 |
/**
|
|
864 |
* Checks that selected selge.ini file is valid.
|
|
865 |
*
|
|
866 |
*/
|
|
867 |
private boolean checkSelgeIniFile() {
|
|
868 |
this.setErrorMessage(null);
|
|
869 |
File selge = new File(comboSelge.getText());
|
|
870 |
if (selge.isFile() && selge.exists() && selge.getName().trim().toLowerCase().equals(SELGE_INI_FILTER)) {
|
|
871 |
return true;
|
|
872 |
} else {
|
|
873 |
if (comboSelge.getText().length() > 0)
|
|
874 |
this.setErrorMessage(Messages.getString("DebugMetadataWizardPage.InvalidSelgeIni")); //$NON-NLS-1$
|
|
875 |
return false;
|
|
876 |
}
|
|
877 |
}
|
|
878 |
|
|
879 |
/**
|
|
880 |
* Checks that atleast one symbol file is in the list
|
|
881 |
*/
|
|
882 |
boolean checkSymbol() {
|
|
883 |
if (listSymbols.getItemCount() < 1)
|
|
884 |
return false;
|
|
885 |
|
|
886 |
return true;
|
|
887 |
}
|
|
888 |
|
|
889 |
/**
|
|
890 |
* Checks that Map files folder or MapFiles.zip file is valid.
|
|
891 |
*/
|
|
892 |
boolean checkMapFiles(boolean cannotBeEmpty) {
|
|
893 |
// Map Files folder radio button is selected
|
|
894 |
if (buttonMapFilesFolderRadio.getSelection()) {
|
|
895 |
try {
|
|
896 |
File f = new File(comboMapFilesFolder.getText());
|
|
897 |
// given folder must exist and it must contain map files
|
|
898 |
if (f.isDirectory() && f.exists()) {
|
|
899 |
if (folderContainsMapFiles(comboMapFilesFolder.getText())) {
|
|
900 |
return true;
|
|
901 |
}
|
|
902 |
this.setErrorMessage(Messages.getString("DebugMetadataWizardPage.SelectedMapFilesFolderContainsNoMapFiles")); //$NON-NLS-1$
|
|
903 |
return false;
|
|
904 |
}
|
|
905 |
this.setErrorMessage(Messages.getString("DebugMetadataWizardPage.InvalidMapFilesFolder")); //$NON-NLS-1$
|
|
906 |
return false;
|
|
907 |
} catch (Exception e) {
|
|
908 |
this.setErrorMessage(Messages.getString("DebugMetadataWizardPage.InvalidMapFilesFolder")); //$NON-NLS-1$
|
|
909 |
return false;
|
|
910 |
}
|
|
911 |
// MapFiles.zip radio button is selected
|
|
912 |
} else if (buttonMapFilesZipRadio.getSelection()) {
|
|
913 |
try {
|
|
914 |
File f = new File(comboMapFilesZip.getText());
|
|
915 |
// given zip file must exist and is must contain map files
|
|
916 |
if (f.isFile() && f.exists() && f.getName().toLowerCase().endsWith("zip")) {
|
|
917 |
if (zipContainsMapFiles(comboMapFilesZip.getText())) {
|
|
918 |
return true;
|
|
919 |
}
|
|
920 |
this.setErrorMessage(Messages.getString("DebugMetadataWizardPage.SelectedZipContainsNoMapFiles")); //$NON-NLS-1$
|
|
921 |
return false;
|
|
922 |
}
|
|
923 |
this.setErrorMessage(Messages.getString("DebugMetadataWizardPage.InvalidMapFilesZip")); //$NON-NLS-1$
|
|
924 |
return false;
|
|
925 |
} catch (Exception e) {
|
|
926 |
this.setErrorMessage(Messages.getString("DebugMetadataWizardPage.InvalidMapFilesZip")); //$NON-NLS-1$
|
|
927 |
return false;
|
|
928 |
}
|
|
929 |
// SDK Map files folder" radio button is selected
|
|
930 |
} else if (buttonSdkFolderRadio.getSelection()) {
|
|
931 |
// an item must be selected in the combo
|
|
932 |
if (comboSdkFolder.getSelectionIndex() >= 0) {
|
|
933 |
return true;
|
|
934 |
}
|
|
935 |
this.setErrorMessage(Messages.getString("DebugMetadataWizardPage.SdkMapFilesFolderNotSelected")); //$NON-NLS-1$
|
|
936 |
return false;
|
|
937 |
} else if (buttonNoMapFilesRadio.getSelection() && cannotBeEmpty) {
|
|
938 |
return false;
|
|
939 |
}
|
|
940 |
|
|
941 |
return true;
|
|
942 |
}
|
|
943 |
|
|
944 |
/**
|
|
945 |
* ROM IDs can be passed with this method. If the ROM ID list contains
|
|
946 |
* multiple ROM IDs, only selge.ini group will be available for user.
|
|
947 |
*/
|
|
948 |
public void setRomIds(String[] ids) {
|
|
949 |
if (buttonSymbolRadio != null) {
|
|
950 |
// if symbol&map group radio button is selected, and there are
|
|
951 |
// multiple ROM IDs, show selge.ini group
|
|
952 |
if (buttonSymbolRadio.getSelection() && ids.length > 1) {
|
|
953 |
buttonSymbolRadio.setSelection(false);
|
|
954 |
// ROWS COMMENTED SO THAT THEY CAN BE RESTORED INCASE SELGE.INI USAGE IS RESTORED
|
|
955 |
/* groupSymbol.setVisible(false);
|
|
956 |
GridData gd = (GridData)groupSymbol.getLayoutData();
|
|
957 |
gd.exclude = true;
|
|
958 |
gd = (GridData)groupSelge.getLayoutData();
|
|
959 |
gd.exclude = false;
|
|
960 |
*/ groupSelge.setVisible(true);
|
|
961 |
buttonSelgeRadio.setSelection(true);
|
|
962 |
setDescription(Messages.getString("DebugMetadataWizardPage.SelgeIniDescription")); //$NON-NLS-1$
|
|
963 |
updateButtons();
|
|
964 |
this.setMessage(Messages.getString("DebugMetadataWizardPage.RomIdsDoNotMatch"), 2); //$NON-NLS-1$
|
|
965 |
composite.layout();
|
|
966 |
}
|
|
967 |
this.buttonSymbolRadio.setEnabled(!(ids.length > 1));
|
|
968 |
}
|
|
969 |
}
|
|
970 |
|
|
971 |
public boolean canFlipToNextPage() {
|
|
972 |
return canProceed();
|
|
973 |
}
|
|
974 |
|
|
975 |
/**
|
|
976 |
* We can proceed to next page if selge.ini is a valid file (if selge.ini is used).
|
|
977 |
* If selge.ini is not used, we'll check that symbol file and mapfiles.zip is valid or empty
|
|
978 |
* @return true if we can proceed to next page, false if not
|
|
979 |
*/
|
|
980 |
protected boolean canProceed() {
|
|
981 |
// selge.ini is used, check that selge.ini is valid
|
|
982 |
if (buttonSelgeRadio.getSelection()) {
|
|
983 |
return checkSelgeIniFile();
|
|
984 |
// selge.ini is not used
|
|
985 |
} else {
|
|
986 |
this.setErrorMessage(null);
|
|
987 |
|
|
988 |
// no symbols provided
|
|
989 |
if (listSymbols.getItemCount() < 1) {
|
|
990 |
if (checkMapFiles(true))
|
|
991 |
return true;
|
|
992 |
|
|
993 |
// symbols are provided
|
|
994 |
} else {
|
|
995 |
if (checkSymbols() && checkMapFiles(false))
|
|
996 |
return true;
|
|
997 |
}
|
|
998 |
|
|
999 |
return false;
|
|
1000 |
}
|
|
1001 |
}
|
|
1002 |
|
|
1003 |
boolean checkSymbols() {
|
|
1004 |
for (int i = 0; i < listSymbols.getItemCount(); i++) {
|
|
1005 |
File f = new File(listSymbols.getItem(i));
|
|
1006 |
if (!f.exists() || !f.isFile()) {
|
|
1007 |
this.setErrorMessage("Invalid symbol files");
|
|
1008 |
return false;
|
|
1009 |
}
|
|
1010 |
}
|
|
1011 |
return true;
|
|
1012 |
}
|
|
1013 |
/**
|
|
1014 |
* Saves the values currently displayed in the UI. These values are
|
|
1015 |
* automatically shown when this UI is shown the next time.
|
|
1016 |
*/
|
|
1017 |
public void saveUserEnteredData() {
|
|
1018 |
// selge.ini is used
|
|
1019 |
if (buttonSelgeRadio.getSelection()) {
|
|
1020 |
saveValue(comboSelge.getText(), LAST_USED_SELGE_INI_FILES, false);
|
|
1021 |
savePreviousDecodingStyle(false);
|
|
1022 |
// symbol & map files are used
|
|
1023 |
} else {
|
|
1024 |
savePreviousDecodingStyle(true);
|
|
1025 |
saveValues(listSymbols.getItems(), LAST_USED_SYMBOL_FILES);
|
|
1026 |
saveValue(comboMapFilesZip.getText(), LAST_USED_MAPZIP_FILES, false);
|
|
1027 |
saveValue(comboMapFilesFolder.getText(), LAST_USED_MAPFILES_FOLDER, false);
|
|
1028 |
saveValue(comboSdkFolder.getText(), LAST_USED_SDK, true);
|
|
1029 |
if (showImageFilesGroup)
|
|
1030 |
saveValues(listImageFiles.getItems(), LAST_USED_IMAGE_FILES);
|
|
1031 |
int mapType = NO_MAP_FILES_RADIO;
|
|
1032 |
if (buttonMapFilesFolderRadio.getSelection())
|
|
1033 |
mapType = MAP_FILES_FOLDER_RADIO;
|
|
1034 |
else if (buttonMapFilesZipRadio.getSelection())
|
|
1035 |
mapType = MAP_FILES_ZIP_RADIO;
|
|
1036 |
else if (buttonSdkFolderRadio.getSelection())
|
|
1037 |
mapType = SDK_MAP_FILES_FOLDER_RADIO;
|
|
1038 |
savePreviousMapFilesType(mapType);
|
|
1039 |
}
|
|
1040 |
}
|
|
1041 |
|
|
1042 |
/**
|
|
1043 |
* Updates next, finish button states
|
|
1044 |
*/
|
|
1045 |
protected void updateButtons() {
|
|
1046 |
try {
|
|
1047 |
getWizard().getContainer().updateButtons();
|
|
1048 |
} catch (Exception E) {}
|
|
1049 |
}
|
|
1050 |
|
|
1051 |
/**
|
|
1052 |
* Set help contexts for UI items.
|
|
1053 |
*/
|
|
1054 |
protected void setHelps() {
|
|
1055 |
String helpContext = getHelpContext();
|
|
1056 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonSelgeRadio, helpContext);
|
|
1057 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonSymbolRadio, helpContext);
|
|
1058 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonSelgeBrowse, helpContext);
|
|
1059 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(listSymbols, helpContext);
|
|
1060 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonZipBrowse, helpContext);
|
|
1061 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(comboSelge, helpContext);
|
|
1062 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonAddSymbol, helpContext);
|
|
1063 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonRemoveSymbol, helpContext);
|
|
1064 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(comboMapFilesZip, helpContext);
|
|
1065 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonMapFolderBrowse, helpContext);
|
|
1066 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonMapFilesZipRadio, helpContext);
|
|
1067 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonMapFilesFolderRadio, helpContext);
|
|
1068 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonSdkFolderRadio, helpContext);
|
|
1069 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonNoMapFilesRadio, helpContext);
|
|
1070 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(comboMapFilesFolder, helpContext);
|
|
1071 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(comboSdkFolder, helpContext);
|
|
1072 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonShowSelgeDetails, helpContext);
|
|
1073 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(textSelgeDetails, helpContext);
|
|
1074 |
if (showImageFilesGroup) {
|
|
1075 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(listImageFiles, helpContext);
|
|
1076 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonAddImageFile, helpContext);
|
|
1077 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonRemoveImageFile, helpContext);
|
|
1078 |
}
|
|
1079 |
}
|
|
1080 |
|
|
1081 |
/**
|
|
1082 |
* If symbol file group was used when this UI was used last time, returns true.
|
|
1083 |
* Otherwise returns false.
|
|
1084 |
*/
|
|
1085 |
boolean symbolFileWasUsedPreviously() {
|
|
1086 |
try {
|
|
1087 |
boolean retval = false;
|
|
1088 |
if (previousValuesSection != null) {
|
|
1089 |
retval = previousValuesSection.getBoolean(LAST_USED_DECODING_STYLE);
|
|
1090 |
}
|
|
1091 |
return retval;
|
|
1092 |
} catch (Exception e) {
|
|
1093 |
return false;
|
|
1094 |
}
|
|
1095 |
}
|
|
1096 |
|
|
1097 |
/**
|
|
1098 |
* Saves whether selge.ini group or symbol group is used for decoding.
|
|
1099 |
* This info can be restored when this UI is shown the next time.
|
|
1100 |
*/
|
|
1101 |
void savePreviousDecodingStyle(boolean symbolFile) {
|
|
1102 |
try {
|
|
1103 |
if (previousValuesSection != null) {
|
|
1104 |
previousValuesSection.put(LAST_USED_DECODING_STYLE, symbolFile);
|
|
1105 |
}
|
|
1106 |
} catch (Exception E) {
|
|
1107 |
}
|
|
1108 |
}
|
|
1109 |
|
|
1110 |
/**
|
|
1111 |
* Returns which map files radio button was selected the last time this
|
|
1112 |
* UI was used.
|
|
1113 |
*/
|
|
1114 |
int lastUsedMapFileType() {
|
|
1115 |
try {
|
|
1116 |
int retval = 0;
|
|
1117 |
if (previousValuesSection != null) {
|
|
1118 |
retval = previousValuesSection.getInt(LAST_USED_MAPFILE_TYPE);
|
|
1119 |
}
|
|
1120 |
return retval;
|
|
1121 |
} catch (Exception e) {
|
|
1122 |
return 0;
|
|
1123 |
}
|
|
1124 |
}
|
|
1125 |
|
|
1126 |
/**
|
|
1127 |
* Saves which map file radio button is selected.
|
|
1128 |
* This info can be restored when this UI is shown the next time.
|
|
1129 |
*/
|
|
1130 |
void savePreviousMapFilesType(int type) {
|
|
1131 |
try {
|
|
1132 |
if (previousValuesSection != null) {
|
|
1133 |
previousValuesSection.put(LAST_USED_MAPFILE_TYPE, type);
|
|
1134 |
}
|
|
1135 |
} catch (Exception E) {
|
|
1136 |
}
|
|
1137 |
}
|
|
1138 |
|
|
1139 |
/**
|
|
1140 |
* Returns previously entered values of given item.
|
|
1141 |
*/
|
|
1142 |
String[] getPreviousPaths(String item) {
|
|
1143 |
String[] retVal = null;
|
|
1144 |
if (previousValuesSection != null) {
|
|
1145 |
retVal = previousValuesSection.getArray(item);
|
|
1146 |
}
|
|
1147 |
|
|
1148 |
return retVal;
|
|
1149 |
}
|
|
1150 |
|
|
1151 |
/**
|
|
1152 |
* Saves values so that they can be used next this this UI is used.
|
|
1153 |
*/
|
|
1154 |
void saveValues(String[] values, String item) {
|
|
1155 |
try {
|
|
1156 |
if (previousValuesSection != null) {
|
|
1157 |
previousValuesSection.put(item, values);
|
|
1158 |
}
|
|
1159 |
} catch (Exception E) {
|
|
1160 |
}
|
|
1161 |
}
|
|
1162 |
|
|
1163 |
/**
|
|
1164 |
* Saves given value to correct section in dialog_settings.xml
|
|
1165 |
* @param value value to save
|
|
1166 |
* @param item name of the array which contains correct values
|
|
1167 |
* @param saveJustOne if true, only 'value' is saved. If false, 'value' is added to previously used values.
|
|
1168 |
*/
|
|
1169 |
void saveValue(String value, String item, boolean saveJustOne) {
|
|
1170 |
if (previousValuesSection != null) {
|
|
1171 |
String[] previousValues = previousValuesSection.getArray(item);
|
|
1172 |
|
|
1173 |
// No previous values exist
|
|
1174 |
if (previousValues == null) {
|
|
1175 |
previousValues = new String[1];
|
|
1176 |
previousValues[0] = value;
|
|
1177 |
// Previous values exists
|
|
1178 |
} else {
|
|
1179 |
int valuesCount = previousValues.length;
|
|
1180 |
|
|
1181 |
boolean valueExisted = false;
|
|
1182 |
// see if passed value already exist.
|
|
1183 |
for (int i = 0; i < valuesCount; i++) {
|
|
1184 |
if (previousValues[i].compareToIgnoreCase(value) == 0) {
|
|
1185 |
valueExisted = true;
|
|
1186 |
|
|
1187 |
// passed value exists, move it to first position
|
|
1188 |
for (int j = i; j > 0; j--) {
|
|
1189 |
previousValues[j] = previousValues[j-1];
|
|
1190 |
}
|
|
1191 |
previousValues[0] = value;
|
|
1192 |
|
|
1193 |
break;
|
|
1194 |
}
|
|
1195 |
}
|
|
1196 |
|
|
1197 |
// passed value did not exist, add it to first position (and move older values "down")
|
|
1198 |
if (!valueExisted) {
|
|
1199 |
if (valuesCount >= MAX_SAVED_VALUES) {
|
|
1200 |
for (int i = valuesCount-1; i > 0; i--) {
|
|
1201 |
previousValues[i] = previousValues[i-1];
|
|
1202 |
}
|
|
1203 |
previousValues[0] = value;
|
|
1204 |
} else {
|
|
1205 |
String[] values = new String[valuesCount + 1];
|
|
1206 |
values[0] = value;
|
|
1207 |
for (int i = 0; i < valuesCount; i++) {
|
|
1208 |
values[i+1] = previousValues[i];
|
|
1209 |
}
|
|
1210 |
previousValues = values;
|
|
1211 |
}
|
|
1212 |
}
|
|
1213 |
}
|
|
1214 |
|
|
1215 |
if (saveJustOne) {
|
|
1216 |
previousValues = new String[1];
|
|
1217 |
previousValues[0] = value;
|
|
1218 |
}
|
|
1219 |
|
|
1220 |
previousValuesSection.put(item, previousValues);
|
|
1221 |
}
|
|
1222 |
}
|
|
1223 |
|
|
1224 |
public void dragEnter(DropTargetEvent event) {
|
|
1225 |
event.detail = DND.DROP_COPY;
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
public void dragLeave(DropTargetEvent event) {
|
|
1229 |
// nothing to be done
|
|
1230 |
}
|
|
1231 |
|
|
1232 |
public void dragOperationChanged(DropTargetEvent event) {
|
|
1233 |
// nothing to be done
|
|
1234 |
}
|
|
1235 |
|
|
1236 |
public void dragOver(DropTargetEvent event) {
|
|
1237 |
event.feedback = DND.FEEDBACK_NONE;
|
|
1238 |
}
|
|
1239 |
|
|
1240 |
public void drop(DropTargetEvent event) {
|
|
1241 |
// we accept only file drops
|
|
1242 |
if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
|
|
1243 |
if (event.data != null) {
|
|
1244 |
String[] files = (String[])event.data;
|
|
1245 |
executeDrop(files);
|
|
1246 |
}
|
|
1247 |
}
|
|
1248 |
}
|
|
1249 |
|
|
1250 |
public void dropAccept(DropTargetEvent event) {
|
|
1251 |
// nothing to be done
|
|
1252 |
}
|
|
1253 |
|
|
1254 |
/**
|
|
1255 |
* Executes drop functionality when files are drag&dropped to wizard page.
|
|
1256 |
* Checks whether dropped files are supported and places them into correct UI element
|
|
1257 |
* @param files drag&dropped files (paths)
|
|
1258 |
*/
|
|
1259 |
protected void executeDrop(String[] files) {
|
|
1260 |
for (int i = 0; i < files.length; i++) {
|
|
1261 |
String file = files[i].toLowerCase();
|
|
1262 |
|
|
1263 |
// symbols file, add to symbols list
|
|
1264 |
if (file.endsWith(".symbol") &&
|
|
1265 |
!listContains(listSymbols, file)) {
|
|
1266 |
listSymbols.add(files[i]);
|
|
1267 |
}
|
|
1268 |
|
|
1269 |
// image file, add to images list
|
|
1270 |
if ( isImageFile(file) &&
|
|
1271 |
!listContains(listImageFiles, file)) {
|
|
1272 |
listImageFiles.add(files[i]);
|
|
1273 |
}
|
|
1274 |
|
|
1275 |
// zip file, select correct radio button and add file to combo
|
|
1276 |
if (file.endsWith(".zip")) {
|
|
1277 |
comboMapFilesZip.setText(file);
|
|
1278 |
if (buttonMapFilesFolderRadio.getSelection())
|
|
1279 |
buttonMapFilesFolderRadio.setSelection(false);
|
|
1280 |
else if (buttonNoMapFilesRadio.getSelection())
|
|
1281 |
buttonNoMapFilesRadio.setSelection(false);
|
|
1282 |
else if (buttonSdkFolderRadio.getSelection())
|
|
1283 |
buttonSdkFolderRadio.setSelection(false);
|
|
1284 |
buttonMapFilesZipRadio.setSelection(true);
|
|
1285 |
enableMapSelections();
|
|
1286 |
}
|
|
1287 |
}
|
|
1288 |
|
|
1289 |
updateButtons();
|
|
1290 |
}
|
|
1291 |
|
|
1292 |
protected boolean isImageFile(String file) {
|
|
1293 |
if (file.endsWith(".fpsx") ||
|
|
1294 |
file.endsWith(".img"))
|
|
1295 |
return true;
|
|
1296 |
|
|
1297 |
// .C?? and .V?? file
|
|
1298 |
if (file.substring(file.length()-4, file.length()-3).equals(".") &&
|
|
1299 |
(file.substring(file.length()-3, file.length()-2).equalsIgnoreCase("v") ||
|
|
1300 |
file.substring(file.length()-3, file.length()-2).equalsIgnoreCase("c")))
|
|
1301 |
return true;
|
|
1302 |
|
|
1303 |
return false;
|
|
1304 |
}
|
|
1305 |
|
|
1306 |
protected boolean listContains(List list, String item) {
|
|
1307 |
for (int i = 0; i < list.getItemCount(); i++) {
|
|
1308 |
if (list.getItem(i).equalsIgnoreCase(item))
|
|
1309 |
return true;
|
|
1310 |
}
|
|
1311 |
|
|
1312 |
return false;
|
|
1313 |
}
|
|
1314 |
|
|
1315 |
}
|