Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/org.eclipse.papyrus.views.documentation.view/src/org/eclipse/papyrus/views/documentation/view/actions/NumberValidator.java')
-rw-r--r--deprecated/org.eclipse.papyrus.views.documentation.view/src/org/eclipse/papyrus/views/documentation/view/actions/NumberValidator.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.views.documentation.view/src/org/eclipse/papyrus/views/documentation/view/actions/NumberValidator.java b/deprecated/org.eclipse.papyrus.views.documentation.view/src/org/eclipse/papyrus/views/documentation/view/actions/NumberValidator.java
new file mode 100644
index 00000000000..fe2f46e989a
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.views.documentation.view/src/org/eclipse/papyrus/views/documentation/view/actions/NumberValidator.java
@@ -0,0 +1,40 @@
+//------------------------------------------------------------------------------
+// Copyright (c) 2009 Anyware Technologies and others
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// which accompanies this distribution, and is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// Contributors:
+// Anyware Technologies - initial API and implementation
+//------------------------------------------------------------------------------
+package org.eclipse.papyrus.views.documentation.view.actions;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+
+/**
+ * Validates whether the text found in the input field of the
+ * dialog forms a positive number.
+ */
+class NumberValidator implements IInputValidator {
+
+ /*
+ * @see IInputValidator#isValid(String)
+ */
+ public String isValid(String input) {
+
+ if (input == null || input.length() == 0)
+ return " "; //$NON-NLS-1$
+
+ try {
+ int i= Integer.parseInt(input);
+ if (i < 0)
+ return "Invalid number";
+
+ } catch (NumberFormatException x) {
+ return "Not a number";
+ }
+
+ return null;
+ }
+} \ No newline at end of file

Back to the top