Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/preferences/ValidIntListener.java

Issue 717423003: add new analysis server preferences to experimental page (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/preferences/ValidIntListener.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/preferences/ValidIntListener.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/preferences/ValidIntListener.java
new file mode 100644
index 0000000000000000000000000000000000000000..913a2ce1289b398fbbacdcafc7b6a520e32fdef5
--- /dev/null
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/preferences/ValidIntListener.java
@@ -0,0 +1,30 @@
+package com.google.dart.tools.ui.internal.preferences;
+
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+/**
+ * Listener that only allows digits to be entered into a text field
+ */
+class ValidIntListener implements Listener {
+ @Override
+ public void handleEvent(Event e) {
+ String txt = e.text;
+ // Allow for delete
+ if (txt.isEmpty()) {
+ return;
+ }
+ try {
+ // Only allow digits
+ int num = Integer.parseInt(txt);
+ if (num >= 0) {
+ return;
+ }
+ } catch (NumberFormatException nfe) {
+ // Error
+ }
+
+ e.doit = false;
+ return;
+ }
+}
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/preferences/PreferencesMessages.properties ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698