org.eclipse.jface.text.source.IVerticalRuler Java Examples

The following examples show how to use org.eclipse.jface.text.source.IVerticalRuler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonEditor.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout compositeLayout = new GridLayout(1, false);
    compositeLayout.marginHeight = 0;
    compositeLayout.marginWidth = 0;
    compositeLayout.horizontalSpacing = 0;
    compositeLayout.verticalSpacing = 0;
    composite.setLayout(compositeLayout);

    topPanel = new Composite(composite, SWT.NONE);
    topPanel.setLayout(new StackLayout());
    topPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    Composite editorComposite = new Composite(composite, SWT.NONE);
    editorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
    fillLayout.marginHeight = 0;
    fillLayout.marginWidth = 0;
    fillLayout.spacing = 0;
    editorComposite.setLayout(fillLayout);

    ISourceViewer result = doCreateSourceViewer(editorComposite, ruler, styles);

    return result;
}
 
Example #2
Source File: TypeScriptMergeViewer.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
protected ISourceViewer createTypeScriptSourceViewer(Composite parent, IVerticalRuler verticalRuler,
		IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
	return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles,
			store) {
		@Override
		protected void handleDispose() {
			super.handleDispose();

			// dispose the compilation unit adapter
			dispose();

			fEditor.remove(this);
			if (fEditor.isEmpty()) {
				fEditor = null;
				fSite = null;
			}

			fSourceViewer.remove(this);
			if (fSourceViewer.isEmpty())
				fSourceViewer = null;

		}
	};
}
 
Example #3
Source File: PythonSourceViewer.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public PythonSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    super(parent, ruler, null, false, styles, new PyAbstractIndentGuidePreferencesProvider() {

        @Override
        public int getTabWidth() {
            return DefaultIndentPrefs.get(null).getTabWidth();
        }
    });
    StyledText text = this.getTextWidget();
    text.addBidiSegmentListener(new BidiSegmentListener() {
        @Override
        public void lineGetSegments(BidiSegmentEvent event) {
            try {
                event.segments = getBidiLineSegments(event.lineOffset);
            } catch (BadLocationException x) {
                // ignore
            }
        }
    });
    updateViewerFont();
    updateViewerColors();
    getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
}
 
Example #4
Source File: ModulaEditor.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private void refreshLineNumberColumn(){
 	Display.getDefault().asyncExec(() ->{
 		IVerticalRuler ruler= getVerticalRuler();
 		// The following sequence mimics what happens during the setInput method.
 		// For now, this is the only known way to get the LineNumberColumn to update its visible status.
 		
 		// called at the end of org.eclipse.ui.texteditor.AbstractTextEditor.createPartControl(Composite)
if (ruler instanceof CompositeRuler) {
	updateContributedRulerColumns((CompositeRuler) ruler);
}

// called at the end of AbstractDecoratedTextEditor.doSetInput(IEditorInput) 
RulerColumnDescriptor lineNumberColumnDescriptor= RulerColumnRegistry.getDefault().getColumnDescriptor(LineNumberColumn.ID);
if (lineNumberColumnDescriptor != null) {
	IColumnSupport columnSupport= (IColumnSupport)getAdapter(IColumnSupport.class);
	columnSupport.setColumnVisible(lineNumberColumnDescriptor, isLineNumberRulerVisible() || isPrefQuickDiffAlwaysOn());
}

// force redraw of the ruler`s content.
IVerticalRuler verticalRuler = getVerticalRuler();
if (verticalRuler != null) {
	verticalRuler.update();
}
 	});
 }
 
Example #5
Source File: OverrideIndicatorRulerAction.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
private OverrideIndicatorAnnotation findOverrideIndicatorAnnotation() {
	IDocument document = getDocument();
	IVerticalRuler verticalRuler = getVerticalRuler();
	int lineOfLastMouseButtonActivity = verticalRuler.getLineOfLastMouseButtonActivity();
	IAnnotationModelExtension2 annotationModel = (IAnnotationModelExtension2) verticalRuler.getModel();
	if (annotationModel != null) {
		Iterator<?> iterator = ImmutableSet.<Object>of().iterator();
		try {
			IRegion line = document.getLineInformation(lineOfLastMouseButtonActivity);
			iterator = annotationModel.getAnnotationIterator(line.getOffset(), line.getLength() + 1, true, true);
		} catch (BadLocationException e) {
		}
		while (iterator.hasNext()) {
			Annotation annotation = (Annotation) iterator.next();
			if (annotation instanceof OverrideIndicatorAnnotation) {
				return (OverrideIndicatorAnnotation) annotation;
			}
		}
	}
	return null;
}
 
Example #6
Source File: DecoratedScriptEditor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected ISourceViewer createSourceViewer( Composite parent,
		IVerticalRuler ruler, int styles )
{
	fAnnotationAccess = getAnnotationAccess( );
	fOverviewRuler = createOverviewRuler( getSharedColors( ) );

	ProjectionViewer viewer = new ProjectionViewer( parent,
			ruler,
			getOverviewRuler( ),
			isOverviewRulerVisible( ),
			styles );

	ProjectionSupport fProjectionSupport = new ProjectionSupport( viewer,
			getAnnotationAccess( ),
			getSharedColors( ) );
	fProjectionSupport.addSummarizableAnnotationType( "org.eclipse.ui.workbench.texteditor.error" ); //$NON-NLS-1$
	fProjectionSupport.addSummarizableAnnotationType( "org.eclipse.ui.workbench.texteditor.warning" ); //$NON-NLS-1$
	fProjectionSupport.install( );

	// Ensures source viewer decoration support has been created and
	// configured.
	getSourceViewerDecorationSupport( viewer );

	return viewer;
}
 
Example #7
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the source viewer to be used by this editor.
 * 
 * @param parent
 *            the parent control
 * @return the source viewer
 */
protected SourceViewer createSourceViewer( Composite parent )
{
	IVerticalRuler ruler = createVerticalRuler( );
	Composite composite = new Composite( parent, SWT.BORDER
			| SWT.LEFT_TO_RIGHT );

	composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
	composite.setLayout( UIUtil.createGridLayoutWithoutMargin( ) );

	int styles = SWT.V_SCROLL
			| SWT.H_SCROLL
			| SWT.MULTI
			| SWT.BORDER
			| SWT.FULL_SELECTION;

	SourceViewer viewer = new SourceViewer( composite, ruler, styles );

	viewer.configure( sourceViewerConfiguration );

	updateStyledTextColors( viewer.getTextWidget( ) );

	JSEditorInput editorInput = new JSEditorInput( expression,
			getEncoding( ) );
	JSDocumentProvider documentProvider = new JSDocumentProvider( );

	try
	{
		documentProvider.connect( editorInput );
	}
	catch ( CoreException e )
	{
		ExceptionHandler.handle( e );
	}

	viewer.setDocument( documentProvider.getDocument( editorInput ),
			ruler == null ? null : ruler.getModel( ) );

	return viewer;
}
 
Example #8
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the vertical ruler to be used by this editor.
 * 
 * @return the vertical ruler
 */
private IVerticalRuler createVerticalRuler( )
{
	IVerticalRuler ruler = createCompositeRuler( );

	if ( ruler instanceof CompositeRuler )
	{
		CompositeRuler compositeRuler = (CompositeRuler) ruler;

		compositeRuler.addDecorator( 0, createLineNumberRulerColumn( ) );
	}
	return ruler;
}
 
Example #9
Source File: BaseSourceViewer.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public BaseSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
        boolean showAnnotationsOverview, int styles, IVerticalIndentGuidePreferencesProvider verticalIndentPrefs) {
    super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);

    verticalLinesPainter = new VerticalIndentGuidesPainter(
            getIndentGuide(verticalIndentPrefs));
    StyledText styledText = this.getTextWidget();
    verticalLinesPainter.setStyledText(styledText);
    styledText.addPaintListener(verticalLinesPainter);
    styledText.setLeftMargin(Math.max(styledText.getLeftMargin(), 2));
}
 
Example #10
Source File: JavaScriptLightWeightEditor.java    From typescript.java with MIT License 5 votes vote down vote up
protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {

		IPreferenceStore store = getPreferenceStore();
		ISourceViewer viewer = createTypeScriptSourceViewer(parent, verticalRuler, getOverviewRuler(),
				isOverviewRulerVisible(), styles, store);

		// JavaUIHelp.setHelp(this, viewer.getTextWidget(),
		// IJavaHelpContextIds.JAVA_EDITOR);

		TypeScriptSourceViewer TypeScriptSourceViewer = null;
		if (viewer instanceof TypeScriptSourceViewer)
			TypeScriptSourceViewer = (TypeScriptSourceViewer) viewer;

		/*
		 * This is a performance optimization to reduce the computation of the
		 * text presentation triggered by {@link #setVisibleDocument(IDocument)}
		 */
		if (TypeScriptSourceViewer != null && isFoldingEnabled()
				&& (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS))) {
			// TypeScriptSourceViewer.prepareDelayedProjection();
		}

		// // do not even install projection support until folding is actually
		// // enabled
		// if (isFoldingEnabled()) {
		// installProjectionSupport(TypeScriptSourceViewer);
		// }

		// fProjectionModelUpdater =
		// JavaScriptPlugin.getDefault().getFoldingStructureProviderRegistry()
		// .getCurrentFoldingProvider();
		// if (fProjectionModelUpdater != null) {
		// fProjectionModelUpdater.install(this, projectionViewer);
		// }
		// ensure source viewer decoration support has been created and
		// configured
		getSourceViewerDecorationSupport(viewer);

		return viewer;
	}
 
Example #11
Source File: PyEditProjection.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    IOverviewRuler overviewRuler = getOverviewRuler();
    PySourceViewer viewer = new PySourceViewer(parent, ruler, overviewRuler, isOverviewRulerVisible(), styles,
            this);

    //ensure decoration support has been created and configured.
    getSourceViewerDecorationSupport(viewer);

    return viewer;
}
 
Example #12
Source File: TLAEditor.java    From tlaplus with MIT License 5 votes vote down vote up
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles)
{
    ProjectionViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(),
            styles);
    // ensure decoration support has been created and configured.
    // @see org.eclipse.ui.texteditor.ExtendedTextEditor#createSourceViewer
    getSourceViewerDecorationSupport(viewer);
    return viewer;
}
 
Example #13
Source File: PySourceViewer.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public PySourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler,
        boolean showsAnnotationOverview, int styles, final PyEditProjection projection) {
    super(parent, ruler, overviewRuler, showsAnnotationOverview, styles,
            new PyAbstractIndentGuidePreferencesProvider() {

                @Override
                public int getTabWidth() {
                    return ((PyEdit) projection).getIndentPrefs().getTabWidth();
                }
            });
    this.projection = new WeakReference<PyEdit>((PyEdit) projection);
}
 
Example #14
Source File: ScriptEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the vertical ruler to be used by this editor.
 * 
 * @return the vertical ruler
 */
protected IVerticalRuler createVerticalRuler( )
{
	CompositeRuler ruler = createCompositeRuler( );

	ruler.addDecorator( 0, createLineNumberRulerColumn( ) );
	return ruler;
}
 
Example #15
Source File: RichStringAwareSourceViewer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public XtextSourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler,
		IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) {
	RichStringAwareSourceViewer result = new RichStringAwareSourceViewer(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
	result.merger = merger;
	return result;
}
 
Example #16
Source File: SARLSourceViewer.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public XtextSourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler,
		IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) {
	final SARLSourceViewer result = new SARLSourceViewer(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
	try {
		final Field field = RichStringAwareSourceViewer.class.getDeclaredField("merger"); //$NON-NLS-1$
		field.setAccessible(true);
		field.set(result, this.merger);
	} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException exception) {
		Exceptions.sneakyThrow(exception);
	}
	this.memberInjector.injectMembers(result);
	return result;
}
 
Example #17
Source File: SourceCodeTextEditor.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    final ISourceViewer viewer = super.createSourceViewer(parent, ruler, styles);
    if (isIndenGuidesSupported()) {
        IndentGuidesPainter.installToViewer(viewer, new IndentGuidesModel(this));
    }
    

    viewer.addTextInputListener(new TextInputListener());
    
    return viewer;
}
 
Example #18
Source File: AbstractLangEditor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
	LangSourceViewer viewer = doCreateSourceViewer(parent, ruler, styles);
	assertInstance(viewer, SourceViewer.class);
	assertInstance(viewer, ISourceViewerExt.class);
	return viewer;
}
 
Example #19
Source File: BibEditor.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    fOverviewRuler = createOverviewRuler(getSharedColors());
    
    ISourceViewer viewer = new ProjectionViewer(parent,
    		ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
    
    // ensure decoration support has been created and configured.
    getSourceViewerDecorationSupport(viewer);
    return viewer;
}
 
Example #20
Source File: AbstractLangEditor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected LangSourceViewer doCreateSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
	LangSourceViewer viewer = 
			new LangSourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
	// ensure decoration support has been created and configured.
	getSourceViewerDecorationSupport(viewer);
	return viewer;
}
 
Example #21
Source File: XtextSourceViewer.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public XtextSourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler,
		IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) {
	XtextSourceViewer result = new XtextSourceViewer(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
	membersInjector.injectMembers(result);
	return result;
}
 
Example #22
Source File: AbstractThemeableEditor.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ISourceViewer createSourceViewer(Composite parent, final IVerticalRuler ruler, int styles)
{
	fAnnotationAccess = getAnnotationAccess();
	fOverviewRuler = createOverviewRuler(getSharedColors());

	// Need to make it a projection viewer now that we have folding...
	CommonProjectionViewer viewer = new CommonProjectionViewer(parent, ruler, getOverviewRuler(),
			isOverviewRulerVisible(), styles)
	{
		@SuppressWarnings("rawtypes")
		@Override
		public Object getAdapter(Class adapter)
		{
			if (AbstractThemeableEditor.class == adapter || ITextEditor.class == adapter)
			{
				return AbstractThemeableEditor.this;
			}
			return super.getAdapter(adapter);
		}

	};

	// ensure decoration support has been created and configured.
	getSourceViewerDecorationSupport(viewer);

	fThemeableEditorColorsExtension.createBackgroundPainter(viewer);

	return viewer;
}
 
Example #23
Source File: XtextEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
	if (log.isDebugEnabled())
		log.debug("Creating Xtext source viewer.");

	// overwrite superclass implementation to allow folding
	fAnnotationAccess = createAnnotationAccess();
	fOverviewRuler = createOverviewRuler(getSharedColors());
	ISourceViewer projectionViewer = sourceViewerFactory.createSourceViewer(parent, ruler, getOverviewRuler(),
			isOverviewRulerVisible(), styles);
	getSourceViewerDecorationSupport(projectionViewer);
	return projectionViewer;
}
 
Example #24
Source File: JavaSourceViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public JavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
	super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
	setPreferenceStore(store);
}
 
Example #25
Source File: XMLEditor.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
		ISourceViewer viewer= super.createSourceViewer( parent, ruler, styles );
//		getSourceViewerDecorationSupport(viewer);
		return viewer;
	}
 
Example #26
Source File: AbstractFoldingEditor.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles)
{
	ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
	getSourceViewerDecorationSupport(viewer);
	return viewer;
}
 
Example #27
Source File: ClassFileMarkerRulerAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public ClassFileMarkerRulerAction(String prefix, IVerticalRuler ruler, ITextEditor editor, String markerType, boolean askForLabel) {
	super(JavaEditorMessages.getBundleForConstructedKeys(), prefix, editor, ruler, markerType, askForLabel);
}
 
Example #28
Source File: PyEdit.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
public IVerticalRuler getIVerticalRuler() {
    return getVerticalRuler();
}
 
Example #29
Source File: LangSourceViewer.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
public LangSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
	super(parent, verticalRuler, null, false, styles);
}
 
Example #30
Source File: LangSourceViewer.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
public LangSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
		boolean showAnnotationsOverview, int styles) {
	super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
}