2
// <copyright see="prj:///doc/copyright.txt"/>
3
// <license see="prj:///doc/license.txt"/>
4
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
5
// <version value="$version"/>
9
using System.Collections;
10
using System.Collections.Specialized;
11
using System.ComponentModel;
13
using MonoDevelop.Core.Properties;
14
using MonoDevelop.Core.Services;
15
using MonoDevelop.Services;
16
using MonoDevelop.Gui;
17
using MonoDevelop.Internal.Project;
21
namespace MonoDevelop.Internal.Project
23
public class IncludeFilesDialog
26
[Glade.Widget] Button okbutton;
27
[Glade.Widget] Button cancelbutton;
28
[Glade.Widget] Button selectAllButton;
29
[Glade.Widget] Button deselectAllButton;
30
[Glade.Widget] RadioButton newFilesOnlyRadioButton;
31
[Glade.Widget] RadioButton allFilesRadioButton;
32
[Glade.Widget] Label newFilesInProjectLabel;
33
[Glade.Widget] Label viewLabel;
34
[Glade.Widget] TreeView IncludeFileListView;
35
[Glade.Widget] Dialog IncludeFilesDialogWidget;
36
public ListStore store;
39
StringCollection newFiles;
41
FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.GetService(typeof(FileUtilityService));
43
public IncludeFilesDialog(IProject project, StringCollection newFiles)
45
Console.WriteLine ("*** Include files dialog ***");
46
// we must do it from *here* otherwise, we get this assembly, not the caller
47
Glade.XML glade = new Glade.XML (null, "Base.glade", "IncludeFilesDialogWidget", null);
48
glade.Autoconnect (this);
50
// set up dialog title
51
this.IncludeFilesDialogWidget.Title = String.Format (GettextCatalog.GetString ("Found new files in {0}"), project.Name);
53
newFilesOnlyRadioButton.Active = true;
54
this.newFiles = newFiles;
55
this.project = project;
57
this.InitialiseIncludeFileList();
59
// wire in event handlers
60
okbutton.Clicked += new EventHandler(AcceptEvent);
61
cancelbutton.Clicked += new EventHandler(CancelEvent);
62
selectAllButton.Clicked += new EventHandler(SelectAll);
63
deselectAllButton.Clicked += new EventHandler(DeselectAll);
65
// FIXME: I'm pretty sure that these radio buttons
66
// don't actually work in SD 0.98 either, so disabling them
67
newFilesOnlyRadioButton.Sensitive = false;
68
allFilesRadioButton.Sensitive = false;
71
#region includeFileListView methods and events
73
// initialises and populates the include file list tree view
74
private void InitialiseIncludeFileList()
76
// set up the list store and treeview
77
store = new ListStore (typeof(bool), typeof(string));
78
IncludeFileListView.Selection.Mode = SelectionMode.None;
79
IncludeFileListView.Model = store;
80
CellRendererToggle rendererToggle = new CellRendererToggle ();
81
rendererToggle.Activatable = true;
82
rendererToggle.Toggled += new ToggledHandler (ItemToggled);
83
IncludeFileListView.AppendColumn ("Choosen", rendererToggle, "active", 0);
84
IncludeFileListView.AppendColumn ("Name", new CellRendererText (), "text", 1);
85
TreeIter iter = new TreeIter ();
87
// add the found files to the check list box
88
foreach (string file in newFiles) {
89
string name = fileUtilityService.AbsoluteToRelativePath(project.BaseDirectory, file);
90
iter = store.AppendValues (false, name);
94
private void ItemToggled (object o, ToggledArgs args)
99
if (store.GetIterFromString(out iter, args.Path)) {
100
bool val = (bool) store.GetValue(iter, column);
101
store.SetValue(iter, column, !val);
107
void AcceptEvent(object sender, EventArgs e)
110
store.GetIterFirst(out first);
111
TreeIter current = first;
112
for (int i = 0; i < store.IterNChildren() ; ++i) {
113
// get column raw values
114
bool isSelected = (bool) store.GetValue(current, 0);
115
string fileName = (string) store.GetValue(current, 1);
117
// process raw values into actual project details
118
string file = fileUtilityService.RelativeToAbsolutePath(project.BaseDirectory,fileName);
119
ProjectFile finfo = new ProjectFile(file);
121
finfo.BuildAction = project.IsCompileable(file) ? BuildAction.Compile : BuildAction.Nothing;
123
finfo.BuildAction = BuildAction.Exclude;
125
project.ProjectFiles.Add(finfo);
127
store.IterNext(ref current);
130
IncludeFilesDialogWidget.Destroy();
133
void CancelEvent(object sender, EventArgs e)
135
IncludeFilesDialogWidget.Destroy();
138
void SelectAll(object sender, EventArgs e)
140
SetAllCheckedValues(true);
143
void DeselectAll(object sender, EventArgs e)
145
SetAllCheckedValues(false);
148
private void SetAllCheckedValues(bool value)
151
store.GetIterFirst(out first);
152
TreeIter current = first;
153
for (int i = 0; i < store.IterNChildren() ; ++i) {
154
store.SetValue(current, 0, value);
156
store.IterNext(ref current);
160
public void ShowDialog()
162
this.IncludeFilesDialogWidget.Run();