| 331 | | plotBox = wx.StaticBox(cPanel, wx.NewId(), 'Uses Ports') |
| 332 | | plotBoxSizer = wx.StaticBoxSizer(plotBox, wx.HORIZONTAL) |
| 333 | | |
| 334 | | for port in component.usesPorts: |
| 335 | | plotButton = wx.Button(cPanel, wx.NewId(), label=port.name) |
| 336 | | cPanel.Bind(wx.EVT_BUTTON, self.OnPlotPort, plotButton) |
| 337 | | plotBoxSizer.Add(plotButton) |
| 338 | | sboxSizer.Add(plotBoxSizer) |
| | 338 | |
| | 339 | portsSizer = wx.BoxSizer(wx.HORIZONTAL) |
| | 340 | |
| | 341 | if len(component.providesPorts) > 0: |
| | 342 | providesPortsBox = self.createPortBox(component.providesPorts, component, cPanel, sboxSizer, 'Input Ports') |
| | 343 | portsSizer.Add(providesPortsBox) |
| | 344 | portsSizer.AddSpacer(wx.Size(10, 10)) |
| | 345 | if len(component.usesPorts) > 0: |
| | 346 | usesPortsBox = self.createPortBox(component.usesPorts, component, cPanel, sboxSizer, 'Output Ports') |
| | 347 | portsSizer.Add(usesPortsBox) |
| | 348 | sboxSizer.AddSpacer(wx.Size(10, 10)) |
| | 349 | sboxSizer.Add(portsSizer) |
| | 350 | |
| | 371 | def createPortBox(self, portList, component, panel, sizer, portType): |
| | 372 | portsBox = wx.StaticBox(panel, wx.NewId(), portType) |
| | 373 | portsBoxSizer = wx.StaticBoxSizer(portsBox, wx.VERTICAL) |
| | 374 | |
| | 375 | for port in portList: |
| | 376 | portLabel = wx.StaticText(panel, wx.NewId(), label=port.name) |
| | 377 | availableTools = self.tools.getSupportedTools(port.interface.nameSpace, port.interface.name) |
| | 378 | toolList = [] |
| | 379 | |
| | 380 | if availableTools: |
| | 381 | for tool in availableTools: |
| | 382 | toolList.append(tool.name) |
| | 383 | portToolCombo = wx.ComboBox(panel, wx.NewId(), value='Available Tools', choices=toolList, style=wx.CB_READONLY) |
| | 384 | portToolCombo.port = port |
| | 385 | portToolCombo.supportedTools = availableTools |
| | 386 | panel.Bind(wx.EVT_COMBOBOX, self.openTool, portToolCombo) |
| | 387 | else: |
| | 388 | portToolCombo = wx.ComboBox(panel, wx.NewId(), value='No Available Tools', choices=toolList, style=wx.CB_READONLY) |
| | 389 | |
| | 390 | portsBoxSizer.Add(portLabel) |
| | 391 | portsBoxSizer.Add(portToolCombo) |
| | 392 | return portsBoxSizer |
| | 393 | |
| | 394 | |
| | 1248 | def openTool(self, event): |
| | 1249 | src = event.GetEventObject() |
| | 1250 | toolName = src.GetValue() |
| | 1251 | if toolName == 'Available Tools': |
| | 1252 | return |
| | 1253 | compName = src.GetParent().GetName() |
| | 1254 | waveformName = src.GetParent().GetParent().GetName() |
| | 1255 | waveform = self.model.getWaveform(waveformName, WaveformModel.INSTANCE_WAVEFORM) |
| | 1256 | component = waveform.getComponent(compName) |
| | 1257 | port = src.port |
| | 1258 | for t in src.supportedTools: |
| | 1259 | if t.name == toolName: |
| | 1260 | tool = t |
| | 1261 | break |
| | 1262 | |
| | 1263 | if tool.module == None: |
| | 1264 | # NOTE: alf_plugins is now the package that contains all tools |
| | 1265 | exec_string = "from alf_plugins." + tool.packagename + " import " |
| | 1266 | exec_string += tool.modulename + " as tool_module" |
| | 1267 | exec exec_string |
| | 1268 | |
| | 1269 | tool.module = tool_module |
| | 1270 | else: |
| | 1271 | tool_module = tool.module |
| | 1272 | reload(tool_module) |
| | 1273 | |
| | 1274 | if port: |
| | 1275 | context = ("DomainName1", str('OSSIE::' + waveformName), str(compName)) |
| | 1276 | newframe = tool_module.create(self, str(port.interface.nameSpace), |
| | 1277 | str(port.interface.name), context, str(port.name)) |
| | 1278 | newframe.Show(True) |
| | 1279 | src.SetValue('Available Tools') |