# HG changeset patch # User Eugene Ostroukhov # Date 1281459149 25200 # Node ID cdc4995b1677948a185be1d8006dfade217ae291 # Parent 7a8f9fa8d278f936b0c2f97a57c965da62ad19a1 Minor bugfix diff -r 7a8f9fa8d278 -r cdc4995b1677 org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTarget.java --- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTarget.java Mon Aug 09 15:18:34 2010 -0700 +++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/tmw/ui/deployment/bluetooth/BluetoothTarget.java Tue Aug 10 09:52:29 2010 -0700 @@ -76,6 +76,10 @@ statuses.clear(); monitor.beginTask(String.format("Deploying application %s to %s", project.getName(), name), IProgressMonitor.UNKNOWN); + if (packager == null) { + return new Status(IStatus.ERROR, TMWCore.PLUGIN_ID, String.format( + "No packager found for project %s with runtime %s", project.getName(), project.getTargetRuntime())); + } final File application = packager.packageApplication(project, new SubProgressMonitor(monitor, 100)); try { deployWidget(application, packager.getFileType(project), new SubProgressMonitor(monitor, 10)); diff -r 7a8f9fa8d278 -r cdc4995b1677 org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Mon Aug 09 15:18:34 2010 -0700 +++ b/org.symbian.tools.wrttools/plugin.xml Tue Aug 10 09:52:29 2010 -0700 @@ -816,7 +816,7 @@ + version="1.1"> listofEmulators; + + public EmulatorTargetType() { + discoverTargets(new NullProgressMonitor()); + } + + public IDeploymentTarget[] getTargets(IMTWProject project) { + Collection values = listofEmulators.values(); + return values.toArray(new Emulator[values.size()]); + } + + public void discoverTargets(IProgressMonitor monitor) { + if (listofEmulators == null) { + listofEmulators = new HashMap(); + } + listofEmulators.clear(); + initialize(); + } + + public IDeploymentTarget findTarget(IMTWProject project, String id) { + // TODO Auto-generated method stub + return null; + } + + public boolean targetsDiscovered() { + return true; + } + + public ISchedulingRule getSchedulingRule(IDeploymentTarget target) { + return null; + } + + // helper methods + + /** + * This will parse the xml and create the nodes to be displayed on the table + * viewer. The information will be used by content & label provider to get + * the contents and display accordingly in the list of the projects in the view. + */ + public Map initialize() { + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + // Parse the devices.xml and retrieve the list of the emulators from it + // and build the list to be displayed in the view. + + try { + DocumentBuilder builder = factory.newDocumentBuilder(); + File file = new File(IWRTConstants.DEVICES_XML_PATH); + if (!file.exists()) { + IPath otherPath = new Path(System.getProperty("user.home")) + .append(IWRTConstants.DEVICES_VISTA_XML_PATH); + file = otherPath.toFile(); + } + if (file.exists()) { + FileInputStream fin = new FileInputStream(file); + Document document = builder.parse(fin); + NodeList childNodes = document.getChildNodes(); + + for (int i = 0; i < childNodes.getLength(); i++) { + + Node node = childNodes.item(i); + String nodeName = node.getNodeName(); + // If the node name is "devices" it is the root node of the xml. + if (nodeName.equals(IWRTConstants.DEVICES_TAG)) { + // once we have the root node get the child information to + // build the devices list. + createDevicesList(node); + + } + } + } + } catch (ParserConfigurationException e) { + // WidgetUtils.getView().getLogger().severe(e.getMessage()); + } catch (SAXException e) { + // WidgetUtils.getView().getLogger().severe(e.getMessage()); + } catch (IOException e) { + // WidgetUtils.getView().getLogger().severe(e.getMessage()); + } + return listofEmulators; + } + + /** + * Creates the devices nodes in the table. + * @param parentNode + */ + private void createDevicesList(Node parentNode) { + NodeList list = getChildNodes(parentNode); + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + String nodeName = node.getNodeName(); + if (nodeName.equals(IWRTConstants.DEVICE_TAG)) { + createDeviceChildNode(node); + } + } + } + + /** + * Gets the EPOC ROOT node and than finally the list of devices. + * @param parentNode + */ + private void createDeviceChildNode(Node parentNode) { + NodeList list = getChildNodes(parentNode); + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + String nodeName = node.getNodeName(); + if (nodeName.equals(IWRTConstants.EPOC_ROOT_TAG)) { + addProject(node, parentNode); + } + } + } + + /** + * Adds the devices to the list to be displayed. + * @param deviceNode the device node + * @param epocNode the epoc root node. + */ + private void addProject(Node epocNode, Node deviceNode) { + NodeList list = getChildNodes(epocNode); + NamedNodeMap attributes = deviceNode.getAttributes(); + String sdkId = ""; + String sdkName = ""; + for (int i = 0; i < attributes.getLength(); i++) { + Node item = attributes.item(i); + if (item.getNodeName().equals(IWRTConstants.NAME_ATTR)) { + sdkName = item.getNodeValue(); + } + if (item.getNodeName().equals(IWRTConstants.ID_ATTR)) { + sdkId = item.getNodeValue(); + } + } + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + if (sdkName.equals(IWRTConstants.EMULATOR_NAME)) { + listofEmulators.put(sdkId, new Emulator(sdkId, node.getNodeValue())); + } + } + } + + /** + * Returns the child list of the particular Node. + * @param parentNode + */ + private static NodeList getChildNodes(Node parentNode) { + return parentNode.getChildNodes(); + } + +}