Package application :: Package dialogs :: Module RecurrenceDialog
[hide private]
[frames] | no frames]

Source Code for Module application.dialogs.RecurrenceDialog

  1  #   Copyright (c) 2003-2007 Open Source Applications Foundation 
  2  # 
  3  #   Licensed under the Apache License, Version 2.0 (the "License"); 
  4  #   you may not use this file except in compliance with the License. 
  5  #   You may obtain a copy of the License at 
  6  # 
  7  #       http://www.apache.org/licenses/LICENSE-2.0 
  8  # 
  9  #   Unless required by applicable law or agreed to in writing, software 
 10  #   distributed under the License is distributed on an "AS IS" BASIS, 
 11  #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 12  #   See the License for the specific language governing permissions and 
 13  #   limitations under the License. 
 14   
 15   
 16  #Boa:Dialog:RecurrenceDialog 
 17   
 18  # RecurrenceDialog's _method methods were created automatically by Boa 
 19  # Constructor's GUI designer, but they've been tweaked so it would be tricky 
 20  # to edit them again in Boa, so it's OK to edit the generated methods. 
 21   
 22  import wx 
 23  from i18n import ChandlerMessageFactory as _ 
 24  import logging 
 25  from application import schema 
 26  from osaf.pim import * 
 27  from osaf.pim.mail import MailStamp, getCurrentMeEmailAddresses 
 28   
 29  logger = logging.getLogger(__name__) 
 30   
31 -class RecurrenceDialog(wx.Dialog):
32 - def _init_coll_buttonSizer_Items(self, parent):
33 # generated method 34 35 parent.AddWindow(self.cancelButton, 2, border=5, flag=wx.ALL) 36 parent.AddSpacer(wx.Size(50, 10), border=0, flag=0) 37 parent.AddWindow(self.allButton, 0, border=5, flag=wx.ALL) 38 parent.AddWindow(self.futureButton, 0, border=5, flag=wx.ALL) 39 parent.AddWindow(self.thisButton, 0, border=5, flag=wx.ALL)
40
41 - def _init_coll_verticalSizer_Items(self, parent):
42 # generated method 43 44 parent.AddWindow(self.questionText, 1, border=10, 45 flag=wx.ADJUST_MINSIZE | wx.ALIGN_LEFT | wx.ALL) 46 parent.AddSizer(self.buttonSizer, 0, border=10, 47 flag=wx.ALIGN_CENTER_HORIZONTAL | wx.LEFT | wx.RIGHT | wx.BOTTOM)
48
49 - def _init_sizers(self):
50 # generated method 51 self.verticalSizer = wx.BoxSizer(orient=wx.VERTICAL) 52 53 self.buttonSizer = wx.FlexGridSizer(cols=0, hgap=0, rows=1, vgap=0) 54 55 self._init_coll_verticalSizer_Items(self.verticalSizer) 56 self._init_coll_buttonSizer_Items(self.buttonSizer) 57 58 self.SetSizer(self.verticalSizer) 59 self.SetAutoLayout(True) 60 self.verticalSizer.Fit(self)
61
62 - def _init_ctrls(self):
63 # generated method 64 wx.Dialog.__init__(self, id=-1, 65 name=u'RecurrenceDialog', parent=None, pos=wx.Point(533, 294), 66 size=wx.Size(443, 121), 67 style=wx.DIALOG_MODAL | wx.DEFAULT_DIALOG_STYLE, 68 title=_(u'Recurring event change')) 69 self.SetMinSize(wx.Size(400, 100)) 70 self.SetClientSize(wx.Size(435, 87)) 71 self.Bind(wx.EVT_CLOSE, self.onCancel) 72 73 self.cancelButton = wx.Button(id=wx.ID_CANCEL, 74 name=u'cancelButton', parent=self) 75 self.cancelButton.Bind(wx.EVT_BUTTON, self.onCancel) 76 77 self.allButton = wx.Button(id=-1, label=u'', 78 name=u'allButton', parent=self) 79 self.allButton.Bind(wx.EVT_BUTTON, self.onAll, 80 id=-1) 81 82 self.futureButton = wx.Button(id=-1, label=u'', 83 name=u'futureButton', parent=self) 84 self.futureButton.Bind(wx.EVT_BUTTON, self.onFuture, 85 id=-1) 86 87 self.thisButton = wx.Button(id=-1, 88 label=u'', name=u'thisButton', parent=self) 89 self.thisButton.Bind(wx.EVT_BUTTON, self.onThis, 90 id=-1) 91 92 self.questionText = wx.StaticText(id=-1, 93 label=u'', name=u'questionText', parent=self) 94 95 labels = {self.allButton : _(u'All events'), 96 self.futureButton : _(u'Future events'), 97 self.thisButton : _(u'Just this event')} 98 99 for item, label in labels.iteritems(): 100 item.SetLabel(label) 101 102 103 self._init_sizers()
104
105 - def __init__(self, proxy, question, disabledButtons=()):
106 self.proxy = proxy 107 self._init_ctrls() 108 109 # use the first action to determine the UI 110 self.questionText.SetLabel(question) 111 self.questionText.Wrap(sum(self.buttonSizer.GetColWidths())) 112 self.SetTitle(_(u'Recurring event change')) 113 114 for buttonName in disabledButtons: 115 button = getattr(self, buttonName + 'Button') 116 button.Enable(False) 117 118 self.Fit() 119 self.Layout() 120 self.CenterOnScreen() 121 self.Show()
122
123 - def _accept(self):
124 for method, args, kwargs in self.proxy.acceptCallbacks: 125 method(*args, **kwargs) 126 self.proxy.acceptCallbacks = [] 127 self._end()
128
129 - def _end(self):
130 self.proxy.dialogUp = False 131 # reset the proxy not to be changing anything 132 self.proxy.cancel() 133 134 # Propagate synchronous notification required to 135 # update widgets before the screen is readrawn. 136 wx.GetApp().propagateAsynchronousNotifications() 137 138 self.Destroy()
139
140 - def onCancel(self, event):
141 self.proxy.cancel() 142 for method in self.proxy.cancelCallbacks: 143 method() 144 self.proxy.acceptCallbacks = [] 145 self._end()
146
147 - def onAll(self, event):
148 self.updateSelection() 149 self.proxy.changing = CHANGE_ALL 150 self.proxy.makeChanges() 151 self._accept()
152
153 - def onFuture(self, event):
154 self.updateSelection() 155 self.proxy.changing = CHANGE_FUTURE 156 self.proxy.makeChanges() 157 self._accept()
158
159 - def onThis(self, event):
160 self.updateSelection() 161 self.proxy.changing = CHANGE_THIS 162 self.proxy.makeChanges() 163 self._accept()
164
165 - def updateSelection(self):
166 view = self.proxy.proxiedItem.itsView 167 for change in self.proxy.changes: 168 changeType = change[1] 169 if (changeType == 'remove' or 170 (changeType == 'add' and 171 change[2] is schema.ns("osaf.pim", view).trashCollection)): 172 from osaf.framework.blocks import Block 173 bpb = Block.Block.findBlockByName("SidebarBranchPointBlock") 174 if bpb is not None: 175 view = bpb.childBlocks.