Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2015-10-23 12:22:31 -0400
committerUwe Stieber2015-10-23 12:22:31 -0400
commitdba4212520245605385ba8337191a5af434a02ec (patch)
tree65cf36912b289173032cbea2436e158203d9d83a /target_explorer
parent19359cb81dc0eb985c774c06a4095f88e7597cd6 (diff)
downloadorg.eclipse.tcf-dba4212520245605385ba8337191a5af434a02ec.tar.gz
org.eclipse.tcf-dba4212520245605385ba8337191a5af434a02ec.tar.xz
org.eclipse.tcf-dba4212520245605385ba8337191a5af434a02ec.zip
Bug #480444: java.lang.NoSuchMethodError with Neon M3 due to Target
Explorer using eclipse.ui internal non-API
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardNode.java45
1 files changed, 41 insertions, 4 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardNode.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardNode.java
index 3f985eeea..e0834e9d1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/wizards/newWizard/NewWizardNode.java
@@ -11,7 +11,10 @@ package org.eclipse.tcf.te.ui.wizards.newWizard;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizard;
@@ -22,13 +25,11 @@ import org.eclipse.tcf.te.ui.nls.Messages;
import org.eclipse.tcf.te.ui.wizards.interfaces.INewTargetWizard;
import org.eclipse.ui.IPluginContribution;
import org.eclipse.ui.IWorkbenchWizard;
-import org.eclipse.ui.internal.util.Util;
import org.eclipse.ui.wizards.IWizardDescriptor;
/**
* New wizard node implementation.
*/
-@SuppressWarnings("restriction")
/* default */ class NewWizardNode implements IWizardNode, IPluginContribution {
// The associated wizard descriptor
private final IWizardDescriptor descriptor;
@@ -72,7 +73,7 @@ import org.eclipse.ui.wizards.IWizardDescriptor;
*/
@Override
public String getLocalId() {
- IPluginContribution contribution = (IPluginContribution)Util.getAdapter(descriptor, IPluginContribution.class);
+ IPluginContribution contribution = getAdapter(descriptor, IPluginContribution.class);
if (contribution != null) {
return contribution.getLocalId();
}
@@ -84,7 +85,7 @@ import org.eclipse.ui.wizards.IWizardDescriptor;
*/
@Override
public String getPluginId() {
- IPluginContribution contribution = (IPluginContribution) Util.getAdapter(descriptor, IPluginContribution.class);
+ IPluginContribution contribution = getAdapter(descriptor, IPluginContribution.class);
if (contribution != null) {
return contribution.getPluginId();
}
@@ -141,4 +142,40 @@ import org.eclipse.ui.wizards.IWizardDescriptor;
return wizard;
}
+
+ /**
+ * Bug# 480444: NoSuchMethodError with Neon M3
+ *
+ * Instead of referring to the internal <code>org.eclipse.ui.internal.util.Util</code> class,
+ * copy the <code>getAdapter</code> method here, so it can work with every platform.
+ */
+ private final <T> T getAdapter(Object sourceObject, Class<T> adapterType) {
+ Assert.isNotNull(adapterType);
+ if (sourceObject == null) {
+ return null;
+ }
+ if (adapterType.isInstance(sourceObject)) {
+ return adapterType.cast(sourceObject);
+ }
+
+ if (sourceObject instanceof IAdaptable) {
+ IAdaptable adaptable = (IAdaptable) sourceObject;
+
+ T result = adaptable.getAdapter(adapterType);
+ if (result != null) {
+ // Sanity-check
+ Assert.isTrue(adapterType.isInstance(result));
+ return result;
+ }
+ }
+
+ if (!(sourceObject instanceof PlatformObject)) {
+ T result = Platform.getAdapterManager().getAdapter(sourceObject, adapterType);
+ if (result != null) {
+ return result;
+ }
+ }
+
+ return null;
+ }
} \ No newline at end of file

Back to the top