Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Dahyabhai2021-01-05 07:57:51 +0000
committerNitin Dahyabhai2021-01-05 07:57:51 +0000
commitd9396e873ce9cb81f364154a817db294a9e20d9e (patch)
treeb6114a2dbfa374176c4a580e739bf40916e2aff3
parenta2973b03eaadb7d5a41b1c1bf6aef8287e80f9ea (diff)
downloadwebtools.sourceediting-d9396e873ce9cb81f364154a817db294a9e20d9e.tar.gz
webtools.sourceediting-d9396e873ce9cb81f364154a817db294a9e20d9e.tar.xz
webtools.sourceediting-d9396e873ce9cb81f364154a817db294a9e20d9e.zip
[526774] "New XML file" wizard doesn't show up for current selection adaptable to IFile
-rwxr-xr-xxml/bundles/org.eclipse.wst.xml.ui/META-INF/MANIFEST.MF4
-rwxr-xr-xxml/bundles/org.eclipse.wst.xml.ui/pom.xml2
-rw-r--r--xml/bundles/org.eclipse.wst.xml.ui/src-wizards/org/eclipse/wst/xml/ui/internal/wizards/NewXMLHandler.java24
3 files changed, 14 insertions, 16 deletions
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 80648de789..64fcdc8fe3 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 @@ Manifest-Version: 1.0
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 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.14.0,4.0.0)",
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 78a7e80ebb..1770ce061e 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 73227df8f1..c024c3cf38 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 @@ import org.eclipse.ui.handlers.HandlerUtil;
public class NewXMLHandler extends AbstractHandler implements IHandler {
- /**
- *
- */
public NewXMLHandler() {
super();
}
@@ -41,7 +38,12 @@ public class NewXMLHandler extends AbstractHandler implements IHandler {
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 @@ public class NewXMLHandler extends AbstractHandler implements IHandler {
}
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;
}

Back to the top