Search in sources :

Example 1 with IEditorChangeLogContrib

use of org.eclipse.linuxtools.changelog.core.IEditorChangeLogContrib in project linuxtools by eclipse.

the class ChangeLogDocumentSetupParticipant method setup.

@Override
public void setup(IDocument document) {
    IExtensionPoint editorExtensions = null;
    IEditorChangeLogContrib editorContrib = null;
    // get editor which is stored in preference.
    IPreferenceStore store = ChangelogPlugin.getDefault().getPreferenceStore();
    String pref_Editor = store.getString(// $NON-NLS-1$
    "IChangeLogConstants.DEFAULT_EDITOR");
    editorExtensions = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.linuxtools.changelog.core", // $NON-NLS-1$ //$NON-NLS-2$
    "editorContribution");
    if (editorExtensions != null) {
        IConfigurationElement[] elements = editorExtensions.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            if (// $NON-NLS-1$
            elements[i].getName().equals("editor") && (elements[i].getAttribute("name").equals(pref_Editor))) {
                try {
                    // If editor has a special setup routine, use it.
                    IConfigurationElement bob = elements[i];
                    editorContrib = (IEditorChangeLogContrib) bob.createExecutableExtension(// $NON-NLS-1$
                    "class");
                    editorContrib.setup(document);
                } catch (CoreException e) {
                    ChangelogPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
                }
            }
        }
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IEditorChangeLogContrib(org.eclipse.linuxtools.changelog.core.IEditorChangeLogContrib) CoreException(org.eclipse.core.runtime.CoreException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 2 with IEditorChangeLogContrib

use of org.eclipse.linuxtools.changelog.core.IEditorChangeLogContrib in project linuxtools by eclipse.

the class ChangeLogEditor method getConfig.

/**
 * Gets appropriate style editor from user pref.
 *
 * @return configuration for the Changelog editor
 */
private SourceViewerConfiguration getConfig() {
    IExtensionPoint editorExtensions = null;
    IEditorChangeLogContrib editorContrib = null;
    // get editor which is stored in preference.
    IPreferenceStore store = ChangelogPlugin.getDefault().getPreferenceStore();
    // $NON-NLS-1$
    String pref_Editor = store.getString("IChangeLogConstants.DEFAULT_EDITOR");
    editorExtensions = // $NON-NLS-1$
    Platform.getExtensionRegistry().getExtensionPoint(// $NON-NLS-1$
    "org.eclipse.linuxtools.changelog.core", // $NON-NLS-1$
    "editorContribution");
    if (editorExtensions != null) {
        IConfigurationElement[] elements = editorExtensions.getConfigurationElements();
        for (int i = 0; i < elements.length; i++) {
            if (// $NON-NLS-1$
            elements[i].getName().equals("editor") && (elements[i].getAttribute("name").equals(pref_Editor))) {
                try {
                    IConfigurationElement bob = elements[i];
                    // $NON-NLS-1$
                    editorContrib = (IEditorChangeLogContrib) bob.createExecutableExtension("class");
                    return (SourceViewerConfiguration) editorContrib;
                } catch (CoreException e) {
                    ChangelogPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
                }
            }
        }
    }
    return null;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) SourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IEditorChangeLogContrib(org.eclipse.linuxtools.changelog.core.IEditorChangeLogContrib) CoreException(org.eclipse.core.runtime.CoreException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 IEditorChangeLogContrib (org.eclipse.linuxtools.changelog.core.IEditorChangeLogContrib)2 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)1