2
// CombineEntryConfigurationsPanel.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.Reflection;
33
using MonoDevelop.Projects;
34
using MonoDevelop.Core;
35
using MonoDevelop.Components;
36
using MonoDevelop.Core.Gui;
37
using MonoDevelop.Core.Gui.Dialogs;
40
namespace MonoDevelop.Projects.Gui.Dialogs.OptionPanels
42
internal class CombineEntryConfigurationsPanel : AbstractOptionPanel
44
CombineEntryConfigurationsPanelWidget widget;
46
public override void LoadPanelContents()
48
Add (widget = new CombineEntryConfigurationsPanelWidget ((Properties) CustomizationObject));
51
public override bool StorePanelContents()
53
bool success = widget.Store ();
58
partial class CombineEntryConfigurationsPanelWidget : Gtk.Bin
61
ConfigurationData configData;
63
public CombineEntryConfigurationsPanelWidget (Properties CustomizationObject)
67
// combine = (Combine)((Properties)CustomizationObject).Get("Combine");
68
configData = ((Properties)CustomizationObject).Get<ConfigurationData>("CombineConfigData");
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 (CombineConfiguration cc in configData.Configurations)
82
store.AppendValues (cc, cc.Name);
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
CombineConfiguration cc = (CombineConfiguration) store.GetValue (iter, 0);
103
AddConfiguration (cc.Name);
106
void AddConfiguration (string copyFrom)
108
NewConfigurationDialog dlg = new NewConfigurationDialog ();
112
if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
113
if (dlg.ConfigName.Length == 0) {
114
Services.MessageService.ShowWarning (GettextCatalog.GetString ("Please enter a valid configuration name."));
115
} else if (configData.Configurations [dlg.ConfigName] != null) {
116
Services.MessageService.ShowWarning (GettextCatalog.GetString ("A configuration with the name '{0}' already exists.", dlg.ConfigName));
118
CombineConfiguration cc = (CombineConfiguration) configData.AddConfiguration (dlg.ConfigName, copyFrom, dlg.CreateChildren);
119
store.AppendValues (cc, cc.Name);
130
void OnRemoveConfiguration (object sender, EventArgs args)
134
if (!configsList.Selection.GetSelected (out foo, out iter))
137
if (configData.Configurations.Count == 1) {
138
Services.MessageService.ShowWarning (GettextCatalog.GetString ("There must be at least one configuration."));
142
CombineConfiguration cc = (CombineConfiguration) store.GetValue (iter, 0);
143
DeleteConfigDialog dlg = new DeleteConfigDialog ();
146
if (dlg.Run () == (int) Gtk.ResponseType.Yes) {
147
configData.RemoveConfiguration (cc.Name, dlg.DeleteChildren);
148
store.Remove (ref iter);
155
void OnRenameConfiguration (object sender, EventArgs args)
159
if (!configsList.Selection.GetSelected (out foo, out iter))
162
CombineConfiguration cc = (CombineConfiguration) store.GetValue (iter, 0);
163
RenameConfigDialog dlg = new RenameConfigDialog ();
164
dlg.ConfigName = cc.Name;
169
if (dlg.Run () == (int) Gtk.ResponseType.Ok) {
170
if (dlg.ConfigName.Length == 0) {
171
Services.MessageService.ShowWarning (GettextCatalog.GetString ("Please enter a valid configuration name."));
172
} else if (configData.Configurations [dlg.ConfigName] != null) {
173
Services.MessageService.ShowWarning (GettextCatalog.GetString ("A configuration with the name '{0}' already exists.", dlg.ConfigName));
175
configData.RenameConfiguration (cc.Name, dlg.ConfigName, dlg.RenameChildren);
176
store.SetValue (iter, 1, cc.Name);
189
// Data stored at dialog level