本文整理汇总了Java中org.eclipse.swt.custom.VerifyKeyListener类的典型用法代码示例。如果您正苦于以下问题:Java VerifyKeyListener类的具体用法?Java VerifyKeyListener怎么用?Java VerifyKeyListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VerifyKeyListener类属于org.eclipse.swt.custom包,在下文中一共展示了VerifyKeyListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeViewer
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
private void initializeViewer(IDocument document) {
fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
setDocument(document);
installViewerConfiguration();
setEditable(true);
Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
getTextWidget().setFont(font);
getTextWidget().setData("document",document);
Control control = getControl();
GridData data = new GridData(GridData.FILL_BOTH);
control.setLayoutData(data);
prependVerifyKeyListener(new VerifyKeyListener() {
@Override
public void verifyKey(VerifyEvent event) {
handleVerifyKeyPressed(event);
}
});
addDocumentListener(document);
}
示例2: getStrategies
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
public List<IAutoEditStrategy> getStrategies(final ISourceViewer sourceViewer,final String contentType) {
final List<IAutoEditStrategy> strategies = Lists.newArrayList();
configure(new IEditStrategyAcceptor() {
public void accept(IAutoEditStrategy strategy, String type) {
if (type == null || contentType.equals(type)) {
if (strategy instanceof ISourceViewerAware) {
((ISourceViewerAware) strategy).setSourceViewer(sourceViewer);
}
if (strategy instanceof VerifyKeyListener) {
sourceViewer.getTextWidget().addVerifyKeyListener((VerifyKeyListener) strategy);
}
strategies.add(strategy);
}
}
});
return strategies;
}
示例3: prependVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
/**
* @see org.eclipse.jface.contentassist.IContentAssistSubjectControl#prependVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
*/
public boolean prependVerifyKeyListener(VerifyKeyListener verifyKeyListener)
{
if (fContentAssistSubjectControl != null)
{
return fContentAssistSubjectControl.prependVerifyKeyListener(verifyKeyListener);
}
else if (fViewer instanceof ITextViewerExtension)
{
ITextViewerExtension e = (ITextViewerExtension) fViewer;
e.prependVerifyKeyListener(verifyKeyListener);
return true;
}
else
{
StyledText textWidget = fViewer.getTextWidget();
if (Helper.okToUse(textWidget))
{
textWidget.addVerifyKeyListener(verifyKeyListener);
return true;
}
}
return false;
}
示例4: appendVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
/**
* @see org.eclipse.jface.contentassist.IContentAssistSubjectControl#appendVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
*/
public boolean appendVerifyKeyListener(VerifyKeyListener verifyKeyListener)
{
if (fContentAssistSubjectControl != null)
{
return fContentAssistSubjectControl.appendVerifyKeyListener(verifyKeyListener);
}
else if (fViewer instanceof ITextViewerExtension)
{
ITextViewerExtension extension = (ITextViewerExtension) fViewer;
extension.appendVerifyKeyListener(verifyKeyListener);
return true;
}
else
{
StyledText textWidget = fViewer.getTextWidget();
if (Helper.okToUse(textWidget))
{
textWidget.addVerifyKeyListener(verifyKeyListener);
return true;
}
}
return false;
}
示例5: removeVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
/**
* @see org.eclipse.jface.contentassist.IContentAssistSubjectControl#removeVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
*/
public void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener)
{
if (fContentAssistSubjectControl != null)
{
fContentAssistSubjectControl.removeVerifyKeyListener(verifyKeyListener);
}
else if (fViewer instanceof ITextViewerExtension)
{
ITextViewerExtension extension = (ITextViewerExtension) fViewer;
extension.removeVerifyKeyListener(verifyKeyListener);
}
else
{
StyledText textWidget = fViewer.getTextWidget();
if (Helper.okToUse(textWidget))
{
textWidget.removeVerifyKeyListener(verifyKeyListener);
}
}
}
示例6: initBaseVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
protected void initBaseVerifyKeyListener() {
VerifyKeyListener baseVerifyKeyListener = new VerifyKeyListener() {
@Override
public void verifyKey(VerifyEvent e) {
lastKeyCode = e.keyCode;
if (currentLineObject == null) {
return;
// updateLineObject();
}
// reinterpret enter as arrow down
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
if (CanvasKeys.isShiftKeyDown(e.stateMask)) { // shift and enter -> mark as paragraph!
toggleParagraphOnSelectedLine();
}
e.keyCode = SWT.ARROW_DOWN;
e.doit = false;
if (CanvasKeys.isCtrlKeyDown(e)) { // if ctrl-enter pressed: focus element, i.e. send mouse double click signal
if (ATranscriptionWidget.this instanceof WordTranscriptionWidget)
sendFocusInSignal(currentWordObject);
else
sendFocusInSignal(currentLineObject);
}
else { // if just enter pressed then jump one line down:
if (!autocomplete.getAdapter().isProposalPopupOpen()) {
sendTextKeyDownEvent(SWT.ARROW_DOWN);
}
}
return;
}
}
};
addUserVerifyKeyListener(baseVerifyKeyListener);
}
示例7: setExecuting
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
public void setExecuting(boolean is, ITextEditor editor, VerifyKeyListener vkf) {
boolean wasExecuting = isExecuting();
// keep track of nested macro executions
if (is) {
++executeCount;
} else {
--executeCount;
}
if (!wasExecuting && is) {
whileExecuting = vkf;
setViewer(findSourceViewer(editor));
if (viewer != null) {
setRedraw(viewer,false);
if (whileExecuting != null
&& viewer instanceof ITextViewerExtension) {
((ITextViewerExtension) viewer)
.prependVerifyKeyListener(whileExecuting);
}
}
setEditor(editor);
} else if (!isExecuting() && viewer != null) {
setRedraw(viewer,true);
if (whileExecuting != null && viewer instanceof ITextViewerExtension){
((ITextViewerExtension) viewer).removeVerifyKeyListener(whileExecuting);
whileExecuting = null;
}
setEditor(null);
}
}
示例8: prependKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
private void prependKeyListener(ITextEditor editor, VerifyKeyListener key) {
if (key != null && editor != null) {
if (viewer == findSourceViewer(editor)) {
((ITextViewerExtension) viewer).prependVerifyKeyListener(key);
}
}
}
示例9: createVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
/**
* Creates a handler that will properly treat backspaces considering python code.
*/
public static VerifyKeyListener createVerifyKeyListener(final TextViewer viewer,
final IIndentationStringProvider indentationStringProvider) {
return new VerifyKeyListener() {
@Override
public void verifyKey(VerifyEvent event) {
if ((event.doit && event.character == SWT.BS && event.stateMask == 0 && viewer != null && viewer
.isEditable())) { //isBackspace
boolean blockSelection = false;
try {
blockSelection = viewer.getTextWidget().getBlockSelection();
} catch (Throwable e) {
//that's OK (only available in eclipse 3.5)
}
if (!blockSelection) {
ISelection selection = viewer.getSelection();
if (selection instanceof ITextSelection) {
//Only do our custom backspace if we're not in block selection mode.
AutoEditStrategyBackspaceHelper pyBackspace = new AutoEditStrategyBackspaceHelper();
pyBackspace.setIndentationStringProvider(indentationStringProvider);
TextSelectionUtils ps = new TextSelectionUtils(viewer.getDocument(),
(ITextSelection) selection);
pyBackspace.perform(ps);
event.doit = false;
}
}
}
}
};
}
示例10: addUserVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
public void addUserVerifyKeyListener(VerifyKeyListener l) {
verifyKeyListener.add(l);
text.addVerifyKeyListener(l);
}
示例11: initVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
@Override
protected void initVerifyKeyListener() {
VerifyKeyListener verifyKeyListener = new VerifyKeyListener() {
@Override
public void verifyKey(VerifyEvent e) {
boolean isAlt = CanvasKeys.isAltKeyDown(e);
boolean isCtrl = CanvasKeys.isCtrlKeyDown(e);
boolean isCmd = CanvasKeys.isCommandKeyDown(e);
// test hooks:
if (false) {
if (isCtrl && isAlt && e.keyCode == 'p') {
callCattiMethod(CattiMethod.SET_PREFIX, 0, 0, null);
}
if (isCtrl && isAlt && e.keyCode == 'u') {
callCattiMethod(CattiMethod.REJECT_SUFFIX, 0, 0, null);
}
}
// on ctlr-arrowdown, call reject suffix method
if (isCattiMode()) {
if (isCtrl && e.keyCode == SWT.ARROW_DOWN) {
callCattiMethod(CattiMethod.REJECT_SUFFIX, 0, 0, null);
} else if (isCmd && e.keyCode =='n') {
callCattiMethod(CattiMethod.REJECT_SUFFIX, 0, 0, null);
}
}
//TODO:FIXME take out!
logger.debug("verifyKey() "+e.keyCode + ": "+e.character + " - "+ e.text);
// VERY OLD SHIT:
// boolean isSingleSelect = (e.start == e.end);
//
// // prevent backspace on start of line
// int xIndex = getCurrentXIndex();
// if (e.keyCode == SWT.BS && xIndex == 0 && isSingleSelect) {
// logger.debug("preventing bs");
// e.doit = false;
// return;
// }
//
// // prevent del on end of line
// int lineLength = text.getLine(text.getLineAtOffset(text.getCaretOffset())).length();
// if (e.keyCode == SWT.DEL && xIndex == lineLength && isSingleSelect) {
// logger.debug("preventing del");
// e.doit = false;
// return;
// }
// else if (e.keyCode == TAG_CHAR) {
// }
}
};
addUserVerifyKeyListener(verifyKeyListener);
}
示例12: initVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
@Override
protected void initVerifyKeyListener() {
VerifyKeyListener verifyKeyListener = new VerifyKeyListener() {
@Override
public void verifyKey(VerifyEvent e) {
// if (currentWordObject == null) {
// updateWordObject();
// }
Pair<Integer, Integer> wi = getCurrentWordIndex();
logger.debug("key/code = "+e.character+"/"+e.keyCode+", wi/wii = "+wi.getKey()+" / "+wi.getValue()+ ", currentLineIndex = "+getCurrentLineIndex());
if (wi.getLeft() == -1) { // // word was not found; should not happen but you know - bad things happen!
logger.warn("word index not found (index = -1) - should not happen here -> won't do it!");
e.doit = false;
return;
}
if (currentLineObject==null || currentWordObject==null) {
logger.warn("line object or word object null - should not happen here -> won't do it!");
e.doit = false;
return;
}
// Jump to next word on tab or ctrl+arrow_right and to previous word on ctrl+arrow_left
if ( (e.keyCode == SWT.TAB || (e.keyCode==SWT.ARROW_LEFT && CanvasKeys.isCtrlKeyDown(e)) || (e.keyCode==SWT.ARROW_RIGHT && CanvasKeys.isCtrlKeyDown(e)) )
&& currentLineObject!=null && currentWordObject != null) {
boolean prev = e.keyCode == SWT.ARROW_LEFT;
TrpWordType nextWord = currentWordObject.getNeighborWord(prev, true, false);
if (nextWord != currentWordObject) {
updateData(nextWord.getLine().getRegion(), nextWord.getLine(), nextWord);
sendSelectionChangedSignal();
e.doit = false;
return;
}
}
}
};
addUserVerifyKeyListener(verifyKeyListener);
}
示例13: createVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
/**
* Creates a handler that will properly treat peers.
*/
public static VerifyKeyListener createVerifyKeyListener(final TextViewer viewer,
final IScopeCreatingCharsProvider provider) {
return new VerifyKeyListener() {
private final AutoEditStrategyScopeCreationHelper scopeHelper = new AutoEditStrategyScopeCreationHelper();
@Override
public void verifyKey(VerifyEvent event) {
if (!event.doit || event.character == '\0') {
return;
}
if (viewer != null && viewer.isEditable()) {
boolean blockSelection = false;
try {
blockSelection = viewer.getTextWidget().getBlockSelection();
} catch (Throwable e) {
//that's OK (only available in eclipse 3.5)
}
if (!blockSelection) {
ISelection selection = viewer.getSelection();
if (selection instanceof ITextSelection) {
//Don't bother in getting the indent prefs from the editor: the default indent prefs are
//always global for the settings we want.
TextSelectionUtils ps = new TextSelectionUtils(viewer.getDocument(),
(ITextSelection) selection);
int absoluteCursorOffset = ps.getAbsoluteCursorOffset();
String contentType = AutoEditStrategyHelper.getContentType(ps.getDoc(),
absoluteCursorOffset, false);
int closeScope = provider.getCharactersThatCreateScope(contentType, event.character);
switch (closeScope) {
case IScopeCreatingCharsProvider.CLOSE_SCOPE:
break; //keep on going in this function
case IScopeCreatingCharsProvider.CLOSE_SCOPE_NO:
return;
case IScopeCreatingCharsProvider.CLOSE_SCOPE_IF_SELECTION:
if (ps.getSelLength() == 0) {
return;
}
break;
}
if (scopeHelper.perform(ps, event.character, viewer, provider)) {
event.doit = false;
}
}
}
}
}
};
}
示例14: createVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
/**
* Creates a handler that will properly treat backspaces considering python code.
*/
public static VerifyKeyListener createVerifyKeyListener(final TextViewer viewer) {
return new VerifyKeyListener() {
private final PyPeerLinker pyPeerLinker = new PyPeerLinker();
@Override
public void verifyKey(VerifyEvent event) {
if (!event.doit) {
return;
}
switch (event.character) {
case '\'':
case '\"':
case '[':
case '{':
case '(':
case ']':
case '}':
case ')':
break;
default:
return;
}
if (viewer != null && viewer.isEditable()) {
boolean blockSelection = false;
try {
blockSelection = viewer.getTextWidget().getBlockSelection();
} catch (Throwable e) {
//that's OK (only available in eclipse 3.5)
}
if (!blockSelection) {
if (viewer instanceof ITextViewerExtensionAutoEditions) {
ITextViewerExtensionAutoEditions autoEditions = (ITextViewerExtensionAutoEditions) viewer;
if (!autoEditions.getAutoEditionsEnabled()) {
return;
}
}
ISelection selection = viewer.getSelection();
if (selection instanceof ITextSelection) {
IAdaptable adaptable;
if (viewer instanceof IAdaptable) {
adaptable = (IAdaptable) viewer;
} else {
adaptable = new IAdaptable() {
@Override
public <T> T getAdapter(Class<T> adapter) {
return null;
}
};
}
//Don't bother in getting the indent prefs from the editor: the default indent prefs are
//always global for the settings we want.
pyPeerLinker.setIndentPrefs(new DefaultIndentPrefs(adaptable));
PySelection ps = new PySelection(viewer.getDocument(), (ITextSelection) selection);
if (pyPeerLinker.perform(ps, event.character, viewer)) {
event.doit = false;
}
}
}
}
}
};
}
示例15: createVerifyKeyListener
import org.eclipse.swt.custom.VerifyKeyListener; //导入依赖的package包/类
/**
* Creates a handler that will properly treat home considering python code (if it's still not defined
* by the platform -- otherwise, just go with what the platform provides).
*/
public static VerifyKeyListener createVerifyKeyListener(final SourceViewer viewer, final IWorkbenchPartSite site,
boolean forceCreation) {
// This only needs to be done for eclipse 3.2 (where line start is not
// defined).
// Eclipse 3.3 onwards already defines the home key in the text editor.
final boolean isDefined;
if (site != null) {
ICommandService commandService = (ICommandService) site.getService(ICommandService.class);
Collection definedCommandIds = commandService.getDefinedCommandIds();
isDefined = definedCommandIds.contains("org.eclipse.ui.edit.text.goto.lineStart");
} else {
isDefined = false;
}
if (forceCreation || !isDefined) {
return new VerifyKeyListener() {
@Override
public void verifyKey(VerifyEvent event) {
if (event.doit) {
boolean isHome;
if (isDefined) {
isHome = KeyBindingHelper.matchesKeybinding(event.keyCode, event.stateMask,
"org.eclipse.ui.edit.text.goto.lineStart");
} else {
isHome = event.keyCode == SWT.HOME && event.stateMask == 0;
}
if (isHome) {
ISelection selection = viewer.getSelection();
if (selection instanceof ITextSelection) {
FirstCharAction firstCharAction = new FirstCharAction();
firstCharAction.viewer = viewer;
firstCharAction.perform(viewer.getDocument(), (ITextSelection) selection);
event.doit = false;
}
}
}
}
};
}
return null;
}