# # Sticky.rb # Stickies # # Created by Laurent Sansonetti on 1/4/07. # Copyright (c) 2007 Apple Computer. All rights reserved. # class Scheduler < NSObject ib_outlet :schedulerWindow, :actionController attr_accessor :actions def schedulerNib @schedulerNib ||= NSNib.alloc.initWithNibNamed_bundle('Scheduler', nil) end WINDOW_FRAME_KEY = 'windowFrameAsString' WINDOW_FRAME_STORAGE = 'noteWindow' def initWithActions(actions) @actions=actions #super_init setupScheduler self end def managedObjectContext @actions[0].managedObjectContext end def managedObjectContext= end # Set up the sticky's window from the sticky nib file def setupScheduler schedulerNib.instantiateNibWithOwner_topLevelObjects(self, nil) @actionController.setSelectedObjects(@actions) @schedulerWindow.setDelegate(self) @schedulerWindow.makeKeyAndOrderFront(self) end # Destroy the sticky def windowShouldClose(sender) ##@action.closeNoteReader true end def doToday(sender) @actionController.selectedObjects.takeValue_forKey(NSCalendarDate.date,"doDateDate") end def dueToday(sender) @actionController.selectedObjects.takeValue_forKey(NSCalendarDate.date,"dueDateDate") end def startToday(sender) @actionController.selectedObjects.takeValue_forKey(NSCalendarDate.date,"startDateDate") end def quickSetDoDay(sender) cell=sender.selectedCell tag=cell.tag date=NSCalendarDate.calendarDate today=date.dayOfWeek tag=tag-today @actionController.selectedObjects.takeValue_forKey(date.dateByAddingDays(tag),"doDateDate") end def quickSetDueDay(sender) cell=sender.selectedCell tag=cell.tag date=NSCalendarDate.calendarDate today=date.dayOfWeek tag=tag-today @actionController.selectedObjects.takeValue_forKey(date.dateByAddingDays(tag),"dueDateDate") end def quickSetStartDay(sender) cell=sender.selectedCell tag=cell.tag date=NSCalendarDate.calendarDate today=date.dayOfWeek tag=tag-today @actionController.selectedObjects.takeValue_forKey(date.dateByAddingDays(tag),"startDateDate") end def instantiateTemplate(sender) tParents= Set.new @actionController.selectedObjects.each do |a| tParents << a.templateParent end tParents.each do |a| a.instantiateTemplate end end =begin - (void) dealloc { if(stickyWindow) { [stickyWindow orderOut:self]; [stickyWindow release]; } [super dealloc]; } =end end