2
// SolutionItemConfigurationsPanel.cs
7
// Copyright (C) 2005 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;
31
using System.Collections.Generic;
32
using System.Reflection;
34
using MonoDevelop.Projects;
35
using MonoDevelop.Core;
36
using MonoDevelop.Components;
37
using MonoDevelop.Core.Gui;
38
using MonoDevelop.Core.Gui.Dialogs;
41
namespace MonoDevelop.Projects.Gui.Dialogs.OptionPanels
43
internal class SolutionItemConfigurationsPanel : ItemOptionsPanel
45
CombineEntryConfigurationsPanelWidget widget;
47
public override Widget CreatePanelWidget ()
49
MultiConfigItemOptionsDialog dlg = (MultiConfigItemOptionsDialog) ParentDialog;
50
return (widget = new CombineEntryConfigurationsPanelWidget (dlg));
53
public override void ApplyChanges()
59
partial class CombineEntryConfigurationsPanelWidget : Gtk.Bin
62
ConfigurationData configData;
64
public CombineEntryConfigurationsPanelWidget (MultiConfigItemOptionsDialog dlg)
68
configData = dlg.ConfigurationData;
70
store = new TreeStore (typeof(object), typeof(string));
71
configsList.Model = store;
72
configsList.HeadersVisible = true;
74
TreeViewColumn col = new TreeViewColumn ();
75
CellRendererText sr = new CellRendererText ();
76
col.PackStart (sr, true);
77
col.AddAttribute (sr, "text", 1);
78
col.Title = GettextCatalog.GetString ("Configuration");
79
configsList.AppendColumn (col);
81
foreach (ItemConfiguration cc in configData.Configurations)
82
store.AppendValues (cc, cc.Id);
84
addButton.Clicked += new EventHandler (OnAddConfiguration);
85
removeButton.Clicked += new EventHandler (OnRemoveConfiguration);
86
renameButton.Clicked += new EventHandler (OnRenameConfiguration);
87
copyButton.Clicked += new EventHandler (OnCopyConfiguration);
90
void OnAddConfiguration (object sender, EventArgs args)
92
AddConfiguration (null);
95
void OnCopyConfiguration (object sender, EventArgs args)
99
if (!configsList.Selection.GetSelected (out foo, out iter))
102
ItemConfiguration cc = (ItemConfiguration) store.GetValue (iter, 0);
103
AddConfiguration (cc.Id);
106
void AddConfiguration (string copyFrom)
108
NewConfigurationDialog dlg = new NewConfigurationDialog (configData.Configurations);
112
dlg.TransientFor = this.Toplevel as Gtk.Window;
113
if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
114
ItemConfiguration cc = configData.AddConfiguration (dlg.ConfigName, copyFrom, dlg.CreateChildren);
115
store.AppendValues (cc, cc.Id);
125
void OnRemoveConfiguration (object sender, EventArgs args)
129
if (!configsList.Selection.GetSelected (out foo, out iter))
132
if (configData.Configurations.Count == 1) {
133
MessageService.ShowWarning (GettextCatalog.GetString ("There must be at least one configuration."));
137
ItemConfiguration cc = (ItemConfiguration) store.GetValue (iter, 0);
138
DeleteConfigDialog dlg = new DeleteConfigDialog ();
141
dlg.TransientFor = this.Toplevel as Gtk.Window;
142
if (dlg.Run () == (int) Gtk.ResponseType.Yes) {
143
configData.RemoveConfiguration (cc.Id, dlg.DeleteChildren);
144
store.Remove (ref iter);
151
void OnRenameConfiguration (object sender, EventArgs args)
155
if (!configsList.Selection.GetSelected (out foo, out iter))
158
ItemConfiguration cc = (ItemConfiguration) store.GetValue (iter, 0);
159
RenameConfigDialog dlg = new RenameConfigDialog (configData.Configurations);
160
dlg.ConfigName = cc.Id;
165
dlg.TransientFor = this.Toplevel as Gtk.Window;
166
if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
167
configData.RenameConfiguration (cc.Id, dlg.ConfigName, dlg.RenameChildren);
168
store.SetValue (iter, 1, cc.Id);
180
// Data stored at dialog level