use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage in project mylyn.docs by eclipse.
the class ListBlock method findCloseOffset.
@Override
public int findCloseOffset(String line, int lineOffset) {
if (listContinuation) {
if (nestingBegin) {
AbstractMarkupLanguage language = (AbstractMarkupLanguage) getParser().getMarkupLanguage();
Block block = language.startBlock(line, lineOffset);
nestedBlockInterruptible = isInterruptibleNestedBlock(block);
nestingBegin = false;
}
if (nestedBlockInterruptible && (line.isEmpty() || isListContinuation(line))) {
listContinuation = isListContinuation(line);
return 0;
}
}
return -1;
}
use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage in project mylyn.docs by eclipse.
the class MarkupEditor method setMarkupLanguage.
public void setMarkupLanguage(MarkupLanguage markupLanguage, boolean persistSetting) {
if (markupLanguage instanceof AbstractMarkupLanguage) {
((AbstractMarkupLanguage) markupLanguage).setEnableMacros(false);
}
((MarkupDocumentProvider) getDocumentProvider()).setMarkupLanguage(markupLanguage);
IDocument document = getDocumentProvider().getDocument(getEditorInput());
IDocumentPartitioner partitioner = document.getDocumentPartitioner();
if (partitioner instanceof FastMarkupPartitioner) {
final FastMarkupPartitioner fastMarkupPartitioner = (FastMarkupPartitioner) partitioner;
fastMarkupPartitioner.setMarkupLanguage(markupLanguage);
}
sourceViewerConfiguration.setMarkupLanguage(markupLanguage);
if (getSourceViewer() != null) {
getSourceViewer().invalidateTextPresentation();
}
outlineDirty = true;
scheduleOutlineUpdate();
updateSourceTabLabel();
if (viewer != null) {
viewer.getTextWidget().setData(MarkupLanguage.class.getName(), getMarkupLanguage());
}
if (persistSetting && markupLanguage != null) {
storeMarkupLanguagePreference(markupLanguage);
}
if (persistSetting) {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer instanceof MarkupProjectionViewer) {
IReconciler reconciler = ((MarkupProjectionViewer) sourceViewer).getReconciler();
if (reconciler instanceof MarkupMonoReconciler) {
((MarkupMonoReconciler) reconciler).forceReconciling();
}
}
}
}
use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage in project mylyn.docs by eclipse.
the class MarkupTaskEditorExtension method createViewer.
@Override
public SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style, IAdaptable context) {
if (markupLanguage == null) {
throw new IllegalStateException();
}
MarkupViewer markupViewer = new MarkupViewer(parent, null, style | SWT.FLAT | SWT.WRAP);
MarkupLanguageType markupLanguageCopy = createRepositoryMarkupLanguage(taskRepository);
configureMarkupLanguage(taskRepository, markupLanguageCopy);
markupViewer.setMarkupLanguage(markupLanguageCopy);
MarkupViewerConfiguration configuration = createViewerConfiguration(taskRepository, markupViewer, context);
configuration.setDisableHyperlinkModifiers(true);
configuration.setEnableSelfContainedIncrementalFind(true);
if (markupLanguageCopy instanceof AbstractMarkupLanguage && ((AbstractMarkupLanguage) markupLanguageCopy).isDetectingRawHyperlinks()) {
// bug 264612 don't detect hyperlinks twice
configuration.addHyperlinkDetectorDescriptorFilter(new DefaultHyperlinkDetectorDescriptorFilter(// $NON-NLS-1$
"org.eclipse.mylyn.tasks.ui.hyperlinks.detectors.url"));
}
markupViewer.configure(configuration);
markupViewer.setEditable(false);
markupViewer.getTextWidget().setCaret(null);
if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT)) {
markupViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_DEFAULT_FONT));
}
if (JFaceResources.getFontRegistry().hasValueFor(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT)) {
markupViewer.setDefaultMonospaceFont(JFaceResources.getFontRegistry().get(WikiTextTasksUiPlugin.FONT_REGISTRY_KEY_MONOSPACE_FONT));
}
markupViewer.setStylesheet(WikiTextUiPlugin.getDefault().getPreferences().getStylesheet());
IFocusService focusService = PlatformUI.getWorkbench().getService(IFocusService.class);
if (focusService != null) {
focusService.addFocusTracker(markupViewer.getTextWidget(), MARKUP_VIEWER);
}
markupViewer.getTextWidget().setData(ISourceViewer.class.getName(), markupViewer);
return markupViewer;
}
use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage in project mylyn.docs by eclipse.
the class WikiTextSourceEditor method setMarkupLanguage.
/**
* set the markup language. If unspecified, it's assumed to be Textile.
*
* @since 3.0
*/
public void setMarkupLanguage(MarkupLanguage markupLanguage) {
this.markupLanguage = markupLanguage;
if (this.markupLanguage instanceof AbstractMarkupLanguage) {
((AbstractMarkupLanguage) this.markupLanguage).setEnableMacros(false);
}
sourceViewerConfiguration.setMarkupLanguage(markupLanguage);
IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider instanceof WikiTextDocumentProvider) {
((WikiTextDocumentProvider) documentProvider).setMarkupLanguage(markupLanguage);
}
if (getEditorInput() != null) {
IDocument document = documentProvider.getDocument(getEditorInput());
IDocumentPartitioner partitioner = document.getDocumentPartitioner();
if (partitioner instanceof FastMarkupPartitioner) {
final FastMarkupPartitioner fastMarkupPartitioner = (FastMarkupPartitioner) partitioner;
fastMarkupPartitioner.setMarkupLanguage(markupLanguage);
}
}
if (viewer != null) {
viewer.getTextWidget().setData(MarkupLanguage.class.getName(), getMarkupLanguage());
}
if (getSourceViewer() != null) {
getSourceViewer().invalidateTextPresentation();
}
}
use of org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage in project mylyn.docs by eclipse.
the class MarkupTask method createMarkupLanguage.
/**
* Create a {@link MarkupLanguage markup language parser} for the {@link #getMarkupLanguage() specified markup
* language}.
*
* @return the markup language
* @throws BuildException
* if the markup language is not specified or if it is unknown.
*/
protected MarkupLanguage createMarkupLanguage() throws BuildException {
if (markupLanguage == null) {
// $NON-NLS-1$
throw new BuildException(Messages.getString("MarkupTask.0"));
}
try {
MarkupLanguage language = ServiceLocator.getInstance(getClass().getClassLoader()).getMarkupLanguage(markupLanguage);
if (internalLinkPattern != null) {
// $NON-NLS-1$
checkAbstractMarkupLanguage(language, "internalLinkPattern");
((AbstractMarkupLanguage) language).setInternalLinkPattern(internalLinkPattern);
}
if (markupLanguageConfiguration != null) {
language.configure(markupLanguageConfiguration);
}
return language;
} catch (IllegalArgumentException e) {
throw new BuildException(e.getMessage(), e);
}
}
Aggregations