func buildConnectionArea()

in plc4go/tools/plc4xbrowser/ui/ui.go [69:111]


func buildConnectionArea(newPrimitive func(text string) tview.Primitive, application *tview.Application) tview.Primitive {
	connectionAreaHeader := newPrimitive("Connections")
	connectionArea := tview.NewGrid().
		SetRows(3, 0, 10).
		SetColumns(0).
		AddItem(connectionAreaHeader, 0, 0, 1, 1, 0, 0, false)
	{
		connectionList := tview.NewList()
		connectionsChanged = func() {
			application.QueueUpdateDraw(func() {
				connectionList.Clear()
				for connectionString, connection := range connections {
					connectionList.AddItem(connectionString, "", 0x0, func() {
						//TODO: disconnect popup
						_ = connection
					})
				}
			})
		}
		connectionArea.AddItem(connectionList, 1, 0, 1, 1, 0, 0, false)
		{
			registeredDriverAreaHeader := newPrimitive("Registered drivers")
			registeredDriverArea := tview.NewGrid().
				SetRows(3, 0).
				SetColumns(0).
				AddItem(registeredDriverAreaHeader, 0, 0, 1, 1, 0, 0, false)
			{
				driverList := tview.NewList()
				driverAdded = func(driver plc4go.PlcDriver) {
					application.QueueUpdateDraw(func() {
						driverList.AddItem(driver.GetProtocolCode(), tview.Escape(fmt.Sprintf("%s", driver)), 0x0, func() {
							//TODO: disconnect popup
						})
					})
				}
				registeredDriverArea.AddItem(driverList, 1, 0, 1, 1, 0, 0, false)
			}
			connectionArea.AddItem(registeredDriverArea, 2, 0, 1, 1, 0, 0, false)
		}

	}
	return connectionArea
}