org.eclipse.jface.text.MarginPainter Java Examples

The following examples show how to use org.eclipse.jface.text.MarginPainter. 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: XtendFormatterPreview.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public XtendFormatterPreview forEmbeddedEditor(EmbeddedEditor editorHandle) {
	if (this.editorHandle != null) {
		throw new IllegalStateException("This formatter preview is already binded to an embedet editor");
	}
	this.editorHandle = editorHandle;
	this.modelAccess = editorHandle.createPartialEditor();
	this.marginPainter = new MarginPainter(editorHandle.getViewer());
	final RGB rgb = PreferenceConverter.getColor(preferenceStoreAccess.getPreferenceStore(),
			AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
	marginPainter.setMarginRulerColor(EditorUtils.colorFromRGB(rgb));
	editorHandle.getViewer().addPainter(marginPainter);
	return this;
}
 
Example #2
Source File: JavaPreview.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public JavaPreview(Map<String, String> workingValues, Composite parent) {
		JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
		fPreviewDocument= new Document();
		fWorkingValues= workingValues;
		tools.setupJavaDocumentPartitioner( fPreviewDocument, IJavaPartitions.JAVA_PARTITIONING);

		PreferenceStore prioritizedSettings= new PreferenceStore();
		HashMap<String, String> complianceOptions= new HashMap<String, String>();
		JavaModelUtil.setComplianceOptions(complianceOptions, JavaModelUtil.VERSION_LATEST);
		for (Entry<String, String> complianceOption : complianceOptions.entrySet()) {
			prioritizedSettings.setValue(complianceOption.getKey(), complianceOption.getValue());
		}

		IPreferenceStore[] chain= { prioritizedSettings, JavaPlugin.getDefault().getCombinedPreferenceStore() };
		fPreferenceStore= new ChainedPreferenceStore(chain);
		fSourceViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore);
		fSourceViewer.setEditable(false);
		Cursor arrowCursor= fSourceViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
		fSourceViewer.getTextWidget().setCursor(arrowCursor);

		// Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263
//		fSourceViewer.getTextWidget().setCaret(null);

		fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, IJavaPartitions.JAVA_PARTITIONING, true);
		fSourceViewer.configure(fViewerConfiguration);
		fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));

		fMarginPainter= new MarginPainter(fSourceViewer);
		final RGB rgb= PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
		fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
		fSourceViewer.addPainter(fMarginPainter);

		new JavaSourcePreviewerUpdater();
		fSourceViewer.setDocument(fPreviewDocument);
	}
 
Example #3
Source File: AbapGitStagingView.java    From ADT_Frontend with MIT License 4 votes vote down vote up
private void createMarginPainter(TextViewer commitMessageTextViewer) {
	MarginPainter marginPainter = new MarginPainter(commitMessageTextViewer);
	marginPainter.setMarginRulerColumn(MAX_COMMIT_MESSAGE_LINE_LENGTH); //maximum recommended commit message line length is 72
	marginPainter.setMarginRulerColor(PlatformUI.getWorkbench().getDisplay().getSystemColor(SWT.COLOR_GRAY));
	commitMessageTextViewer.addPainter(marginPainter);
}
 
Example #4
Source File: FormatterPreview.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public void turnOnMarginPainter() {
    fMarginPainter= new MarginPainter(this);
    fMarginPainter.setMarginRulerStyle(SWT.LINE_DOT);
    fMarginPainter.setMarginRulerColor(new Color(Display.getDefault(), 0,0,0));
    this.addPainter(fMarginPainter);
}