Changeset 243 for trunk/hiptop/pester/net
- Timestamp:
- 07/09/06 03:16:34 (18 years ago)
- Location:
- trunk/hiptop/pester/net/sabi/pester
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hiptop/pester/net/sabi/pester/Alarm.java
r242 r243 7 7 import danger.app.Application; 8 8 import danger.internal.Date; 9 import danger.util.LocaleUtils; 9 10 import danger.util.StdActiveList; 10 11 import danger.util.StdActiveObject; 11 12 import danger.util.DEBUG; 13 import danger.util.format.DateFormat; 14 import danger.util.format.StringFormat; 12 15 13 16 public class Alarm extends StdActiveObject { … … 51 54 mType = repeating ? TYPE_PERIODIC_REPEATING : TYPE_PERIODIC; 52 55 mPeriod = period; 53 mDate = new Date();54 mDate.addSeconds(period);55 56 } 56 57 public void setDate(Date date) { … … 99 100 } 100 101 102 void resume() { 103 mState = STATE_SCHEDULED; 104 int period = mDate.getDangerTimeGMT() - new Date().getDangerTimeGMT(); 105 if (period < 0) period = 0; 106 mAlarm.resetWake(period); 107 DEBUG.p("resetWake: " + description() + " - " + period + "s left"); 108 update(); 109 } 110 111 void schedule() { 112 if (getUsesPeriod()) { 113 mDate = new Date(); 114 mDate.addSeconds(mPeriod); 115 } 116 resume(); 117 } 118 101 119 void dismiss() { 102 120 if (getRepeating()) … … 111 129 } 112 130 113 void schedule() { 114 mState = STATE_SCHEDULED; 115 DEBUG.p("schedule alarm: " + mMessage); 131 public String description() { 132 StringBuffer sb = new StringBuffer(); 133 switch (mState) { 134 case STATE_INVALID: sb.append("invalid "); break; 135 case STATE_EDITING: sb.append("editing "); break; 136 case STATE_SCHEDULED: sb.append("scheduled "); break; 137 } 116 138 switch (mType) { 117 139 case TYPE_PERIODIC: 118 DEBUG.p(" - periodic: " + mPeriod); break;140 sb.append("periodic (").append(mPeriod).append("s) "); break; 119 141 case TYPE_PERIODIC_REPEATING: 120 DEBUG.p(" - periodic repeating: " + mPeriod); break; 142 sb.append("repeating periodic (").append(mPeriod).append("s) "); 143 break; 121 144 case TYPE_DATE: 122 DEBUG.p(" - date: " + mDate); break;145 sb.append("date (").append(getDateTimeString()).append(") "); break; 123 146 } 124 mAlarm.resetWake(mPeriod); 147 sb.append("alarm: "); 148 sb.append('"').append(mMessage).append('"'); 149 return sb.toString(); 125 150 } 126 151 152 protected static String dateTimeString(Date date) { 153 if (date == null) 154 return null; 155 String layout = LocaleUtils.getDateTimePattern(); 156 String timeFormat = LocaleUtils.getMediumTimeFormat(); 157 String dateFormat = LocaleUtils.getShortDateFormat(); 158 return StringFormat.withFormat(layout, 159 DateFormat.withFormat(timeFormat, date), 160 DateFormat.withFormat(dateFormat, date)); 161 } 162 163 public String getDateTimeString() { 164 return dateTimeString(mDate); 165 } 166 127 167 public String toString() { 128 168 return mMessage; -
trunk/hiptop/pester/net/sabi/pester/AlarmListView.java
r242 r243 124 124 Date date = sDateEditor.getDate(); 125 125 date.setTime(sTimeEditor.getDate().getTime()); 126 date.setSeconds(0); 126 127 return date; 127 128 } … … 153 154 sEditingAlarm.setDate(editingDate()); 154 155 } 156 // schedule before adding so the tooltip is correct 157 sEditingAlarm.schedule(); 155 158 if (sEditingAlarm != sFocusedAlarm) { // new alarm 156 159 sAlarmList.addItem(sEditingAlarm); 157 160 setFocusedItem(sEditingAlarm); 158 161 sFocusedAlarm = sEditingAlarm; 159 } else { 160 sEditingAlarm.update(); 161 } 162 } 163 return true; 162 164 case EVENT_CANCEL_ALARM: 163 if (sEditingAlarm == sFocusedAlarm) 164 sEditingAlarm. schedule();165 if (sEditingAlarm == sFocusedAlarm) // existing alarm 166 sEditingAlarm.resume(); 165 167 sEditingAlarm = null; 166 168 return true; … … 200 202 201 203 protected void itemActivated(Object item) { 202 // XXX deschedule alarm203 204 editAlarm(sFocusedAlarm, false); 204 205 } … … 223 224 if (item == null) // this is dumb, why do we get asked for a tooltip? 224 225 return null; 225 // XXX only set a tooltip if the message is truncated226 return ((Alarm)item).get Message();226 // XXX need "in XXX minutes" too 227 return ((Alarm)item).getDateTimeString(); 227 228 } 228 229 } -
trunk/hiptop/pester/net/sabi/pester/Pester.java
r242 r243 23 23 Alarm alarm = (Alarm)e.argument; 24 24 AlertWindow alert = getAlert(ID_ALARM_ALERT, this); 25 alert.setTitle(alert.getTitle() + ": " + alarm.getDateTimeString()); 25 26 alert.setMessage(alarm.getMessage()); 26 27 // alert.setMessageFormatDate(alarm.getDate());
Note:
See TracChangeset
for help on using the changeset viewer.