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

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport/PropertyPadVisitor.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:
28
28
 
29
29
using System;
30
30
using MonoDevelop.Components.Commands;
 
31
using MonoDevelop.Ide;
 
32
using MonoDevelop.Ide.Gui;
31
33
 
32
34
namespace MonoDevelop.DesignerSupport
33
35
{
34
36
        class PropertyPadVisitor: ICommandTargetVisitor
35
37
        {
 
38
                // Set to true when a property pad provider is found
 
39
                bool found;
 
40
 
 
41
                // Set to true if the current active document has been visited
 
42
                bool visitedCurrentDoc;
 
43
 
 
44
                // Set to true if the current active document is being visited
 
45
                // on a second try
 
46
                bool visitingCurrentDoc;
 
47
 
 
48
                Gtk.Widget activeWidget;
 
49
 
 
50
                public void Start ()
 
51
                {
 
52
                        found = false;
 
53
                        visitedCurrentDoc = false;
 
54
                        activeWidget = null;
 
55
                }
 
56
 
 
57
                public void End ()
 
58
                {
 
59
                        if (!found) {
 
60
                                if (!visitingCurrentDoc && !visitedCurrentDoc) {
 
61
                                        // A provider has not been found, but the current document has not been visited
 
62
                                        // (the focus may be for example in a pad).
 
63
                                        // Try visiting the command route again, but this time starting at the currently
 
64
                                        // active document. The visitingCurrentDoc flag is used to avoid entering in a loop.
 
65
                                        var wb = (DefaultWorkbench)IdeApp.Workbench.RootWindow;
 
66
                                        if (wb.ActiveWorkbenchWindow != null) {
 
67
                                                visitingCurrentDoc = true;
 
68
                                                IdeApp.CommandService.VisitCommandTargets (this, wb.ActiveWorkbenchWindow);
 
69
                                                visitingCurrentDoc = false;
 
70
                                                // All done, VisitCommandTargets will set the final state of the pad
 
71
                                                return;
 
72
                                        }
 
73
                                }
 
74
                                DesignerSupport.Service.ReSetPad ();
 
75
                        }
 
76
                }
 
77
 
36
78
                public bool Visit (object ob)
37
79
                {
38
 
                        if (ob == null) {
39
 
                                DesignerSupport.Service.ReSetPad ();
40
 
                                return true;
41
 
                        }
42
 
                        else if (ob is PropertyPad) {
 
80
                        if (activeWidget == null && ob is Gtk.Widget)
 
81
                                activeWidget = (Gtk.Widget) ob;
 
82
 
 
83
                        if (ob == ((DefaultWorkbench)IdeApp.Workbench.RootWindow).ActiveWorkbenchWindow)
 
84
                                visitedCurrentDoc = true;
 
85
 
 
86
                        if (ob is PropertyPad) {
43
87
                                // Don't change the property grid selection when the focus is inside the property grid itself
 
88
                                found = true;
44
89
                                return true;
45
90
                        }
46
91
                        else if (ob is IPropertyPadProvider) {
47
 
                                DesignerSupport.Service.SetPadContent ((IPropertyPadProvider)ob);
 
92
                                DesignerSupport.Service.SetPadContent ((IPropertyPadProvider)ob, activeWidget);
 
93
                                found = true;
48
94
                                return true;
49
95
                        }
50
96
                        else if (ob is ICustomPropertyPadProvider) {
51
 
                                DesignerSupport.Service.SetPadContent ((ICustomPropertyPadProvider)ob);
 
97
                                DesignerSupport.Service.SetPadContent ((ICustomPropertyPadProvider)ob, activeWidget);
 
98
                                found = true;
52
99
                                return true;
53
100
                        }
54
101
                        else