Ejemplo n.º 1
0
func txNavComm(m sparta.Widget, e interface{}) bool {
	d := m.Property(sparta.Data)
	if d == nil {
		return true
	}
	data := d.(*txList)
	ev := e.(sparta.CommandEvent)
	switch ev.Source.Property(sparta.Name).(string) {
	case "taxonList":
		if ev.Value < 0 {
			i := -ev.Value - 1
			if i >= len(data.desc) {
				break
			}
			title := fmt.Sprintf("%s: please wait", cmd.Name)
			m.SetProperty(sparta.Caption, title)
			ev.Source.SetProperty(widget.ListList, nil)
			tx := wnd["info"]
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			sparta.Block(nil)
			go txNavInitList(m, ev.Source, data.db, data, i)
			break
		}
		if data.IsSel(ev.Value) {
			data.sels = nil
		} else {
			data.sels = []int{ev.Value}
		}
		tx := wnd["info"]
		tx.SetProperty(sparta.Data, nil)
		tx.Update()
		ev.Source.Update()
		sparta.Block(nil)
		go func() {
			txNavInfo(tx, data)
			sparta.Unblock(nil)
		}()
	case "upTax":
		if data.tax.Id == "0" {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		l := wnd["taxonList"]
		l.SetProperty(widget.ListList, nil)
		tx := wnd["info"]
		tx.SetProperty(sparta.Data, nil)
		sparta.Block(nil)
		go txNavAncList(m, l, data.db, data.tax)
	}
	return true
}
Ejemplo n.º 2
0
func txEdRun(c *cmdapp.Command, args []string) {
	cmd = c
	openLocal(c)
	title := fmt.Sprintf("%s: please wait", c.Name)
	m := widget.NewMainWindow("main", title)
	geo := m.Property(sparta.Geometry).(image.Rectangle)
	widget.NewButton(m, "upTax", "up", image.Rect(5, 5, 5+(sparta.WidthUnit*10), 5+(3*sparta.HeightUnit/2)))
	widget.NewButton(m, "val", "validate", image.Rect(10+(sparta.WidthUnit*10), 5, 10+(sparta.WidthUnit*20), 5+(3*sparta.HeightUnit/2)))
	widget.NewButton(m, "upVal", "up", image.Rect(270, 5, 270+(sparta.WidthUnit*10), 5+(3*sparta.HeightUnit/2)))
	widget.NewButton(m, "syn", "syn ->", image.Rect(205, 10+(3*sparta.HeightUnit/2), 205+(sparta.WidthUnit*10), 10+(6*sparta.HeightUnit/2)))
	widget.NewButton(m, "move", "move ->", image.Rect(205, 15+(6*sparta.HeightUnit/2), 205+(sparta.WidthUnit*10), 15+(9*sparta.HeightUnit/2)))

	l := widget.NewList(m, "taxonList", image.Rect(5, 10+(3*sparta.HeightUnit/2), 200, geo.Dy()-10))
	wnd["taxonList"] = l

	s := widget.NewList(m, "validList", image.Rect(210+(sparta.WidthUnit*10), 10+(3*sparta.HeightUnit/2), 405+(sparta.WidthUnit*10), geo.Dy()-10))
	wnd["validList"] = s

	m.Capture(sparta.Configure, txEdConf)
	m.Capture(sparta.Command, txEdComm)
	sparta.Block(nil)

	go func() {
		txEdInitList(m, l, nil, 0, true)
		txEdInitList(m, s, nil, 0, false)
		txEdSetCaption(m)
		sparta.Unblock(nil)
	}()

	sparta.Run()
}
Ejemplo n.º 3
0
func txNavRun(c *cmdapp.Command, args []string) {
	cmd = c
	var db jdh.DB
	if len(extDBFlag) != 0 {
		openExt(c, extDBFlag, "")
		db = extDB
	} else {
		openLocal(c)
		db = localDB
	}

	title := fmt.Sprintf("%s: please wait", c.Name)
	m := widget.NewMainWindow("main", title)
	geo := m.Property(sparta.Geometry).(image.Rectangle)
	widget.NewButton(m, "upTax", "up", image.Rect(5, 5, 5+(sparta.WidthUnit*10), 5+(3*sparta.HeightUnit/2)))
	tx := widget.NewCanvas(m, "info", image.Rect(210, 10+(3*sparta.HeightUnit/2), geo.Dx()-10, geo.Dy()-10))
	tx.SetProperty(sparta.Border, true)
	tx.Capture(sparta.Expose, txNavInfoExpose)
	wnd["info"] = tx
	l := widget.NewList(m, "taxonList", image.Rect(5, 10+(3*sparta.HeightUnit/2), 200, geo.Dy()-10))
	wnd["taxonList"] = l

	m.Capture(sparta.Configure, txNavConf)
	m.Capture(sparta.Command, txNavComm)
	sparta.Block(nil)
	go txNavInitList(m, l, db, nil, 0)

	sparta.Run()
}
Ejemplo n.º 4
0
func spNavRun(c *cmdapp.Command, args []string) {
	cmd = c
	var db jdh.DB
	openLocal(c)
	db = localDB

	title := fmt.Sprintf("%s: please wait", c.Name)
	m := widget.NewMainWindow("main", title)
	geo := m.Property(sparta.Geometry).(image.Rectangle)
	widget.NewButton(m, "upTax", "up", image.Rect(5, 5, 5+(sparta.WidthUnit*10), 5+(3*sparta.HeightUnit/2)))

	dy := geo.Dy() - 10 - (10 + (3 * sparta.HeightUnit / 2))

	l := widget.NewList(m, "taxonList", image.Rect(5, 10+(3*sparta.HeightUnit/2), 200, (dy/2)+10+(3*sparta.HeightUnit/2)))
	wnd["taxonList"] = l

	s := widget.NewList(m, "speList", image.Rect(210, 10+(3*sparta.HeightUnit/2), 410, (dy/2)+10+(3*sparta.HeightUnit/2)))
	wnd["speList"] = s

	tx := widget.NewCanvas(m, "info", image.Rect(5, (dy/2)+20+(3*sparta.HeightUnit/2), geo.Dx()-10, geo.Dy()-10))
	tx.SetProperty(sparta.Border, true)
	tx.Capture(sparta.Expose, spNavInfoExpose)
	wnd["info"] = tx

	m.Capture(sparta.Configure, spNavConf)
	m.Capture(sparta.Command, spNavComm)
	sparta.Block(nil)

	go func() {
		spNavInitTaxList(m, l, db, nil, 0)
		sparta.Unblock(nil)
	}()

	sparta.Run()
}
Ejemplo n.º 5
0
func txEdComm(m sparta.Widget, e interface{}) bool {
	ev := e.(sparta.CommandEvent)
	switch ev.Source.Property(sparta.Name).(string) {
	case "move":
		frWg := wnd["taxonList"]
		d := frWg.Property(widget.ListList)
		if d == nil {
			break
		}
		frLs := d.(*txList)
		if (len(frLs.sels) == 0) && (frLs.tax.Id == "0") {
			break
		}
		toWg := wnd["validList"]
		d = toWg.Property(widget.ListList)
		if d == nil {
			break
		}
		toLs := d.(*txList)
		var to *jdh.Taxon
		if len(toLs.sels) == 0 {
			to = toLs.tax
		} else {
			to = toLs.desc[toLs.sels[0]]
		}
		if (len(frLs.sels) == 0) && (frLs.tax.Id == to.Id) {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		frWg.SetProperty(widget.ListList, nil)
		toWg.SetProperty(widget.ListList, nil)
		sparta.Block(nil)
		go func() {
			if len(frLs.sels) == 0 {
				txEdMove(frLs.tax, to)
			} else {
				for _, s := range frLs.sels {
					from := frLs.desc[s]
					txEdMove(from, to)
				}
			}
			localDB.Exec(jdh.Commit, "", nil)
			txEdUpdateList(m, frWg, frLs, true)
			txEdUpdateList(m, toWg, toLs, false)
			txEdSetCaption(m)
			sparta.Unblock(nil)
		}()
	case "syn":
		frWg := wnd["taxonList"]
		d := frWg.Property(widget.ListList)
		if d == nil {
			break
		}
		frLs := d.(*txList)
		if (len(frLs.sels) == 0) && (frLs.tax.Id == "0") {
			break
		}
		toWg := wnd["validList"]
		d = toWg.Property(widget.ListList)
		if d == nil {
			break
		}
		toLs := d.(*txList)
		var to *jdh.Taxon
		if len(toLs.sels) == 0 {
			to = toLs.tax
		} else {
			to = toLs.desc[toLs.sels[0]]
		}
		if to.Id == "0" {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		frWg.SetProperty(widget.ListList, nil)
		toWg.SetProperty(widget.ListList, nil)
		sparta.Block(nil)
		go func() {
			if len(frLs.sels) == 0 {
				txEdSyn(frLs.tax, to)
			} else {
				for _, s := range frLs.sels {
					from := frLs.desc[s]
					txEdSyn(from, to)
				}
			}
			localDB.Exec(jdh.Commit, "", nil)
			txEdUpdateList(m, frWg, frLs, true)
			txEdUpdateList(m, toWg, toLs, false)
			txEdSetCaption(m)
			sparta.Unblock(nil)
		}()
	case "taxonList":
		d := ev.Source.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		if ev.Value < 0 {
			i := -ev.Value - 1
			if i >= len(data.desc) {
				break
			}
			title := fmt.Sprintf("%s: please wait", cmd.Name)
			m.SetProperty(sparta.Caption, title)
			ev.Source.SetProperty(widget.ListList, nil)
			sparta.Block(nil)
			go func() {
				txEdInitList(m, ev.Source, data, i, true)
				txEdSetCaption(m)
				sparta.Unblock(nil)
			}()
			break
		}
		sel := true
		for j, s := range data.sels {
			if s == ev.Value {
				sel = false
				data.sels[j] = data.sels[len(data.sels)-1]
				data.sels = data.sels[:len(data.sels)-1]
				break
			}
		}
		if sel {
			data.sels = append(data.sels, ev.Value)
		}
		ev.Source.Update()
		break
	case "upTax":
		l := wnd["taxonList"]
		d := l.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		if data.tax.Id == "0" {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		l.SetProperty(widget.ListList, nil)
		sparta.Block(nil)
		go func() {
			txEdAncList(m, l, data.tax, true)
			txEdSetCaption(m)
			sparta.Unblock(nil)
		}()
	case "upVal":
		l := wnd["validList"]
		d := l.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		if data.tax.Id == "0" {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		l.SetProperty(widget.ListList, nil)
		sparta.Block(nil)
		go func() {
			txEdAncList(m, l, data.tax, false)
			txEdSetCaption(m)
			sparta.Unblock(nil)
		}()
	case "val":
		frWg := wnd["taxonList"]
		d := frWg.Property(widget.ListList)
		if d == nil {
			break
		}
		frLs := d.(*txList)
		if len(frLs.sels) == 0 {
			if frLs.tax.Id == "0" {
				break
			}
			if frLs.tax.IsValid {
				break
			}
		}
		toWg := wnd["validList"]
		d = toWg.Property(widget.ListList)
		if d == nil {
			break
		}
		toLs := d.(*txList)
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		frWg.SetProperty(widget.ListList, nil)
		toWg.SetProperty(widget.ListList, nil)
		sparta.Block(nil)
		go func() {
			if len(frLs.sels) == 0 {
				txEdVal(frLs.tax)
			} else {
				for _, s := range frLs.sels {
					from := frLs.desc[s]
					txEdVal(from)
				}
			}
			localDB.Exec(jdh.Commit, "", nil)
			txEdUpdateList(m, frWg, frLs, true)
			txEdUpdateList(m, toWg, toLs, false)
			txEdSetCaption(m)
			sparta.Unblock(nil)
		}()
	case "validList":
		d := ev.Source.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		if ev.Value < 0 {
			i := -ev.Value - 1
			if i >= len(data.desc) {
				break
			}
			title := fmt.Sprintf("%s: please wait", cmd.Name)
			m.SetProperty(sparta.Caption, title)
			ev.Source.SetProperty(widget.ListList, nil)
			sparta.Block(nil)
			go func() {
				txEdInitList(m, ev.Source, data, i, false)
				txEdSetCaption(m)
				sparta.Unblock(nil)
			}()
			break
		}
		if data.IsSel(ev.Value) {
			data.sels = nil
		} else {
			data.sels = []int{ev.Value}
		}
		ev.Source.Update()
	}
	return true
}
Ejemplo n.º 6
0
func spNavComm(m sparta.Widget, e interface{}) bool {
	ev := e.(sparta.CommandEvent)
	switch ev.Source.Property(sparta.Name).(string) {
	case "speList":
		d := ev.Source.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*spList)
		i := ev.Value
		if ev.Value < 0 {
			i = -ev.Value - 1
		}
		tx := wnd["info"]
		if data.IsSel(i) {
			data.sel = -1
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			ev.Source.Update()
			break
		}
		data.sel = i
		tx.SetProperty(sparta.Data, nil)
		tx.Update()
		ev.Source.Update()
		sparta.Block(nil)
		go func() {
			spNavInfo(tx, data.db, data.spe[i], data.tax)
			sparta.Unblock(nil)
		}()
	case "taxonList":
		d := ev.Source.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		s := wnd["speList"]
		tx := wnd["info"]
		if ev.Value < 0 {
			i := -ev.Value - 1
			if i >= len(data.desc) {
				break
			}
			title := fmt.Sprintf("%s: please wait", cmd.Name)
			m.SetProperty(sparta.Caption, title)
			ev.Source.SetProperty(widget.ListList, nil)
			s.SetProperty(widget.ListList, nil)
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			sparta.Block(nil)
			go func() {
				spNavInitTaxList(m, ev.Source, data.db, data, i)
				sparta.Unblock(nil)
			}()
			break
		}
		if data.IsSel(ev.Value) {
			data.sels = nil
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			s.SetProperty(widget.ListList, nil)
		} else {
			data.sels = []int{ev.Value}
			tx.SetProperty(sparta.Data, nil)
			tx.Update()
			sparta.Block(nil)
			go func() {
				spNavInitSpeList(m, s)
				sparta.Unblock(nil)
			}()
		}
		ev.Source.Update()
	case "upTax":
		l := wnd["taxonList"]
		s := wnd["speList"]
		tx := wnd["info"]
		d := l.Property(widget.ListList)
		if d == nil {
			break
		}
		data := d.(*txList)
		if data.tax.Id == "0" {
			break
		}
		title := fmt.Sprintf("%s: please wait", cmd.Name)
		m.SetProperty(sparta.Caption, title)
		l.SetProperty(widget.ListList, nil)
		s.SetProperty(widget.ListList, nil)
		tx.SetProperty(sparta.Data, nil)
		tx.Update()
		sparta.Block(nil)
		go func() {
			spNavAncList(m, l, data.db, data.tax)
			spNavInitSpeList(m, s)
			sparta.Unblock(nil)
		}()
	}
	return true
}