6cdfee554149fb03ad79dd8cce5fc7675fdef13e
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / wizards / html / NumVerifyListener.java
1 /*
2  * $Id: NumVerifyListener.java,v 1.3 2006-10-21 23:18:43 pombredanne Exp $
3  * Copyright Narushima Hironori. All rights reserved.
4  */
5 package net.sourceforge.phpeclipse.wizards.html;
6
7 import java.util.regex.Pattern;
8
9 import org.eclipse.swt.SWT;
10 import org.eclipse.swt.events.VerifyEvent;
11 import org.eclipse.swt.events.VerifyListener;
12
13 public class NumVerifyListener implements VerifyListener {
14
15         Pattern numPattern = Pattern.compile("^\\d+$");
16
17         public void verifyText(VerifyEvent ev) {
18                 ev.doit = numPattern.matcher(ev.text).matches()
19                                 || ev.keyCode == SWT.DEL || ev.character == SWT.BS;
20         }
21 }