Search in sources :

Example 1 with StructuredTextViewerConfigurationCSS

use of org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS in project webtools.sourceediting by eclipse.

the class TestViewerConfigurationCSS method setUpViewerConfiguration.

private void setUpViewerConfiguration() {
    if (Display.getCurrent() != null) {
        Shell shell = null;
        Composite parent = null;
        if (PlatformUI.isWorkbenchRunning()) {
            shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        } else {
            shell = new Shell(Display.getCurrent());
        }
        parent = new Composite(shell, SWT.NONE);
        // dummy viewer
        fViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
        fConfig = new StructuredTextViewerConfigurationCSS();
    } else {
        fDisplayExists = false;
        Logger.log(Logger.INFO, "Remember, viewer configuration tests are not run because workbench is not open (normal on build machine)");
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) StructuredTextViewerConfigurationCSS(org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer)

Example 2 with StructuredTextViewerConfigurationCSS

use of org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS in project webtools.sourceediting by eclipse.

the class TestCSSContentAssist method configureSourceViewer.

protected void configureSourceViewer() {
    sourceViewer.configure(new StructuredTextViewerConfigurationCSS());
    sourceViewer.setDocument(document);
}
Also used : StructuredTextViewerConfigurationCSS(org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS)

Example 3 with StructuredTextViewerConfigurationCSS

use of org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS in project webtools.sourceediting by eclipse.

the class NewCSSTemplatesWizardPage method createViewer.

/**
 * Creates, configures and returns a source viewer to present the template
 * pattern on the preference page. Clients may override to provide a
 * custom source viewer featuring e.g. syntax coloring.
 *
 * @param parent
 *            the parent control
 * @return a configured source viewer
 */
private SourceViewer createViewer(Composite parent) {
    SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {

        StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationCSS();

        public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
            return baseConfiguration.getConfiguredContentTypes(sourceViewer);
        }

        public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
            return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
        }
    };
    SourceViewer 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(ContentTypeIdForCSS.ContentTypeID_CSS);
    IDocument document = scratchModel.getStructuredDocument();
    viewer.configure(sourceViewerConfiguration);
    viewer.setDocument(document);
    return viewer;
}
Also used : SourceViewerConfiguration(org.eclipse.jface.text.source.SourceViewerConfiguration) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) LineStyleProvider(org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) StructuredTextViewerConfiguration(org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration) StructuredTextViewerConfigurationCSS(org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) IDocument(org.eclipse.jface.text.IDocument)

Example 4 with StructuredTextViewerConfigurationCSS

use of org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS in project webtools.sourceediting by eclipse.

the class TestCSSContentAssistComputers method getProposals.

/**
 * <p>Invoke content assist on the given viewer at the given offset, for the given number of pages
 * and return the results of each page</p>
 *
 * @param viewer
 * @param offset
 * @param pageCount
 * @return
 * @throws Exception
 */
private static ICompletionProposal[][] getProposals(StructuredTextViewer viewer, int offset, int pageCount) throws Exception {
    // setup the viewer
    StructuredTextViewerConfigurationCSS configuration = new StructuredTextViewerConfigurationCSS();
    ContentAssistant contentAssistant = (ContentAssistant) configuration.getContentAssistant(viewer);
    viewer.configure(configuration);
    viewer.setSelectedRange(offset, 0);
    // get the processor
    String partitionTypeID = viewer.getDocument().getPartition(offset).getType();
    IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(partitionTypeID);
    // fire content assist session about to start
    Method privateFireSessionBeginEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionBeginEvent", new Class[] { boolean.class });
    privateFireSessionBeginEventMethod.setAccessible(true);
    privateFireSessionBeginEventMethod.invoke(contentAssistant, new Object[] { Boolean.TRUE });
    // get content assist suggestions
    ICompletionProposal[][] pages = new ICompletionProposal[pageCount][];
    for (int p = 0; p < pageCount; ++p) {
        pages[p] = processor.computeCompletionProposals(viewer, offset);
    }
    // fire content assist session ending
    Method privateFireSessionEndEventMethod = ContentAssistant.class.getDeclaredMethod("fireSessionEndEvent", null);
    privateFireSessionEndEventMethod.setAccessible(true);
    privateFireSessionEndEventMethod.invoke(contentAssistant, null);
    return pages;
}
Also used : IContentAssistProcessor(org.eclipse.jface.text.contentassist.IContentAssistProcessor) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) Method(java.lang.reflect.Method) StructuredTextViewerConfigurationCSS(org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS) ContentAssistant(org.eclipse.jface.text.contentassist.ContentAssistant)

Aggregations

StructuredTextViewerConfigurationCSS (org.eclipse.wst.css.ui.StructuredTextViewerConfigurationCSS)4 StructuredTextViewer (org.eclipse.wst.sse.ui.internal.StructuredTextViewer)2 Method (java.lang.reflect.Method)1 IDocument (org.eclipse.jface.text.IDocument)1 ContentAssistant (org.eclipse.jface.text.contentassist.ContentAssistant)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 IContentAssistProcessor (org.eclipse.jface.text.contentassist.IContentAssistProcessor)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)1 Composite (org.eclipse.swt.widgets.Composite)1 Shell (org.eclipse.swt.widgets.Shell)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 StructuredTextViewerConfiguration (org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration)1 LineStyleProvider (org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider)1