blob: 52aa25dd170ab6180c463e522f2b8306f0f874ac [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2014, 2020 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.internal.redocs.wikitext.r.textile;
import static org.eclipse.statet.internal.redocs.wikitext.r.textile.core.RTextileLanguage.TEXTILE_LANGUAGE_NAME;
import static org.eclipse.statet.internal.redocs.wikitext.r.textile.core.RTextileLanguage.TEXTILE_RWEAVE_LANGUAGE_NAME;
import org.osgi.framework.BundleContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage;
import org.eclipse.mylyn.wikitext.ui.WikiText;
import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.statet.docmlet.wikitext.core.WikitextCore;
import org.eclipse.statet.internal.redocs.wikitext.r.textile.core.RTextileLanguage;
import org.eclipse.statet.redocs.wikitext.r.core.source.WikitextRweaveTemplateContextType;
public class TextileRweavePlugin extends AbstractUIPlugin {
public static final String BUNDLE_ID= "org.eclipse.statet.redocs.wikitext.r.textile"; //$NON-NLS-1$
public static final String DOC_CONTENT_ID= "org.eclipse.statet.redocs.contentTypes.TextileRweave"; //$NON-NLS-1$
public static final IContentType DOC_CONTENT_TYPE;
static {
final IContentTypeManager contentTypeManager= Platform.getContentTypeManager();
DOC_CONTENT_TYPE= contentTypeManager.getContentType(DOC_CONTENT_ID);
}
public static final String TEMPLATES_WEAVE_DOCDEFAULT_CONTEXTTYPE= TEXTILE_RWEAVE_LANGUAGE_NAME +
WikitextRweaveTemplateContextType.WEAVE_DOCDEFAULT_CONTEXTTYPE_SUFFIX;
public static final String TEMPLATES_QUALIFIER= BUNDLE_ID + "/codegen"; //$NON-NLS-1$
public static final String NEWDOC_TEMPLATE_CATEGORY_ID= "TextileRweave.NewDoc"; //$NON-NLS-1$
private static TextileRweavePlugin instance;
/**
* Returns the shared plug-in instance
*
* @return the shared instance
*/
public static TextileRweavePlugin getInstance() {
return TextileRweavePlugin.instance;
}
public static void log(final IStatus status) {
final Plugin plugin= getInstance();
if (plugin != null) {
plugin.getLog().log(status);
}
}
private boolean started;
private RTextileLanguage markupLanguage;
public TextileRweavePlugin() {
}
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
instance= this;
final MarkupLanguage baseLanguage= WikiText.getMarkupLanguage(TEXTILE_LANGUAGE_NAME);
if (baseLanguage == null) {
throw new CoreException(new Status(IStatus.ERROR, BUNDLE_ID,
NLS.bind("Failed to load markup language ''{0}''.", TEXTILE_LANGUAGE_NAME) ));
}
this.markupLanguage= (RTextileLanguage) WikitextCore.getMarkupLanguageManager()
.getLanguage(TEXTILE_RWEAVE_LANGUAGE_NAME);
this.started= true;
}
@Override
public void stop(final BundleContext context) throws Exception {
try {
synchronized (this) {
this.started= false;
}
}
finally {
instance= null;
super.stop(context);
}
}
public RTextileLanguage getMarkupLanguage() {
return this.markupLanguage;
}
}