~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric-updates

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Search/WholeProjectDocumentIterator.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2009-02-18 08:40:51 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090218084051-gh8m6ukvokbwj7cf
Tags: 1.9.2+dfsg-1ubuntu1
* Merge from Debian Experimental (LP: #330519), remaining Ubuntu changes:
  + debian/control:
    - Update for Gnome# 2.24
    - Add libmono-cairo1.0-cil to build-deps to fool pkg-config check

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  WholeProjectDocumentIterator.cs
2
 
//
3
 
//  This file was derived from a file from #Develop. 
4
 
//
5
 
//  Copyright (C) 2001-2007 Mike Krüger <mkrueger@novell.com>
6
 
// 
7
 
//  This program is free software; you can redistribute it and/or modify
8
 
//  it under the terms of the GNU General Public License as published by
9
 
//  the Free Software Foundation; either version 2 of the License, or
10
 
//  (at your option) any later version.
11
 
// 
12
 
//  This program is distributed in the hope that it will be useful,
13
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 
//  GNU General Public License for more details.
16
 
//  
17
 
//  You should have received a copy of the GNU General Public License
18
 
//  along with this program; if not, write to the Free Software
19
 
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
 
 
21
 
using System;
22
 
using System.Collections;
23
 
using System.IO;
24
 
 
25
 
using MonoDevelop.Projects;
26
 
using MonoDevelop.Core;
27
 
using MonoDevelop.Ide.Gui;
28
 
 
29
 
namespace MonoDevelop.Ide.Gui.Search
30
 
{
31
 
        internal class WholeProjectDocumentIterator : IDocumentIterator
32
 
        {
33
 
                ArrayList files    = new ArrayList();
34
 
                int       curIndex = -1;
35
 
                
36
 
                public WholeProjectDocumentIterator()
37
 
                {
38
 
                        Reset();
39
 
                }
40
 
                
41
 
                public string CurrentFileName {
42
 
                        get {
43
 
                                if (curIndex < 0 || curIndex >= files.Count) {
44
 
                                        return null;
45
 
                                }
46
 
                                
47
 
                                return files[curIndex].ToString();
48
 
                        }
49
 
                }
50
 
                                
51
 
                public IDocumentInformation Current {
52
 
                        get {
53
 
                                if (curIndex < 0 || curIndex >= files.Count) {
54
 
                                        return null;
55
 
                                }
56
 
                                if (!File.Exists(files[curIndex].ToString())) {
57
 
                                        ++curIndex;
58
 
                                        return Current;
59
 
                                }
60
 
 
61
 
                                string fileName = files[curIndex].ToString();
62
 
                                foreach (Document document in IdeApp.Workbench.Documents) {
63
 
                                        // WINDOWS DEPENDENCY : ToUpper
64
 
                                        if (document.FileName != null && document.FileName.ToUpper() == fileName.ToUpper()) {
65
 
                                                IDocumentInformation doc = document.Window.ViewContent as IDocumentInformation;
66
 
                                                if (doc != null) return doc;
67
 
                                        }
68
 
                                }
69
 
                                return new FileDocumentInformation (fileName, 0);
70
 
                        }
71
 
                }
72
 
                
73
 
                public bool MoveForward() 
74
 
                {
75
 
                        return ++curIndex < files.Count;
76
 
                }
77
 
                
78
 
                public bool MoveBackward()
79
 
                {
80
 
                        if (curIndex == -1) {
81
 
                                curIndex = files.Count - 1;
82
 
                                return true;
83
 
                        }
84
 
                        return --curIndex >= -1;
85
 
                }
86
 
                
87
 
                
88
 
                void AddFiles(Project project)
89
 
                {
90
 
                        foreach (ProjectFile file in project.ProjectFiles) {
91
 
                                if (file.Subtype == Subtype.Code) {
92
 
                                        files.Add(file.Name);
93
 
                                }
94
 
                        }
95
 
                }
96
 
                
97
 
                void AddFiles(Combine combine)
98
 
                {
99
 
                        foreach (CombineEntry entry in combine.Entries) {
100
 
                                if (entry is Project) {
101
 
                                        AddFiles ((Project)entry);
102
 
                                } else if (entry is Combine) {
103
 
                                        AddFiles ((Combine)entry);
104
 
                                }
105
 
                        }
106
 
                }
107
 
                
108
 
                public void Reset() 
109
 
                {
110
 
                        files.Clear();
111
 
                        if (IdeApp.ProjectOperations.CurrentOpenCombine != null) {
112
 
                                AddFiles (IdeApp.ProjectOperations.CurrentOpenCombine);
113
 
                        }
114
 
                        
115
 
                        curIndex = -1;
116
 
                }
117
 
        }
118
 
}