ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/CaseUploadsDialog.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 6637 byte(s)
Log Message:
Initial Import

File Contents

# Content
1 """
2
3 CaseUploadsDialog
4
5 Created by
6 Emanuel Borges
7 04.16.2011
8
9 This will display the case uploads in a grid
10
11 """
12
13 import wx, wx.grid
14
15 class CaseUploadsDialog(wx.Dialog):
16 #class CaseUploadsDialog(wx.Frame):
17 colLabels = ['UEPOCH','Platform','Upload Date', 'Upload Size']
18
19 def __init__(self, parent,numberOfRows,uploadList, uploadTotal,CLM):
20 self.CLM = CLM
21
22 self.parent = parent
23 wx.Dialog.__init__(self, parent, -1, "Case Uploads for %s"% self.CLM, style = wx.DEFAULT_DIALOG_STYLE, size = (440,600))
24 #wx.Frame.__init__(self, parent, -1, 'test', size =(435,500))
25 #panel = wx.Panel(self,-1)
26 if numberOfRows > 24:
27 self.grid = wx.grid.Grid(self,-1,size = (435,500))
28 else:
29 self.grid = wx.grid.Grid(self,-1, )#size = (435,500))
30 self.grid.CreateGrid(numberOfRows,4)
31
32 for row in range (4):
33 self.grid.SetColLabelValue(row, self.colLabels[row])
34 for col in range(numberOfRows):
35
36 self.grid.SetCellValue(col,row,uploadList[col][row])
37
38
39
40 self.grid.AutoSize()
41
42
43 addButton = wx.Button(self, -1, "+", size=(30,20), style=wx.NO_BORDER)
44 #addButton.Disable()
45 minusButton = wx.Button(self, -1, "-", size=(30,20), style=wx.NO_BORDER)
46 total_Lbl = wx.StaticText(self, -1, "Total Uploaded For This Case: ")
47 total_textCtrl = wx.TextCtrl(self, -1, uploadTotal, wx.DefaultPosition, (150,-1))
48 total_textCtrl.Disable()
49 totalSizer = wx.BoxSizer(wx.HORIZONTAL)
50 totalSizer.Add(total_Lbl,5)
51 totalSizer.Add(total_textCtrl,5)
52 addRemoveButtonSizer = wx.BoxSizer(wx.HORIZONTAL)
53 addRemoveButtonSizer.Add(addButton, 0, wx.LEFT,3)
54 addRemoveButtonSizer.Add(minusButton, 0, wx.LEFT,0)
55
56
57 mainSizer = wx.BoxSizer(wx.VERTICAL)
58 mainSizer.Add(self.grid, 0)
59 mainSizer.Add(addRemoveButtonSizer, 0, wx.LEFT,10)
60 mainSizer.Add(totalSizer, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 20)
61 self.SetSizer(mainSizer)
62 self.grid.EnableEditing(False)
63
64 self.Bind(wx.EVT_BUTTON, self.OnPopupOne, addButton)
65 self.Bind(wx.EVT_BUTTON, self.OnPopupTwo, minusButton)
66
67 def OnPopupTwo(self, event):
68 selectionList = self.grid.GetSelectedRows()
69 ## if there is only one value selected, go
70 if len(selectionList) == 1:
71 UEPOCHValue = self.grid.GetCellValue(selectionList[0],0)
72 if UEPOCHValue.isalpha():
73 canNotProcessDiag = wx.MessageDialog(self,"This record can not be deleted by the MCP. Please delete it manually from the access database.", "Selection",wx.OK | wx.ICON_INFORMATION)
74 canNotProcessDiag.ShowModal()
75 canNotProcessDiag.Destroy()
76 else:
77 confirmDiag = wx.MessageDialog(self,"This one case upload record will be deleted from the database.\nClick OK to delete.", "WARNING.",wx.OK |wx.CANCEL| wx.ICON_INFORMATION)
78 if confirmDiag.ShowModal() == wx.ID_OK:
79 self.grid.DeleteRows(selectionList[0],1)
80 self.parent.console.RemoveDataUpload(self.CLM,UEPOCHValue)
81
82 #print "%s Removed"% UEPOCHValue
83 else:
84 diag = wx.MessageDialog(self,"Please select just one record to delete and try again.", "Selection",wx.OK | wx.ICON_INFORMATION)
85 diag.ShowModal()
86 diag.Destroy()
87 ## if more than one value selelcted, tell them to only select one.
88 #print selectionList
89
90 def OnPopupOne(self, event):
91 dlg = AddCaseUploadDialog(self)
92 if dlg.ShowModal() == wx.ID_OK:
93 platform, sizeFormat, sizeValue = dlg.GetValues()
94 reportSize = sizeValue + sizeFormat
95 #epoch = str(int(time.time()))
96 self.parent.console.AddDataUpload(self.CLM, platform, reportSize)
97 finishedDlg = wx.MessageDialog(self, "MCP: The new record has been added to the matter database.\nPlease close this window and reopen to see your changes.", "Process Complete",wx.OK, wx.DefaultPosition)
98 finishedDlg.ShowModal()
99 #nextIndexNumb = self.tagListBox.GetItemCount()
100 #self.tagListBox.InsertStringItem(nextIndexNumb,"Reviewer_%s"% str(nextIndexNumb+1))
101 #self.tagListBox.SetItemState(nextIndexNumb, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
102 #print "one"
103
104 class AddCaseUploadDialog(wx.Dialog):
105
106 def __init__(self, parent):
107 #self.CLM = CLM
108 #self.parent = parent
109 platformChoices = ["Concordance DIS","Concordance LN","Relativity"]
110 sizeFormatChoices = [" GB"," MB"," KB"]
111 wx.Dialog.__init__(self, parent, -1, "Add Single Case Upload for %s"%parent.CLM, style = wx.DEFAULT_DIALOG_STYLE, size = (300,300))
112 #wx.Frame.__init__(self, parent, -1, 'test', size =(435,500))
113 platform_lbl = wx.StaticText(self, -1, "Platform: ")
114 size_lbl = wx.StaticText(self, -1, "Size: ")
115 self.platform_SelectBox = wx.Choice(self, -1,(100, 50), choices = platformChoices)
116 self.size_TextBox = wx.TextCtrl(self, size=(90,-1))
117 self.sizeFormat_SelectBox = wx.Choice(self, -1,(100, 50), choices = sizeFormatChoices)
118 mainSizer = wx.BoxSizer(wx.VERTICAL)
119
120 sizeBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
121 sizeBoxSizer.Add(self.size_TextBox)
122 sizeBoxSizer.Add(self.sizeFormat_SelectBox)
123 fGSizer = wx.FlexGridSizer(2, 2, 5,5)
124 fGSizer.Add(platform_lbl, 0, wx.ALIGN_RIGHT)
125 fGSizer.Add(self.platform_SelectBox, 0, wx.EXPAND)
126 fGSizer.Add(size_lbl, 0, wx.ALIGN_RIGHT)
127 fGSizer.Add(sizeBoxSizer, 0, wx.EXPAND)
128 mainSizer.Add(fGSizer, 0, wx.EXPAND|wx.ALL, 5)
129
130 oKButton = wx.Button(self, wx.ID_OK)
131 oKButton.SetDefault()
132 cancelButton = wx.Button(self, wx.ID_CANCEL)
133 buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
134 buttonSizer.Add(oKButton,0,wx.ALL,5)
135 buttonSizer.Add(cancelButton,0,wx.ALL,5)
136 mainSizer.Add(buttonSizer)
137 self.SetSizer(mainSizer)
138
139 def GetValues(self):
140 platform = self.platform_SelectBox.GetStringSelection()
141 sizeFormat = self.sizeFormat_SelectBox.GetStringSelection()
142 sizeValue = self.size_TextBox.GetValue()
143 return platform, sizeFormat, sizeValue
144