Search in sources :

Example 6 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class HTMLTemplatePreferencePage method doCreateViewer.

SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) {
    SourceViewer viewer = null;
    String contentTypeID = ContentTypeIdForHTML.ContentTypeID_HTML;
    viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    // $NON-NLS-1$
    viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
    IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID);
    IDocument document = scratchModel.getStructuredDocument();
    viewer.configure(viewerConfiguration);
    viewer.setDocument(document);
    return viewer;
}
Also used : ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) IDocument(org.eclipse.jface.text.IDocument)

Example 7 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class JSONTemplatePreferencePage method doCreateViewer.

SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) {
    SourceViewer viewer = null;
    String contentTypeID = ContentTypeIdForJSON.ContentTypeID_JSON;
    viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    // $NON-NLS-1$
    viewer.getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont"));
    IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID);
    IDocument document = scratchModel.getStructuredDocument();
    viewer.configure(viewerConfiguration);
    viewer.setDocument(document);
    return viewer;
}
Also used : ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) IDocument(org.eclipse.jface.text.IDocument)

Example 8 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class TestJSPContentAssistComputers method runProposalTest.

/**
 * <p>Run a proposal test by opening the given file and invoking content assist for
 * each expected proposal count at the given line number and line character
 * offset and then compare the number of proposals for each invocation (pages) to the
 * expected number of proposals.</p>
 *
 * @param fileName
 * @param lineNum
 * @param lineRelativeCharOffset
 * @param expectedProposalCounts
 * @throws Exception
 */
private static void runProposalTest(String fileName, int lineNum, int lineRelativeCharOffset, int[] expectedProposalCounts) throws Exception {
    IFile file = getFile(fileName);
    StructuredTextEditor editor = getEditor(file);
    StructuredTextViewer viewer = editor.getTextViewer();
    int offset = viewer.getDocument().getLineOffset(lineNum) + lineRelativeCharOffset;
    ICompletionProposal[][] pages = getProposals(viewer, offset, expectedProposalCounts.length);
    verifyProposalCounts(pages, expectedProposalCounts);
}
Also used : IFile(org.eclipse.core.resources.IFile) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer)

Example 9 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class CSSCodeFoldingTest method testAddNode.

/**
 * <p><b>TEST:</b> that folding annotations are updated after node is added</p>
 */
public void testAddNode() throws Exception {
    IFile file = getFile("CSSFoldingTest2.css");
    StructuredTextEditor editor = getEditor(file);
    try {
        StructuredTextViewer viewer = editor.getTextViewer();
        IDocument doc = viewer.getDocument();
        doc.replace(255, 0, "\ntd {\nborder: 1px solid black;\n}\n");
        editor.doSave(null);
        List expectedPositions = new ArrayList();
        expectedPositions.add(new Position(291, 69));
        expectedPositions.add(new Position(256, 31));
        expectedPositions.add(new Position(21, 113));
        expectedPositions.add(new Position(434, 120));
        expectedPositions.add(new Position(181, 72));
        expectedPositions.add(new Position(366, 62));
        waitForReconcileThenVerify(viewer, expectedPositions);
    } catch (BadLocationException e) {
        fail("Test is broken, add location has become invalid.\n" + e.getMessage());
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) Position(org.eclipse.jface.text.Position) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 10 with StructuredTextViewer

use of org.eclipse.wst.sse.ui.internal.StructuredTextViewer in project webtools.sourceediting by eclipse.

the class CSSCodeFoldingTest method testRemoveNode.

/**
 * <p><b>TEST:</b> that folding annotations are updated after node is removed</p>
 */
public void testRemoveNode() throws Exception {
    IFile file = getFile("CSSFoldingTest1.css");
    StructuredTextEditor editor = getEditor(file);
    try {
        StructuredTextViewer viewer = editor.getTextViewer();
        IDocument doc = viewer.getDocument();
        doc.replace(253, 76, "");
        editor.doSave(null);
        final List expectedPositions = new ArrayList();
        expectedPositions.add(new Position(325, 120));
        expectedPositions.add(new Position(21, 113));
        expectedPositions.add(new Position(181, 72));
        expectedPositions.add(new Position(257, 62));
        waitForReconcileThenVerify(viewer, expectedPositions);
    } catch (BadLocationException e) {
        fail("Test is broken, replace location has become invalid.\n" + e.getMessage());
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) Position(org.eclipse.jface.text.Position) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

StructuredTextViewer (org.eclipse.wst.sse.ui.internal.StructuredTextViewer)62 StructuredTextEditor (org.eclipse.wst.sse.ui.StructuredTextEditor)21 IDocument (org.eclipse.jface.text.IDocument)19 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)18 IFile (org.eclipse.core.resources.IFile)14 SourceViewer (org.eclipse.jface.text.source.SourceViewer)14 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)14 Composite (org.eclipse.swt.widgets.Composite)13 Shell (org.eclipse.swt.widgets.Shell)13 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)12 StructuredTextViewerConfiguration (org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration)9 LineStyleProvider (org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider)8 ArrayList (java.util.ArrayList)7 BadLocationException (org.eclipse.jface.text.BadLocationException)6 Position (org.eclipse.jface.text.Position)6 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)6 List (java.util.List)5 Action (org.eclipse.jface.action.Action)4 IContributionManager (org.eclipse.jface.action.IContributionManager)4 Separator (org.eclipse.jface.action.Separator)4