Index: trunk/hiptop/pester/locale/en_US/Pester.rsrc
===================================================================
--- trunk/hiptop/pester/locale/en_US/Pester.rsrc	(revision 240)
+++ trunk/hiptop/pester/locale/en_US/Pester.rsrc	(revision 241)
@@ -67,12 +67,18 @@
 menu ID_PERIOD_UNITS_MENU
 	menuItem
+		id = ID_PERIOD_SECONDS
 		title = "second(s)"
-		id = 1
+		event = EVENT_PERIOD_UNIT
+		eventData = 1
 	menuItem
+		id = ID_PERIOD_MINUTES
 		title = "minute(s)"
-		id = 60
+		event = EVENT_PERIOD_UNIT
+		eventData = 60
 	menuItem
+		id = ID_PERIOD_HOURS
 		title = "hour(s)"
-		id = 3600
+		event = EVENT_PERIOD_UNIT
+		eventData = 3600
 endMenu
 
Index: trunk/hiptop/pester/net/sabi/pester/Alarm.java
===================================================================
--- trunk/hiptop/pester/net/sabi/pester/Alarm.java	(revision 240)
+++ trunk/hiptop/pester/net/sabi/pester/Alarm.java	(revision 241)
@@ -19,8 +19,8 @@
 
     // transient
-    private int mStatus;
+    private int mState;
 
     public Alarm() {
-	mStatus = STATUS_INVALID;
+	mState = STATE_INVALID;
     }
 
@@ -91,9 +91,9 @@
 
     void beginEditing() {
-	mStatus = STATUS_EDITING;
+	mState = STATE_EDITING;
     }
 
     void endEditing() {
-	mStatus = STATUS_SCHEDULED;
+	mState = STATE_SCHEDULED;
 	DEBUG.p("schedule alarm: " + mMessage);
 	switch (mType) {
@@ -115,7 +115,7 @@
     public static final int TYPE_DATE = 2;
 
-    public static final int STATUS_INVALID = 0;
-    public static final int STATUS_EDITING = 1;
-    public static final int STATUS_SCHEDULED = 2;
-    public static final int STATUS_EXPIRED = 3;
+    public static final int STATE_INVALID = 0;
+    public static final int STATE_EDITING = 1;
+    public static final int STATE_SCHEDULED = 2;
+    public static final int STATE_EXPIRED = 3;
 }
Index: trunk/hiptop/pester/net/sabi/pester/AlarmListView.java
===================================================================
--- trunk/hiptop/pester/net/sabi/pester/AlarmListView.java	(revision 240)
+++ trunk/hiptop/pester/net/sabi/pester/AlarmListView.java	(revision 241)
@@ -10,4 +10,6 @@
 import danger.ui.DatePicker;
 import danger.ui.DialogWindow;
+import danger.ui.Menu;
+import danger.ui.MenuItem;
 import danger.ui.NumberEditor;
 import danger.ui.PopupMenu;
@@ -31,4 +33,5 @@
     private RadioButton sInButton, sAtButton;
     private NumberEditor sPeriodField;
+    private Menu sPeriodUnitsMenu;
     private PopupMenu sPeriodUnitsPopup;
     private CheckBox sRepeatCheckBox;
@@ -54,4 +57,5 @@
 	sAtButton = (RadioButton)sEditWindow.getDescendantWithID(ID_AT_BUTTON);
 	sPeriodField = (NumberEditor)sEditWindow.getDescendantWithID(ID_PERIOD_FIELD);
+	sPeriodUnitsMenu = (Menu)sEditWindow.getDescendantWithID(ID_PERIOD_UNITS_MENU);
 	sPeriodUnitsPopup = (PopupMenu)sEditWindow.getDescendantWithID(ID_PERIOD_UNITS_POPUP);
 	sRepeatCheckBox = (CheckBox)sEditWindow.getDescendantWithID(ID_PERIOD_REPEAT_CHECKBOX);
@@ -81,14 +85,13 @@
 	if (usesPeriod) {
 	    int period = alarm.getPeriod();
-	    int unitsPerSec = 1;
-	    DEBUG.p("period is " + period);
 	    for (int i = sPeriodUnitsPopup.itemCount() - 1 ; i >= 0 ; --i) {
-		unitsPerSec =
-		    sPeriodUnitsPopup.getIDOfItem(sPeriodUnitsPopup.getItem(i));
-		DEBUG.p("unitsPerSec = " + unitsPerSec);
-		if (period % unitsPerSec == 0) break;
-	    }
-	    sPeriodField.setValue(period / unitsPerSec);
-	    sPeriodUnitsPopup.setValueWithItemID(unitsPerSec);
+		MenuItem item = sPeriodUnitsPopup.getItem(i);
+		int unitsPerSec = item.getEvent().data;
+		if (period % unitsPerSec == 0) {
+		    sPeriodUnitsPopup.setValueWithItemID(sPeriodUnitsMenu.getIDOfItem(item));
+		    sPeriodField.setValue(period / unitsPerSec);
+		    break;
+		}
+	    }
 	    sRepeatCheckBox.setValue(alarm.getRepeating() ? 1 : 0);
 	}
@@ -139,8 +142,8 @@
 	    sEditingAlarm.setMessage(sMessageField.toString());
 	    if (sInButton.getValue() == 1) {
-		DEBUG.p("period: " + sPeriodField.getValue());
-		DEBUG.p(" units: " + sPeriodUnitsPopup.getValueAsItemID());
-		sEditingAlarm.setPeriod(sPeriodField.getValue() * 
-					sPeriodUnitsPopup.getValueAsItemID(),
+		int itemID = sPeriodUnitsPopup.getValueAsItemID();
+		MenuItem itemWithID = sPeriodUnitsMenu.getItemWithID(itemID);
+		Event event = itemWithID.getEvent();
+		sEditingAlarm.setPeriod(sPeriodField.getValue() * event.data,
 					sRepeatCheckBox.getValue() == 1);
 	    } else {
@@ -150,10 +153,14 @@
 		sAlarmList.addItem(sEditingAlarm);
 		setFocusedItem(sEditingAlarm);
+		sFocusedAlarm = sEditingAlarm; // XXX do we need this?
 	    } else {
 		sEditingAlarm.update();
 	    }
 	case EVENT_CANCEL_ALARM:
-	    // XXX (re)schedule alarm
-	    sEditingAlarm.endEditing();
+	    if (sEditingAlarm == sFocusedAlarm) { // existing alarm
+		// XXX (re)schedule alarm
+		sEditingAlarm.endEditing();
+	    }
+	    sEditingAlarm = null;
 	    return true;
 	case EVENT_DISCARD_ALARM:
