本文整理汇总了Java中org.eclipse.jface.text.TextViewer类的典型用法代码示例。如果您正苦于以下问题:Java TextViewer类的具体用法?Java TextViewer怎么用?Java TextViewer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextViewer类属于org.eclipse.jface.text包,在下文中一共展示了TextViewer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TMEditor
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
public TMEditor(IGrammar grammar, ITokenProvider tokenProvider, String text) {
shell = new Shell();
viewer = new TextViewer(shell, SWT.NONE);
document = new Document();
viewer.setDocument(document);
commands = new ArrayList<>();
collector = new StyleRangesCollector();
setAndExecute(text);
reconciler = new TMPresentationReconciler();
reconciler.addTMPresentationReconcilerListener(collector);
reconciler.setGrammar(grammar);
reconciler.setTokenProvider(tokenProvider);
reconciler.install(viewer);
}
示例2: createTextArea
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
/**
* �����༭��
*
* @return
*/
public void createTextArea(TextViewerUndoManager undo) {
if (wv == null || wv.isDisposed()) {
tv = new TextViewer(this, SWT.WRAP | SWT.V_SCROLL);
StyledText styledText = tv.getTextWidget();
if (undo != null) {
undo.disconnect();
undo.connect(tv);
} else
tvum = new TextViewerUndoManager(100);
tv.setUndoManager(tvum);
tv.activatePlugins();
setCurrentTextArea(styledText);
blackTextArea = new blackTextArea(styledText, this);
} else {
// wv.disposeTextArea();
wv.createTextArea(null);
}
}
示例3: createTextArea
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
public void createTextArea(IDocument iDocument){
if(b.text != null && !b.text.isDisposed()){
disposeTextArea();
}
b.tv = new TextViewer(b, SWT.V_SCROLL|SWT.WRAP);
b.text = b.tv.getTextWidget();
b.text.setVisible(false);
b.text.setParent(this);
setStyledTextLayout(x);
b.blackTextArea = new blackTextArea(b.text,b);
b.blackTextArea.writingView();
b.tv.setUndoManager(new TextViewerUndoManager(100));
b.tv.activatePlugins();
if(b.ba.isFullScreenWritingView())
b.ba.changeColor(b.ba.lastForeColor, b.ba.lastBackColor);
if(iDocument != null) {
b.tv.setDocument(iDocument);
}
addSlider();
layout();
b.text.setFocus();
b.text.setVisible(true);
}
示例4: configureTextViewer
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
@Override
protected void configureTextViewer(TextViewer viewer) {
if (viewer instanceof SourceViewer) {
SourceViewer sourceViewer = (SourceViewer) viewer;
if (fSourceViewer == null)
fSourceViewer = new ArrayList<>();
if (!fSourceViewer.contains(sourceViewer))
fSourceViewer.add(sourceViewer);
TypeScriptTextTools tools = JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools();
if (tools != null) {
IEditorInput editorInput = getEditorInput(sourceViewer);
sourceViewer.unconfigure();
if (editorInput == null) {
sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null));
return;
}
getSourceViewerConfiguration(sourceViewer, editorInput);
}
}
}
示例5: createDMNtab
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
private CTabItem createDMNtab()
{
CTabItem dmnTab = new CTabItem(tabs, SWT.NONE);
dmnTab.setText("DMN");
// assign a XML or DMN icon
TextViewer dmnViewer = new TextViewer(tabs, SWT.V_SCROLL);
dmnViewer.setDocument(new Document());
dmnTab.setControl(dmnViewer.getTextWidget());
dmnTab.addListener(SWT.SELECTED, evt -> {
dmnViewer.getDocument().set(toDMN(table.model));
});
tabs.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
tabs.getSelection().notifyListeners(SWT.SELECTED, new Event());
}
});
return dmnTab;
}
示例6: ignoreAutoEditStrategies
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
/**
* Tries to tell to the Xtext viewer whether the registered
* auto edit strategies should be ignored.
*
* @param ignore <code>true</code> if the strategies should be ignored.
*/
public void ignoreAutoEditStrategies(boolean ignore){
try {
// org.eclipse.jface.text.TextViewer#ignoreAutoEditStrategies(boolean) is protected by definition.
// XtextSourceViewer does not extend its visibility so we have to bypass it
// invoking the method via Reflection API.
// N.B: This way of using reflection is a "violation" of OOP basis but
// it is also a trick that works fine.
Method declaredMethod = TextViewer.class.getDeclaredMethod("ignoreAutoEditStrategies",boolean.class); //$NON-NLS-1$
declaredMethod.setAccessible(true);
declaredMethod.invoke(getXtextSourceviewer(), ignore);
} catch (Exception e) {
JRExpressionsActivator.getInstance().getLog().log(
new Status(IStatus.ERROR, JRExpressionsUIPlugin.PLUGIN_ID,
Messages.StyledTextXtextAdapter2_AutoEditStrategiesError, e));
}
}
示例7: configureTextViewer
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
@Override
protected void configureTextViewer(final TextViewer textViewer)
{
ThemePlugin.getDefault().getControlThemerFactory().apply(textViewer);
// Force line highlight color. We need to perform this after the line painter is attached, which happens after
// the return of this method. Scheduling async seems to work.
UIUtils.getDisplay().asyncExec(new Runnable()
{
public void run()
{
CursorLinePainter p = getCursorLinePainterInstalled(textViewer);
if (p != null)
{
p.setHighlightColor(getColorManager().getColor(getCurrentTheme().getLineHighlightAgainstBG()));
}
}
});
}
示例8: getCursorLinePainterInstalled
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
private CursorLinePainter getCursorLinePainterInstalled(TextViewer viewer)
{
Listener[] listeners = viewer.getTextWidget().getListeners(3001/* StyledText.LineGetBackground */);
for (Listener listener : listeners)
{
if (listener instanceof TypedListener)
{
TypedListener typedListener = (TypedListener) listener;
if (typedListener.getEventListener() instanceof CursorLinePainter)
{
return (CursorLinePainter) typedListener.getEventListener();
}
}
}
return null;
}
示例9: handleDispose
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
@Override
protected void handleDispose()
{
// HACK We force the widget command to be nulled out so it can be garbage collected. Might want to
// report a bug with eclipse to clean this up.
try
{
Field f = TextViewer.class.getDeclaredField("fWidgetCommand"); //$NON-NLS-1$
if (f != null)
{
f.setAccessible(true);
f.set(this, null);
}
}
catch (Throwable t)
{
// ignore
}
finally
{
super.handleDispose();
}
}
示例10: configureTextViewer
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
@Override
protected void configureTextViewer(TextViewer textViewer) {
if (!(textViewer instanceof SourceViewer))
return;
if (fPreferenceStore == null) {
fSourceViewerConfigurations= new ArrayList<SourceViewerConfiguration>(3);
fPreferenceStore= JavaPlugin.getDefault().getCombinedPreferenceStore();
fPreferenceChangeListener= new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
Iterator<SourceViewerConfiguration> iter= fSourceViewerConfigurations.iterator();
while (iter.hasNext())
((PropertiesFileSourceViewerConfiguration)iter.next()).handlePropertyChangeEvent(event);
invalidateTextPresentation();
}
};
fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
}
SourceViewerConfiguration sourceViewerConfiguration= new PropertiesFileSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), fPreferenceStore, null,
getDocumentPartitioning());
fSourceViewerConfigurations.add(sourceViewerConfiguration);
((SourceViewer)textViewer).configure(sourceViewerConfiguration);
}
示例11: configureTextViewer
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
@Override
protected void configureTextViewer(TextViewer viewer) {
if (viewer instanceof SourceViewer) {
SourceViewer sourceViewer= (SourceViewer)viewer;
if (fSourceViewer == null)
fSourceViewer= new ArrayList<SourceViewer>();
if (!fSourceViewer.contains(sourceViewer))
fSourceViewer.add(sourceViewer);
JavaTextTools tools= JavaCompareUtilities.getJavaTextTools();
if (tools != null) {
IEditorInput editorInput= getEditorInput(sourceViewer);
sourceViewer.unconfigure();
if (editorInput == null) {
sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null));
return;
}
getSourceViewerConfiguration(sourceViewer, editorInput);
}
}
}
示例12: ExplanationComposite
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
/**
* Create the composite.
* @param parent
* @param style
*/
public ExplanationComposite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(1, false));
SashForm sashForm = new SashForm(this, SWT.NONE);
sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
sashForm.setLocation(0, 0);
TextViewer textViewer = new TextViewer(sashForm, SWT.BORDER | SWT.READ_ONLY | SWT.WRAP);
styledTextExplanation = textViewer.getTextWidget();
styledTextExplanation.setEditable(false);
composite = new Composite(sashForm, SWT.NONE);
composite.setLayout(new FillLayout(SWT.HORIZONTAL));
sashForm.setWeights(new int[] {1, 2});
}
示例13: createDialogArea
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new GridLayout(1, false));
Label lblFixes = new Label(container, SWT.NONE);
lblFixes.setText("Fixes");
tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION);
table = tableViewer.getTable();
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
TextViewer textViewer = new TextViewer(container, SWT.BORDER);
StyledText styledText = textViewer.getTextWidget();
styledText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tableViewer.setContentProvider(new QuickfixContentProvider());
tableViewer.setLabelProvider(new QuickfixLabelProvider());
tableViewer.setInput(quickfixes);
return container;
}
示例14: transform
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
/**
* A semi-hack... This uses stuff that may change at any time in Eclipse.
* In the java editor, the projection annotation model contains the collapsible regions which correspond to methods (and other areas
* such as import groups).
*
* This may work in other editor types as well... TBD
*/
protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection,
ExecutionEvent event) throws BadLocationException {
ITextViewerExtension viewer = MarkUtils.getITextViewer(editor);
if (viewer instanceof ProjectionViewer) {
ProjectionAnnotationModel projection = ((ProjectionViewer)viewer).getProjectionAnnotationModel();
@SuppressWarnings("unchecked") // the method name says it all
Iterator<Annotation> pit = projection.getAnnotationIterator();
while (pit.hasNext()) {
Position p = projection.getPosition(pit.next());
if (p.includes(currentSelection.getOffset())) {
if (isUniversalPresent()) {
// Do this here to prevent subsequent scrolling once range is revealed
MarkUtils.setSelection(editor, new TextSelection(document, p.offset, 0));
}
// the viewer is pretty much guaranteed to be a TextViewer
if (viewer instanceof TextViewer) {
((TextViewer)viewer).revealRange(p.offset, p.length);
}
break;
}
}
}
return NO_OFFSET;
}
示例15: perform
import org.eclipse.jface.text.TextViewer; //导入依赖的package包/类
/**
* @param ps
* @param provider
*/
public boolean perform(TextSelectionUtils ps, final char c, TextViewer viewer, IScopeCreatingCharsProvider provider) {
linkOffset = -1;
linkExitPos = -1;
linkLen = 0;
try {
IDocument doc = ps.getDoc();
DocCmd docCmd = new DocCmd(ps.getAbsoluteCursorOffset(), ps.getSelLength(), Character.toString(c));
if (!handleScopeCreationChar(doc, docCmd, ps, provider, c)) {
return false; //not handled
}
if (linkOffset == -1 || linkExitPos == -1) {
return true; //it was handled (without the link)
}
if (viewer != null) {
viewer.setSelectedRange(linkOffset, linkLen);
}
} catch (Exception e) {
Log.log(e);
}
return true;
}