Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2013-06-20 13:31:40 +0000
committerDani Megert2013-06-20 13:31:40 +0000
commit1a558034808c92939635cc35dd9a4943988d1678 (patch)
treefd4d9ae64492962341a2da475f778a6ab5b6ac41
parente2a64527973722b66e2f1392f1ee360104d343a6 (diff)
downloadeclipse.platform.text-1a558034808c92939635cc35dd9a4943988d1678.tar.gz
eclipse.platform.text-1a558034808c92939635cc35dd9a4943988d1678.tar.xz
eclipse.platform.text-1a558034808c92939635cc35dd9a4943988d1678.zip
Fixed bug 406994: [implementation] ClassCastException in HyperlinkDetectorDescriptor 102, if CustomHyperlinkDetector implements IHyperlinkDetector but does not extend AbstractHyperlinkDetector
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java22
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java18
2 files changed, 26 insertions, 14 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java
index 70233cda38f..d2607eb683d 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 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
@@ -82,14 +82,26 @@ public final class HyperlinkDetectorDescriptor {
}
/**
- * Creates a new {@link IHyperlinkDetector}.
- *
+ * Creates a new {@link AbstractHyperlinkDetector}.
+ *
* @return the hyperlink detector or <code>null</code> if the plug-in isn't loaded yet
* @throws CoreException if a failure occurred during creation
+ * @deprecated As of 3.9, replaced by {@link #createHyperlinkDetectorImplementation()}
*/
public AbstractHyperlinkDetector createHyperlinkDetector() throws CoreException {
+ return (AbstractHyperlinkDetector)createHyperlinkDetectorImplementation();
+ }
+
+ /**
+ * Creates a new {@link IHyperlinkDetector}.
+ *
+ * @return the hyperlink detector or <code>null</code> if the plug-in isn't loaded yet
+ * @throws CoreException if a failure occurred during creation
+ * @since 3.9
+ */
+ public IHyperlinkDetector createHyperlinkDetectorImplementation() throws CoreException {
final Throwable[] exception= new Throwable[1];
- final AbstractHyperlinkDetector[] result= new AbstractHyperlinkDetector[1];
+ final IHyperlinkDetector[] result= new IHyperlinkDetector[1];
String message= NLSUtility.format(EditorMessages.Editor_error_HyperlinkDetector_couldNotCreate_message, new String[] { getId(), fElement.getContributor().getName() });
ISafeRunnable code= new SafeRunnable(message) {
/*
@@ -99,7 +111,7 @@ public final class HyperlinkDetectorDescriptor {
String pluginId = fElement.getContributor().getName();
boolean isPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE;
if (isPlugInActivated || canActivatePlugIn())
- result[0]= (AbstractHyperlinkDetector)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ result[0]= (IHyperlinkDetector)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
}
/*
* @see org.eclipse.jface.util.SafeRunnable#handleException(java.lang.Throwable)
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java
index e2d0b04be33..970975ce0d9 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2013 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
@@ -45,7 +45,7 @@ public final class HyperlinkDetectorRegistry {
private class HyperlinkDetectorDelegate implements IHyperlinkDetector, IHyperlinkDetectorExtension, IHyperlinkDetectorExtension2 {
private HyperlinkDetectorDescriptor fHyperlinkDescriptor;
- private AbstractHyperlinkDetector fHyperlinkDetector;
+ private IHyperlinkDetector fHyperlinkDetector;
private boolean fFailedDuringCreation= false;
private IAdaptable fContext;
private int fStateMask;
@@ -69,12 +69,12 @@ public final class HyperlinkDetectorRegistry {
if (!fFailedDuringCreation && fHyperlinkDetector == null) {
try {
- fHyperlinkDetector= fHyperlinkDescriptor.createHyperlinkDetector();
+ fHyperlinkDetector= fHyperlinkDescriptor.createHyperlinkDetectorImplementation();
} catch (CoreException ex) {
fFailedDuringCreation= true;
}
- if (fHyperlinkDetector != null && fContext != null)
- fHyperlinkDetector.setContext(fContext);
+ if (fContext != null && fHyperlinkDetector instanceof AbstractHyperlinkDetector)
+ ((AbstractHyperlinkDetector)fHyperlinkDetector).setContext(fContext);
}
if (fHyperlinkDetector != null)
return fHyperlinkDetector.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
@@ -94,10 +94,10 @@ public final class HyperlinkDetectorRegistry {
* @see org.eclipse.jface.text.hyperlink.IHyperlinkDetectorExtension#dispose()
*/
public void dispose() {
- if (fHyperlinkDetector != null) {
- fHyperlinkDetector.dispose();
- fHyperlinkDetector= null;
- }
+ if (fHyperlinkDetector instanceof AbstractHyperlinkDetector)
+ ((AbstractHyperlinkDetector)fHyperlinkDetector).dispose();
+
+ fHyperlinkDetector= null;
fHyperlinkDescriptor= null;
fContext= null;
}

Back to the top