[526774] "New XML file" wizard doesn't show up for current selection adaptable to IFile
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/META-INF/MANIFEST.MF b/xml/bundles/org.eclipse.wst.xml.ui/META-INF/MANIFEST.MF
index 80648de..64fcdc8 100755
--- a/xml/bundles/org.eclipse.wst.xml.ui/META-INF/MANIFEST.MF
+++ b/xml/bundles/org.eclipse.wst.xml.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.wst.xml.ui; singleton:=true
-Bundle-Version: 1.2.500.qualifier
+Bundle-Version: 1.2.600.qualifier
Bundle-Activator: org.eclipse.wst.xml.ui.internal.XMLUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -58,7 +58,7 @@
org.eclipse.wst.sse.core;bundle-version="[1.2.400,1.3.0)",
org.eclipse.ui;bundle-version="[3.109.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.13.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.14.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.20.0,4.0.0)",
org.eclipse.wst.common.uriresolver;bundle-version="[1.2.300,2.0.0)",
org.eclipse.wst.xml.core;bundle-version="[1.2.0,1.3.0)",
org.eclipse.wst.common.ui;bundle-version="[1.1.500,2.0.0)",
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/pom.xml b/xml/bundles/org.eclipse.wst.xml.ui/pom.xml
index 78a7e80..1770ce0 100755
--- a/xml/bundles/org.eclipse.wst.xml.ui/pom.xml
+++ b/xml/bundles/org.eclipse.wst.xml.ui/pom.xml
@@ -21,7 +21,7 @@
<groupId>org.eclipse.webtools.sourceediting</groupId>
<artifactId>org.eclipse.wst.xml.ui</artifactId>
- <version>1.2.500-SNAPSHOT</version>
+ <version>1.2.600-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<build>
diff --git a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java
index 73227df..c024c3c 100644
--- a/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java
+++ b/xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
+ * Copyright (c) 2008, 2021 Standards for Technology in Automotive Retail and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -13,13 +13,13 @@
*******************************************************************************/
package org.eclipse.wst.xml.ui.internal.wizards;
-import java.util.Iterator;
-
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Adapters;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
@@ -27,9 +27,6 @@
public class NewXMLHandler extends AbstractHandler implements IHandler {
- /**
- *
- */
public NewXMLHandler() {
super();
}
@@ -41,7 +38,12 @@
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = workbenchWindow.getSelectionService().getSelection();
Object selectedObject = getSelection(selection);
-
+ if (selectedObject instanceof IAdaptable) {
+ IFile file = Adapters.adapt(selectedObject, IFile.class);
+ if (file != null) {
+ selectedObject = file;
+ }
+ }
if ((selectedObject instanceof IFile) && (selection instanceof IStructuredSelection)) {
IFile file = (IFile) selectedObject;
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
@@ -61,12 +63,8 @@
}
Object result = null;
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection es = (IStructuredSelection) selection;
- Iterator i = es.iterator();
- if (i.hasNext()) {
- result = i.next();
- }
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ result = ((IStructuredSelection) selection).getFirstElement();
}
return result;
}