本文整理汇总了Java中org.eclipse.swt.events.VerifyListener类的典型用法代码示例。如果您正苦于以下问题:Java VerifyListener类的具体用法?Java VerifyListener怎么用?Java VerifyListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VerifyListener类属于org.eclipse.swt.events包,在下文中一共展示了VerifyListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachKeyValidator
import org.eclipse.swt.events.VerifyListener; //导入依赖的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();
}
}
});
}
示例2: addVerifyListnerToOutputEditingSupport
import org.eclipse.swt.events.VerifyListener; //导入依赖的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;
}
}
});
}
示例3: createJumpPageTextBox
import org.eclipse.swt.events.VerifyListener; //导入依赖的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);
}
示例4: refreshThePaletteBasedOnSearchString
import org.eclipse.swt.events.VerifyListener; //导入依赖的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);
}
}
});
}
示例5: UndoRedoManager
import org.eclipse.swt.events.VerifyListener; //导入依赖的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());
}
});
}
示例6: createPackageField
import org.eclipse.swt.events.VerifyListener; //导入依赖的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;
}
}
});
}
示例7: verifyListenerInteger
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
public static VerifyListener verifyListenerInteger(final boolean canBeNegative) {
return new VerifyListener() {
@Override
public void verifyText(final VerifyEvent e) {
// check backspace and del key
if (e.character == SWT.BS || e.character == SWT.DEL) {
return;
}
// check '-' key
if (canBeNegative && e.character == '-') {
return;
}
try {
Integer.parseInt(e.text);
} catch (final NumberFormatException ex) {
e.doit = false;
}
}
};
}
示例8: verifyFilenameInput
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
public static VerifyListener verifyFilenameInput() {
return new VerifyListener() {
@Override
public void verifyText(final VerifyEvent e) {
// check invalid chars
for (final char invalidChar : INVALID_FILENAME_CHARS) {
if (invalidChar == e.character) {
e.doit = false;
return;
}
}
}
};
}
示例9: verifyFilePathInput
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
public static VerifyListener verifyFilePathInput() {
return new VerifyListener() {
@Override
public void verifyText(final VerifyEvent e) {
// check invalid chars
for (final char invalidChar : INVALID_FILEPATH_CHARS) {
if (invalidChar == e.character) {
e.doit = false;
return;
}
}
}
};
}
示例10: verifyListenerTypeLong
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
public static VerifyListener verifyListenerTypeLong() {
return new VerifyListener() {
@Override
public void verifyText(final VerifyEvent e) {
if (e.text.equals(EMPTY_STRING)) {
return;
}
try {
Long.parseLong(e.text);
} catch (final NumberFormatException e1) {
e.doit = false;
}
}
};
}
示例11: verifyListenerInteger
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
public static VerifyListener verifyListenerInteger(final boolean canBeNegative) {
return new VerifyListener() {
public void verifyText(final VerifyEvent e) {
// check backspace and del key
if (e.character == SWT.BS || e.character == SWT.DEL) {
return;
}
// check '-' key
if (canBeNegative && e.character == '-') {
return;
}
try {
Integer.parseInt(e.text);
} catch (final NumberFormatException ex) {
e.doit = false;
}
}
};
}
示例12: main
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
public static void main(String [] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout ());
final Text text0 = new Text (shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
final Text text1 = new Text (shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
text0.addVerifyListener (new VerifyListener () {
@Override
public void verifyText (VerifyEvent event) {
text1.setTopIndex (text0.getTopIndex ());
text1.setSelection (event.start, event.end);
text1.insert (event.text);
}
});
shell.setBounds(10, 10, 200, 200);
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
示例13: initVerifyListener
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
@Override
protected void initVerifyListener() {
VerifyListener verifyListener = new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
//TODO:FIXME take out!
logger.debug("verifyText() "+e.keyCode + ": "+e.character + " - "+ e.text);
// prevent del and backspace on begin and end of line:
preventDelAndBackspace(e);
if (e.doit == false)
return;
// logger.debug("range changed = "+e.start+" / "+e.end+ " e = "+e.toString());
// TEST: print ranges and text of affected lines of replacement:
// List<Pair<TrpTextLineType, IntRange>> rrs = getReplaceRanges(e);
// logger.debug("replace ranges for e = "+e);
// for (Pair<TrpTextLineType, IntRange> pr : rrs) {
// TrpTextLineType line = pr.getLeft();
// IntRange range = pr.getRight();
// String text = line.getUnicodeText().substring(range.offset, range.offset+range.length);
// logger.debug("range: "+range+" text: "+text);
// }
// preventChangeOverMultipleLines(e);
// if (e.doit == false)
// return;
checkAndReinterpretMultilineInsertions(e);
if (e.doit == false)
return;
lastReplacements = getReplaceRanges(e.start, e.end);
}
};
addUserVerifyListener(verifyListener);
}
示例14: initVerifyListener
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
@Override
protected void initVerifyListener() {
VerifyListener verifyListener = new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
if (currentWordObject == null) {
e.doit = false;
return;
}
// prevent changes over multiple lines:
preventChangeOverMultipleLines(e);
if (e.doit == false)
return;
preventInsertionOfMultipleLines(e);
if (e.doit == false)
return;
preventSomeStuff(e);
if (e.doit == false)
return;
preventAndReinterpretDeletionOfWholeWord(e);
if (e.doit == false)
return;
detectEditOfEmptyWord(e);
if (e.doit == false)
return;
}
};
addUserVerifyListener(verifyListener);
}
示例15: LabeledText
import org.eclipse.swt.events.VerifyListener; //导入依赖的package包/类
public LabeledText(Composite parent, String labelText, boolean makeColumnsEqualWidth) {
super(parent, 0);
this.setLayout(SWTUtil.createGridLayout(2, makeColumnsEqualWidth, 0, 0));
label = new Label(this, 0);
label.setText(labelText);
text = new Text(this, SWT.BORDER | SWT.SINGLE);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
text.addVerifyListener( new VerifyListener() {
@Override
public void verifyText(VerifyEvent e) {
if (validateToInt) {
String oldS = text.getText();
String newS = oldS.substring(0, e.start) + e.text + oldS.substring(e.end);
try {
Integer.parseInt(newS);
e.doit = true;
} catch (Exception ex) {
e.doit = false;
}
}
}
});
}