本文整理汇总了Java中org.eclipse.swt.events.VerifyEvent类的典型用法代码示例。如果您正苦于以下问题:Java VerifyEvent类的具体用法?Java VerifyEvent怎么用?Java VerifyEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VerifyEvent类属于org.eclipse.swt.events包,在下文中一共展示了VerifyEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExit
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* If the entered character is not a valid identifier part, it is processed after linked editing has been quit.
* Exceptions are the {@link #exitCharacters} that have been passed into the constructor.
*/
@Override
public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {
if (event.character == '\0')
return null;
for (char c : exitCharacters) {
if (event.character == c) {
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
}
}
switch (event.character) {
case SWT.CR:
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
default: {
if (!Character.isJavaIdentifierPart(event.character)) {
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
}
return null;
}
}
}
示例2: attachKeyValidator
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
private void attachKeyValidator(final Text text) {
text.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
txtDecorator.hide();
String currentText = ((Text) e.widget).getText();
String newName = (currentText.substring(0, e.start) + e.text + currentText.substring(e.end));
Matcher matchName = Pattern.compile("[\\@]{1}[\\{]{1}[\\w]*[\\}]{1}||[\\w]*").matcher(newName);
if(!matchName.matches()){
text.setToolTipText(Messages.CHARACTERSET);
txtDecorator=WidgetUtility.addDecorator(text,Messages.CHARACTERSET);
txtDecorator.setDescriptionText(Messages.CHARACTERSET);
txtDecorator.show();
e.doit=false;
}
else
{
text.setToolTipText("");
text.setMessage("");
txtDecorator.hide();
}
}
});
}
示例3: initializeViewer
import org.eclipse.swt.events.VerifyEvent; //导入依赖的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);
}
示例4: addVerifyListnerToOutputEditingSupport
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
public static void addVerifyListnerToOutputEditingSupport(JoinMappingEditingSupport outputEditingSupport) {
((Text)outputEditingSupport.getEditor().getControl()).addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
String text=e.text;
Matcher matcher=Pattern.compile(Constants.REGEX).matcher(text);
if(matcher.matches()){
e.doit=true;
}else{
e.doit=false;
}
}
});
}
示例5: createJumpPageTextBox
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
private void createJumpPageTextBox(Composite composite_3) {
Text jumpPageTextBox = new Text(composite_3, SWT.BORDER);
jumpPageTextBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
jumpPageTextBox.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
String currentText = ((Text) e.widget).getText();
String pageNumberText = currentText.substring(0, e.start) + e.text + currentText.substring(e.end);
try {
long pageNumber = Long.valueOf(pageNumberText);
if (pageNumber < 1) {
e.doit = false;
}
} catch (NumberFormatException ex) {
if (!pageNumberText.equals(""))
e.doit = false;
}
}
});
dataViewerListeners.attachJumpPageListener(jumpPageTextBox);
windowControls.put(ControlConstants.JUMP_TEXT, jumpPageTextBox);
}
示例6: validateForSingleAndDuplicateCharacter
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
private void validateForSingleAndDuplicateCharacter(VerifyEvent e, String textBoxValue,
ControlDecoration singleCharactorDecorator, ControlDecoration duplicateDecorator, ControlDecoration emptyDecorator) {
singleCharactorDecorator.hide();
duplicateDecorator.hide();
emptyDecorator.hide();
String value = ((Text) e.widget).getText();
String currentValue = (value.substring(0, e.start) + e.text + value.substring(e.end));
if (StringUtils.isNotEmpty(currentValue)) {
validateDelimiterAndQuoteCharactorProperty(currentValue, textBoxValue, singleCharactorDecorator,
duplicateDecorator);
} else {
getButton(0).setEnabled(false);
emptyDecorator.show();
warningLabel.setText(Messages.WARNING_MESSAGE);
warningLabel.setVisible(true);
warningImageLabel.setVisible(true);
}
}
示例7: refreshThePaletteBasedOnSearchString
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
private void refreshThePaletteBasedOnSearchString(final PaletteRoot paletteRoot,
final ELTGraphicalEditor editor, final Map<String, PaletteDrawer> categoryPaletteContainer,
final Text text, final List<Component> componentsConfig, final Composite container) {
text.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
boolean matchFound = false;
final List<Component> matchingComponents = new ArrayList<>();
paletteRoot.getChildren().clear();
String currentText = ((Text) e.widget).getText();
createPaletteContainers(paletteRoot, categoryPaletteContainer, editor);
String searchedString = (currentText.substring(0, e.start) + e.text + currentText.substring(e.end))
.toUpperCase();
if (StringUtils.isEmpty(searchedString)) {
showAllContainers(paletteRoot, editor, categoryPaletteContainer, componentsConfig);
} else {
showOpenPaletteContainers(paletteRoot.getChildren());
matchFound = checkSearchedComponentFoundInPalette(editor, categoryPaletteContainer, componentsConfig,
matchingComponents, searchedString);
showMessageWhenComponentNotFound(container, matchFound);
showMatchingContainers(paletteRoot, categoryPaletteContainer, matchingComponents);
}
}
});
}
示例8: UndoRedoManager
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
/**
* Constructor. Creates data structures and adds listener to note modifications.
*
* @param note
*/
public UndoRedoManager(final Note note) {
undoDeque = new ArrayDeque<>();
redoDeque = new ArrayDeque<>();
this.note = note;
// Listen to text modifications.
note.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent event) {
// Last modification was due to an undo/redo action: do not record it.
if (lastActionUndoOrRedo) {
lastActionUndoOrRedo = false;
return;
}
recordNoteModification(event, note.getStyleRanges());
}
});
}
示例9: recordNoteModification
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
/**
* Records history for undo/redo functions.
*
* @param event
* @param styles
*/
public void recordNoteModification(VerifyEvent event, StyleRange[] styles) {
// Previous action cannot be an undo: empty redo deque and remove stylesBeforeUndo.
redoDeque.clear();
stylesBeforeUndo = null;
// Construct modification record depending on whether the function was called by a style or a text
// modification and push it on the deque.
if (event != null) {
undoDeque.push(new ModificationRecord(styles, event.start, event.text.length(),
note.getText().substring(event.start, event.end), event.text));
} else {
undoDeque.push(new ModificationRecord(styles, 0, 0, null, null));
}
// Limit maximum size of deque by clearing oldest records.
if (undoDeque.size() > MAX_DEQUE_SIZES) {
undoDeque.pollLast();
}
}
示例10: createPackageField
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
private void createPackageField(Composite parent) {
Label packageNameLabel = new Label(parent, SWT.LEAD);
packageNameLabel.setText(Messages.getString("java.package")); //$NON-NLS-1$
javaPackageField = new Text(parent, SWT.BORDER);
javaPackageField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
revalidate();
}
});
javaPackageField.addVerifyListener(new VerifyListener() {
@Override
public void verifyText(VerifyEvent event) {
// if the user ever changes the package name field, then we never auto-generate again.
if (!javaPackageProgrammaticUpdate) {
autoGeneratePackageName = false;
}
}
});
}
示例11: doExit
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
if (fSize == fStack.size() && !isMasked(offset)) {
if (event.character == fExitCharacter) {
BracketLevel level= (BracketLevel) fStack.peek();
if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
return null;
if (level.fSecondPosition.offset == offset && length == 0)
// don't enter the character if if its the closing peer
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
}
// when entering an anonymous class between the parenthesis', we don't want
// to jump after the closing parenthesis when return is pressed
if (event.character == SWT.CR && offset > 0) {
IDocument document= sourceViewer.getDocument();
try {
if (document.getChar(offset - 1) == '{')
return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
} catch (BadLocationException e) {
}
}
}
return null;
}
示例12: preventDelAndBackspace
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
private void preventDelAndBackspace(VerifyEvent e) {
// one char max between start and end
boolean isSingleSelect = (e.end - e.start < 2); // (e.start == e.end);
// prevent backspace on start of line
int xIndex = getCurrentXIndex();
if (lastKeyCode == SWT.BS && xIndex == 0 && isSingleSelect && e.text.equals("")) {
logger.debug("preventing bs");
e.doit = false;
return;
}
// prevent del on end of line
int lineLength = text.getLine(text.getLineAtOffset(text.getCaretOffset())).length();
if (lastKeyCode == SWT.DEL && xIndex == lineLength && isSingleSelect && e.text.equals("")) {
logger.debug("preventing del");
e.doit = false;
return;
}
}
示例13: doExit
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
@Override
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
LinkedPosition position= model.findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP));
if (position != null) {
if (event.character == SWT.BS) {
if (offset - 1 < position.getOffset()) {
//skip backspace at beginning of linked position
event.doit= false;
}
} else /* event.character == SWT.DEL */ {
if (offset + 1 > position.getOffset() + position.getLength()) {
//skip delete at end of linked position
event.doit= false;
}
}
}
}
return null; // don't change behavior
}
示例14: handleVerifyKeyPressed
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
private void handleVerifyKeyPressed(VerifyEvent event) {
if (!event.doit)
return;
if (event.stateMask != SWT.MOD1)
return;
switch (event.character) {
case ' ':
fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
event.doit = false;
break;
// CTRL-Z
case 'z' - 'a' + 1:
fPatternEditor.doOperation(ITextOperationTarget.UNDO);
event.doit = false;
break;
}
}
示例15: doExit
import org.eclipse.swt.events.VerifyEvent; //导入依赖的package包/类
public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
if (fSize == fStack.size() && !isMasked(offset)) {
if (event.character == fExitCharacter) {
BracketLevel level = (BracketLevel) fStack.peek();
if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
return null;
if (level.fSecondPosition.offset == offset && length == 0)
// don't enter the character if if its the closing peer
return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
}
// when entering an anonymous class between the parenthesis', we
// don't want
// to jump after the closing parenthesis when return is pressed
if (event.character == SWT.CR && offset > 0) {
IDocument document = getSourceViewer().getDocument();
try {
if (document.getChar(offset - 1) == '{')
return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
} catch (BadLocationException e) {
}
}
}
return null;
}