Пример #1
0
func fileNewMap(fts *models.FilesTreeStore, ftv *views.FilesTreeView) {
	var sgname, pfname string
	var ok bool
	sgname, ok = runFileDialog([]FileType{FileTypeGraph}, false, "Choose Signal Graph")
	if !ok {
		return
	}
	pfname, ok = runFileDialog([]FileType{FileTypePlat}, false, "Choose Platform")
	if !ok {
		return
	}
	var f tr.ToplevelTreeElementIf
	var err error
	prefix, fname := dirMgr.FilenameToShow(sgname)
	f, err = global.SignalGraphMgr().Access(fname)
	if err != nil {
		log.Printf("fileNewMap: %s\n", err)
		return
	}
	f.SetPathPrefix(prefix)
	global.MappingMgr().SetGraphForNew(f.(bh.SignalGraphIf))
	prefix, fname = dirMgr.FilenameToShow(pfname)
	f, err = global.PlatformMgr().Access(fname)
	if err != nil {
		log.Printf("fileNewMap: %s\n", err)
		return
	}
	f.SetPathPrefix(prefix)
	global.MappingMgr().SetPlatformForNew(f.(pf.PlatformIf))
	_, err = global.MappingMgr().New()
	if err != nil {
		log.Printf("fileNewMap: %s\n", err)
		return
	}
}
Пример #2
0
func fileOpen(fts *models.FilesTreeStore, ftv *views.FilesTreeView) {
	log.Println("fileOpen")
	filename, ok := getFilenameToOpen()
	if !ok {
		return
	}
	prefix, fname := dirMgr.FilenameToShow(filename)
	var err error
	var obj tr.ToplevelTreeElementIf
	var fileMgr mod.FileManagerIf
	fileMgr, err = getFileMgr(FileType(tool.Suffix(fname)))
	obj, err = fileMgr.Access(fname)
	if err != nil {
		log.Printf("fileOpen error: %s\n", err)
		return
	}
	obj.SetPathPrefix(prefix)
	dirMgr.SetCurrent(fileType(obj), tool.Dirname(fname))
}