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

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Components/NodeState.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-06-22 20:35:35 UTC
  • mfrom: (10.3.2)
  • Revision ID: package-import@ubuntu.com-20120622203535-zrozwvcf6kfk6l6i
Tags: 3.0.3.2+dfsg-1
* [3fd89ae] Imported Upstream version 3.0.3.2+dfsg
* [379a680] Remove old patches we haven't used for ages from git.
* [d71161d] Remove correct_paths_in_monodevelop-core-addins.pc.patch.
  Upstream claim to have fixed this by moving assembly install locations.
* [15dbfb9] Fix install location for MonoDevelop.Gettext.dll.config.
* [26eb434] Fix install location for MonoDevelop.SourceEditor2.dll.config.
* [4169974] Upstream commit 53282c9 which finally reconciles the 
  MonoDevelop.Gettext.dll install location with the 
  monodevelop-core-addins.pc location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
{
38
38
        public class NodeState : ICustomXmlSerializer
39
39
        {
40
 
                string nodeName;
41
 
                
42
 
                bool expanded;
43
 
                bool selected;
44
 
                ExtensibleTreeView.TreeOptions options;
45
 
                
46
 
                List<NodeState> childrenState;
47
 
 
48
 
                public string NodeName {
49
 
                        get {
50
 
                                return nodeName;
51
 
                        }
52
 
                        set {
53
 
                                nodeName = value;
54
 
                        }
55
 
                }
56
 
 
57
 
                public bool Expanded {
58
 
                        get {
59
 
                                return expanded;
60
 
                        }
61
 
                        set {
62
 
                                expanded = value;
63
 
                        }
64
 
                }
65
 
 
66
 
                public bool Selected {
67
 
                        get {
68
 
                                return selected;
69
 
                        }
70
 
                        set {
71
 
                                selected = value;
72
 
                        }
73
 
                }
74
 
 
75
 
                internal ExtensibleTreeView.TreeOptions Options {
76
 
                        get {
77
 
                                return options;
78
 
                        }
79
 
                        set {
80
 
                                options = value;
81
 
                        }
82
 
                }
83
 
 
84
 
                public System.Collections.Generic.List<NodeState> ChildrenState {
85
 
                        get {
86
 
                                return childrenState;
87
 
                        }
88
 
                        set {
89
 
                                childrenState = value;
90
 
                        }
91
 
                }
 
40
                public string NodeName { get; set; }
 
41
                public bool Expanded { get; set; }
 
42
                public bool Selected { get; set; }
 
43
                public List<NodeState> ChildrenState { get; set; }
 
44
 
 
45
                internal Dictionary<string,bool> Options { get; set; }
92
46
                
93
47
                void ICustomXmlSerializer.WriteTo (XmlWriter writer)
94
48
                {
95
 
                        WriteTo (writer, null);
 
49
                        WriteTo (writer);
96
50
                }
97
51
                
98
52
                ICustomXmlSerializer ICustomXmlSerializer.ReadFrom (XmlReader reader)
99
53
                {
100
 
                        return ReadFrom (reader, null);
 
54
                        return ReadFrom (reader);
101
55
                }
102
56
                
103
57
                const string Node              = "Node";
105
59
                const string expandedAttribute = "expanded";
106
60
                const string selectedAttribute = "selected";
107
61
 
108
 
                void WriteTo (XmlWriter writer, ExtensibleTreeView.TreeOptions parentOptions)
 
62
                void WriteTo (XmlWriter writer)
109
63
                {
110
64
                        writer.WriteStartElement (Node);
111
65
                        if (NodeName != null)
115
69
                        if (Selected)
116
70
                                writer.WriteAttributeString (selectedAttribute, bool.TrueString);
117
71
 
118
 
                        ExtensibleTreeView.TreeOptions ops = Options;
119
 
                        if (ops != null) {
120
 
                                foreach (DictionaryEntry de in ops) {
121
 
                                        object parentVal = parentOptions != null ? parentOptions [de.Key] : null;
122
 
                                        if (parentVal != null && !parentVal.Equals (de.Value) || (parentVal == null && de.Value != null) || parentOptions == null) {
123
 
                                                writer.WriteStartElement ("Option");
124
 
                                                writer.WriteAttributeString ("id", de.Key.ToString());
125
 
                                                writer.WriteAttributeString ("value", de.Value.ToString ());
126
 
                                                writer.WriteEndElement (); // Option
127
 
                                        }
 
72
                        if (Options != null) {
 
73
                                foreach (var opt in Options) {
 
74
                                        writer.WriteStartElement ("Option");
 
75
                                        writer.WriteAttributeString ("id", opt.Key.ToString());
 
76
                                        writer.WriteAttributeString ("value", opt.Value.ToString ());
 
77
                                        writer.WriteEndElement (); // Option
128
78
                                }
129
79
                        }
130
80
                        
131
81
                        if (ChildrenState != null) { 
132
82
                                foreach (NodeState ces in ChildrenState) {
133
 
                                        ces.WriteTo (writer, Options != null ? Options : parentOptions);
 
83
                                        ces.WriteTo (writer);
134
84
                                }
135
85
                        }
136
86
                        
137
87
                        writer.WriteEndElement (); // NodeState
138
88
                }
139
89
 
140
 
                ICustomXmlSerializer ReadFrom (XmlReader reader, ExtensibleTreeView.TreeOptions parentOptions)
 
90
                ICustomXmlSerializer ReadFrom (XmlReader reader)
141
91
                {
142
92
                        NodeState result = new NodeState ();
143
93
                        result.NodeName = reader.GetAttribute (nameAttribute);
150
100
                                switch (reader.LocalName) {
151
101
                                case "Option":
152
102
                                        if (result.Options == null) 
153
 
                                                result.Options = parentOptions != null ? parentOptions.CloneOptions (Gtk.TreeIter.Zero) : new ExtensibleTreeView.TreeOptions ();   
 
103
                                                result.Options = new Dictionary<string, bool> ();
154
104
                                        result.Options [reader.GetAttribute ("id")] = bool.Parse (reader.GetAttribute ("value"));
155
105
                                        return true;
156
106
                                case "Node":
157
107
                                        if (result.ChildrenState == null)
158
108
                                                result.ChildrenState = new List<NodeState> ();
159
 
                                        result.ChildrenState.Add ((NodeState)ReadFrom (reader, result.Options != null ? result.Options : parentOptions));
 
109
                                        result.ChildrenState.Add ((NodeState)ReadFrom (reader));
160
110
                                        return true;
161
111
                                }
162
112
                                return false;
188
138
                                } while (nav.MoveNext ());
189
139
                                nav.MoveToParent ();
190
140
                        }
191
 
                        
192
 
                        ExtensibleTreeView.TreeOptions ops = pad.GetNodeOptions (nav);
193
 
                        
194
 
                        if (ops != null || nav.Expanded || childrenState != null || nav.Selected) {
 
141
 
 
142
                        if (nav.Expanded || childrenState != null || nav.Selected) {
195
143
                                NodeState es = new NodeState ();
196
144
                                es.Expanded = nav.Expanded;
197
145
                                es.Selected = nav.Selected;
198
 
                                es.Options = ops;
199
146
                                es.ChildrenState = childrenState;
200
147
                                return es;
201
148
                        } else
205
152
                public override string ToString ()
206
153
                {
207
154
                        return String.Format ("[NodeState: NodeName={0}, Expanded={1}, Selected={2}, Options={3}, #ChildrenState={4}]",
208
 
                                              this.nodeName,
209
 
                                              this.expanded,
210
 
                                              this.selected,
211
 
                                              this.options != null ? this.options.ToString () : "null",
212
 
                                              this.childrenState != null ? this.childrenState.Count.ToString () : "null");
 
155
                                              this.NodeName,
 
156
                                              this.Expanded,
 
157
                                              this.Selected,
 
158
                                              this.Options != null ? this.Options.ToString () : "null",
 
159
                                              this.ChildrenState != null ? this.ChildrenState.Count.ToString () : "null");
213
160
                }
214
161
                 
215
162
                internal static void RestoreState (ExtensibleTreeView pad, ITreeNavigator nav, NodeState es)
216
163
                {
217
164
                        if (es == null) 
218
165
                                return;
219
 
                        
220
 
                        if (es.Options != null) 
221
 
                                pad.SetNodeOptions (nav, es.Options);
222
 
                        
 
166
 
223
167
                        pad.ResetState (nav);
224
168
                        nav.Expanded = es.Expanded;
225
169
                        
236
180
                                nav.Selected = true;
237
181
                }
238
182
        }
239
 
}
 
183
}
 
 
b'\\ No newline at end of file'