development
修订版 | e8c4a0d26754497028c7e654ff8599364e4a68ba (tree) |
---|---|
时间 | 2009-03-26 07:55:29 |
作者 | Raphael Moll <> |
Commiter | The Android Open Source Project |
Automated import from //branches/master/...@142743,142743
@@ -34,6 +34,7 @@ import org.xml.sax.SAXException; | ||
34 | 34 | import org.xml.sax.SAXParseException; |
35 | 35 | |
36 | 36 | import java.io.File; |
37 | +import java.io.FileNotFoundException; | |
37 | 38 | import java.io.FileReader; |
38 | 39 | import java.io.IOException; |
39 | 40 | import java.util.ArrayList; |
@@ -585,19 +586,31 @@ public class AndroidManifestParser { | ||
585 | 586 | // get the result from the handler |
586 | 587 | |
587 | 588 | return new AndroidManifestParser(manifestHandler.getPackage(), |
588 | - manifestHandler.getActivities(), manifestHandler.getLauncherActivity(), | |
589 | - manifestHandler.getProcesses(), manifestHandler.getDebuggable(), | |
590 | - manifestHandler.getApiLevelRequirement(), manifestHandler.getInstrumentations(), | |
589 | + manifestHandler.getActivities(), | |
590 | + manifestHandler.getLauncherActivity(), | |
591 | + manifestHandler.getProcesses(), | |
592 | + manifestHandler.getDebuggable(), | |
593 | + manifestHandler.getApiLevelRequirement(), | |
594 | + manifestHandler.getInstrumentations(), | |
591 | 595 | manifestHandler.getUsesLibraries()); |
592 | 596 | } catch (ParserConfigurationException e) { |
593 | 597 | AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), |
594 | - "Bad parser configuration for %s", manifestFile.getFullPath()); | |
598 | + "Bad parser configuration for %s: %s", | |
599 | + manifestFile.getFullPath(), | |
600 | + e.getMessage()); | |
595 | 601 | } catch (SAXException e) { |
596 | 602 | AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), |
597 | - "Parser exception for %s", manifestFile.getFullPath()); | |
603 | + "Parser exception for %s: %s", | |
604 | + manifestFile.getFullPath(), | |
605 | + e.getMessage()); | |
598 | 606 | } catch (IOException e) { |
599 | - AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), | |
600 | - "I/O error for %s", manifestFile.getFullPath()); | |
607 | + // Don't log a console error when failing to read a non-existing file | |
608 | + if (!(e instanceof FileNotFoundException)) { | |
609 | + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), | |
610 | + "I/O error for %s: %s", | |
611 | + manifestFile.getFullPath(), | |
612 | + e.getMessage()); | |
613 | + } | |
601 | 614 | } |
602 | 615 | |
603 | 616 | return null; |
@@ -633,20 +646,33 @@ public class AndroidManifestParser { | ||
633 | 646 | // get the result from the handler |
634 | 647 | |
635 | 648 | return new AndroidManifestParser(manifestHandler.getPackage(), |
636 | - manifestHandler.getActivities(), manifestHandler.getLauncherActivity(), | |
637 | - manifestHandler.getProcesses(), manifestHandler.getDebuggable(), | |
638 | - manifestHandler.getApiLevelRequirement(), manifestHandler.getInstrumentations(), | |
649 | + manifestHandler.getActivities(), | |
650 | + manifestHandler.getLauncherActivity(), | |
651 | + manifestHandler.getProcesses(), | |
652 | + manifestHandler.getDebuggable(), | |
653 | + manifestHandler.getApiLevelRequirement(), | |
654 | + manifestHandler.getInstrumentations(), | |
639 | 655 | manifestHandler.getUsesLibraries()); |
640 | 656 | } catch (ParserConfigurationException e) { |
641 | 657 | AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), |
642 | - "Bad parser configuration for %s", manifestFile.getAbsolutePath()); | |
658 | + "Bad parser configuration for %s: %s", | |
659 | + manifestFile.getAbsolutePath(), | |
660 | + e.getMessage()); | |
643 | 661 | } catch (SAXException e) { |
644 | 662 | AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), |
645 | - "Parser exception for %s", manifestFile.getAbsolutePath()); | |
663 | + "Parser exception for %s: %s", | |
664 | + manifestFile.getAbsolutePath(), | |
665 | + e.getMessage()); | |
646 | 666 | } catch (IOException e) { |
647 | - AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), | |
648 | - "I/O error for %s", manifestFile.getAbsolutePath()); | |
649 | - } | |
667 | + // Don't log a console error when failing to read a non-existing file | |
668 | + if (!(e instanceof FileNotFoundException)) { | |
669 | + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), | |
670 | + "I/O error for %s: %s", | |
671 | + manifestFile.getAbsolutePath(), | |
672 | + e.getMessage()); | |
673 | + } | |
674 | + } | |
675 | + | |
650 | 676 | return null; |
651 | 677 | } |
652 | 678 |
@@ -1233,8 +1233,9 @@ public class UiElementNode implements IPropertySource { | ||
1233 | 1233 | Node attr = attrs.item(n); |
1234 | 1234 | if ("xmlns".equals(attr.getPrefix())) { //$NON-NLS-1$ |
1235 | 1235 | String uri = attr.getNodeValue(); |
1236 | - String nsPrefix = attr.getLocalName(); | |
1237 | - if (SdkConstants.NS_RESOURCES.equals(uri)) { | |
1236 | + String nsPrefix = attr.getLocalName(); | |
1237 | + // Is this the URI we are looking for? If yes, we found its prefix. | |
1238 | + if (nsUri.equals(uri)) { | |
1238 | 1239 | return nsPrefix; |
1239 | 1240 | } |
1240 | 1241 | visited.add(nsPrefix); |
@@ -1244,7 +1245,8 @@ public class UiElementNode implements IPropertySource { | ||
1244 | 1245 | |
1245 | 1246 | // Use a sensible default prefix if we can't find one. |
1246 | 1247 | // We need to make sure the prefix is not one that was declared in the scope |
1247 | - // visited above. | |
1248 | + // visited above. Use a default namespace prefix "android" for the Android resource | |
1249 | + // NS and use "ns" for all other custom namespaces. | |
1248 | 1250 | String prefix = SdkConstants.NS_RESOURCES.equals(nsUri) ? "android" : "ns"; //$NON-NLS-1$ //$NON-NLS-2$ |
1249 | 1251 | String base = prefix; |
1250 | 1252 | for (int i = 1; visited.contains(prefix); i++) { |
@@ -1475,18 +1477,18 @@ public class UiElementNode implements IPropertySource { | ||
1475 | 1477 | } |
1476 | 1478 | } |
1477 | 1479 | } |
1478 | - | |
1480 | + | |
1479 | 1481 | if (attribute != null) { |
1480 | - final UiAttributeNode fAttribute = attribute; | |
1481 | 1482 | |
1482 | 1483 | // get the current value and compare it to the new value |
1483 | - String oldValue = fAttribute.getCurrentValue(); | |
1484 | + String oldValue = attribute.getCurrentValue(); | |
1484 | 1485 | final String newValue = (String)value; |
1485 | 1486 | |
1486 | 1487 | if (oldValue.equals(newValue)) { |
1487 | 1488 | return; |
1488 | 1489 | } |
1489 | - | |
1490 | + | |
1491 | + final UiAttributeNode fAttribute = attribute; | |
1490 | 1492 | AndroidEditor editor = getEditor(); |
1491 | 1493 | editor.editXmlModel(new Runnable() { |
1492 | 1494 | public void run() { |
@@ -1495,6 +1497,4 @@ public class UiElementNode implements IPropertySource { | ||
1495 | 1497 | }); |
1496 | 1498 | } |
1497 | 1499 | } |
1498 | - | |
1499 | - | |
1500 | 1500 | } |