Search in sources :

Example 46 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer in project webtools.sourceediting by eclipse.

the class NewXSLFileTemplatesWizardPage method createViewer.

private SourceViewer createViewer(Composite parent) {
    SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {

        StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationXSL();

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

        @Override
        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(ContentTypeIdForXML.ContentTypeID_XML);
    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) StructuredTextViewerConfigurationXSL(org.eclipse.wst.xsl.ui.internal.StructuredTextViewerConfigurationXSL) 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)

Example 47 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer in project webtools.sourceediting by eclipse.

the class CSSTemplatePreferencePage method doCreateViewer.

SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) {
    SourceViewer viewer = null;
    String contentTypeID = ContentTypeIdForCSS.ContentTypeID_CSS;
    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 48 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer in project webtools.sourceediting by eclipse.

the class DTDTemplatePreferencePage method doCreateViewer.

SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) {
    SourceViewer viewer = null;
    String contentTypeID = ContentTypeIdForDTD.ContentTypeID_DTD;
    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 49 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer in project webtools.sourceediting by eclipse.

the class NewDTDTemplatesWizardPage method doCreateViewer.

private SourceViewer doCreateViewer(Composite parent) {
    Label label = new Label(parent, SWT.NONE);
    label.setText(DTDUIMessages.NewDTDTemplatesWizardPage_5);
    GridData data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    SourceViewer viewer = createViewer(parent);
    viewer.setEditable(false);
    Control control = viewer.getControl();
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.heightHint = convertHeightInCharsToPixels(5);
    // [261274] - source viewer was growing to fit the max line width of the template
    data.widthHint = convertWidthInCharsToPixels(2);
    control.setLayoutData(data);
    return viewer;
}
Also used : Control(org.eclipse.swt.widgets.Control) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) SourceViewer(org.eclipse.jface.text.source.SourceViewer) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData)

Example 50 with SourceViewer

use of org.eclipse.jface.text.source.SourceViewer 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)

Aggregations

SourceViewer (org.eclipse.jface.text.source.SourceViewer)67 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)39 IDocument (org.eclipse.jface.text.IDocument)26 GridData (org.eclipse.swt.layout.GridData)24 Label (org.eclipse.swt.widgets.Label)23 Composite (org.eclipse.swt.widgets.Composite)16 Document (org.eclipse.jface.text.Document)15 SourceViewerConfiguration (org.eclipse.jface.text.source.SourceViewerConfiguration)14 StructuredTextViewer (org.eclipse.wst.sse.ui.internal.StructuredTextViewer)14 Control (org.eclipse.swt.widgets.Control)13 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 Button (org.eclipse.swt.widgets.Button)11 Iterator (java.util.Iterator)10 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)8 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8