Search in sources :

Example 1 with XMLTextHover

use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.

the class AntEditorSourceViewerConfiguration method getInformationPresenter.

@Override
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
    InformationPresenter presenter = new InformationPresenter(getInformationPresenterControlCreator());
    presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    IInformationProvider provider = new AntInformationProvider(new XMLTextHover(fEditor));
    presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
    presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_CDATA);
    presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_COMMENT);
    presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_DTD);
    presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_TAG);
    presenter.setSizeConstraints(60, 10, true, true);
    return presenter;
}
Also used : XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IInformationProvider(org.eclipse.jface.text.information.IInformationProvider) IInformationPresenter(org.eclipse.jface.text.information.IInformationPresenter) InformationPresenter(org.eclipse.jface.text.information.InformationPresenter) AntInformationProvider(org.eclipse.ant.internal.ui.editor.text.AntInformationProvider)

Example 2 with XMLTextHover

use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.

the class AntEditorTests method testHoverForProperty.

public void testHoverForProperty() throws PartInitException, BadLocationException {
    // $NON-NLS-1$
    IFile file = getIFile("refid.xml");
    // $NON-NLS-1$
    AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
    XMLTextHover hover = new XMLTextHover(editor);
    int offset = getOffsetWithinLine(editor, 42, 13);
    IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
    String hoverText = hover.getHoverInfo(editor.getViewer(), region);
    // $NON-NLS-1$
    assertNotNull("Expecting a hovertext object", hoverText);
    // $NON-NLS-1$
    String correctResult = "<p>value with spaces</body></html>";
    // $NON-NLS-1$
    assertTrue("Expected the following hover text to end with: " + correctResult, hoverText.endsWith(correctResult));
}
Also used : AntEditor(org.eclipse.ant.internal.ui.editor.AntEditor) IFile(org.eclipse.core.resources.IFile) XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IRegion(org.eclipse.jface.text.IRegion)

Example 3 with XMLTextHover

use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.

the class AntEditorTests method testBadPatternSetHover.

public void testBadPatternSetHover() throws PartInitException, BadLocationException {
    // $NON-NLS-1$
    IFile file = getIFile("refid.xml");
    // $NON-NLS-1$
    AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
    XMLTextHover hover = new XMLTextHover(editor);
    int offset = getOffsetWithinLine(editor, 46, 25);
    IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
    String hoverText = hover.getHoverInfo(editor.getViewer(), region);
    // $NON-NLS-1$
    assertNotNull("Expecting a hovertext object", hoverText);
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    String correctResult = "Ant UI Tests" + File.separatorChar + "buildfiles" + File.separatorChar + "nothere not found.";
    // $NON-NLS-1$
    assertTrue("Expected the following hover text to ends with: " + correctResult, hoverText.endsWith(correctResult));
}
Also used : AntEditor(org.eclipse.ant.internal.ui.editor.AntEditor) IFile(org.eclipse.core.resources.IFile) XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IRegion(org.eclipse.jface.text.IRegion)

Example 4 with XMLTextHover

use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.

the class AntEditorTests method testAugmentOpenSelectHover.

/**
 * Tests that the element augmented by the augment task properly displays the augmented elements when hovering
 *
 * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=377075
 * @throws Exception
 */
public void testAugmentOpenSelectHover() throws Exception {
    // $NON-NLS-1$
    IFile file = getIFile("bug377075.ent");
    // $NON-NLS-1$
    IEditorPart part = EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
    // $NON-NLS-1$
    assertTrue("The opened editor must be the AntEditor", part instanceof AntEditor);
    AntEditor editor = (AntEditor) part;
    int offset = getOffsetWithinLine(editor, 1, 11);
    // select the 'path1' id for the path element
    editor.selectAndReveal(offset, 5);
    ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("Selection is not correct", "path1", selection.getText());
    XMLTextHover hover = new XMLTextHover(editor);
    IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
    // $NON-NLS-1$
    assertNotNull("The selected region for the augmented element cannot be null", region);
    String text = hover.getHoverInfo(editor.getViewer(), region);
    // $NON-NLS-1$
    assertNotNull("The hover text for the path element must not be null", text);
    // $NON-NLS-1$ //$NON-NLS-2$
    assertTrue("The hover text must contain the augmented element 'foo'", text.contains("foo"));
}
Also used : AntEditor(org.eclipse.ant.internal.ui.editor.AntEditor) IFile(org.eclipse.core.resources.IFile) XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IEditorPart(org.eclipse.ui.IEditorPart) ITextSelection(org.eclipse.jface.text.ITextSelection) IRegion(org.eclipse.jface.text.IRegion)

Example 5 with XMLTextHover

use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.

the class AntEditorTests method testFileSetHover.

public void testFileSetHover() throws PartInitException, BadLocationException {
    // $NON-NLS-1$
    IFile file = getIFile("refid.xml");
    // $NON-NLS-1$
    AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
    XMLTextHover hover = new XMLTextHover(editor);
    int offset = getOffsetWithinLine(editor, 44, 20);
    IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
    String hoverText = hover.getHoverInfo(editor.getViewer(), region);
    // $NON-NLS-1$
    assertNotNull("Expecting a hovertext object", hoverText);
    // $NON-NLS-1$ //$NON-NLS-2$
    assertTrue("Expected to see '<h5>Includes:</h5><li>include</li>'", hoverText.contains("<h5>Includes:</h5><li>include</li>"));
    // $NON-NLS-1$ //$NON-NLS-2$
    assertTrue("Expected to see '<h5>Excludes:</h5><li>exclude</li>'", hoverText.contains("<h5>Excludes:</h5><li>exclude</li>"));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    String text = "<li>**" + File.separator + "SCCS" + File.separator + "**</li>";
    // $NON-NLS-1$
    assertTrue("Expected to see '<li>**/SCCS/**</li>'", hoverText.contains(text));
    // $NON-NLS-1$ //$NON-NLS-2$
    text = "<li>**" + File.separator + ".DS_Store</li>";
    // $NON-NLS-1$
    assertTrue("Expected to see '<li>**/.DS_Store</li>'", hoverText.contains(text));
    // $NON-NLS-1$ //$NON-NLS-2$
    text = "<li>**" + File.separator + ".bzrignore</li>";
    // $NON-NLS-1$
    assertTrue("Expected to see '<li>**/.bzrignore</li>'", hoverText.contains(text));
    // $NON-NLS-1$ //$NON-NLS-2$
    text = "<li>**" + File.separator + ".gitattributes</li>";
    // $NON-NLS-1$
    assertTrue("Expected to see '<li>**/.gitattributes</li>'", hoverText.contains(text));
    // $NON-NLS-1$ //$NON-NLS-2$
    text = "<li>**" + File.separator + ".hgtags</li>";
    // $NON-NLS-1$
    assertTrue("Expected to see '<li>**/.hgtags</li>'", hoverText.contains(text));
}
Also used : AntEditor(org.eclipse.ant.internal.ui.editor.AntEditor) IFile(org.eclipse.core.resources.IFile) XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IRegion(org.eclipse.jface.text.IRegion)

Aggregations

XMLTextHover (org.eclipse.ant.internal.ui.editor.text.XMLTextHover)8 AntEditor (org.eclipse.ant.internal.ui.editor.AntEditor)7 IFile (org.eclipse.core.resources.IFile)7 IRegion (org.eclipse.jface.text.IRegion)7 AntInformationProvider (org.eclipse.ant.internal.ui.editor.text.AntInformationProvider)1 IDocument (org.eclipse.jface.text.IDocument)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 IInformationPresenter (org.eclipse.jface.text.information.IInformationPresenter)1 IInformationProvider (org.eclipse.jface.text.information.IInformationProvider)1 InformationPresenter (org.eclipse.jface.text.information.InformationPresenter)1 IEditorPart (org.eclipse.ui.IEditorPart)1