blob: 1c90564ec312d530b4a2f9d5cad7ad79aff92d3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
using System;
using MonoDevelop.Core.Collections;
using MonoDevelop.Components.Commands;
using MonoDevelop.Projects;
using MonoDevelop.Ide.Gui.Components;
using MonoDevelop.Ide;
namespace MonoDevelop.Autotools
{
class FileNodeBuilderExtension: NodeBuilderExtension
{
public override bool CanBuildNode (Type dataType)
{
return typeof(ProjectFile).IsAssignableFrom (dataType);
}
public override Type CommandHandlerType {
get { return typeof(FileNodeCommandHandler); }
}
}
class FileNodeCommandHandler: NodeCommandHandler
{
const string infoProperty = "MonoDevelop.Autotools.MakefileInfo";
[CommandHandler (Commands.SynchWithMakefile)]
[AllowMultiSelection]
public void OnExclude ()
{
//if all of the selection is already checked, then toggle checks them off
//else it turns them on. hence we need to find if they're all checked,
bool allChecked = true;
foreach (ITreeNavigator node in CurrentNodes) {
ProjectFile file = (ProjectFile) node.DataItem;
if (file.Project != null) {
MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData;
if (data != null && data.IsFileIntegrationEnabled (file.BuildAction)) {
if (data.IsFileExcluded (file.FilePath)) {
allChecked = false;
break;
}
}
}
}
Set<SolutionItem> projects = new Set<SolutionItem> ();
foreach (ITreeNavigator node in CurrentNodes) {
ProjectFile file = (ProjectFile) node.DataItem;
if (file.Project != null) {
projects.Add (file.Project);
MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData;
if (data != null && data.IntegrationEnabled) {
data.SetFileExcluded (file.FilePath, allChecked);
}
}
}
IdeApp.ProjectOperations.SaveAsync (projects);
}
[CommandUpdateHandler (Commands.SynchWithMakefile)]
public void OnUpdateExclude (CommandInfo cinfo)
{
bool anyChecked = false;
bool allChecked = true;
bool anyEnabled = false;
bool allEnabled = true;
foreach (ITreeNavigator node in CurrentNodes) {
ProjectFile file = (ProjectFile) node.DataItem;
if (file.Project != null) {
MakefileData data = file.Project.ExtendedProperties [infoProperty] as MakefileData;
if (data != null && data.IsFileIntegrationEnabled (file.BuildAction)) {
anyEnabled = true;
if (!data.IsFileExcluded (file.FilePath)) {
anyChecked = true;
} else {
allChecked = false;
}
} else {
allEnabled = false;
}
}
}
cinfo.Visible = anyEnabled;
cinfo.Enabled = anyEnabled && allEnabled;
cinfo.Checked = anyChecked;
cinfo.CheckedInconsistent = anyChecked && !allChecked;
}
}
}
|