| 1 | #Boa:Dialog:PropertiesDialog |
|---|
| 2 | |
|---|
| 3 | import wx |
|---|
| 4 | import wx.gizmos |
|---|
| 5 | import ComponentClass as CC |
|---|
| 6 | from errorMsg import * |
|---|
| 7 | import commands |
|---|
| 8 | |
|---|
| 9 | def create(parent): |
|---|
| 10 | return PropertiesDialog(parent) |
|---|
| 11 | |
|---|
| 12 | [wxID_PROPERTIESDIALOG, wxID_PROPERTIESDIALOGACTIONCHOICE, |
|---|
| 13 | wxID_PROPERTIESDIALOGADDPROP, wxID_PROPERTIESDIALOGADDVALUE, |
|---|
| 14 | wxID_PROPERTIESDIALOGCANCEL, wxID_PROPERTIESDIALOGDESCRIPTION, |
|---|
| 15 | wxID_PROPERTIESDIALOGELEMENTCHOICE, wxID_PROPERTIESDIALOGENUMBOX, |
|---|
| 16 | wxID_PROPERTIESDIALOGIDBOX, wxID_PROPERTIESDIALOGKINDCHOICE, |
|---|
| 17 | wxID_PROPERTIESDIALOGMAXBOX, wxID_PROPERTIESDIALOGMINBOX, |
|---|
| 18 | wxID_PROPERTIESDIALOGMODECHOICE, wxID_PROPERTIESDIALOGNAMEBOX, |
|---|
| 19 | wxID_PROPERTIESDIALOGOK, wxID_PROPERTIESDIALOGSASHWINDOW1, |
|---|
| 20 | wxID_PROPERTIESDIALOGSASHWINDOW2, wxID_PROPERTIESDIALOGSPLITTERWINDOW1, |
|---|
| 21 | wxID_PROPERTIESDIALOGSTATICTEXT1, wxID_PROPERTIESDIALOGSTATICTEXT10, |
|---|
| 22 | wxID_PROPERTIESDIALOGSTATICTEXT11, wxID_PROPERTIESDIALOGSTATICTEXT12, |
|---|
| 23 | wxID_PROPERTIESDIALOGSTATICTEXT2, wxID_PROPERTIESDIALOGSTATICTEXT3, |
|---|
| 24 | wxID_PROPERTIESDIALOGSTATICTEXT4, wxID_PROPERTIESDIALOGSTATICTEXT5, |
|---|
| 25 | wxID_PROPERTIESDIALOGSTATICTEXT6, wxID_PROPERTIESDIALOGSTATICTEXT7, |
|---|
| 26 | wxID_PROPERTIESDIALOGSTATICTEXT8, wxID_PROPERTIESDIALOGSTATICTEXT9, |
|---|
| 27 | wxID_PROPERTIESDIALOGTYPECHOICE, wxID_PROPERTIESDIALOGUNITSCHOICE, |
|---|
| 28 | wxID_PROPERTIESDIALOGVALUEBOX, wxID_PROPERTIESDIALOGVALUELIST, |
|---|
| 29 | ] = [wx.NewId() for _init_ctrls in range(34)] |
|---|
| 30 | |
|---|
| 31 | [wxID_PROPERTIESDIALOGVALUELISTPOPUPREMOVE] = [wx.NewId() for _init_coll_valueListPopup_Items in range(1)] |
|---|
| 32 | |
|---|
| 33 | class PropertiesDialog(wx.Dialog): |
|---|
| 34 | def _init_coll_valueListPopup_Items(self, parent): |
|---|
| 35 | # generated method, don't edit |
|---|
| 36 | |
|---|
| 37 | parent.Append(help='', id=wxID_PROPERTIESDIALOGVALUELISTPOPUPREMOVE, |
|---|
| 38 | kind=wx.ITEM_NORMAL, text=u'Remove') |
|---|
| 39 | self.Bind(wx.EVT_MENU, self.OnValueListPopupRemoveMenu, |
|---|
| 40 | id=wxID_PROPERTIESDIALOGVALUELISTPOPUPREMOVE) |
|---|
| 41 | |
|---|
| 42 | def _init_coll_valueList_Columns(self, parent): |
|---|
| 43 | # generated method, don't edit |
|---|
| 44 | |
|---|
| 45 | parent.InsertColumn(col=0, format=wx.LIST_FORMAT_LEFT, heading=u'Value', |
|---|
| 46 | width=92) |
|---|
| 47 | parent.InsertColumn(col=1, format=wx.LIST_FORMAT_LEFT, |
|---|
| 48 | heading=u'Default', width=92) |
|---|
| 49 | |
|---|
| 50 | def _init_utils(self): |
|---|
| 51 | # generated method, don't edit |
|---|
| 52 | self.valueListPopup = wx.Menu(title=u'') |
|---|
| 53 | |
|---|
| 54 | self._init_coll_valueListPopup_Items(self.valueListPopup) |
|---|
| 55 | |
|---|
| 56 | def _init_ctrls(self, prnt): |
|---|
| 57 | # generated method, don't edit |
|---|
| 58 | wx.Dialog.__init__(self, id=wxID_PROPERTIESDIALOG, |
|---|
| 59 | name=u'PropertiesDialog', parent=prnt, pos=wx.Point(483, 325), |
|---|
| 60 | size=wx.Size(775, 446), style=wx.DEFAULT_DIALOG_STYLE, |
|---|
| 61 | title=u'Properties') |
|---|
| 62 | self._init_utils() |
|---|
| 63 | self.SetClientSize(wx.Size(775, 446)) |
|---|
| 64 | self.Center(wx.BOTH) |
|---|
| 65 | self.Bind(wx.EVT_ACTIVATE, self.OnPropertiesDialogActivate) |
|---|
| 66 | |
|---|
| 67 | self.AddProp = wx.Button(id=wxID_PROPERTIESDIALOGADDPROP, |
|---|
| 68 | label=u'Add Property', name=u'AddProp', parent=self, |
|---|
| 69 | pos=wx.Point(479, 399), size=wx.Size(85, 30), style=0) |
|---|
| 70 | self.AddProp.Bind(wx.EVT_BUTTON, self.OnAddPropButton, |
|---|
| 71 | id=wxID_PROPERTIESDIALOGADDPROP) |
|---|
| 72 | |
|---|
| 73 | self.splitterWindow1 = wx.SplitterWindow(id=wxID_PROPERTIESDIALOGSPLITTERWINDOW1, |
|---|
| 74 | name='splitterWindow1', parent=self, point=wx.Point(8, 79), |
|---|
| 75 | size=wx.Size(760, 308), style=wx.ALWAYS_SHOW_SB | wx.SP_3D) |
|---|
| 76 | self.splitterWindow1.SetBestFittingSize(wx.Size(760, 305)) |
|---|
| 77 | |
|---|
| 78 | self.sashWindow2 = wx.SashWindow(id=wxID_PROPERTIESDIALOGSASHWINDOW2, |
|---|
| 79 | name='sashWindow2', parent=self.splitterWindow1, pos=wx.Point(204, |
|---|
| 80 | 0), size=wx.Size(556, 305), |
|---|
| 81 | style=wx.ALWAYS_SHOW_SB | wx.CLIP_CHILDREN | wx.HSCROLL | wx.VSCROLL | wx.SW_3D) |
|---|
| 82 | self.sashWindow2.SetAutoLayout(True) |
|---|
| 83 | self.sashWindow2.SetBestFittingSize(wx.Size(556, 285)) |
|---|
| 84 | self.sashWindow2.SetMaximumSizeY(375) |
|---|
| 85 | |
|---|
| 86 | self.nameBox = wx.TextCtrl(id=wxID_PROPERTIESDIALOGNAMEBOX, |
|---|
| 87 | name=u'nameBox', parent=self, pos=wx.Point(208, 40), |
|---|
| 88 | size=wx.Size(144, 25), style=0, value=u'') |
|---|
| 89 | |
|---|
| 90 | self.idBox = wx.TextCtrl(id=wxID_PROPERTIESDIALOGIDBOX, name=u'idBox', |
|---|
| 91 | parent=self, pos=wx.Point(360, 40), size=wx.Size(283, 25), |
|---|
| 92 | style=0, value=u'') |
|---|
| 93 | |
|---|
| 94 | self.typeChoice = wx.Choice(choices=["boolean", "char", "double", |
|---|
| 95 | "float", "short", "long", "objref", "octet", "string", "ulong", |
|---|
| 96 | "ushort"], id=wxID_PROPERTIESDIALOGTYPECHOICE, name=u'typeChoice', |
|---|
| 97 | parent=self.sashWindow2, pos=wx.Point(32, 105), size=wx.Size(100, |
|---|
| 98 | 27), style=0) |
|---|
| 99 | self.typeChoice.SetBestFittingSize(wx.Size(100, 27)) |
|---|
| 100 | |
|---|
| 101 | self.elementChoice = wx.Choice(choices=["Simple", "SimpleSequence", |
|---|
| 102 | "Test", "Struct", "StructSequence"], |
|---|
| 103 | id=wxID_PROPERTIESDIALOGELEMENTCHOICE, name=u'elementChoice', |
|---|
| 104 | parent=self, pos=wx.Point(32, 40), size=wx.Size(152, 27), |
|---|
| 105 | style=0) |
|---|
| 106 | self.elementChoice.Bind(wx.EVT_CHOICE, self.OnElementChoiceChoice, |
|---|
| 107 | id=wxID_PROPERTIESDIALOGELEMENTCHOICE) |
|---|
| 108 | |
|---|
| 109 | self.modeChoice = wx.Choice(choices=["readonly", "readwrite", |
|---|
| 110 | "writeonly"], id=wxID_PROPERTIESDIALOGMODECHOICE, |
|---|
| 111 | name=u'modeChoice', parent=self, pos=wx.Point(653, 39), |
|---|
| 112 | size=wx.Size(104, 27), style=0) |
|---|
| 113 | |
|---|
| 114 | self.description = wx.TextCtrl(id=wxID_PROPERTIESDIALOGDESCRIPTION, |
|---|
| 115 | name=u'description', parent=self.sashWindow2, pos=wx.Point(16, |
|---|
| 116 | 32), size=wx.Size(272, 40), style=wx.TE_MULTILINE, value=u'') |
|---|
| 117 | |
|---|
| 118 | self.unitsChoice = wx.Choice(choices=["None", "Hz", "W", "V", "cycles_per_sample"], |
|---|
| 119 | id=wxID_PROPERTIESDIALOGUNITSCHOICE, name=u'unitsChoice', |
|---|
| 120 | parent=self.sashWindow2, pos=wx.Point(185, 105), size=wx.Size(85, |
|---|
| 121 | 27), style=0) |
|---|
| 122 | self.unitsChoice.SetBestFittingSize(wx.Size(85, 27)) |
|---|
| 123 | |
|---|
| 124 | self.minBox = wx.TextCtrl(id=wxID_PROPERTIESDIALOGMINBOX, |
|---|
| 125 | name=u'minBox', parent=self.sashWindow2, pos=wx.Point(184, 236), |
|---|
| 126 | size=wx.Size(80, 25), style=0, value=u'min') |
|---|
| 127 | |
|---|
| 128 | self.maxBox = wx.TextCtrl(id=wxID_PROPERTIESDIALOGMAXBOX, |
|---|
| 129 | name=u'maxBox', parent=self.sashWindow2, pos=wx.Point(184, 268), |
|---|
| 130 | size=wx.Size(80, 25), style=0, value=u'max') |
|---|
| 131 | |
|---|
| 132 | self.staticText1 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT1, |
|---|
| 133 | label=u'Description', name='staticText1', parent=self.sashWindow2, |
|---|
| 134 | pos=wx.Point(16, 11), size=wx.Size(76, 17), style=0) |
|---|
| 135 | |
|---|
| 136 | self.kindChoice = wx.Choice(choices=["allocation", "configure", "test", |
|---|
| 137 | "execparam", "factoryparam"], id=wxID_PROPERTIESDIALOGKINDCHOICE, |
|---|
| 138 | name=u'kindChoice', parent=self.sashWindow2, pos=wx.Point(27, |
|---|
| 139 | 170), size=wx.Size(110, 27), style=0) |
|---|
| 140 | self.kindChoice.SetBestFittingSize(wx.Size(110, 27)) |
|---|
| 141 | self.kindChoice.Bind(wx.EVT_CHOICE, self.OnKindChoiceChoice, |
|---|
| 142 | id=wxID_PROPERTIESDIALOGKINDCHOICE) |
|---|
| 143 | |
|---|
| 144 | self.staticText2 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT2, |
|---|
| 145 | label=u'Type', name='staticText2', parent=self.sashWindow2, |
|---|
| 146 | pos=wx.Point(65, 84), size=wx.Size(39, 17), style=0) |
|---|
| 147 | |
|---|
| 148 | self.staticText3 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT3, |
|---|
| 149 | label=u'Units', name='staticText3', parent=self.sashWindow2, |
|---|
| 150 | pos=wx.Point(212, 84), size=wx.Size(41, 17), style=0) |
|---|
| 151 | |
|---|
| 152 | self.staticText4 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT4, |
|---|
| 153 | label=u'Kind', name='staticText4', parent=self.sashWindow2, |
|---|
| 154 | pos=wx.Point(69, 149), size=wx.Size(36, 17), style=0) |
|---|
| 155 | |
|---|
| 156 | self.staticText5 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT5, |
|---|
| 157 | label=u'Range', name='staticText5', parent=self.sashWindow2, |
|---|
| 158 | pos=wx.Point(205, 215), size=wx.Size(48, 17), style=0) |
|---|
| 159 | |
|---|
| 160 | self.staticText6 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT6, |
|---|
| 161 | label=u'Value(s)', name='staticText6', parent=self.sashWindow2, |
|---|
| 162 | pos=wx.Point(362, 23), size=wx.Size(58, 17), style=0) |
|---|
| 163 | |
|---|
| 164 | self.sashWindow1 = wx.SashWindow(id=wxID_PROPERTIESDIALOGSASHWINDOW1, |
|---|
| 165 | name='sashWindow1', parent=self.splitterWindow1, pos=wx.Point(0, |
|---|
| 166 | 0), size=wx.Size(199, 305), style=wx.CLIP_CHILDREN | wx.SW_3D) |
|---|
| 167 | self.splitterWindow1.SplitVertically(self.sashWindow1, self.sashWindow2, |
|---|
| 168 | 200) |
|---|
| 169 | |
|---|
| 170 | self.valueBox = wx.TextCtrl(id=wxID_PROPERTIESDIALOGVALUEBOX, |
|---|
| 171 | name=u'valueBox', parent=self.sashWindow2, pos=wx.Point(336, 44), |
|---|
| 172 | size=wx.Size(100, 25), style=0, value=u'') |
|---|
| 173 | self.valueBox.SetBestFittingSize(wx.Size(100, 25)) |
|---|
| 174 | |
|---|
| 175 | self.addValue = wx.BitmapButton(bitmap=wx.Bitmap(u'plus.bmp', |
|---|
| 176 | wx.BITMAP_TYPE_BMP), id=wxID_PROPERTIESDIALOGADDVALUE, |
|---|
| 177 | name=u'addValue', parent=self.sashWindow2, pos=wx.Point(456, 44), |
|---|
| 178 | size=wx.Size(24, 24), style=wx.BU_AUTODRAW) |
|---|
| 179 | self.addValue.Bind(wx.EVT_BUTTON, self.OnAddValueButton, |
|---|
| 180 | id=wxID_PROPERTIESDIALOGADDVALUE) |
|---|
| 181 | |
|---|
| 182 | self.staticText7 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT7, |
|---|
| 183 | label=u'Element Type', name='staticText7', parent=self, |
|---|
| 184 | pos=wx.Point(57, 16), size=wx.Size(141, 17), style=0) |
|---|
| 185 | |
|---|
| 186 | self.staticText8 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT8, |
|---|
| 187 | label=u'Name', name='staticText8', parent=self, pos=wx.Point(252, |
|---|
| 188 | 16), size=wx.Size(45, 17), style=0) |
|---|
| 189 | |
|---|
| 190 | self.staticText9 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT9, |
|---|
| 191 | label=u'ID', name='staticText9', parent=self, pos=wx.Point(485, |
|---|
| 192 | 16), size=wx.Size(24, 17), style=0) |
|---|
| 193 | |
|---|
| 194 | self.staticText10 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT10, |
|---|
| 195 | label=u'Mode', name='staticText10', parent=self, pos=wx.Point(687, |
|---|
| 196 | 16), size=wx.Size(42, 17), style=0) |
|---|
| 197 | |
|---|
| 198 | self.valueList = wx.ListCtrl(id=wxID_PROPERTIESDIALOGVALUELIST, |
|---|
| 199 | name=u'valueList', parent=self.sashWindow2, pos=wx.Point(316, 82), |
|---|
| 200 | size=wx.Size(185, 206), |
|---|
| 201 | style=wx.ALWAYS_SHOW_SB | wx.LC_EDIT_LABELS | wx.LC_VRULES | wx.LC_REPORT | wx.SIMPLE_BORDER | wx.LC_HRULES | wx.VSCROLL | wx.LC_SINGLE_SEL) |
|---|
| 202 | self.valueList.SetBestFittingSize(wx.Size(185, 206)) |
|---|
| 203 | self._init_coll_valueList_Columns(self.valueList) |
|---|
| 204 | self.valueList.Bind(wx.EVT_RIGHT_UP, self.OnValueListRightUp) |
|---|
| 205 | |
|---|
| 206 | self.Cancel = wx.Button(id=wxID_PROPERTIESDIALOGCANCEL, label=u'Cancel', |
|---|
| 207 | name=u'Cancel', parent=self, pos=wx.Point(680, 399), |
|---|
| 208 | size=wx.Size(85, 30), style=0) |
|---|
| 209 | self.Cancel.Bind(wx.EVT_BUTTON, self.OnCancelButton, |
|---|
| 210 | id=wxID_PROPERTIESDIALOGCANCEL) |
|---|
| 211 | |
|---|
| 212 | self.enumBox = wx.TextCtrl(id=wxID_PROPERTIESDIALOGENUMBOX, |
|---|
| 213 | name=u'enumBox', parent=self.sashWindow2, pos=wx.Point(20, 251), |
|---|
| 214 | size=wx.Size(125, 25), style=0, value=u'') |
|---|
| 215 | |
|---|
| 216 | self.staticText11 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT11, |
|---|
| 217 | label=u'Enumeration', name=u'staticText11', |
|---|
| 218 | parent=self.sashWindow2, pos=wx.Point(36, 230), size=wx.Size(90, |
|---|
| 219 | 17), style=0) |
|---|
| 220 | |
|---|
| 221 | self.ok = wx.Button(id=wxID_PROPERTIESDIALOGOK, label=u'OK', name=u'ok', |
|---|
| 222 | parent=self, pos=wx.Point(579, 399), size=wx.Size(85, 30), |
|---|
| 223 | style=0) |
|---|
| 224 | self.ok.Bind(wx.EVT_BUTTON, self.OnOkButton, id=wxID_PROPERTIESDIALOGOK) |
|---|
| 225 | |
|---|
| 226 | self.actionChoice = wx.Choice(choices=["eq", "ne", "gt", "lt", "ge", |
|---|
| 227 | "le", "external"], id=wxID_PROPERTIESDIALOGACTIONCHOICE, |
|---|
| 228 | name=u'actionChoice', parent=self.sashWindow2, pos=wx.Point(185, |
|---|
| 229 | 170), size=wx.Size(85, 27), style=0) |
|---|
| 230 | |
|---|
| 231 | self.staticText12 = wx.StaticText(id=wxID_PROPERTIESDIALOGSTATICTEXT12, |
|---|
| 232 | label=u'Action', name='staticText12', parent=self.sashWindow2, |
|---|
| 233 | pos=wx.Point(209, 149), size=wx.Size(50, 17), style=0) |
|---|
| 234 | |
|---|
| 235 | def __init__(self, parent): |
|---|
| 236 | self._init_ctrls(parent) |
|---|
| 237 | self.parent = parent |
|---|
| 238 | self.calledByParent = False |
|---|
| 239 | self.active_prop = None |
|---|
| 240 | |
|---|
| 241 | def OnPropertiesDialogActivate(self, event): |
|---|
| 242 | if self.calledByParent == True: |
|---|
| 243 | |
|---|
| 244 | self.active_comp = self.parent.active_comp |
|---|
| 245 | |
|---|
| 246 | if self.active_prop == None: |
|---|
| 247 | self.elementType = "Simple" |
|---|
| 248 | self.elementChoice.SetSelection(0) |
|---|
| 249 | self.modeChoice.SetSelection(0) |
|---|
| 250 | self.typeChoice.SetStringSelection("short") |
|---|
| 251 | self.kindChoice.SetStringSelection("configure") |
|---|
| 252 | self.unitsChoice.SetStringSelection("None") |
|---|
| 253 | self.AddProp.Enable(True) |
|---|
| 254 | self.idBox.SetValue("DCE:"+uuidgen()) |
|---|
| 255 | self.ok.Enable(False) |
|---|
| 256 | else: |
|---|
| 257 | #read in the property and display |
|---|
| 258 | self.AddProp.Enable(False) |
|---|
| 259 | self.ok.Enable(True) |
|---|
| 260 | self.idBox.SetValue(self.active_prop.id) |
|---|
| 261 | self.nameBox.SetValue(self.active_prop.name) |
|---|
| 262 | tmp = self.modeChoice.FindString(self.active_prop.mode) |
|---|
| 263 | self.modeChoice.SetSelection(tmp) |
|---|
| 264 | self.elementType = self.active_prop.elementType |
|---|
| 265 | tmp = self.elementChoice.FindString(self.elementType) |
|---|
| 266 | self.elementChoice.SetSelection(tmp) |
|---|
| 267 | self.description.SetValue(self.active_prop.description) |
|---|
| 268 | |
|---|
| 269 | self.initializeDisplay() |
|---|
| 270 | |
|---|
| 271 | self.unitsChoice.Enable(False) # we don't support units yet |
|---|
| 272 | |
|---|
| 273 | self.refreshDisplay() |
|---|
| 274 | |
|---|
| 275 | self.calledByParent = False |
|---|
| 276 | event.Skip() |
|---|
| 277 | |
|---|
| 278 | def OnPropBoxLeftUp(self, event): |
|---|
| 279 | self.propBox.Refresh() |
|---|
| 280 | |
|---|
| 281 | event.Skip() |
|---|
| 282 | |
|---|
| 283 | def OnElementChoiceChoice(self, event): |
|---|
| 284 | pos = self.elementChoice.GetSelection() |
|---|
| 285 | if pos == wx.NOT_FOUND: |
|---|
| 286 | return |
|---|
| 287 | self.elementType = self.elementChoice.GetString(pos) |
|---|
| 288 | if self.elementType != "Simple" and self.elementType != "SimpleSequence": |
|---|
| 289 | errorMsg(self,'This element type is not supported yet!') |
|---|
| 290 | self.elementType = "Simple" |
|---|
| 291 | self.elementChoice.SetSelection(0) |
|---|
| 292 | |
|---|
| 293 | self.refreshDisplay() |
|---|
| 294 | event.Skip() |
|---|
| 295 | |
|---|
| 296 | def refreshDisplay(self): |
|---|
| 297 | if self.active_prop != None: |
|---|
| 298 | |
|---|
| 299 | if self.active_prop.elementType == "Simple": |
|---|
| 300 | pass |
|---|
| 301 | if self.elementType == "Simple": |
|---|
| 302 | if self.valueList.GetItemCount() >= 1: |
|---|
| 303 | self.addValue.Enable(False) |
|---|
| 304 | else: |
|---|
| 305 | self.addValue.Enable(True) |
|---|
| 306 | self.enumBox.Enable(True) |
|---|
| 307 | |
|---|
| 308 | pos = self.kindChoice.GetSelection() |
|---|
| 309 | if pos != wx.NOT_FOUND: |
|---|
| 310 | if self.kindChoice.GetString(pos) == "allocation": |
|---|
| 311 | self.actionChoice.Enable(True) |
|---|
| 312 | else: |
|---|
| 313 | self.actionChoice.Enable(False) |
|---|
| 314 | |
|---|
| 315 | elif self.elementType == "SimpleSequence": |
|---|
| 316 | self.addValue.Enable(True) |
|---|
| 317 | self.enumBox.Enable(False) |
|---|
| 318 | |
|---|
| 319 | def initializeDisplay(self): |
|---|
| 320 | if self.elementType == "Simple" or self.elementType == "SimpleSequence": |
|---|
| 321 | # Load the type (ie. long, string, boolean) |
|---|
| 322 | pos = self.typeChoice.FindString(self.active_prop.type) |
|---|
| 323 | self.typeChoice.SetSelection(pos) |
|---|
| 324 | |
|---|
| 325 | # Load the action (ie. eq, lt, ge) |
|---|
| 326 | if self.active_prop.action != None: |
|---|
| 327 | pos = self.actionChoice.FindString(self.active_prop.action) |
|---|
| 328 | self.actionChoice.SetSelection(pos) |
|---|
| 329 | |
|---|
| 330 | # Load the kind (ie. allocation, configure, execparam) |
|---|
| 331 | pos = self.kindChoice.FindString(self.active_prop.kind) |
|---|
| 332 | self.kindChoice.SetSelection(pos) |
|---|
| 333 | |
|---|
| 334 | # Load the range of the value(s) |
|---|
| 335 | if self.active_prop.range[0] == -1 and self.active_prop.range[1] == -1: |
|---|
| 336 | pass |
|---|
| 337 | else: |
|---|
| 338 | self.minBox.SetValue(str(self.active_prop.range[0])) |
|---|
| 339 | self.maxBox.SetValue(str(self.active_prop.range[1])) |
|---|
| 340 | |
|---|
| 341 | # If this is already installed on the system - can't change anything but the value(s) |
|---|
| 342 | if self.editable == False: |
|---|
| 343 | self.nameBox.Enable(False) |
|---|
| 344 | self.idBox.Enable(False) |
|---|
| 345 | self.typeChoice.Enable(False) |
|---|
| 346 | self.kindChoice.Enable(False) |
|---|
| 347 | self.elementChoice.Enable(False) |
|---|
| 348 | self.actionChoice.Enable(False) |
|---|
| 349 | self.enumBox.Enable(False) |
|---|
| 350 | self.minBox.Enable(False) |
|---|
| 351 | self.maxBox.Enable(False) |
|---|
| 352 | self.modeChoice.Enable(False) |
|---|
| 353 | self.description.Enable(False) |
|---|
| 354 | |
|---|
| 355 | if self.elementType == "Simple": |
|---|
| 356 | # Load the value for a Simple type |
|---|
| 357 | self.valueList.InsertStringItem(0,unicode(self.active_prop.value)) |
|---|
| 358 | self.valueList.SetStringItem(0,1,unicode(self.active_prop.defaultValue)) |
|---|
| 359 | |
|---|
| 360 | # Load the enumeration |
|---|
| 361 | if self.active_prop.enum != '': |
|---|
| 362 | self.enumBox.SetValue(self.active_prop.enum) |
|---|
| 363 | |
|---|
| 364 | if self.elementType == "SimpleSequence": |
|---|
| 365 | for v in self.active_prop.values: |
|---|
| 366 | self.valueList.InsertStringItem(0,v) #create list (backwards at first) |
|---|
| 367 | tmpPropCounter = 0 |
|---|
| 368 | for v in self.active_prop.values: |
|---|
| 369 | self.valueList.SetStringItem(tmpPropCounter,0,v) #set the items in the listin the correct order |
|---|
| 370 | tmpPropCounter = tmpPropCounter + 1 |
|---|
| 371 | tmpPropCounter = 0 |
|---|
| 372 | for dv in self.active_prop.defaultValues: |
|---|
| 373 | self.valueList.SetStringItem(tmpPropCounter,1,dv) |
|---|
| 374 | tmpPropCounter = tmpPropCounter + 1 |
|---|
| 375 | |
|---|
| 376 | def OnBitmapButton1Button(self, event): |
|---|
| 377 | event.Skip() |
|---|
| 378 | |
|---|
| 379 | def OnAddValueButton(self, event): |
|---|
| 380 | tmpStr = self.valueBox.GetLineText(0) |
|---|
| 381 | if tmpStr != '': |
|---|
| 382 | self.valueList.InsertStringItem(0,tmpStr) |
|---|
| 383 | self.valueList.SetStringItem(0,1,tmpStr) |
|---|
| 384 | self.valueBox.Clear() |
|---|
| 385 | |
|---|
| 386 | self.refreshDisplay() |
|---|
| 387 | event.Skip() |
|---|
| 388 | |
|---|
| 389 | def OnValueListPopupRemoveMenu(self, event): |
|---|
| 390 | if self.editable == False: |
|---|
| 391 | errorMsg(self,"This property is not removable!") |
|---|
| 392 | return |
|---|
| 393 | sel = self.valueList.GetFirstSelected() |
|---|
| 394 | if sel >= 0: |
|---|
| 395 | if self.elementType == "Simple": |
|---|
| 396 | self.addValue.Enable(True) |
|---|
| 397 | self.valueList.DeleteItem(sel) |
|---|
| 398 | event.Skip() |
|---|
| 399 | |
|---|
| 400 | def OnValueListRightUp(self, event): |
|---|
| 401 | self.valueList.PopupMenu(self.valueListPopup) |
|---|
| 402 | |
|---|
| 403 | event.Skip() |
|---|
| 404 | |
|---|
| 405 | def OnCancelButton(self, event): |
|---|
| 406 | self.Close() |
|---|
| 407 | event.Skip() |
|---|
| 408 | |
|---|
| 409 | def OnAddPropButton(self, event): |
|---|
| 410 | # Check for the name |
|---|
| 411 | tmpName = self.nameBox.GetLineText(0) |
|---|
| 412 | if tmpName == '': |
|---|
| 413 | errorMsg(self,"Please enter a property name first!") |
|---|
| 414 | return |
|---|
| 415 | |
|---|
| 416 | # Check for the id |
|---|
| 417 | tmpid = self.idBox.GetLineText(0) |
|---|
| 418 | if tmpid == '': |
|---|
| 419 | errorMsg(self,"Please enter a property id first!") |
|---|
| 420 | return |
|---|
| 421 | |
|---|
| 422 | # Check for the mode |
|---|
| 423 | pos = self.modeChoice.GetSelection() |
|---|
| 424 | if pos == wx.NOT_FOUND: |
|---|
| 425 | errorMsg(self,"Please select a property mode first!") |
|---|
| 426 | return |
|---|
| 427 | tmpMode = self.modeChoice.GetString(pos) |
|---|
| 428 | |
|---|
| 429 | # Get the description |
|---|
| 430 | tmpDes = self.description.GetValue() |
|---|
| 431 | |
|---|
| 432 | # Check for the type ex: bool, char, short, etc. |
|---|
| 433 | pos = self.typeChoice.GetSelection() |
|---|
| 434 | if pos == wx.NOT_FOUND: |
|---|
| 435 | errorMsg(self,"Please select a type first!") |
|---|
| 436 | return |
|---|
| 437 | tmpType = self.typeChoice.GetString(pos) |
|---|
| 438 | |
|---|
| 439 | if self.elementType == "Simple": |
|---|
| 440 | # instantiate the property object |
|---|
| 441 | newProp = CC.SimpleProperty(tmpName,tmpMode,tmpType,tmpDes) |
|---|
| 442 | |
|---|
| 443 | # store the default value and the value |
|---|
| 444 | if self.valueList.GetItemCount() == 0: |
|---|
| 445 | errorMsg(self,"Please enter a value first!") |
|---|
| 446 | return |
|---|
| 447 | |
|---|
| 448 | v = self.valueList.GetItem(0,0) |
|---|
| 449 | dv = self.valueList.GetItem(0,1) |
|---|
| 450 | newProp.value = v.GetText() |
|---|
| 451 | newProp.defaultValue = dv.GetText() |
|---|
| 452 | |
|---|
| 453 | if self.elementType == "SimpleSequence": |
|---|
| 454 | # store the default value and the value |
|---|
| 455 | if self.valueList.GetItemCount() == 0: |
|---|
| 456 | errorMsg(self,"Please enter a value first!") |
|---|
| 457 | return |
|---|
| 458 | |
|---|
| 459 | newProp = CC.SimpleSequenceProperty(tmpName,tmpMode,tmpType,tmpDes) |
|---|
| 460 | |
|---|
| 461 | |
|---|
| 462 | newProp.values = [] |
|---|
| 463 | newProp.defaultValues = [] |
|---|
| 464 | |
|---|
| 465 | for x in range(self.valueList.GetItemCount()): |
|---|
| 466 | v = self.valueList.GetItem(x,0) |
|---|
| 467 | dv = self.valueList.GetItem(x,1) |
|---|
| 468 | |
|---|
| 469 | newProp.values.append(v.GetText()) |
|---|
| 470 | newProp.defaultValues.append(dv.GetText()) |
|---|
| 471 | |
|---|
| 472 | # store the enum if any |
|---|
| 473 | newProp.enum = self.enumBox.GetLineText(0) |
|---|
| 474 | |
|---|
| 475 | # Check for the kind ex: allocation, configure, test, etc. |
|---|
| 476 | pos = self.kindChoice.GetSelection() |
|---|
| 477 | if pos == wx.NOT_FOUND: |
|---|
| 478 | errorMsg(self,"Please select a kind first!") |
|---|
| 479 | return |
|---|
| 480 | newProp.kind = self.kindChoice.GetString(pos) |
|---|
| 481 | |
|---|
| 482 | # Check and store the range |
|---|
| 483 | tmpMin = self.minBox.GetLineText(0) |
|---|
| 484 | tmpMax = self.maxBox.GetLineText(0) |
|---|
| 485 | |
|---|
| 486 | if tmpMin == 'min' or tmpMin == '': |
|---|
| 487 | tmpMin = -1 |
|---|
| 488 | |
|---|
| 489 | if tmpMax == 'max' or tmpMax == '': |
|---|
| 490 | tmpMax = -1 |
|---|
| 491 | |
|---|
| 492 | newProp.range = (tmpMin,tmpMax) |
|---|
| 493 | |
|---|
| 494 | # Check and store the action |
|---|
| 495 | pos = self.actionChoice.GetSelection() |
|---|
| 496 | if pos == wx.NOT_FOUND: |
|---|
| 497 | if newProp.kind == "allocation": |
|---|
| 498 | errorMsg(self,"Please select an action first!") |
|---|
| 499 | return |
|---|
| 500 | else: |
|---|
| 501 | newProp.action = self.actionChoice.GetString(pos) |
|---|
| 502 | |
|---|
| 503 | self.parent.active_comp.properties.append(newProp) |
|---|
| 504 | self.Close() |
|---|
| 505 | |
|---|
| 506 | event.Skip() |
|---|
| 507 | |
|---|
| 508 | def OnOkButton(self, event): |
|---|
| 509 | if self.editable: |
|---|
| 510 | # Check for the name |
|---|
| 511 | tmpName = self.nameBox.GetLineText(0) |
|---|
| 512 | if tmpName == '': |
|---|
| 513 | errorMsg(self,"Please enter a property name first!") |
|---|
| 514 | return |
|---|
| 515 | self.active_prop.name = tmpName |
|---|
| 516 | |
|---|
| 517 | # Check for the id |
|---|
| 518 | tmpid = self.idBox.GetLineText(0) |
|---|
| 519 | if tmpid == '': |
|---|
| 520 | errorMsg(self,"Please enter a property id first!") |
|---|
| 521 | return |
|---|
| 522 | self.active_prop.id = tmpid |
|---|
| 523 | |
|---|
| 524 | # Check for the mode |
|---|
| 525 | pos = self.modeChoice.GetSelection() |
|---|
| 526 | if pos == wx.NOT_FOUND: |
|---|
| 527 | errorMsg(self,"Please select a property mode first!") |
|---|
| 528 | return |
|---|
| 529 | tmpMode = self.modeChoice.GetString(pos) |
|---|
| 530 | self.active_prop.mode = tmpMode |
|---|
| 531 | |
|---|
| 532 | # Get the description |
|---|
| 533 | tmpDes = self.description.GetValue() |
|---|
| 534 | self.active_prop.description = tmpDes |
|---|
| 535 | |
|---|
| 536 | # Check for the type ex: bool, char, short, etc. |
|---|
| 537 | pos = self.typeChoice.GetSelection() |
|---|
| 538 | if pos == wx.NOT_FOUND: |
|---|
| 539 | errorMsg(self,"Please select a type first!") |
|---|
| 540 | return |
|---|
| 541 | tmpType = self.typeChoice.GetString(pos) |
|---|
| 542 | self.active_prop.type = tmpType |
|---|
| 543 | |
|---|
| 544 | if self.elementType == "Simple": |
|---|
| 545 | # store the default value and the value |
|---|
| 546 | if self.valueList.GetItemCount() == 0: |
|---|
| 547 | errorMsg(self,"Please enter a value first!") |
|---|
| 548 | return |
|---|
| 549 | |
|---|
| 550 | v = self.valueList.GetItem(0,0) |
|---|
| 551 | dv = self.valueList.GetItem(0,1) |
|---|
| 552 | self.active_prop.value = v.GetText() |
|---|
| 553 | self.active_prop.defaultValue = dv.GetText() |
|---|
| 554 | |
|---|
| 555 | if self.elementType == "SimpleSequence": |
|---|
| 556 | # store the default value and the value |
|---|
| 557 | if self.valueList.GetItemCount() == 0: |
|---|
| 558 | errorMsg(self,"Please enter a value first!") |
|---|
| 559 | return |
|---|
| 560 | |
|---|
| 561 | self.active_prop.values = [] |
|---|
| 562 | self.active_prop.defaultValues = [] |
|---|
| 563 | |
|---|
| 564 | for x in range(self.valueList.GetItemCount()): |
|---|
| 565 | v = self.valueList.GetItem(x,0) |
|---|
| 566 | dv = self.valueList.GetItem(x,1) |
|---|
| 567 | |
|---|
| 568 | self.active_prop.values.append(v.GetText()) |
|---|
| 569 | self.active_prop.defaultValues.append(dv.GetText()) |
|---|
| 570 | |
|---|
| 571 | # store the enum if any |
|---|
| 572 | self.active_prop.enum = self.enumBox.GetLineText(0) |
|---|
| 573 | |
|---|
| 574 | # Check for the kind ex: allocation, configure, test, etc. |
|---|
| 575 | pos = self.kindChoice.GetSelection() |
|---|
| 576 | if pos == wx.NOT_FOUND: |
|---|
| 577 | errorMsg(self,"Please select a kind first!") |
|---|
| 578 | return |
|---|
| 579 | self.active_prop.kind = self.kindChoice.GetString(pos) |
|---|
| 580 | |
|---|
| 581 | # Check and store the range |
|---|
| 582 | tmpMin = self.minBox.GetLineText(0) |
|---|
| 583 | tmpMax = self.maxBox.GetLineText(0) |
|---|
| 584 | |
|---|
| 585 | if tmpMin == 'min' or tmpMin == '': |
|---|
| 586 | tmpMin = -1 |
|---|
| 587 | |
|---|
| 588 | if tmpMax == 'max' or tmpMax == '': |
|---|
| 589 | tmpMax = -1 |
|---|
| 590 | |
|---|
| 591 | self.active_prop.range = (tmpMin,tmpMax) |
|---|
| 592 | |
|---|
| 593 | # Check and store the action |
|---|
| 594 | pos = self.actionChoice.GetSelection() |
|---|
| 595 | if pos == wx.NOT_FOUND: |
|---|
| 596 | if self.active_prop.kind == "allocation": |
|---|
| 597 | errorMsg(self,"Please select an action first!") |
|---|
| 598 | return |
|---|
| 599 | else: |
|---|
| 600 | self.active_prop.action = self.actionChoice.GetString(pos) |
|---|
| 601 | |
|---|
| 602 | else: |
|---|
| 603 | if self.elementType == "Simple": |
|---|
| 604 | # store the default value and the value |
|---|
| 605 | if self.valueList.GetItemCount() == 0: |
|---|
| 606 | errorMsg(self,"Please enter a value first!") |
|---|
| 607 | return |
|---|
| 608 | |
|---|
| 609 | v = self.valueList.GetItem(0,0) |
|---|
| 610 | dv = self.valueList.GetItem(0,1) |
|---|
| 611 | self.active_prop.value = v.GetText() |
|---|
| 612 | self.active_prop.defaultValue = dv.GetText() |
|---|
| 613 | |
|---|
| 614 | if self.elementType == "SimpleSequence": |
|---|
| 615 | # store the default value and the value |
|---|
| 616 | if self.valueList.GetItemCount() == 0: |
|---|
| 617 | errorMsg(self,"Please enter a value first!") |
|---|
| 618 | return |
|---|
| 619 | |
|---|
| 620 | self.active_prop.values = [] |
|---|
| 621 | self.active_prop.defaultValues = [] |
|---|
| 622 | |
|---|
| 623 | for x in range(self.valueList.GetItemCount()): |
|---|
| 624 | v = self.valueList.GetItem(x,0) |
|---|
| 625 | dv = self.valueList.GetItem(x,1) |
|---|
| 626 | self.active_prop.values.append(v.GetText()) |
|---|
| 627 | self.active_prop.defaultValues.append(dv.GetText()) |
|---|
| 628 | |
|---|
| 629 | self.Close() |
|---|
| 630 | |
|---|
| 631 | def OnKindChoiceChoice(self, event): |
|---|
| 632 | self.refreshDisplay() |
|---|
| 633 | event.Skip() |
|---|
| 634 | |
|---|
| 635 | #------------------------------------------------------------------------------- |
|---|
| 636 | # |
|---|
| 637 | # UUID Generator |
|---|
| 638 | # |
|---|
| 639 | def uuidgen(): |
|---|
| 640 | return commands.getoutput('uuidgen -t') |
|---|
| 641 | |
|---|