[393683] NPE when cancelling out of snippets import operation
diff --git a/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF b/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF
index b85af89..62ccaac 100644
--- a/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF
+++ b/org.eclipse.wst.common.snippets/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %Snippets_View.name
Bundle-SymbolicName: org.eclipse.wst.common.snippets; singleton:=true
-Bundle-Version: 1.2.3.qualifier
+Bundle-Version: 1.2.4.qualifier
Bundle-Activator: org.eclipse.wst.common.snippets.internal.SnippetsPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java b/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java
index 07ea690..6db8e29 100644
--- a/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java
+++ b/org.eclipse.wst.common.snippets/src/org/eclipse/wst/common/snippets/internal/palette/SnippetCustomizerDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -21,8 +21,8 @@
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.List;
+import java.util.Locale;
import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
@@ -45,6 +45,7 @@
import org.eclipse.wst.common.snippets.core.ISnippetCategory;
import org.eclipse.wst.common.snippets.core.ISnippetItem;
import org.eclipse.wst.common.snippets.internal.IHelpContextIds;
+import org.eclipse.wst.common.snippets.internal.Logger;
import org.eclipse.wst.common.snippets.internal.SnippetDefinitions;
import org.eclipse.wst.common.snippets.internal.SnippetsMessages;
import org.eclipse.wst.common.snippets.internal.SnippetsPlugin;
@@ -73,9 +74,10 @@
public ExportAction() {
setEnabled(false);
setText(SnippetsMessages.SnippetCustomizerDialog_1); //$NON-NLS-1$
- setImageDescriptor(SnippetsPluginImageHelper.getInstance().getImageDescriptor(SnippetsPluginImages.IMG_ELCL_EXPORT));
- setDisabledImageDescriptor(SnippetsPluginImageHelper.getInstance().getImageDescriptor(SnippetsPluginImages.IMG_DLCL_EXPORT));
- setHoverImageDescriptor(SnippetsPluginImageHelper.getInstance().getImageDescriptor(SnippetsPluginImages.IMG_CLCL_EXPORT));
+ SnippetsPluginImageHelper pluginImageHelper = SnippetsPluginImageHelper.getInstance();
+ setImageDescriptor(pluginImageHelper.getImageDescriptor(SnippetsPluginImages.IMG_ELCL_EXPORT));
+ setDisabledImageDescriptor(pluginImageHelper.getImageDescriptor(SnippetsPluginImages.IMG_DLCL_EXPORT));
+ setHoverImageDescriptor(pluginImageHelper.getImageDescriptor(SnippetsPluginImages.IMG_CLCL_EXPORT));
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IHelpContextIds.CUSTOMIZE_EXPORT_BUTTON);
}
@@ -254,14 +256,15 @@
protected void handleImport() {
final FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN);
fileDialog.setText(SnippetsMessages.Import_Snippets);
-// fileDialog.setFileName("snippets.xml"); //$NON-NLS-1$
String[] filterExtensions = new String[2];
filterExtensions[0] = "*.xml; *.zip"; //$NON-NLS-1$
filterExtensions[1] = "*.*"; //$NON-NLS-1$
fileDialog.setFilterExtensions(filterExtensions);
String filename = fileDialog.open();
+ if (filename == null)
+ return;
try {
- if (filename.toLowerCase().endsWith(".zip")) {
+ if (filename.toLowerCase(Locale.US).endsWith(".zip")) {
ZipFile zip = new ZipFile(new File(filename));
ZipEntry entry = zip.getEntry("snippets.xml");
loadMetadata(zip.getInputStream(entry));
@@ -272,16 +275,8 @@
loadMetadata(new FileInputStream(filename));
}
}
- catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- catch (ZipException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Logger.logException(e);
}
}