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

The following examples show how to use org.eclipse.jface.text.source.CompositeRuler. 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: 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 #2
Source File: GamlEditor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void handlePreferenceStoreChanged(final PropertyChangeEvent event) {
	final LineNumberColumn c;
	super.handlePreferenceStoreChanged(event);
	if (event.getProperty().equals(PREFERENCE_COLOR_BACKGROUND)) {
		// this.fSourceViewerDecorationSupport.updateOverviewDecorations();

		this.getVerticalRuler().getControl()
				.setBackground(GamaColors.get(GamaPreferences.Modeling.EDITOR_BACKGROUND_COLOR.getValue()).color());

		final Iterator e = ((CompositeRuler) getVerticalRuler()).getDecoratorIterator();
		while (e.hasNext()) {
			final IVerticalRulerColumn column = (IVerticalRulerColumn) e.next();
			column.getControl().setBackground(
					GamaColors.get(GamaPreferences.Modeling.EDITOR_BACKGROUND_COLOR.getValue()).color());
			column.redraw();
		}
	}
}
 
Example #3
Source File: GroovyViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void dispose() {
    final ProvidedGroovyRepositoryStore store = RepositoryManager.getInstance()
            .getRepositoryStore(ProvidedGroovyRepositoryStore.class);
    GroovyFileStore fStore = store.getChild(GroovyFileStore.EXPRESSION_SCRIPT_NAME, true);
    if (fStore != null) {
        fStore.delete();
    }
    final IColumnSupport columSupport = (IColumnSupport) editor.getAdapter(IColumnSupport.class);
    if (columSupport != null) {
        columSupport.dispose();
    }
    final CompositeRuler verticalRuler = (CompositeRuler) editor.getAdapter(IVerticalRulerInfo.class);
    if (verticalRuler != null && verticalRuler.getControl() != null) {
        verticalRuler.getControl().dispose();
    }
    editor.dispose();
}
 
Example #4
Source File: TypeScriptMergeViewer.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public void createPartControl(Composite composite) {
	SourceViewer sourceViewer = (SourceViewer) createTypeScriptSourceViewer(composite, new CompositeRuler(),
			null, false, fTextOrientation | SWT.H_SCROLL | SWT.V_SCROLL, createChainedPreferenceStore(null));
	setSourceViewer(this, sourceViewer);
	createNavigationActions();
	getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
}
 
Example #5
Source File: ThemeableEditorExtension.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void overrideRulerColors()
{
	IThemeableEditor editor = this.fEditor.get();

	// default to bg color of surrounding composite
	Color bg = null;
	// Use editor background color if we can
	if (editor != null)
	{
		ISourceViewer sv = editor.getISourceViewer();
		if (sv != null)
		{
			StyledText text = sv.getTextWidget();
			if (text != null)
			{
				bg = text.getBackground();
				// copy the color because for some reason it gets disposed
				bg = ThemePlugin.getDefault().getColorManager().getColor(bg.getRGB());
			}
		}

		// force the colors for all the ruler columns (specifically so we force the folding bg to match).
		CompositeRuler ruler = (CompositeRuler) editor.getIVerticalRuler();
		Iterator<IVerticalRulerColumn> iter = ruler.getDecoratorIterator();
		while (iter.hasNext())
		{
			IVerticalRulerColumn column = iter.next();
			column.getControl().setBackground(bg);
		}
	}

	if (fLineColumn != null)
	{
		fLineColumn.setBackground(bg);
	}
}
 
Example #6
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler) {
	if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
		return super.createAnnotationRulerColumn(ruler);

	AnnotationRulerColumn column= new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess());
	column.setHover(new JavaExpandHover(ruler, getAnnotationAccess(), new IDoubleClickListener() {

		public void doubleClick(DoubleClickEvent event) {
			// for now: just invoke ruler double click action
			triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
		}

		private void triggerAction(String actionID) {
			IAction action= getAction(actionID);
			if (action != null) {
				if (action instanceof IUpdate)
					((IUpdate) action).update();
				// hack to propagate line change
				if (action instanceof ISelectionListener) {
					((ISelectionListener)action).selectionChanged(null, null);
				}
				if (action.isEnabled())
					action.run();
			}
		}

	}));

	return column;
}
 
Example #7
Source File: JavaMergeViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createPartControl(Composite composite) {
	SourceViewer sourceViewer= (SourceViewer)createJavaSourceViewer(composite, new CompositeRuler(), null, false, fTextOrientation | SWT.H_SCROLL | SWT.V_SCROLL, createChainedPreferenceStore(null));
	setSourceViewer(this, sourceViewer);
	createNavigationActions();
	getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
}
 
Example #8
Source File: ScriptEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new line number ruler column that is appropriately initialized.
 * 
 * @return the created line number column
 */
private CompositeRuler createCompositeRuler( )
{
	CompositeRuler ruler = new CompositeRuler( );

	ruler.setModel( new AnnotationModel( ) );
	return ruler;
}
 
Example #9
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 #10
Source File: ExpressionBuilder.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new line number ruler column that is appropriately initialized.
 * 
 * @return the created line number column
 */
private CompositeRuler createCompositeRuler( )
{
	CompositeRuler ruler = new CompositeRuler( );

	ruler.setModel( new AnnotationModel( ) );
	return ruler;
}
 
Example #11
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 #12
Source File: BookmarkColumn.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
    Assert.isTrue(fDelegate != null);
    return fDelegate.createControl(parentRuler, parentControl);
}
 
Example #13
Source File: CommonLineNumberChangeRulerColumn.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public Control createControl(CompositeRuler parentRuler, Composite parentControl) {
	Control control= super.createControl(parentRuler, parentControl);
	fRevisionPainter.setParentRuler(parentRuler);
	fDiffPainter.setParentRuler(parentRuler);
	return control;
}
 
Example #14
Source File: JavaExpandHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public JavaExpandHover(CompositeRuler ruler, IAnnotationAccess access, IDoubleClickListener doubleClickListener) {
	super(ruler, access, doubleClickListener);
}
 
Example #15
Source File: LangTextMergeViewer.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected SourceViewer createSourceViewer(Composite parent, int textOrientation) {
	int styles = textOrientation | SWT.H_SCROLL | SWT.V_SCROLL;
	return new LangSourceViewer(parent, new CompositeRuler(), styles);
}
 
Example #16
Source File: AnnotationExpandHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a new hover instance.
 *
 * @param ruler
 * @param access
 * @param doubleClickListener
 */
public AnnotationExpandHover(CompositeRuler ruler, IAnnotationAccess access, IDoubleClickListener doubleClickListener) {
	fCompositeRuler= ruler;
	fAnnotationAccess= access;
	fDblClickListener= doubleClickListener;
}