~ubuntu-branches/ubuntu/saucy/monodevelop/saucy-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Projects.Gui/MonoDevelop.Projects.Gui.Dialogs.OptionPanels/SolutionItemConfigurationsPanel.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2010-09-10 16:54:48 UTC
  • mfrom: (19.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100910165448-0rybfk25zd4o9431
Tags: 2.4+dfsg-2
* debian/patches/inject_Mono.Debugger.Soft_source.patch,
  debian/patches/use_system_Mono.Debugger.Soft.patch,
  debian/control:
  + Build against system Soft Debugger, since we now have a new
    enough Mono to match MonoDevelop's required API

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// SolutionItemConfigurationsPanel.cs
3
 
//
4
 
// Author:
5
 
//   Lluis Sanchez Gual
6
 
//
7
 
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
8
 
//
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:
16
 
// 
17
 
// The above copyright notice and this permission notice shall be
18
 
// included in all copies or substantial portions of the Software.
19
 
// 
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.
27
 
//
28
 
 
29
 
using System;
30
 
using System.Collections;
31
 
using System.Collections.Generic;
32
 
using System.Reflection;
33
 
 
34
 
using MonoDevelop.Projects;
35
 
using MonoDevelop.Core;
36
 
using MonoDevelop.Components;
37
 
using MonoDevelop.Core.Gui;
38
 
using MonoDevelop.Core.Gui.Dialogs;
39
 
using Gtk;
40
 
 
41
 
namespace MonoDevelop.Projects.Gui.Dialogs.OptionPanels
42
 
{
43
 
        internal class SolutionItemConfigurationsPanel : ItemOptionsPanel
44
 
        {
45
 
                CombineEntryConfigurationsPanelWidget widget;
46
 
                
47
 
                public override Widget CreatePanelWidget ()
48
 
                {
49
 
                        MultiConfigItemOptionsDialog dlg = (MultiConfigItemOptionsDialog) ParentDialog;
50
 
                        return (widget = new CombineEntryConfigurationsPanelWidget (dlg));
51
 
                }
52
 
 
53
 
                public override void ApplyChanges()
54
 
                {
55
 
                widget.Store ();
56
 
        }
57
 
        }
58
 
 
59
 
        partial class CombineEntryConfigurationsPanelWidget : Gtk.Bin 
60
 
        {
61
 
                TreeStore store;
62
 
                ConfigurationData configData;
63
 
                
64
 
                public CombineEntryConfigurationsPanelWidget (MultiConfigItemOptionsDialog dlg)
65
 
                {
66
 
                        Build ();
67
 
                        
68
 
                        configData = dlg.ConfigurationData;
69
 
                        
70
 
                        store = new TreeStore (typeof(object), typeof(string));
71
 
                        configsList.Model = store;
72
 
                        configsList.HeadersVisible = true;
73
 
                        
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);
80
 
                        
81
 
                        foreach (ItemConfiguration cc in configData.Configurations)
82
 
                                store.AppendValues (cc, cc.Id);
83
 
 
84
 
                        addButton.Clicked += new EventHandler (OnAddConfiguration);
85
 
                        removeButton.Clicked += new EventHandler (OnRemoveConfiguration);
86
 
                        renameButton.Clicked += new EventHandler (OnRenameConfiguration);
87
 
                        copyButton.Clicked += new EventHandler (OnCopyConfiguration);
88
 
                }
89
 
                
90
 
                void OnAddConfiguration (object sender, EventArgs args)
91
 
                {
92
 
                        AddConfiguration (null);
93
 
                }
94
 
 
95
 
                void OnCopyConfiguration (object sender, EventArgs args)
96
 
                {
97
 
                        Gtk.TreeModel foo;
98
 
                        Gtk.TreeIter iter;
99
 
                        if (!configsList.Selection.GetSelected (out foo, out iter))
100
 
                                return;
101
 
                                
102
 
                        ItemConfiguration cc = (ItemConfiguration) store.GetValue (iter, 0);
103
 
                        AddConfiguration (cc.Id);
104
 
                }
105
 
 
106
 
                void AddConfiguration (string copyFrom)
107
 
                {
108
 
                        NewConfigurationDialog dlg = new NewConfigurationDialog (configData.Configurations);
109
 
                        try {
110
 
                                bool done = false;
111
 
                                do {
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);
116
 
                                                done = true;
117
 
                                        } else
118
 
                                                done = true;
119
 
                                } while (!done);
120
 
                        } finally {
121
 
                                dlg.Destroy ();
122
 
                        }
123
 
                }
124
 
 
125
 
                void OnRemoveConfiguration (object sender, EventArgs args)
126
 
                {
127
 
                        Gtk.TreeModel foo;
128
 
                        Gtk.TreeIter iter;
129
 
                        if (!configsList.Selection.GetSelected (out foo, out iter))
130
 
                                return;
131
 
                        
132
 
                        if (configData.Configurations.Count == 1) {
133
 
                                MessageService.ShowWarning (GettextCatalog.GetString ("There must be at least one configuration."));
134
 
                                return;
135
 
                        }
136
 
                        
137
 
                        ItemConfiguration cc = (ItemConfiguration) store.GetValue (iter, 0);
138
 
                        DeleteConfigDialog dlg = new DeleteConfigDialog ();
139
 
                        
140
 
                        try {
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);
145
 
                                }
146
 
                        } finally {
147
 
                                dlg.Destroy ();
148
 
                        }
149
 
                }
150
 
                
151
 
                void OnRenameConfiguration (object sender, EventArgs args)
152
 
                {
153
 
                        Gtk.TreeModel foo;
154
 
                        Gtk.TreeIter iter;
155
 
                        if (!configsList.Selection.GetSelected (out foo, out iter))
156
 
                                return;
157
 
                                
158
 
                        ItemConfiguration cc = (ItemConfiguration) store.GetValue (iter, 0);
159
 
                        RenameConfigDialog dlg = new RenameConfigDialog (configData.Configurations);
160
 
                        dlg.ConfigName = cc.Id;
161
 
                        
162
 
                        try {
163
 
                                bool done = false;
164
 
                                do {
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);
169
 
                                                done = true;
170
 
                                        } else
171
 
                                                done = true;
172
 
                                } while (!done);
173
 
                        } finally {
174
 
                                dlg.Destroy ();
175
 
                        }
176
 
                }
177
 
 
178
 
                public bool Store()
179
 
                {
180
 
                        // Data stored at dialog level
181
 
                        return true;
182
 
                }
183
 
        }
184
 
}
185