Exemplo n.º 1
0
func (d *ProjectTree) SetProject(project string) {
	for _, proj := range settings.Projects() {
		if proj.Name == project {
			d.SetRoot(proj.Path)
			return
		}
	}
	panic(fmt.Errorf("Could not find project %s", project))
}
Exemplo n.º 2
0
func (p *Projects) Init(driver gxui.Driver, theme *basic.Theme) {
	p.driver = driver
	p.theme = theme
	p.button = createIconButton(driver, theme, "projects.png")
	p.projects = theme.CreateList()
	p.projectsAdapter = gxui.CreateDefaultAdapter()

	p.projectsAdapter.SetItems(settings.Projects())
	p.projects.SetAdapter(p.projectsAdapter)
}
Exemplo n.º 3
0
func NewProjectsPane(driver gxui.Driver, theme gxui.Theme, projFrame gxui.Control) *Projects {
	pane := &Projects{
		theme:           theme,
		projectFrame:    projFrame,
		button:          createIconButton(driver, theme, "projects.png"),
		projects:        theme.CreateList(),
		projectsAdapter: gxui.CreateDefaultAdapter(),
	}
	pane.projectsAdapter.SetItems(settings.Projects())
	pane.projects.SetAdapter(pane.projectsAdapter)
	return pane
}
Exemplo n.º 4
0
func (p *ProjectAdder) Exec(element interface{}) (executed, consume bool) {
	if projects, ok := element.(projectPane); ok {
		project := p.Project()
		for _, prevProject := range settings.Projects() {
			if prevProject.Name == project.Name {
				// TODO: Let the user choose a new name
				p.err = fmt.Sprintf("There is already a project named %s", project.Name)
				return true, true
			}
		}
		settings.AddProject(project)
		projects.Add(project)
		return true, true
	}
	return false, false
}
Exemplo n.º 5
0
func (p *ProjectOpener) Exec(element interface{}) (executed, consume bool) {
	setter, ok := element.(projectSetter)
	if !ok {
		return false, false
	}
	var proj settings.Project
	for _, proj = range settings.Projects() {
		if proj.Name == p.name.Text() {
			break
		}
	}
	if proj.Name != p.name.Text() {
		p.err = fmt.Sprintf("No project by the name of %s found", p.name.Text())
		return false, false
	}
	setter.SetProject(proj)
	return true, false
}