Search in sources :

Example 1 with StructuredTextViewerConfigurationDTD

use of org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD in project webtools.sourceediting by eclipse.

the class ViewerTestDTD method createPartControl.

/**
 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(Composite)
 */
public void createPartControl(Composite parent) {
    IContributionManager mgr = getViewSite().getActionBars().getMenuManager();
    addActions(mgr);
    // create source viewer & its content type-specific viewer
    // configuration
    fSourceViewer = new StructuredTextViewer(parent, null, null, false, SWT.NONE);
    fConfig = new StructuredTextViewerConfigurationDTD();
    // set up the viewer with a document & viewer config
    setupViewerForNew();
    setupViewerPreferences();
}
Also used : StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) IContributionManager(org.eclipse.jface.action.IContributionManager) StructuredTextViewerConfigurationDTD(org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD)

Example 2 with StructuredTextViewerConfigurationDTD

use of org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD in project webtools.sourceediting by eclipse.

the class TestViewerConfigurationDTD 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 StructuredTextViewerConfigurationDTD();
    } 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) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) StructuredTextViewerConfigurationDTD(org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD)

Example 3 with StructuredTextViewerConfigurationDTD

use of org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD in project webtools.sourceediting by eclipse.

the class NewDTDTemplatesWizardPage 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 StructuredTextViewerConfigurationDTD();

        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(ContentTypeIdForDTD.ContentTypeID_DTD);
    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) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) StructuredTextViewer(org.eclipse.wst.sse.ui.internal.StructuredTextViewer) IDocument(org.eclipse.jface.text.IDocument) StructuredTextViewerConfigurationDTD(org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD)

Example 4 with StructuredTextViewerConfigurationDTD

use of org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD in project webtools.sourceediting by eclipse.

the class ViewerTestDTD method setupViewerForEditor.

/**
 * Sets up the viewer with the same document/fInput as the given editor
 *
 * @param ITextEditor
 *            editor - the editor to use *cannot to be null*
 */
private void setupViewerForEditor(ITextEditor editor) {
    // if was following fSelection, stop
    stopFollowSelection();
    IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    fSourceViewer.setDocument(doc);
    // need to reconfigure after set document just so highlighter works
    fSourceViewer.configure(new StructuredTextViewerConfigurationDTD());
}
Also used : IDocument(org.eclipse.jface.text.IDocument) StructuredTextViewerConfigurationDTD(org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD)

Aggregations

StructuredTextViewerConfigurationDTD (org.eclipse.wst.dtd.ui.StructuredTextViewerConfigurationDTD)4 StructuredTextViewer (org.eclipse.wst.sse.ui.internal.StructuredTextViewer)3 IDocument (org.eclipse.jface.text.IDocument)2 IContributionManager (org.eclipse.jface.action.IContributionManager)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