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"/>
10
using System.Collections;
11
using System.ComponentModel;
13
using MonoDevelop.Projects;
14
using MonoDevelop.Core.Properties;
15
using MonoDevelop.Core;
16
using MonoDevelop.Core.Gui;
17
using MonoDevelop.Core.Gui.Components;
18
using MonoDevelop.Core.Gui.Dialogs;
19
using MonoDevelop.Components;
23
namespace MonoDevelop.Projects.Gui.Dialogs.OptionPanels
25
internal class DeployFileProjectOptions : AbstractOptionPanel
28
class DeployFileOptionsWidget : GladeWidgetExtract
31
[Glade.Widget] RadioButton projectFileRadioButton;
32
[Glade.Widget] RadioButton compiledAssemblyRadioButton;
33
[Glade.Widget] RadioButton scriptFileRadioButton;
34
[Glade.Widget] Gnome.FileEntry selectScriptButton;
35
[Glade.Widget] Gnome.FileEntry selectTargetButton;
36
//[Glade.Widget] VBox deployScriptBox;
37
[Glade.Widget] VBox deployTargetBox;
38
[Glade.Widget] Gtk.TreeView includeTreeView;
39
public ListStore store;
43
static FileUtilityService fileUtilityService = Runtime.FileUtilityService;
45
public DeployFileOptionsWidget (IProperties CustomizationObject) :
46
base ("Base.glade", "DeployFileOptionsPanel")
48
this.project = (Project)((IProperties)CustomizationObject).GetProperty("Project");
50
projectFileRadioButton.Clicked += new EventHandler(RadioButtonClicked);
51
compiledAssemblyRadioButton.Clicked += new EventHandler(RadioButtonClicked);
52
scriptFileRadioButton.Clicked += new EventHandler(RadioButtonClicked);
54
store = new ListStore (typeof(bool), typeof(string));
55
includeTreeView.Selection.Mode = SelectionMode.None;
56
includeTreeView.Model = store;
57
CellRendererToggle rendererToggle = new CellRendererToggle ();
58
rendererToggle.Activatable = true;
59
rendererToggle.Toggled += new ToggledHandler (ItemToggled);
60
includeTreeView.AppendColumn ("Choosen", rendererToggle, "active", 0);
61
includeTreeView.AppendColumn ("Name", new CellRendererText (), "text", 1);
63
foreach (ProjectFile info in project.ProjectFiles) {
64
if (info.BuildAction != BuildAction.Exclude) {
65
string name = fileUtilityService.AbsoluteToRelativePath(project.BaseDirectory, info.Name);
66
store.AppendValues (project.DeployInformation.IsFileExcluded(info.Name) ? true : false, name);
70
selectTargetButton.Filename = project.DeployInformation.DeployTarget;
71
selectScriptButton.Filename = project.DeployInformation.DeployScript;
73
projectFileRadioButton.Active = project.DeployInformation.DeploymentStrategy == DeploymentStrategy.File;
74
compiledAssemblyRadioButton.Active = project.DeployInformation.DeploymentStrategy == DeploymentStrategy.Assembly;
75
scriptFileRadioButton.Active = project.DeployInformation.DeploymentStrategy == DeploymentStrategy.Script;
77
RadioButtonClicked(null, null);
80
void RadioButtonClicked(object sender, EventArgs e)
82
deployTargetBox.Sensitive = compiledAssemblyRadioButton.Active || projectFileRadioButton.Active;
83
selectScriptButton.Sensitive = scriptFileRadioButton.Active;
86
private void ItemToggled (object o, ToggledArgs args)
91
if (store.GetIterFromString(out iter, args.Path)) {
92
bool val = (bool) store.GetValue(iter, column);
93
store.SetValue(iter, column, !val);
99
if (selectTargetButton.Filename.Length > 0) {
100
if (!fileUtilityService.IsValidFileName(selectTargetButton.Filename)) {
101
Services.MessageService.ShowError (GettextCatalog.GetString ("Invalid deploy target specified"));
106
if (selectScriptButton.Filename.Length > 0) {
107
if (!fileUtilityService.IsValidFileName(selectScriptButton.Filename)) {
108
Services.MessageService.ShowError (GettextCatalog.GetString ("Invalid deploy script specified"));
113
if (!System.IO.File.Exists(selectScriptButton.Filename)) {
114
Services.MessageService.ShowError (GettextCatalog.GetString ("Deploy script doesn't exist"));
118
project.DeployInformation.DeployTarget = selectTargetButton.Filename;
119
project.DeployInformation.DeployScript = selectScriptButton.Filename;
121
if (projectFileRadioButton.Active) {
122
project.DeployInformation.DeploymentStrategy = DeploymentStrategy.File;
123
} else if (compiledAssemblyRadioButton.Active) {
124
project.DeployInformation.DeploymentStrategy = DeploymentStrategy.Assembly;
126
project.DeployInformation.DeploymentStrategy = DeploymentStrategy.Script;
130
store.GetIterFirst(out first);
131
TreeIter current = first;
132
project.DeployInformation.ClearExcludedFiles();
133
for (int i = 0; i < store.IterNChildren() ; ++i) {
134
if ( (bool) store.GetValue(current, 0)){
135
project.DeployInformation.AddExcludedFile(fileUtilityService.RelativeToAbsolutePath(
136
project.BaseDirectory,
137
(string) store.GetValue(current, 1)));
139
store.IterNext(ref current);
145
DeployFileOptionsWidget widget;
147
public override void LoadPanelContents()
149
Add (widget = new DeployFileOptionsWidget ((IProperties) CustomizationObject));
152
public override bool StorePanelContents()
154
bool success = widget.Store();