Search in sources :

Example 11 with OutlineItem

use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.

the class XslfoDocumentBuilderIntegrationTest method testforTableRowAlign_bug336813.

public void testforTableRowAlign_bug336813() {
    final String markup = "{|\n" + "|- valign=\"top\"\n |'''Row heading'''\n" + "| A longer piece of text. Lorem ipsum...\n |A shorter piece of text.\n" + "|- style=\"vertical-align: bottom;\"\n |'''Row heading'''\n" + "|A longer piece of text. Lorem ipsum... \n |A shorter piece of text.\n" + "|}";
    documentBuilder.getConfiguration().setPageNumbering(true);
    documentBuilder.getConfiguration().setTitle("Title");
    OutlineItem op = new OutlineParser(new MediaWikiLanguage()).parse(markup);
    documentBuilder.setOutline(op);
    parser.setMarkupLanguage(new MediaWikiLanguage());
    parser.parse(markup, true);
    final String xslfo = out.toString();
    // From "valign" attribute
    assertTrue(Pattern.compile("<table-row display-align=\"before\">").matcher(xslfo).find());
    // From css styling
    assertTrue(Pattern.compile("<table-row display-align=\"after\">").matcher(xslfo).find());
}
Also used : OutlineParser(org.eclipse.mylyn.wikitext.parser.outline.OutlineParser) MediaWikiLanguage(org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Example 12 with OutlineItem

use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem 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);
}
Also used : AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) Point(org.eclipse.swt.graphics.Point) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Example 13 with OutlineItem

use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.

the class MarkupEditor method show.

public boolean show(ShowInContext context) {
    ISelection selection = context.getSelection();
    if (selection instanceof IStructuredSelection) {
        for (Object element : ((IStructuredSelection) selection).toArray()) {
            if (element instanceof OutlineItem) {
                OutlineItem item = (OutlineItem) element;
                selectAndReveal(item);
                if (isOutlinePageValid()) {
                    outlinePage.setSelection(selection);
                }
                return true;
            }
        }
    } else if (selection instanceof ITextSelection) {
        ITextSelection textSel = (ITextSelection) selection;
        selectAndReveal(textSel.getOffset(), textSel.getLength());
        return true;
    }
    return false;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITextSelection(org.eclipse.jface.text.ITextSelection) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Example 14 with OutlineItem

use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem 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));
    }
}
Also used : SetMarkupLanguageAction(org.eclipse.mylyn.internal.wikitext.ui.editor.actions.SetMarkupLanguageAction) PreviewOutlineItemAction(org.eclipse.mylyn.internal.wikitext.ui.editor.actions.PreviewOutlineItemAction) TreeSet(java.util.TreeSet) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) AbstractMarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Example 15 with OutlineItem

use of org.eclipse.mylyn.wikitext.parser.outline.OutlineItem in project mylyn.docs by eclipse.

the class OutlineItemAdapterFactoryTest method testAdaptsToIWorkbenchAdapter.

public void testAdaptsToIWorkbenchAdapter() {
    Object adapter = Platform.getAdapterManager().getAdapter(new OutlineItem(null, 0, "id", 0, 10, "ID"), IWorkbenchAdapter.class);
    assertNotNull(adapter);
    assertTrue(IWorkbenchAdapter.class.isAssignableFrom(adapter.getClass()));
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Aggregations

OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)58 OutlineParser (org.eclipse.mylyn.wikitext.parser.outline.OutlineParser)18 MediaWikiLanguage (org.eclipse.mylyn.wikitext.mediawiki.MediaWikiLanguage)9 Point (org.eclipse.swt.graphics.Point)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ITextSelection (org.eclipse.jface.text.ITextSelection)5 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)5 MarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage)5 BufferedOutputStream (java.io.BufferedOutputStream)4 FileOutputStream (java.io.FileOutputStream)4 OutputStreamWriter (java.io.OutputStreamWriter)4 Writer (java.io.Writer)4 BuildException (org.apache.tools.ant.BuildException)4 ISelection (org.eclipse.jface.viewers.ISelection)4 AbstractMarkupLanguage (org.eclipse.mylyn.wikitext.parser.markup.AbstractMarkupLanguage)4 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 IMenuManager (org.eclipse.jface.action.IMenuManager)3 MenuManager (org.eclipse.jface.action.MenuManager)3