2
// DeploymentOptionsPanel.cs
7
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
using System.Collections.Generic;
33
using MonoDevelop.Core;
34
using MonoDevelop.Core.Properties;
35
using MonoDevelop.Core.Gui.Dialogs;
36
using MonoDevelop.Projects.Deployment;
37
using MonoDevelop.Components;
38
using MonoDevelop.Projects.Gui.Deployment;
40
namespace MonoDevelop.Projects.Gui.Dialogs.OptionPanels
42
public class DeploymentOptionsPanel : AbstractOptionPanel
44
DeploymentOptionsWidget widget;
46
class DeploymentOptionsWidget : GladeWidgetExtract
49
[Glade.Widget] Gtk.TreeView targetsTree;
50
[Glade.Widget] Gtk.HBox targetsBox;
51
[Glade.Widget] Gtk.Button buttonEdit;
52
[Glade.Widget] Gtk.Button buttonRemove;
55
List<DeployTarget> targets = new List<DeployTarget> ();
57
DeployTarget defaultTarget;
59
public DeploymentOptionsWidget (IProperties CustomizationObject) :
60
base ("Base.glade", "DeployOptionsPanel")
62
entry = ((IProperties)CustomizationObject).GetProperty("Combine") as Combine;
64
entry = ((IProperties)CustomizationObject).GetProperty("Project") as Project;
69
if (MonoDevelop.Projects.Services.DeployService.GetDeployHandlers (entry).Length == 0) {
70
foreach (Gtk.Widget w in targetsBox.Children)
71
targetsBox.Remove (w);
72
Gtk.Label lab = new Gtk.Label (GettextCatalog.GetString ("There are no deployment handlers available for this solution item."));
74
targetsBox.PackStart (lab, false, false, 0);
78
store = new ListStore (typeof(Gdk.Pixbuf), typeof(string), typeof(object));
79
targetsTree.Model = store;
81
targetsTree.HeadersVisible = false;
82
Gtk.CellRendererPixbuf cr = new Gtk.CellRendererPixbuf();
84
targetsTree.AppendColumn ("", cr, "pixbuf", 0);
85
targetsTree.AppendColumn ("", new Gtk.CellRendererText(), "markup", 1);
87
foreach (DeployTarget target in entry.DeployTargets) {
88
if (target is UnknownDeployTarget)
91
DeployTarget ct = target.DeployHandler.CreateTarget (entry);
94
if (target == entry.DefaultDeployTarget)
99
targetsTree.Selection.Changed += delegate (object s, EventArgs a) {
110
foreach (DeployTarget target in targets) {
111
if (target is UnknownDeployTarget) {
112
Gdk.Pixbuf pix = MonoDevelop.Core.Gui.Services.Resources.GetIcon ("md-package", Gtk.IconSize.Dialog);
113
string desc = "<b>" + target.Name + "</b>\n<small>Unknown target</small>";
114
store.AppendValues (pix, desc, target);
116
Gdk.Pixbuf pix = MonoDevelop.Core.Gui.Services.Resources.GetIcon (target.DeployHandler.Icon, Gtk.IconSize.Dialog);
117
string desc = "<b>" + target.Name + "</b>";
118
if (target == defaultTarget)
119
desc += " " + GettextCatalog.GetString ("(default target)");
120
desc += "\n<small>" + target.DeployHandler.Description + "</small>";
121
store.AppendValues (pix, desc, target);
126
void UpdateButtons ()
128
DeployTarget t = GetSelection ();
130
buttonRemove.Sensitive = true;
131
buttonEdit.Sensitive = !(t is UnknownDeployTarget) && DeployTargetEditor.HasEditor (t);
133
buttonRemove.Sensitive = false;
134
buttonEdit.Sensitive = false;
138
protected void OnAddTarget (object s, EventArgs args)
140
using (AddDeployTargetDialog dlg = new AddDeployTargetDialog (entry)) {
141
if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
142
targets.Add (dlg.NewTarget);
143
if (targets.Count == 1)
144
defaultTarget = dlg.NewTarget;
150
protected void OnRemoveTarget (object s, EventArgs args)
152
DeployTarget t = GetSelection ();
159
protected void OnEditTarget (object s, EventArgs args)
161
DeployTarget t = GetSelection ();
163
DeployTarget tc = t.DeployHandler.CreateTarget (entry);
165
using (EditDeployTargetDialog dlg = new EditDeployTargetDialog (tc)) {
166
if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
167
targets [targets.IndexOf (t)] = tc;
174
protected void OnSetDefault (object s, EventArgs args)
176
DeployTarget t = GetSelection ();
183
DeployTarget GetSelection ()
188
if (targetsTree.Selection.GetSelected (out model, out iter)) {
189
return (DeployTarget) store.GetValue (iter, 2);
196
entry.DeployTargets.Clear ();
197
entry.DeployTargets.AddRange (targets);
198
entry.DefaultDeployTarget = defaultTarget;
203
public override void LoadPanelContents()
206
Add (widget = new DeploymentOptionsWidget ((IProperties) CustomizationObject));
207
} catch (Exception ex) {
208
Console.WriteLine (ex);
212
public override bool StorePanelContents ()
214
bool success = widget.Store ();