Lines 58-63
Link Here
|
58 |
import org.eclipse.ui.internal.registry.EditorDescriptor; |
58 |
import org.eclipse.ui.internal.registry.EditorDescriptor; |
59 |
import org.eclipse.ui.progress.IWorkbenchSiteProgressService; |
59 |
import org.eclipse.ui.progress.IWorkbenchSiteProgressService; |
60 |
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; |
60 |
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; |
|
|
61 |
import org.osgi.framework.Bundle; |
61 |
|
62 |
|
62 |
public class Utils { |
63 |
public class Utils { |
63 |
|
64 |
|
Lines 988-1001
Link Here
|
988 |
* @return whether the editor associated with a descriptor is a text editor |
989 |
* @return whether the editor associated with a descriptor is a text editor |
989 |
* @throws CoreException |
990 |
* @throws CoreException |
990 |
*/ |
991 |
*/ |
991 |
public static boolean isTextEditor(IEditorDescriptor descriptor) |
992 |
public static boolean isTextEditor(IEditorDescriptor descriptor) throws CoreException { |
992 |
throws CoreException { |
993 |
if (!(descriptor instanceof EditorDescriptor)) |
993 |
if (descriptor instanceof EditorDescriptor) { |
994 |
return false; |
994 |
EditorDescriptor desc = (EditorDescriptor) descriptor; |
995 |
|
|
|
996 |
EditorDescriptor desc = (EditorDescriptor) descriptor; |
997 |
String className = desc.getClassName(); |
998 |
String contributor = desc.getPluginId(); |
999 |
|
1000 |
if (className == null || contributor == null) |
1001 |
return false; |
1002 |
|
1003 |
Bundle bundle= Platform.getBundle(contributor); |
1004 |
Class clazz; |
1005 |
try { |
1006 |
clazz= bundle.loadClass(className); |
1007 |
} catch (ClassNotFoundException e) { |
1008 |
return false; // be graceful and continue with default Text Editor |
1009 |
} |
1010 |
|
1011 |
if (AbstractDecoratedTextEditor.class.isAssignableFrom(clazz)) |
1012 |
return true; |
1013 |
else if (IExecutableExtensionFactory.class.isAssignableFrom(clazz)) { |
1014 |
// must create editor |
995 |
IEditorPart editor= desc.createEditor(); |
1015 |
IEditorPart editor= desc.createEditor(); |
996 |
editor.dispose(); |
1016 |
editor.dispose(); |
997 |
return editor instanceof AbstractDecoratedTextEditor; |
1017 |
return editor instanceof AbstractDecoratedTextEditor; |
998 |
} |
1018 |
} |
|
|
1019 |
|
999 |
return false; |
1020 |
return false; |
1000 |
} |
1021 |
} |
1001 |
|
1022 |
|