public void setMarkupLanguage(MarkupLanguage markupLanguage) { if (markupLanguage == this.markupLanguage || (markupLanguage != null && this.markupLanguage != null && markupLanguage.getName().equals( this.markupLanguage.getName()))) { return; } this.markupLanguage = markupLanguage; delegate = markupLanguage == null ? null : WikiText.getMarkupValidator(markupLanguage.getName()); }
/** * save markup content to a temporary file to facilitate analysis of the problem * * @return the absolute path to the saved file, or null if the file was not saved */ private static String saveToTempFile(MarkupLanguage markupLanguage, String markupContent) { String markupSavePath = null; try { File file = File.createTempFile("markup-content-", "." //$NON-NLS-1$ //$NON-NLS-2$ + markupLanguage.getName().toLowerCase().replaceAll("[^a-z]", "")); //$NON-NLS-1$ //$NON-NLS-2$ Writer writer = new FileWriter(file); try { writer.write(markupContent); } finally { writer.close(); } markupSavePath = file.getAbsolutePath(); } catch (IOException e) { } return markupSavePath; } }
public void setMarkupLanguage(MarkupLanguage markupLanguage) { templates = markupLanguage == null ? null : WikiTextUiPlugin.getDefault() .getTemplates() .get(markupLanguage.getName()); }
private void updateSourceTabLabel() { if (sourceTab != null) { // bug 270215 carbon shows tooltip in source editing area. boolean isCarbon = Platform.WS_CARBON.equals(Platform.getWS()); MarkupLanguage markupLanguage = getMarkupLanguage(); if (markupLanguage == null) { sourceTab.setText(Messages.MarkupEditor_markupSource); if (!isCarbon) { sourceTab.setToolTipText(Messages.MarkupEditor_markupSource_tooltip); } } else { sourceTab.setText(NLS.bind(Messages.MarkupEditor_markupSource_named, new Object[] { markupLanguage.getName() })); if (!isCarbon) { sourceTab.setToolTipText(NLS.bind(Messages.MarkupEditor_markupSource_tooltip_named, new Object[] { markupLanguage.getName() })); } } } }
private String computeCheatSheet(MarkupLanguage markupLanguage) { HelpContent content = null; if (markupLanguage != null) { content = WikiTextUiPlugin.getDefault().getCheatSheets().get(markupLanguage.getName()); if (content == null) { // explore the hierarchy for cheat-sheet content MarkupLanguage l = markupLanguage; while (content == null && l != null && l.getExtendsLanguage() != null) { l = WikiText.getMarkupLanguage(l.getExtendsLanguage()); if (l != null) { content = WikiTextUiPlugin.getDefault().getCheatSheets().get(l.getName()); } } } } if (content != null) { try { return content.getContent(); } catch (Exception e) { WikiTextUiPlugin.getDefault().log(e); } } return NLS.bind(Messages.ShowCheatSheetCommand_noCheatSheetContent, new Object[] { markupLanguage == null ? Messages.ShowCheatSheetCommand_unknownLanguage : markupLanguage.getName() }); } }
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); } } }
markupLanguage.getName() }); if (FastMarkupPartitioner.debug) { String markupSavePath = saveToTempFile(markupLanguage, markupContent);
@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<String>(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)); } }