本文整理匯總了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;
}
}
}
});
}