本文整理汇总了Java中org.eclipse.jface.text.TextEvent.getDocumentEvent方法的典型用法代码示例。如果您正苦于以下问题:Java TextEvent.getDocumentEvent方法的具体用法?Java TextEvent.getDocumentEvent怎么用?Java TextEvent.getDocumentEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.TextEvent
的用法示例。
在下文中一共展示了TextEvent.getDocumentEvent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeChange
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
/**
* Computes the change abstraction given a text event.
*
* @param event the text event to analyze
* @return a change object describing the event
*/
private Change computeChange(TextEvent event) {
DocumentEvent e = event.getDocumentEvent();
if (e == null) return new Change(TypingRun.NO_CHANGE, -1);
int start = e.getOffset();
int end = e.getOffset() + e.getLength();
String newText = e.getText();
if (newText == null) newText = new String();
if (start == end) {
// no replace / delete / overwrite
if (newText.length() == 1) return new Change(TypingRun.INSERT, end + 1);
} else if (start == end - 1) {
if (newText.length() == 1) return new Change(TypingRun.OVERTYPE, end);
if (newText.length() == 0) return new Change(TypingRun.DELETE, start);
}
return new Change(TypingRun.UNKNOWN, -1);
}
示例2: textChanged
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
public void textChanged(TextEvent event) {
fCachedRedrawState= event.getViewerRedrawState();
if (!fCachedRedrawState)
return;
if (updateNumberOfDigits()) {
computeIndentations();
layout(event.getViewerRedrawState());
return;
}
boolean viewerCompletelyShown= isViewerEntirelyShown();
if (viewerCompletelyShown || fSensitiveToTextChanges || event.getDocumentEvent() == null)
doPostRedraw();
fSensitiveToTextChanges= viewerCompletelyShown;
}
示例3: computeChange
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
/**
* Computes the change abstraction given a text event.
*
* @param event the text event to analyze
* @return a change object describing the event
*/
private Change computeChange(TextEvent event) {
DocumentEvent e= event.getDocumentEvent();
if (e == null)
return new Change(TypingRun.NO_CHANGE, -1);
int start= e.getOffset();
int end= e.getOffset() + e.getLength();
String newText= e.getText();
if (newText == null)
newText= new String();
if (start == end) {
// no replace / delete / overwrite
if (newText.length() == 1)
return new Change(TypingRun.INSERT, end + 1);
} else if (start == end - 1) {
if (newText.length() == 1)
return new Change(TypingRun.OVERTYPE, end);
if (newText.length() == 0)
return new Change(TypingRun.DELETE, start);
}
return new Change(TypingRun.UNKNOWN, -1);
}
示例4: textChanged
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
@Override
public void textChanged(TextEvent event) {
if (event.getDocumentEvent() != null) {
return;
}
String command = "viewer.invalidateTextPresentation(" + event.getOffset() + ", " + event.getLength() + ");";
write("\t\t" + command, true);
//commands.add(new Command(command));
}
示例5: textChanged
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
@Override
public void textChanged(TextEvent e) {
if (fTextViewer != null && e.getDocumentEvent() == null && e.getViewerRedrawState()) {
// handle only changes of visible document
redraw();
}
}
示例6: textChanged
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
@Override
public void textChanged(TextEvent e) {
if (!e.getViewerRedrawState()) {
return;
}
// changed text: propagate previous style, which will be overridden
// later asynchronously by TM
if (e.getDocumentEvent() != null) {
int diff = e.getText().length() - e.getLength();
if (diff > 0 && e.getOffset() > 0) {
StyleRange range = viewer.getTextWidget().getStyleRangeAtOffset(e.getOffset() - 1);
if (range != null) {
range.length += diff;
viewer.getTextWidget().setStyleRange(range);
}
}
} else { // TextViewer#invalidateTextPresentation is called (because
// of validation, folding, etc)
// case 2), do the colorization.
IDocument document = viewer.getDocument();
if (document != null) {
IRegion region = null;
int fromLineNumber = -1;
int toLineNumber = -1;
if (e.getOffset() == 0 && e.getLength() == 0 && e.getText() == null) {
// redraw state change, damage the whole document
fromLineNumber = 0;
toLineNumber = document.getNumberOfLines() - 1;
} else {
region = widgetRegion2ModelRegion(e);
if (region != null) {
if (region.getLength() == 0) {
// Some text was removed, don't colorize it.
return;
}
try {
String text = document.get(region.getOffset(), region.getLength());
DocumentEvent de = new DocumentEvent(document, region.getOffset(), region.getLength(),
text);
fromLineNumber = DocumentHelper.getStartLine(de);
toLineNumber = DocumentHelper.getEndLine(de, false);
} catch (BadLocationException x) {
}
}
}
if (enabled) {
// case where there is grammar & theme -> update text presentation with the
// grammar tokens
ITMModel model = getTMModelManager().connect(document);
colorize(fromLineNumber, toLineNumber, region, (TMDocumentModel) model);
} else {
if (region != null) {
// case where there is no grammar & theme -> update text presentation with the
// default styles (ex: to support highlighting with GenericEditor)
TextPresentation presentation = new TextPresentation(region, 100);
presentation.setDefaultStyleRange(
new StyleRange(region.getOffset(), region.getLength(), null, null));
applyTextRegionCollection(presentation);
}
}
}
}
}
示例7: textChanged
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
public void textChanged(TextEvent event) {
if (event.getDocumentEvent() != null)
leave(true);
}
示例8: textChanged
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
public void textChanged(TextEvent event) {
if (event.getDocumentEvent() != null) {
// leave();
}
}
示例9: textChanged
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
@Override
public void textChanged(TextEvent event) {
if (event.getDocumentEvent() != null)
leave();
}
示例10: textChanged
import org.eclipse.jface.text.TextEvent; //导入方法依赖的package包/类
@Override
public void textChanged(TextEvent event) {
if(event.getDocumentEvent() != null) {
validator.resetCount();
}
}