use of org.eclipse.jface.text.source.SourceViewer in project xtext-eclipse by eclipse.
the class AbstractSourceView method setViewerFont.
private void setViewerFont() {
Font font = getFont(getViewerFontName());
SourceViewer viewer = getSourceViewer();
if (viewer.getDocument() != null) {
Point selection = viewer.getSelectedRange();
int topIndex = viewer.getTopIndex();
StyledText styledText = viewer.getTextWidget();
Control parent = viewer.getControl();
parent.setRedraw(false);
styledText.setFont(font);
viewer.setSelectedRange(selection.x, selection.y);
viewer.setTopIndex(topIndex);
if (parent instanceof Composite) {
Composite composite = (Composite) parent;
composite.layout(true);
}
parent.setRedraw(true);
} else {
StyledText styledText = viewer.getTextWidget();
styledText.setFont(font);
}
}
use of org.eclipse.jface.text.source.SourceViewer in project cubrid-manager by CUBRID.
the class CUBRIDTextEditor method initTextViewer.
/**
* Initialize the Text Viewer.
*
* @param composite which is text viewer's parent.
*/
protected void initTextViewer(final Composite composite) {
textViewer = new SourceViewer(composite, getRuler(), SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
textViewer.getTextWidget().setFont(new Font(Display.getCurrent(), "Default", 12, SWT.NORMAL));
textViewer.configure(svConfiguration);
textViewer.setDocument(documentProvider.getDocument(getEditorInput()));
textViewer.setUndoManager(undoManager);
textInputListener = new TextInputListener();
textViewer.addTextListener(textInputListener);
textViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
updateActions();
}
});
textViewer.getTextWidget().setData(TextEditorFindReplaceMediator.SQL_EDITOR_FLAG, textViewer);
editorDialogMediator = new TextEditorFindReplaceMediator();
textViewer.getTextWidget().addFocusListener(editorDialogMediator);
}
use of org.eclipse.jface.text.source.SourceViewer in project eclipse.platform.text by eclipse.
the class AbstractTemplatesPage method createPatternViewer.
/**
* Creates, configures and returns a source viewer to present the template
* pattern on the templates page.
* <p>
* Clients may override to provide a custom source viewer featuring e.g. syntax coloring.</p>
*
* @param parent the parent control
* @return a configured source viewer
*/
protected SourceViewer createPatternViewer(Composite parent) {
SourceViewer viewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL);
SourceViewerConfiguration configuration = new SourceViewerConfiguration();
viewer.configure(configuration);
IDocument document = new Document();
viewer.setDocument(document);
viewer.setEditable(false);
return viewer;
}
use of org.eclipse.jface.text.source.SourceViewer in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method createSourceViewer.
@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
fAnnotationAccess = getAnnotationAccess();
fOverviewRuler = createOverviewRuler(getSharedColors());
ISourceViewer viewer = new SourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
// ensure decoration support has been created and configured.
getSourceViewerDecorationSupport(viewer);
return viewer;
}
use of org.eclipse.jface.text.source.SourceViewer in project eclipse.platform.releng by eclipse.
the class CopyrightPreferencePage method createEditor.
/**
* Create the sourceviewer editor to be used to edit the copyright template
*/
private SourceViewer createEditor(Composite parent) {
fCopyrightLabel = new Label(parent, SWT.NONE);
// $NON-NLS-1$
fCopyrightLabel.setText(Messages.getString("CopyrightPreferencePage.5"));
GridData data = new GridData();
data.horizontalSpan = 2;
fCopyrightLabel.setLayoutData(data);
SourceViewer viewer = createViewer(parent);
IDocument document = new Document();
viewer.setEditable(true);
viewer.setDocument(document);
// just use a default 10 lines
int nLines = 10;
// int nLines= document.getNumberOfLines();
// if (nLines < 5) {
// nLines= 5;
// } else if (nLines > 12) {
// nLines= 12;
// }
Control control = viewer.getControl();
data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = convertWidthInCharsToPixels(80);
data.heightHint = convertHeightInCharsToPixels(nLines);
data.horizontalSpan = 2;
control.setLayoutData(data);
return viewer;
}
Aggregations