当前位置: 首页>>代码示例>>Golang>>正文


Golang models.FilesTreeStore类代码示例

本文整理汇总了Golang中github.com/axel-freesp/sge/models.FilesTreeStore的典型用法代码示例。如果您正苦于以下问题:Golang FilesTreeStore类的具体用法?Golang FilesTreeStore怎么用?Golang FilesTreeStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FilesTreeStore类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: init

// Initialize view to reflect the model:
func (v *FilesTreeView) init(model *models.FilesTreeStore) error {
	renderer1, err := gtk.CellRendererTextNew()
	if err != nil {
		return fmt.Errorf("Error CellRendererTextNew:", err)
	}
	renderer2, err := gtk.CellRendererPixbufNew()
	if err != nil {
		return fmt.Errorf("Error CellRendererPixbufNew:", err)
	}
	col1, err := gtk.TreeViewColumnNewWithAttribute("Type", renderer2, "pixbuf", 0)
	if err != nil {
		return fmt.Errorf("Error col1:", err)
	}
	col2, err := gtk.TreeViewColumnNewWithAttribute("Name", renderer1, "text", 1)
	if err != nil {
		return fmt.Errorf("Error col2:", err)
	}
	v.view, err = gtk.TreeViewNewWithModel(model.TreeStore())
	if err != nil {
		return fmt.Errorf("Error TreeViewNew", err)
	}
	v.view.AppendColumn(col1)
	v.view.AppendColumn(col2)
	v.scrolled.Add(v.view)
	return nil
}
开发者ID:axel-freesp,项目名称:sge,代码行数:27,代码来源:filestreeview.go

示例2: getCurrentTopObject

func getCurrentTopObject(fts *models.FilesTreeStore) tr.ToplevelTreeElementIf {
	id0 := getToplevelId(fts)
	obj, err := fts.GetObjectById(id0)
	if err != nil {
		log.Fatal("fileSave error: fts.GetObjectByPath failed:", err)
	}
	return obj.(tr.ToplevelTreeElementIf)
}
开发者ID:axel-freesp,项目名称:sge,代码行数:8,代码来源:menufile.go

示例3: getToplevelId

func getToplevelId(fts *models.FilesTreeStore) string {
	p := fts.GetCurrentId()
	if p == "" {
		log.Fatal("fileSave error: fts.GetCurrentId() failed")
	}
	spl := strings.Split(p, ":")
	return spl[0] // TODO: move to function in fts...
}
开发者ID:axel-freesp,项目名称:sge,代码行数:8,代码来源:menufile.go

示例4: MenuEditPost

func MenuEditPost(menu *GoAppMenu, fts *models.FilesTreeStore, jl IJobList) {
	MenuEditCurrent(menu, fts, jl)
	cursor := fts.Current()
	var obj tr.TreeElementIf
	if len(cursor.Path) != 0 {
		obj = fts.Object(cursor)
	}
	global.GVC().XmlTextView().Set(obj)
	global.GVC().Sync()
}
开发者ID:axel-freesp,项目名称:sge,代码行数:10,代码来源:menuedit.go

示例5: fileClose

func fileClose(menu *GoAppMenu, fts *models.FilesTreeStore, ftv *views.FilesTreeView, jl IJobList) {
	path := fts.GetCurrentId()
	if strings.Contains(path, ":") {
		path = strings.Split(path, ":")[0]
	}
	obj, err := fts.GetObjectById(path)
	if err != nil {
		return
	}
	global.FileMgr(obj).Remove(obj.(fd.Filenamer).Filename())
	jl.Reset()
	MenuEditPost(menu, fts, jl)
}
开发者ID:axel-freesp,项目名称:sge,代码行数:13,代码来源:menufile.go

示例6: editCopy

func editCopy(fts *models.FilesTreeStore, clp *gtk.Clipboard) {
	var buf []byte
	obj, err := fts.GetObjectById(fts.GetCurrentId())
	if err != nil {
		log.Printf("editCopy error: %s\n", err)
		return
	}
	buf, err = obj.(gr.XmlCreator).CreateXml()
	if err != nil {
		log.Printf("editCopy error: %s\n", err)
		return
	}
	clp.SetText(string(buf))
}
开发者ID:axel-freesp,项目名称:sge,代码行数:14,代码来源:menuedit.go

示例7: editDelete

func editDelete(menu *GoAppMenu, fts *models.FilesTreeStore, jl IJobList, ftv *views.FilesTreeView) {
	defer MenuEditPost(menu, fts, jl)
	job := DeleteObjectJobNew(fts.GetCurrentId())
	state, ok := jl.Apply(EditorJobNew(JobDeleteObject, job))
	if ok {
		global.win.graphViews.Sync()
		path, err := gtk.TreePathNewFromString(state.(string))
		if err != nil {
			log.Println("editNew error: TreePathNewFromString failed:", err)
			return
		}
		ftv.TreeView().ExpandToPath(path)
		ftv.TreeView().SetCursor(path, ftv.TreeView().GetExpanderColumn(), false)
	}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:15,代码来源:menuedit.go

示例8: MenuEditCurrent

func MenuEditCurrent(menu *GoAppMenu, fts *models.FilesTreeStore, jl IJobList) {
	menu.editUndo.SetSensitive(jl.CanUndo())
	menu.editRedo.SetSensitive(jl.CanRedo())
	var prop tr.Property
	cursor := fts.Current()
	if len(cursor.Path) != 0 {
		prop = fts.Property(cursor)
		menu.editNew.SetSensitive(prop.MayAddObject())
		menu.editDelete.SetSensitive(prop.MayRemove())
		menu.editEdit.SetSensitive(prop.MayEdit())
	} else {
		menu.editNew.SetSensitive(false)
		menu.editDelete.SetSensitive(false)
		menu.editEdit.SetSensitive(false)
	}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:16,代码来源:menuedit.go

示例9: EditObject

func (j *EditJob) EditObject(fts *models.FilesTreeStore, direction EditJobDirection) (state string, err error) {
	var detail, old *map[inputElement]string
	if direction == EditJobForward {
		detail, old = &j.detail, &j.old
	} else {
		old, detail = &j.detail, &j.old
	}
	var obj tr.TreeElementIf
	obj, err = fts.GetObjectById(j.objId)
	state = j.objId
	switch j.elemType {
	case eNode:
		n := obj.(bh.NodeIf)
		(*old)[iNodeName] = n.Name()
		n.SetName((*detail)[iNodeName])
		fts.SetValueById(j.objId, n.Name())
		for _, p := range n.InPorts() {
			updateConnections(p, fts)
		}
		for _, p := range n.OutPorts() {
			updateConnections(p, fts)
		}
	case eOutputNode:
		n := obj.(bh.NodeIf)
		(*old)[iOutputNodeName] = n.Name()
		n.SetName((*detail)[iOutputNodeName])
		fts.SetValueById(j.objId, n.Name())
		for _, p := range n.InPorts() {
			updateConnections(p, fts)
		}
	case eInputNode:
		n := obj.(bh.NodeIf)
		(*old)[iInputNodeName] = n.Name()
		n.SetName((*detail)[iInputNodeName])
		fts.SetValueById(j.objId, n.Name())
		for _, p := range n.OutPorts() {
			updateConnections(p, fts)
		}
	case eNodeType:
		nt := obj.(bh.NodeTypeIf)
		if len(nt.Instances()) > 0 {
			log.Printf("jobApplier.Apply(JobEdit): WARNING: NodeTypeIf %s has instances.\n", nt.TypeName())
			log.Printf("jobApplier.Apply(JobEdit): Editing is not implemented in this case.\n")
			return
		}
		(*old)[iTypeName] = nt.TypeName()
		nt.SetTypeName((*detail)[iTypeName])
		fts.SetValueById(j.objId, nt.TypeName())
	case ePortType:
		pt := obj.(bh.PortTypeIf)
		ptCursor := fts.Cursor(pt)
		ntCursor := fts.Parent(ptCursor)
		nt := fts.Object(ntCursor).(bh.NodeTypeIf)
		if len(nt.Instances()) > 0 {
			log.Printf("jobApplier.Apply(JobEdit): WARNING: NodeTypeIf %s has instances.\n", nt.TypeName())
			log.Printf("jobApplier.Apply(JobEdit): Editing is not implemented in this case.\n")
			return
		}
		(*old)[iPortName] = pt.Name()
		(*old)[iSignalTypeSelect] = pt.SignalType().TypeName()
		(*old)[iDirection] = direction2string[pt.Direction()]
		fts.DeleteObject(ptCursor.Path)
		fts.AddNewObject(ntCursor.Path, ntCursor.Position,
			behaviour.PortTypeNew((*detail)[iPortName],
				(*detail)[iSignalTypeSelect],
				string2direction[(*detail)[iDirection]]))
		state = ptCursor.Path
	case eSignalType:
		st := obj.(bh.SignalTypeIf)
		if (*detail)[iSignalTypeName] != st.TypeName() {
			log.Printf("jobApplier.Apply(JobEdit): Renaming SignalType is not implemented.\n")
		}
		(*old)[iCType] = st.CType()
		st.SetCType((*detail)[iCType])
		(*old)[iChannelId] = st.ChannelId()
		st.SetChannelId((*detail)[iChannelId])
		(*old)[iScope] = scope2string[st.Scope()]
		st.SetScope(string2scope[(*detail)[iScope]])
		(*old)[iSignalMode] = mode2string[st.Mode()]
		st.SetMode(string2mode[(*detail)[iSignalMode]])
	case eImplementation:
		impl := obj.(bh.ImplementationIf)
		(*old)[iImplName] = impl.ElementName()
		impl.SetElemName((*detail)[iImplName])
		fts.SetValueById(j.objId, (*detail)[iImplName])
	case eArch:
		a := obj.(pf.ArchIf)
		(*old)[iArchName] = a.Name()
		a.SetName((*detail)[iArchName])
		for _, p := range a.Processes() {
			for _, c := range p.InChannels() {
				link := c.Link()
				id := fts.Cursor(link)
				fts.SetValueById(id.Path, link.Name())
			}
			for _, c := range p.OutChannels() {
				link := c.Link()
				id := fts.Cursor(link)
				fts.SetValueById(id.Path, link.Name())
			}
//.........这里部分代码省略.........
开发者ID:axel-freesp,项目名称:sge,代码行数:101,代码来源:editjob.go

示例10: updateConnections

func updateConnections(p bh.PortIf, fts *models.FilesTreeStore) {
	nodeCursor := fts.Cursor(p.Node())
	portCursor := fts.CursorAt(nodeCursor, p)
	for _, c := range p.Connections() {
		conn := p.Connection(c)
		connCursor := fts.CursorAt(portCursor, conn)
		otherNode := c.Node()
		otherNodeCursor := fts.Cursor(otherNode)
		otherPortCursor := fts.CursorAt(otherNodeCursor, c)
		otherConnCursor := fts.CursorAt(otherPortCursor, conn)
		connText := fmt.Sprintf("%s/%s -> %s/%s",
			conn.From().Node().Name(), conn.From().Name(),
			conn.To().Node().Name(), conn.To().Name())
		fts.SetValueById(connCursor.Path, connText)
		fts.SetValueById(otherConnCursor.Path, connText)
	}
}
开发者ID:axel-freesp,项目名称:sge,代码行数:17,代码来源:editjob.go

示例11: ParseText

func ParseText(text string, fts *models.FilesTreeStore) (job *EditorJob, err error) {
	var parent tr.TreeElementIf
	context := fts.GetCurrentId()
	if len(context) == 0 {
		err = fmt.Errorf("NewElementJob.ParseText TODO: Toplevel elements not implemented")
		return
	}
	parent, err = fts.GetObjectById(context)
	if err != nil {
		return
	}
	var ok bool
	var j *PasteJob
	switch parent.(type) {
	case bh.SignalGraphIf:
		j, ok = parseNode(text, context, parent.(bh.SignalGraphIf).ItsType())
		if ok {
			job = EditorJobNew(JobPaste, j)
			//log.Printf("NewElementJob.ParseText: successfully parsed SignalGraphIf\n")
			return
		}

	case bh.SignalGraphTypeIf:
		j, ok = parseNode(text, context, parent.(bh.SignalGraphTypeIf))
		if ok {
			job = EditorJobNew(JobPaste, j)
			//log.Printf("NewElementJob.ParseText: successfully parsed SignalGraphTypeIf\n")
			return
		}

	case bh.NodeIf:
		j, ok = parseNode(text, getParentId(context), parent.(bh.NodeIf).Context())
		if ok {
			job = EditorJobNew(JobPaste, j)
			//log.Printf("NewElementJob.ParseText: successfully parsed NodeIf\n")
			return
		}

	case bh.NodeTypeIf:
		j, ok = parseNodeType(text, getParentId(context))
		if ok {
			job = EditorJobNew(JobPaste, j)
			//log.Printf("NewElementJob.ParseText: successfully parsed NodeTypeIf\n")
			return
		}

	case bh.PortIf:

	case bh.PortTypeIf:

	case bh.ConnectionIf:

	case bh.SignalTypeIf:
		j, ok = parseSignalType(text, getParentId(context))
		if ok {
			job = EditorJobNew(JobPaste, j)
			//log.Printf("NewElementJob.ParseText: successfully parsed SignalTypeIf\n")
			return
		}

	case bh.LibraryIf:
		j, ok = parseNodeType(text, context)
		if ok {
			job = EditorJobNew(JobPaste, j)
			log.Printf("NewElementJob.ParseText: successfully parsed NodeTypeIf\n")
			return
		}
		j, ok = parseSignalType(text, context)
		if ok {
			job = EditorJobNew(JobPaste, j)
			log.Printf("NewElementJob.ParseText: successfully parsed SignalTypeIf\n")
			return
		}

	case bh.ImplementationIf:

	default:
		err = fmt.Errorf("NewElementJob.ParseText error: can't insert to context %T", parent)
		return
	}

	err = fmt.Errorf("NewElementJob.ParseText error: function not implemented")
	return
}
开发者ID:axel-freesp,项目名称:sge,代码行数:84,代码来源:pastejob.go

示例12: setCurrentTopValue

func setCurrentTopValue(fts *models.FilesTreeStore, value string) {
	id0 := getToplevelId(fts)
	fts.SetValueById(id0, value)
}
开发者ID:axel-freesp,项目名称:sge,代码行数:4,代码来源:menufile.go

示例13: CreateObject

func (j *NewElementJob) CreateObject(fts *models.FilesTreeStore) (ret tr.TreeElementIf, err error) {
	var parentObject tr.TreeElementIf
	parentObject, err = fts.GetObjectById(j.parentId)
	if err != nil {
		log.Fatal("NewElementJob.CreateObject error: referenced parentObject run away...")
	}
	switch j.elemType {
	case eNode, eInputNode, eOutputNode:
		var context bh.SignalGraphTypeIf
		switch parentObject.(type) {
		case bh.NodeIf:
			context = parentObject.(bh.NodeIf).Context()
			j.parentId = getParentId(j.parentId)
		case bh.SignalGraphIf:
			context = parentObject.(bh.SignalGraphIf).ItsType()
		case bh.SignalGraphTypeIf:
			context = parentObject.(bh.SignalGraphTypeIf)
		case bh.ImplementationIf:
			if parentObject.(bh.ImplementationIf).ImplementationType() == bh.NodeTypeGraph {
				context = parentObject.(bh.ImplementationIf).Graph()
			} else {
				log.Fatal("NewElementJob.CreateObject(eNode) error: parent implementation is no graph...")
			}
		default:
			log.Fatal("NewElementJob.CreateObject(eNode) error: referenced parentObject wrong type...")
		}
		if j.elemType == eNode {
			ntype, ok := freesp.GetNodeTypeByName(j.input[iNodeTypeSelect])
			if !ok {
				log.Fatal("NewElementJob.CreateObject(eNode) error: referenced parentObject type wrong...")
			}
			ret, err = behaviour.NodeNew(j.input[iNodeName], ntype, context)
		} else if j.elemType == eInputNode {
			ret, err = behaviour.InputNodeNew(j.input[iInputNodeName], j.input[iInputTypeSelect], context)
		} else {
			ret, err = behaviour.OutputNodeNew(j.input[iOutputNodeName], j.input[iOutputTypeSelect], context)
		}
		if len(j.extra) > 0 {
			coords := strings.Split(j.extra, "|")
			var x, y int
			fmt.Sscanf(coords[0], "%d", &x)
			fmt.Sscanf(coords[1], "%d", &y)
			//pos := image.Point{x, y}
			//log.Printf("NewElementJob.CreateObject(eNode) setting position %s: %v\n", j.extra, pos)
			//ret.(bh.NodeIf).SetPosition(pos)
			// TODO: SetModePosition...
		}

	case eNodeType:
		var context string
		switch parentObject.(type) {
		case bh.NodeTypeIf:
			context = parentObject.(bh.NodeTypeIf).DefinedAt()
			j.parentId = getParentId(j.parentId)
		case bh.SignalTypeIf:
			j.parentId = getParentId(j.parentId)
			parentObject, err = fts.GetObjectById(j.parentId)
			context = parentObject.(bh.LibraryIf).Filename()
		case bh.LibraryIf:
			context = parentObject.(bh.LibraryIf).Filename()
		default:
			log.Fatal("NewElementJob.CreateObject(eNodeType) error: referenced parentObject wrong type...")
		}
		ret = behaviour.NodeTypeNew(j.input[iTypeName], context)

	case eConnection:
		switch parentObject.(type) {
		case bh.PortIf:
		case bh.SignalGraphTypeIf:
			fromTo := strings.Split(j.extra, "/")
			var n bh.NodeIf
			for _, n = range parentObject.(bh.SignalGraphTypeIf).Nodes() {
				if n.Name() == fromTo[0] {
					for _, parentObject = range n.OutPorts() {
						if parentObject.(bh.PortIf).Name() == fromTo[1] {
							break
						}
					}
					break
				}
			}
			if parentObject == nil {
				log.Fatalf("NewElementJob.CreateObject(eNodeType) error: no valid FROM port for edge job %v\n", j)
			}
			_ = parentObject.(bh.PortIf)
		case bh.ImplementationIf:
			fromTo := strings.Split(j.extra, "/")
			var n bh.NodeIf
			for _, n = range parentObject.(bh.ImplementationIf).Graph().Nodes() {
				if n.Name() == fromTo[0] {
					for _, parentObject = range n.OutPorts() {
						if parentObject.(bh.PortIf).Name() == fromTo[1] {
							break
						}
					}
					break
				}
			}
			if parentObject == nil {
				log.Fatalf("NewElementJob.CreateObject(eNodeType) error: no valid FROM port for edge job %v\n", j)
//.........这里部分代码省略.........
开发者ID:axel-freesp,项目名称:sge,代码行数:101,代码来源:newelementjob.go


注:本文中的github.com/axel-freesp/sge/models.FilesTreeStore类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。