~ubuntu-branches/ubuntu/gutsy/monodevelop/gutsy

« back to all changes in this revision

Viewing changes to Core/src/MonoDevelop.Projects.Gui/MonoDevelop.Projects.Gui.Dialogs.OptionPanels/DeployFileOptions.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-09-15 02:15:25 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060915021525-ngsnriip5e3uqi9d
Tags: 0.12-0ubuntu1
* New upstream release
* debian/patches/gtk-sharp-2.10.dpatch,
  debian/patches/versioncontrol_buildfix.dpatch:
  + Dropped, merged upstream
* debian/patches/use_nunit2.2.dpatch,
  debian/patches/firefox.dpatch:
  + Updated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// <file>
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"/>
6
 
// </file>
7
 
 
8
 
using System;
9
 
using System.IO;
10
 
using System.Collections;
11
 
using System.ComponentModel;
12
 
 
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;
20
 
 
21
 
using Gtk;
22
 
 
23
 
namespace MonoDevelop.Projects.Gui.Dialogs.OptionPanels
24
 
{
25
 
        internal class DeployFileProjectOptions : AbstractOptionPanel
26
 
        {
27
 
 
28
 
                class DeployFileOptionsWidget : GladeWidgetExtract 
29
 
                {
30
 
                        // Gtk Controls
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;
40
 
 
41
 
                        // Services
42
 
                        Project project;
43
 
                        static FileUtilityService fileUtilityService = Runtime.FileUtilityService;
44
 
 
45
 
                        public DeployFileOptionsWidget (IProperties CustomizationObject) : 
46
 
                                base ("Base.glade", "DeployFileOptionsPanel")
47
 
                        {
48
 
                                this.project = (Project)((IProperties)CustomizationObject).GetProperty("Project");
49
 
 
50
 
                                projectFileRadioButton.Clicked += new EventHandler(RadioButtonClicked);
51
 
                                compiledAssemblyRadioButton.Clicked += new EventHandler(RadioButtonClicked);
52
 
                                scriptFileRadioButton.Clicked += new EventHandler(RadioButtonClicked);
53
 
 
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);
62
 
                                
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);
67
 
                                        }
68
 
                                }
69
 
 
70
 
                                selectTargetButton.Filename = project.DeployInformation.DeployTarget;
71
 
                                selectScriptButton.Filename = project.DeployInformation.DeployScript;
72
 
                        
73
 
                                projectFileRadioButton.Active = project.DeployInformation.DeploymentStrategy == DeploymentStrategy.File;
74
 
                                compiledAssemblyRadioButton.Active = project.DeployInformation.DeploymentStrategy == DeploymentStrategy.Assembly;
75
 
                                scriptFileRadioButton.Active = project.DeployInformation.DeploymentStrategy == DeploymentStrategy.Script;
76
 
                                
77
 
                                RadioButtonClicked(null, null);
78
 
                        }
79
 
 
80
 
                        void RadioButtonClicked(object sender, EventArgs e)
81
 
                        {
82
 
                                deployTargetBox.Sensitive = compiledAssemblyRadioButton.Active || projectFileRadioButton.Active;
83
 
                                selectScriptButton.Sensitive = scriptFileRadioButton.Active;
84
 
                        }
85
 
                        
86
 
                        private void ItemToggled (object o, ToggledArgs args)
87
 
                        {
88
 
                                const int column = 0;
89
 
                                Gtk.TreeIter iter;
90
 
                                
91
 
                                if (store.GetIterFromString(out iter, args.Path)) {
92
 
                                        bool val = (bool) store.GetValue(iter, column);
93
 
                                        store.SetValue(iter, column, !val);
94
 
                                }
95
 
                        }
96
 
                        
97
 
                        public bool Store () 
98
 
                        {
99
 
                                if (selectTargetButton.Filename.Length > 0) {
100
 
                                        if (!fileUtilityService.IsValidFileName(selectTargetButton.Filename)) {
101
 
                                                Services.MessageService.ShowError (GettextCatalog.GetString ("Invalid deploy target specified"));
102
 
                                                return false;
103
 
                                        }
104
 
                                }
105
 
                                
106
 
                                if (selectScriptButton.Filename.Length > 0) {
107
 
                                        if (!fileUtilityService.IsValidFileName(selectScriptButton.Filename)) {
108
 
                                                Services.MessageService.ShowError (GettextCatalog.GetString ("Invalid deploy script specified"));
109
 
                                                return false;                           
110
 
                                        }
111
 
                                }
112
 
                                
113
 
                                if (!System.IO.File.Exists(selectScriptButton.Filename)) {
114
 
                                        Services.MessageService.ShowError (GettextCatalog.GetString ("Deploy script doesn't exist"));
115
 
                                        return false;
116
 
                                }
117
 
                        
118
 
                        project.DeployInformation.DeployTarget = selectTargetButton.Filename;
119
 
                        project.DeployInformation.DeployScript = selectScriptButton.Filename;
120
 
                        
121
 
                        if (projectFileRadioButton.Active) {
122
 
                                project.DeployInformation.DeploymentStrategy = DeploymentStrategy.File;
123
 
                        } else if (compiledAssemblyRadioButton.Active) {
124
 
                                project.DeployInformation.DeploymentStrategy = DeploymentStrategy.Assembly;
125
 
                        } else {
126
 
                                project.DeployInformation.DeploymentStrategy = DeploymentStrategy.Script;
127
 
                        }
128
 
 
129
 
                        TreeIter first; 
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)));
138
 
                                                        }
139
 
                                store.IterNext(ref current);
140
 
                        }
141
 
                        return true;
142
 
                        }
143
 
                }
144
 
                
145
 
                DeployFileOptionsWidget widget;
146
 
                
147
 
                public override void LoadPanelContents()
148
 
                {
149
 
                        Add (widget = new  DeployFileOptionsWidget ((IProperties) CustomizationObject));
150
 
                }
151
 
                
152
 
                public override bool StorePanelContents()
153
 
                {
154
 
                        bool success = widget.Store();
155
 
                        return success;
156
 
                }
157
 
        }
158
 
}