~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectFileSelectorDialog.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
using Gtk;
30
30
using MonoDevelop.Core;
31
31
using MonoDevelop.Projects;
 
32
using MonoDevelop.Components.Extensions;
32
33
 
33
34
namespace MonoDevelop.Ide.Projects
34
35
{
35
36
        public partial class ProjectFileSelectorDialog : Gtk.Dialog
36
37
        {
37
 
                List<string> filters;
38
 
                string defaultFilterName;
39
 
                string defaultFilterPattern;
 
38
                List<SelectFileDialogFilter> filters;
 
39
                SelectFileDialogFilter defaultFilter;
 
40
                string [] buildActions;
40
41
                Project project;
41
42
                TreeStore dirStore = new TreeStore (typeof (string), typeof (FilePath));
42
43
                ListStore fileStore = new ListStore (typeof (ProjectFile), typeof (Gdk.Pixbuf));
49
50
                        : this (project, GettextCatalog.GetString ("All files"), "*")
50
51
                {
51
52
                }
52
 
                
 
53
 
53
54
                public ProjectFileSelectorDialog (Project project, string defaultFilterName, string defaultFilterPattern)
 
55
                        : this (project, defaultFilterName, defaultFilterPattern, null)
 
56
                {
 
57
                }
 
58
 
 
59
                public ProjectFileSelectorDialog (Project project, string defaultFilterName, string defaultFilterPattern, string [] buildActions)
54
60
                {
55
61
                        this.project = project;
56
 
                        this.defaultFilterName = defaultFilterName;
57
 
                        this.defaultFilterPattern = defaultFilterPattern ?? "*";
 
62
                        this.defaultFilter = new SelectFileDialogFilter (defaultFilterName, defaultFilterPattern ?? "*");
 
63
                        this.buildActions = buildActions;
58
64
                        
59
65
                        this.Build();
60
66
                        
215
221
                public void AddFileFilter (string name, string pattern)
216
222
                {
217
223
                        if (filters == null) {
218
 
                                filters = new List<string> ();
219
 
                                if (defaultFilterPattern != null) {
220
 
                                        filters.Add (defaultFilterPattern);
221
 
                                        fileTypeCombo.AppendText (defaultFilterName);
 
224
                                filters = new List<SelectFileDialogFilter> ();
 
225
                                if (defaultFilter != null) {
 
226
                                        filters.Add (defaultFilter);
 
227
                                        fileTypeCombo.AppendText (defaultFilter.Name);
222
228
                                }
223
229
                                typeBox.Visible = false;
224
230
                                typeBox.ShowAll ();
225
231
                        }
226
 
                        
227
 
                        filters.Add (name);
 
232
 
 
233
                        filters.Add (new SelectFileDialogFilter (name, pattern));
228
234
                        fileTypeCombo.AppendText (pattern);
229
235
                }
230
236
                
246
252
                {
247
253
                        fileStore.Clear ();
248
254
                        
249
 
                        string pattern = defaultFilterPattern;
 
255
                        string pattern = defaultFilter.Patterns [0];
250
256
                        if (filters != null) {
251
 
                                pattern = filters[fileTypeCombo.Active];
 
257
                                pattern = filters[fileTypeCombo.Active].Patterns [0];
252
258
                        }
253
259
                        pattern = System.Text.RegularExpressions.Regex.Escape (pattern);
254
260
                        pattern = pattern.Replace ("\\*",".*");
286
292
                        this.DefaultResponse = selected? ResponseType.Ok : ResponseType.Cancel;
287
293
                        SelectedFile = selected? (ProjectFile) fileStore.GetValue (iter, 0) : null;
288
294
                }
 
295
 
 
296
                protected void OnAddFileButtonClicked (object sender, EventArgs e)
 
297
                {
 
298
                        var baseDirectory = GetSelectedDirectory ();
 
299
                        var fileDialog = new AddFileDialog (GettextCatalog.GetString ("Add files")) {
 
300
                                CurrentFolder = baseDirectory,
 
301
                                SelectMultiple = true,
 
302
                                TransientFor = IdeApp.Workbench.RootWindow,
 
303
                                BuildActions = buildActions ?? project.GetBuildActions ()
 
304
                        };
 
305
 
 
306
                        if (defaultFilter != null) {
 
307
                                fileDialog.Filters.Clear ();
 
308
                                fileDialog.Filters.Add (defaultFilter);
 
309
                                fileDialog.DefaultFilter = defaultFilter;
 
310
                        }
 
311
 
 
312
                        if (!fileDialog.Run ())
 
313
                                return;
 
314
 
 
315
                        var buildAction = fileDialog.OverrideAction;
 
316
                        if (buildActions != null && buildActions.Length > 0 && String.IsNullOrEmpty (buildAction))
 
317
                                buildAction = buildActions [0];
 
318
 
 
319
                        IdeApp.ProjectOperations.AddFilesToProject (project,
 
320
                                fileDialog.SelectedFiles, baseDirectory, buildAction);
 
321
 
 
322
                        IdeApp.ProjectOperations.Save (project);
 
323
 
 
324
                        UpdateFileList (sender, e);
 
325
                }
289
326
        }
290
327
}