20 |
20 |
21 import java.beans.PropertyChangeListener; |
21 import java.beans.PropertyChangeListener; |
22 import java.beans.PropertyChangeSupport; |
22 import java.beans.PropertyChangeSupport; |
23 import java.net.URI; |
23 import java.net.URI; |
24 import java.text.MessageFormat; |
24 import java.text.MessageFormat; |
|
25 import java.util.Arrays; |
|
26 import java.util.Collections; |
|
27 import java.util.HashSet; |
25 import java.util.Map; |
28 import java.util.Map; |
|
29 import java.util.Set; |
26 import java.util.TreeMap; |
30 import java.util.TreeMap; |
27 |
31 |
28 import org.symbian.tools.wrttools.core.ProjectTemplate; |
32 import org.symbian.tools.wrttools.core.ProjectTemplate; |
|
33 import org.symbian.tools.wrttools.core.libraries.JSLibrary; |
29 import org.symbian.tools.wrttools.util.Util; |
34 import org.symbian.tools.wrttools.util.Util; |
30 |
35 |
31 public class WizardContext { |
36 public class WizardContext { |
32 public static final String PROJECT_URI = "projectUri"; |
37 public static final String PROJECT_URI = "projectUri"; |
33 public static final String CSS_FILE = "cssFile"; |
38 public static final String CSS_FILE = "cssFile"; |
36 public static final String PROJECT_NAME = "projectName"; |
41 public static final String PROJECT_NAME = "projectName"; |
37 public static final String TEMPLATE = "template"; |
42 public static final String TEMPLATE = "template"; |
38 public static final String WIDGET_ID = "widgetId"; |
43 public static final String WIDGET_ID = "widgetId"; |
39 public static final String WIDGET_NAME = "widgetName"; |
44 public static final String WIDGET_NAME = "widgetName"; |
40 public static final String HOME_SCREEN = "homeScreen"; |
45 public static final String HOME_SCREEN = "homeScreen"; |
|
46 public static final String LIBRARIES = "libraries"; |
41 |
47 |
42 private String cssFile; |
48 private String cssFile; |
43 private String htmlFile; |
49 private String htmlFile; |
44 private String jsFile; |
50 private String jsFile; |
45 private String projectName; |
51 private String projectName; |
46 private PropertyChangeSupport propertySupport = new PropertyChangeSupport(this); |
52 private final PropertyChangeSupport propertySupport = new PropertyChangeSupport(this); |
47 private ProjectTemplate template; |
53 private ProjectTemplate template; |
48 private String widgetId; |
54 private String widgetId; |
49 private String widgetName; |
55 private String widgetName; |
50 private Map<String, String> extensions = new TreeMap<String, String>(); |
56 private Map<String, String> extensions = new TreeMap<String, String>(); |
51 private URI projectUri; |
57 private URI projectUri; |
52 private boolean homeScreen; |
58 private boolean homeScreen; |
|
59 private Set<JSLibrary> libraries = new HashSet<JSLibrary>(); |
53 |
60 |
54 public void addPropertyChangeListener(PropertyChangeListener arg0) { |
61 public void addPropertyChangeListener(PropertyChangeListener arg0) { |
55 propertySupport.addPropertyChangeListener(arg0); |
62 propertySupport.addPropertyChangeListener(arg0); |
56 } |
63 } |
57 |
64 |
185 propertySupport.firePropertyChange(JS_FILE, getJsFile(), js); |
192 propertySupport.firePropertyChange(JS_FILE, getJsFile(), js); |
186 } |
193 } |
187 if (cssFile == null) { |
194 if (cssFile == null) { |
188 propertySupport.firePropertyChange(CSS_FILE, getCssFile(), css); |
195 propertySupport.firePropertyChange(CSS_FILE, getCssFile(), css); |
189 } |
196 } |
|
197 if (cssFile == null) { |
|
198 propertySupport.firePropertyChange(LIBRARIES, getCssFile(), css); |
|
199 } |
190 } |
200 } |
191 |
201 |
192 public void setWidgetId(String widgetId) { |
202 public void setWidgetId(String widgetId) { |
193 String prev = getWidgetId(); |
203 String prev = getWidgetId(); |
194 if (getDefaultWidgetId().equals(widgetId)) { |
204 if (getDefaultWidgetId().equals(widgetId)) { |
273 return fileName.substring(0, fileName.length() - extensionAndDot.length()); |
283 return fileName.substring(0, fileName.length() - extensionAndDot.length()); |
274 } |
284 } |
275 } |
285 } |
276 return fileName; |
286 return fileName; |
277 } |
287 } |
|
288 |
|
289 public boolean isRequiredLibrary(JSLibrary element) { |
|
290 return template != null && template.requires(element); |
|
291 } |
|
292 |
|
293 public Set<JSLibrary> getLibraries() { |
|
294 final Set<JSLibrary> set = new HashSet<JSLibrary>(libraries); |
|
295 if (template != null) { |
|
296 set.addAll(Arrays.asList(template.getRequiredLibraries())); |
|
297 } |
|
298 return set; |
|
299 } |
|
300 |
|
301 public void setLibraries(Set<JSLibrary> libraries) { |
|
302 Set<JSLibrary> prev = this.libraries; |
|
303 this.libraries = libraries; |
|
304 propertySupport.firePropertyChange(LIBRARIES, prev, libraries); |
|
305 } |
|
306 |
|
307 public Map<String, String> getLibraryParameters(JSLibrary library) { |
|
308 return Collections.emptyMap(); |
|
309 } |
278 } |
310 } |