コード例 #1
0
ファイル: menufile.go プロジェクト: axel-freesp/sge
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...
}
コード例 #2
0
ファイル: menufile.go プロジェクト: axel-freesp/sge
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)
}
コード例 #3
0
ファイル: menuedit.go プロジェクト: axel-freesp/sge
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))
}
コード例 #4
0
ファイル: menuedit.go プロジェクト: axel-freesp/sge
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)
	}
}
コード例 #5
0
ファイル: pastejob.go プロジェクト: axel-freesp/sge
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
}