Changeset 439

Show
Ignore:
Timestamp:
Tue Jun 10 15:50:51 2008
Author:
Alexander
Message:

extend 'Edit Column Options' to cover different bar types

Files:

Legend:

Unmodified
Added
Removed
Modified
  • scripts/trunk/Edit Column Options.py

    r275 r439  
    23 23 # 040902 - added edit for column label  
    24 24 # 050912 - Alex - get the column list from GanttReport  
      25 # 080610 - Alex - allow the user to turn on actual and base bars  
    25 26  
    26 27 def hint(s):  
     
    30 31         self.SetStatusText(s)  
    31 32  
      33 class GanttOptionsDialog(wx.Dialog):  
      34     def __init__(self, parent, rc):  
      35         wx.Dialog.__init__(self, parent, -1, 'Edit Column Options')  
      36         self.rc = rc  
      37         periods = rc.Periods or 1  
      38         bars = rc.Bars or 'p'  
      39  
      40         border_sizer = wx.BoxSizer(wx.HORIZONTAL)  
      41         sizer = wx.BoxSizer(wx.VERTICAL)  
      42  
      43         period_sizer = wx.BoxSizer(wx.HORIZONTAL)  
      44         period_label = wx.StaticText(self, -1, "Number of time periods:")  
      45         period_sizer.Add(period_label, 0, wx.ALL | wx.ALIGN_CENTRE, 5)  
      46         self.period_ctrl = wx.TextCtrl(self, -1, str(periods), size=(60, 25))  
      47         period_sizer.Add(self.period_ctrl, 0, wx.ALL, 5)  
      48         sizer.Add(period_sizer)  
      49  
      50         sizer.Add((10, 10))  
      51         self.planbar_ctrl = wx.CheckBox(self, -1, "Show Plan Bar")  
      52         self.planbar_ctrl.SetValue('p' in bars or 'c' in bars or 'C' in bars)  
      53         sizer.Add(self.planbar_ctrl, 0, wx.ALL, 5)  
      54  
      55         self.completionbar_ctrl = wx.CheckBox(self, -1, "Show Completion")  
      56         self.completionbar_ctrl.SetValue('c' in bars or 'C' in bars)  
      57         sizer.Add(self.completionbar_ctrl, 0, wx.LEFT, 40)  
      58         sizer.Add((5, 5))  
      59  
      60         self.actualbar_ctrl = wx.CheckBox(self, -1, "Show Actual Bar")  
      61         self.actualbar_ctrl.SetValue('a' in bars)  
      62         sizer.Add(self.actualbar_ctrl, 0, wx.ALL, 5)  
      63  
      64         self.basebar_ctrl = wx.CheckBox(self, -1, "Show Base Bar")  
      65         self.basebar_ctrl.SetValue('b' in bars)  
      66         sizer.Add(self.basebar_ctrl, 0, wx.ALL, 5)  
      67  
      68         buttons = wx.BoxSizer(wx.HORIZONTAL)  
      69         cancelbutton = wx.Button(self, wx.ID_CANCEL, "Cancel", size=(70, 20))  
      70         buttons.Add(cancelbutton, 0, wx.ALL, 5)  
      71         okbutton = wx.Button(self, wx.ID_OK, "OK", size=(70, 20))  
      72         okbutton.SetDefault()  
      73         buttons.Add(okbutton, 0, wx.ALL, 5)  
      74         sizer.Add(buttons, 0, wx.ALIGN_RIGHT)  
      75  
      76         border_sizer.Add(sizer, 0, wx.ALL | wx.ALIGN_CENTRE, 10)  
      77         self.SetSizer(border_sizer)  
      78         self.Fit()  
      79         self.CentreOnScreen()  
      80  
      81         self.UpdateChecks()  
      82         wx.EVT_BUTTON(self, wx.ID_OK, self.OnOK)  
      83         wx.EVT_CHECKBOX(self, -1, self.OnCheck)  
      84  
      85     def UpdateChecks(self):  
      86         self.completionbar_ctrl.Enable(self.planbar_ctrl.GetValue())  
      87  
      88     def OnCheck(self, event):  
      89         self.UpdateChecks()  
      90         event.Skip()  
      91  
      92     def OnOK(self, event):  
      93         try:  
      94             newvalue = int(self.period_ctrl.GetValue())  
      95         except ValueError:  
      96             pass  
      97         else:  
      98             if newvalue < 1:  
      99                 newvalue = 1  
      100             self.rc.Periods = newvalue  
      101         bars = ""  
      102         if self.planbar_ctrl.GetValue():  
      103             if self.completionbar_ctrl.GetValue():  
      104                 bars += "c"  
      105             else:  
      106                 bars += "p"  
      107         if self.actualbar_ctrl.GetValue():  
      108             bars += "a"  
      109         if self.basebar_ctrl.GetValue():  
      110             bars += "b"  
      111         self.rc.Bars = bars  
      112         Data.SetUndo('Edit Column Options')  
      113         event.Skip()  
      114  
    32 115 def UpdateColumn(self):  
    33 116     sel = self.Report.GetSelectedCols()  # current selection  
     
    51 134     if ct.get('AccessType') == 's':  
    52 135         periods = c.get('Periods') or 1  
    53           dlg = wx.TextEntryDialog(None, 'Enter new number of periods', 'Edit Column Periods', str(periods))  
    54           if dlg.ShowModal() == wx.ID_OK:  
    55               try:  
    56                   newvalue = int(dlg.GetValue())  
    57               except ValueError:  
    58                   pass  
    59               else:  
    60                   if newvalue < 1:  
    61                       newvalue = 1  
    62                   if newvalue != periods:  
    63                       change = {'Table': 'ReportColumn', 'ID': cid, 'Periods': newvalue}  
    64                       Data.Update(change)  
    65                       Data.SetUndo('Edit Column Periods')  
    66           dlg.Destroy()  
      136         rc_object = Data.DBObject.GetObject('ReportColumn', cid)  
      137         dlg = GanttOptionsDialog(None, rc_object)  
      138         dlg.ShowModal()  
    67 139     else:  
    68 140         # allow edit of column label