Changeset 4225
- Timestamp:
- 06/25/07 16:48:31 (6 years ago)
- Files:
-
- 1 modified
-
WaveDev/trunk/WaveDev/wavedev/MainFrame.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
WaveDev/trunk/WaveDev/wavedev/MainFrame.py
r4222 r4225 381 381 self.resourceBox.SetBestFittingSize(wx.Size(175, 396)) 382 382 self.resourceBox.Bind(wx.EVT_RIGHT_UP, self.OnResourceBoxRightUp) 383 383 self.resourceBox.Bind(wx.EVT_LEFT_UP, self.OnResourceBoxLeftUp) 384 self.resourceBox.Bind(wx.EVT_LEFT_DCLICK, self.OnResourceBoxLeftDoubleClick) 384 385 self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1, 385 386 label=u'Available Resources', name='staticText1', parent=self, … … 1503 1504 def OnResourceBoxPopupAddMenu(self, event): 1504 1505 sn = self.resourceBox.GetSelection() 1505 tmpRes = self.resourceBox.GetPyData(sn) 1506 #if tmpRes.type != 'resource': 1507 # errorMsg(self,'You cannot add this type of resource') 1508 # return 1509 1510 tmpBaseName = tmpRes.name 1511 tmpCount = 1 1512 for c in self.active_wave.components: 1513 if c.baseName == tmpBaseName: 1514 tmpCount += 1 1515 1516 dlg = wx.TextEntryDialog(self, 'Please enter an instance name for this '\ 1517 + tmpRes.name + ' component.', 'Enter Name', tmpRes.name + str(tmpCount)) 1518 try: 1519 returnCode = dlg.ShowModal() 1520 if returnCode == wx.ID_OK: 1521 newname = dlg.GetValue() 1522 if len(newname) <= 0: 1523 errorMsg(self,'Invalid instance name.') 1524 dlg.Destroy() 1525 return 1506 tmpRes = None 1507 if (sn != self.resourceBox.GetRootItem() and self.resourceBox.GetItemParent(sn) != self.resourceBox.GetRootItem()): 1508 # a child component (Component or Device) 1509 tmpRes = self.resourceBox.GetPyData(sn) 1510 if tmpRes.type == 'resource': 1511 # errorMsg(self,'You cannot add this type of resource to a waveform. Right click to add to platform or node') 1512 # return 1513 tmpBaseName = tmpRes.name 1514 tmpCount = 1 1515 for c in self.active_wave.components: 1516 if c.baseName == tmpBaseName: 1517 tmpCount += 1 1518 1519 dlg = wx.TextEntryDialog(self, 'Please enter an instance name for this '\ 1520 + tmpRes.name + ' component.', 'Enter Name', tmpRes.name + str(tmpCount)) 1521 try: 1522 returnCode = dlg.ShowModal() 1523 if returnCode == wx.ID_OK: 1524 newname = dlg.GetValue() 1525 if len(newname) <= 0: 1526 errorMsg(self,'Invalid instance name.') 1527 dlg.Destroy() 1528 return 1526 1529 1527 for c in self.active_wave.components: 1528 if newname == c.name: 1529 errorMsg(self,'A component instance with this name already exists in your waveform.') 1530 for c in self.active_wave.components: 1531 if newname == c.name: 1532 errorMsg(self,'A component instance with this name already exists in your waveform.') 1533 dlg.Destroy() 1534 return 1535 elif returnCode == wx.ID_CANCEL: 1530 1536 dlg.Destroy() 1531 1537 return 1532 elif returnCode == wx.ID_CANCEL: 1533 dlg.Destroy() 1534 return 1535 finally: 1536 dlg.Destroy() 1537 1538 1539 newRes = copy.deepcopy(tmpRes) 1540 newRes.name = newname 1541 newRes.baseName = tmpBaseName 1542 newRes.setUUID() # this gives the component instance a unique id 1538 finally: 1539 dlg.Destroy() 1540 1541 1542 newRes = copy.deepcopy(tmpRes) 1543 newRes.name = newname 1544 newRes.baseName = tmpBaseName 1545 newRes.setUUID() # this gives the component instance a unique id 1543 1546 # we do not set the newRes.file_uuid because it is the same for all components of this type 1544 1547 1545 self.active_wave.components.append(newRes)1546 self.displayComps()1547 self.resourceBox.Unselect()1548 event.Skip()1548 self.active_wave.components.append(newRes) 1549 self.displayComps() 1550 self.resourceBox.Unselect() 1551 event.Skip() 1549 1552 1550 1553 def OnResourceBoxRightUp(self, event): … … 1599 1602 event.Skip() 1600 1603 1604 def OnResourceBoxLeftUp(self, event): 1605 self.OnResourceBoxPopupGetDescr(event) 1606 1607 def OnResourceBoxLeftDoubleClick(self, event): 1608 self.OnResourceBoxPopupAddMenu(event) 1609 1601 1610 def OnResourceBoxPopupAdddevMenu(self, event): 1602 1611 sn = self.resourceBox.GetSelection() … … 1669 1678 1670 1679 def OnResourceBoxPopupGetDescr(self, event): 1680 1671 1681 sn = self.resourceBox.GetSelection() 1672 tmpRes = self.resourceBox.GetPyData(sn) 1673 self.compDescrBox.Clear() 1674 self.compDescrBox.WriteText(tmpRes.name + ": " + tmpRes.description) 1682 tmpRes = None 1683 if (sn != self.resourceBox.GetRootItem() and self.resourceBox.GetItemParent(sn) != self.resourceBox.GetRootItem()): 1684 # a child component (Component or Device) 1685 tmpRes = self.resourceBox.GetPyData(sn) 1686 if tmpRes.type == 'resource': 1687 self.compDescrBox.Clear() 1688 self.compDescrBox.WriteText(tmpRes.name + ": " + tmpRes.description) 1675 1689 1676 1690 def OnResourceBoxPopupGetDoxygenRefMan(self, event):