summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-06-25 23:41:54 +0000
committerPaul Buetow <paul@buetow.org>2008-06-25 23:41:54 +0000
commit18729d5c4b1b8282e293466cf2a802337ba7e397 (patch)
tree5b9aaf192ed16afae458660b7ff23ddf98b9a040 /sources
parent64d02bcf7fed715b9fee74d3a635791beb8131d1 (diff)
bugfix
Diffstat (limited to 'sources')
-rw-r--r--sources/exceptions/VSNegativeNumberException.java33
-rw-r--r--sources/simulator/VSSimulator.java9
2 files changed, 41 insertions, 1 deletions
diff --git a/sources/exceptions/VSNegativeNumberException.java b/sources/exceptions/VSNegativeNumberException.java
new file mode 100644
index 0000000..ea6073c
--- /dev/null
+++ b/sources/exceptions/VSNegativeNumberException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * All icons of the icons/ folder are under a Creative Commons
+ * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa.
+ *
+ * The icon's homepage is http://code.google.com/p/ultimate-gnome/
+ */
+
+package exceptions;
+
+/**
+ * The Interface VSNegativeNumberException, this exception is thrown if
+ * a negative number has returned if a positive number has been expected.
+ *
+ * @author Paul C. Buetow
+ */
+public class VSNegativeNumberException extends Exception {
+}
diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java
index 9b0ef2a..ae3c2db 100644
--- a/sources/simulator/VSSimulator.java
+++ b/sources/simulator/VSSimulator.java
@@ -34,6 +34,7 @@ import javax.swing.table.*;
import core.*;
import events.*;
import events.internal.*;
+import exceptions.*;
import prefs.*;
import prefs.editors.*;
import serialize.*;
@@ -515,6 +516,8 @@ public class VSSimulator extends JPanel implements VSSerializable {
public void actionPerformed(ActionEvent ae) {
try {
Long val = Long.valueOf(valField.getText());
+ if (val.longValue() < 0)
+ throw new VSNegativeNumberException();
VSTask task = model.removeTaskAtRow(row);
task.setTaskTime(val.longValue());
taskManager.addTask(task, VSTaskManager.PROGRAMMED);
@@ -532,7 +535,11 @@ public class VSSimulator extends JPanel implements VSSerializable {
} catch (NumberFormatException exc) {
valField.setBackground(Color.RED);
isRed = true;
- }
+
+ } catch (VSNegativeNumberException exc) {
+ valField.setBackground(Color.RED);
+ isRed = true;
+ }
}
});
return valField;