Changeset 4225

Show
Ignore:
Timestamp:
06/25/07 16:48:31 (6 years ago)
Author:
cdietric
Message:

left click on component shows description, left double click adds component to waveform

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • WaveDev/trunk/WaveDev/wavedev/MainFrame.py

    r4222 r4225  
    381381        self.resourceBox.SetBestFittingSize(wx.Size(175, 396)) 
    382382        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) 
    384385        self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1, 
    385386              label=u'Available Resources', name='staticText1', parent=self, 
     
    15031504    def OnResourceBoxPopupAddMenu(self, event): 
    15041505        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 
    15261529                 
    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: 
    15301536                        dlg.Destroy() 
    15311537                        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 
    15431546        # we do not set the newRes.file_uuid because it is the same for all components of this type 
    15441547         
    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() 
    15491552 
    15501553    def OnResourceBoxRightUp(self, event): 
     
    15991602        event.Skip() 
    16001603 
     1604    def OnResourceBoxLeftUp(self, event): 
     1605        self.OnResourceBoxPopupGetDescr(event) 
     1606 
     1607    def OnResourceBoxLeftDoubleClick(self, event): 
     1608        self.OnResourceBoxPopupAddMenu(event) 
     1609 
    16011610    def OnResourceBoxPopupAdddevMenu(self, event): 
    16021611        sn = self.resourceBox.GetSelection() 
     
    16691678 
    16701679    def OnResourceBoxPopupGetDescr(self, event): 
     1680 
    16711681        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) 
    16751689 
    16761690    def OnResourceBoxPopupGetDoxygenRefMan(self, event):