use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.
the class MarkupEditor method updateOutlineNow.
private void updateOutlineNow() {
if (!outlineDirty) {
return;
}
if (!isSourceViewerValid()) {
return;
}
// we maintain the outline even if the outline page is not in use, which allows us to use the outline for
// content assist and other things
MarkupLanguage markupLanguage = getMarkupLanguage();
if (markupLanguage == null) {
return;
}
final MarkupLanguage language = markupLanguage.clone();
final String content = document.get();
final int contentGeneration;
synchronized (MarkupEditor.this) {
contentGeneration = documentGeneration;
}
outlineParser.setMarkupLanguage(language);
OutlineItem rootItem = outlineParser.parse(content);
updateOutline(contentGeneration, rootItem);
}
use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.
the class MarkupEditor method storeMarkupLanguagePreference.
private void storeMarkupLanguagePreference(MarkupLanguage markupLanguage) {
if (markupLanguage == null) {
throw new IllegalArgumentException();
}
IFile file = getFile();
if (file != null) {
MarkupLanguage defaultMarkupLanguage = WikiText.getMarkupLanguageForFilename(file.getName());
String preference = markupLanguage.getName();
if (defaultMarkupLanguage != null && defaultMarkupLanguage.getName().equals(preference)) {
preference = null;
}
try {
file.setPersistentProperty(new QualifiedName(WikiTextUiPlugin.getDefault().getPluginId(), MARKUP_LANGUAGE), preference);
} catch (CoreException e) {
WikiTextUiPlugin.getDefault().log(IStatus.ERROR, NLS.bind(Messages.MarkupEditor_markupPreferenceError2, new Object[] { preference }), e);
}
}
}
use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage 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.MarkupLanguage in project mylyn.docs by eclipse.
the class MarkupEditor method editorContextMenuAboutToShow.
@Override
protected void editorContextMenuAboutToShow(IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
final MarkupLanguage markupLanguage = getMarkupLanguage();
MenuManager markupLanguageMenu = new MenuManager(Messages.MarkupEditor_markupLanguage);
for (String markupLanguageName : new TreeSet<>(WikiText.getMarkupLanguageNames())) {
markupLanguageMenu.add(new SetMarkupLanguageAction(this, markupLanguageName, markupLanguage != null && markupLanguageName.equals(markupLanguage.getName())));
}
menu.prependToGroup(ITextEditorActionConstants.GROUP_SETTINGS, markupLanguageMenu);
OutlineItem nearestOutlineItem = getNearestMatchingOutlineItem();
if (nearestOutlineItem != null && !nearestOutlineItem.isRootItem()) {
menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, new PreviewOutlineItemAction(this, nearestOutlineItem));
}
}
use of org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage in project mylyn.docs by eclipse.
the class MarkupEditor method initializeMarkupLanguage.
private void initializeMarkupLanguage(IEditorInput input) {
MarkupLanguage markupLanguage = loadMarkupLanguagePreference();
if (markupLanguage == null) {
String name = input.getName();
if (input instanceof IFileEditorInput) {
name = ((IFileEditorInput) input).getFile().getName();
} else if (input instanceof IPathEditorInput) {
name = ((IPathEditorInput) input).getPath().lastSegment();
}
markupLanguage = WikiText.getMarkupLanguageForFilename(name);
if (markupLanguage == null) {
// $NON-NLS-1$
markupLanguage = WikiText.getMarkupLanguage("Textile");
}
}
setMarkupLanguage(markupLanguage, false);
}
Aggregations