aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2010-03-31 14:27:38 -0700
committerRaphael <raphael@google.com>2010-03-31 14:27:38 -0700
commit452fb42f5f6f6b81f215caa819d14636aaec47cf (patch)
tree7169c786c710b8c7588b7023cde2a23e43c15b83 /eclipse
parent1f05559a6c5e2c02da4d0978f32ab6df1b93db87 (diff)
downloadsdk-452fb42f5f6f6b81f215caa819d14636aaec47cf.zip
sdk-452fb42f5f6f6b81f215caa819d14636aaec47cf.tar.gz
sdk-452fb42f5f6f6b81f215caa819d14636aaec47cf.tar.bz2
ADT NPW: NPE when trying to expand project templates.
This does not solve the NPE, it adds logging so that we can identify the issue since it doesn't happend in debug mode. Probably some template is not loaded correctly. SDK Bug: 2546962 Change-Id: Idf0df2bd4e4b7a632fc7777b296df830c2f642da
Diffstat (limited to 'eclipse')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java40
1 files changed, 36 insertions, 4 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java
index 2d51f89..39be01c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/newproject/NewProjectWizard.java
@@ -39,6 +39,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
@@ -513,6 +514,9 @@ public class NewProjectWizard extends Wizard implements INewWizard {
try {
getContainer().run(true /* fork */, true /* cancelable */, op);
} catch (InvocationTargetException e) {
+
+ AdtPlugin.log(e, "New Project Wizard failed");
+
// The runnable threw an exception
Throwable t = e.getTargetException();
if (t instanceof CoreException) {
@@ -522,11 +526,20 @@ public class NewProjectWizard extends Wizard implements INewWizard {
// and there's a resource with a similar name.
MessageDialog.openError(getShell(), "Error", "Error: Case Variant Exists");
} else {
- ErrorDialog.openError(getShell(), "Error", null, core.getStatus());
+ ErrorDialog.openError(getShell(), "Error", core.getMessage(), core.getStatus());
}
} else {
// Some other kind of exception
- MessageDialog.openError(getShell(), "Error", t.getMessage());
+ String msg = t.getMessage();
+ Throwable t1 = t;
+ while (msg == null && t1.getCause() != null) {
+ msg = t1.getMessage();
+ t1 = t1.getCause();
+ }
+ if (msg == null) {
+ msg = t.toString();
+ }
+ MessageDialog.openError(getShell(), "Error", msg);
}
e.printStackTrace();
} catch (InterruptedException e) {
@@ -1083,9 +1096,28 @@ public class NewProjectWizard extends Wizard implements INewWizard {
* @return A new String object with the placeholder replaced by the values.
*/
private String replaceParameters(String str, Map<String, Object> parameters) {
+
+ if (parameters == null) {
+ AdtPlugin.log(IStatus.ERROR,
+ "NPW replace parameters: null parameter map. String: '%s'", str); //$NON-NLS-1$
+ return str;
+ } else if (str == null) {
+ AdtPlugin.log(IStatus.ERROR,
+ "NPW replace parameters: null template string"); //$NON-NLS-1$
+ return str;
+ }
+
for (Entry<String, Object> entry : parameters.entrySet()) {
- if (entry.getValue() instanceof String) {
- str = str.replaceAll(entry.getKey(), (String) entry.getValue());
+ if (entry != null && entry.getValue() instanceof String) {
+ Object value = entry.getValue();
+ if (value == null) {
+ AdtPlugin.log(IStatus.ERROR,
+ "NPW replace parameters: null value for key '%s' in template '%s'", //$NON-NLS-1$
+ entry.getKey(),
+ str);
+ } else {
+ str = str.replaceAll(entry.getKey(), (String) value);
+ }
}
}