Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<extension point="">
<sourceeditor class="org.eclipse.wst.sse.ui.StructuredTextEditor" id="">
<element name="extension">
<element ref="sourceEditor"></element>
<element name="sourceEditor">
<attribute name="id" type="string" use="required">
<attribute name="class" type="string" use="required">
<meta.attribute kind="java" basedon=":org.eclipse.ui.texteditor.ITextEditor">
public class SourceEditorFactory {
private static IConfigurationElement cachedConfigurationElement;
private static final String ATTRIBUTE_CLASS = "class";
public static ITextEditor createSourceEditor() {
if (cachedConfigurationElement == null) {
cachedConfigurationElement = readConfigurationElement();
if (cachedConfigurationElement != null) {
try {
return (ITextEditor) cachedConfigurationElement
} catch (Exception exception) {
// errors when initializing the source editor
return new TextEditor();
// Reads the first configuration element whose implemented class is not
// TextEditor
private static IConfigurationElement readConfigurationElement() {
IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
.getExtensionPoint(FitPlugin.PLUGIN_ID, "fitSourceEditor");
for (IConfigurationElement configurationElement : extensionPoint
.getConfigurationElements()) {
if (!StringUtils.equals(TextEditor.class.getCanonicalName(),
configurationElement.getAttribute(ATTRIBUTE_CLASS))) {
return configurationElement;
return null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.