Changeset 248 for trunk/hiptop/pester


Ignore:
Timestamp:
07/09/06 21:28:43 (18 years ago)
Author:
Nicholas Riley
Message:

Better way of retrieving selected unit (thanks, Jean-Sebastien Payette)

Location:
trunk/hiptop/pester
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/hiptop/pester/locale/en_US/Pester.rsrc

    r247 r248  
    6868menu ID_PERIOD_UNITS_MENU
    6969        menuItem
    70                 id = ID_PERIOD_SECONDS
    7170                title = "second(s)"
    7271                event = EVENT_PERIOD_UNIT
    7372                eventData = 1
    7473        menuItem
    75                 id = ID_PERIOD_MINUTES
    7674                title = "minute(s)"
    7775                event = EVENT_PERIOD_UNIT
    7876                eventData = 60
    7977        menuItem
    80                 id = ID_PERIOD_HOURS
    8178                title = "hour(s)"
    8279                event = EVENT_PERIOD_UNIT
  • trunk/hiptop/pester/net/sabi/pester/AlarmListView.java

    r246 r248  
    1313import danger.ui.DatePicker;
    1414import danger.ui.DialogWindow;
    15 import danger.ui.Menu;
    1615import danger.ui.MenuItem;
    1716import danger.ui.NumberEditor;
     
    3736    private RadioButton sInButton, sAtButton;
    3837    private NumberEditor sPeriodField;
    39     private Menu sPeriodUnitsMenu;
    4038    private PopupMenu sPeriodUnitsPopup;
    4139    // XXX don't allow <5 second repeating alarms
     
    6361        sAtButton = (RadioButton)sEditWindow.getDescendantWithID(ID_AT_BUTTON);
    6462        sPeriodField = (NumberEditor)sEditWindow.getDescendantWithID(ID_PERIOD_FIELD);
    65         sPeriodUnitsMenu = (Menu)sEditWindow.getDescendantWithID(ID_PERIOD_UNITS_MENU);
    6663        sPeriodUnitsPopup = (PopupMenu)sEditWindow.getDescendantWithID(ID_PERIOD_UNITS_POPUP);
    6764        sRepeatCheckBox = (CheckBox)sEditWindow.getDescendantWithID(ID_PERIOD_REPEAT_CHECKBOX);
     
    9794            int period = alarm.getPeriod();
    9895            for (int i = sPeriodUnitsPopup.itemCount() - 1 ; i >= 0 ; --i) {
    99                 MenuItem item = sPeriodUnitsPopup.getItem(i);
    100                 int unitsPerSec = item.getEvent().data;
     96                int unitsPerSec = sPeriodUnitsPopup.getItem(i).getEvent().data;
    10197                if (period % unitsPerSec == 0) {
    102                     sPeriodUnitsPopup.setValueWithItemID(sPeriodUnitsMenu.getIDOfItem(item));
     98                    sPeriodUnitsPopup.setValue(i);
    10399                    sPeriodField.setValue(period / unitsPerSec);
    104100                    break;
     
    139135    }
    140136
     137    // XXX make this into a more general validation method;
     138    // XXX check before dismissing dialog that alarm is valid
     139    // XXX and display alarm date
    141140    protected void constrainDate() {
    142141        // XXX schedule every minute (second?) if in AT mode
     
    157156            sEditingAlarm.setMessage(sMessageField.toString());
    158157            if (sInButton.getValue() == 1) {
    159                 int itemID = sPeriodUnitsPopup.getValueAsItemID();
    160                 MenuItem itemWithID = sPeriodUnitsMenu.getItemWithID(itemID);
    161                 Event event = itemWithID.getEvent();
     158                int itemIndex = sPeriodUnitsPopup.getValue();
     159                MenuItem itemAtIndex = sPeriodUnitsPopup.getItem(itemIndex);
     160                Event event = itemAtIndex.getEvent();
    162161                sEditingAlarm.setPeriod(sPeriodField.getValue() * event.data,
    163162                                        sRepeatCheckBox.getValue() == 1);
Note: See TracChangeset for help on using the changeset viewer.