diff options
author | Lluis Sanchez Gual <lluis@novell.com> | 2011-03-22 21:33:32 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@novell.com> | 2011-03-22 21:33:32 +0300 |
commit | a2674ee729fe11b2b2692f4b9622ee85f8aea29c (patch) | |
tree | 28ffdeb87eecffac5f5e53640d9ebd4b552f1ed7 /main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer | |
parent | 55112c1043bea560d65b0fa25ea6d763c2aed516 (diff) |
Improved support for visualizers
Added some documentation.
Added method for checking if a visualizer supports editing. The OK
button is hidden when the visualizer doesn't support it.
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer')
4 files changed, 84 insertions, 1 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/IValueVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/IValueVisualizer.cs index da5c4a6c42..b2d876ba7b 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/IValueVisualizer.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/IValueVisualizer.cs @@ -31,10 +31,80 @@ namespace MonoDevelop.Debugger { public interface IValueVisualizer { + /// <summary> + /// Display name of the visualizer + /// </summary> + /// <remarks> + /// This name is shown in a combo box at the top of the visualizer dialog when + /// there is more than one visualizer available for a value + /// </remarks> string Name { get; } + + /// <summary> + /// Determines whether this instance can visualize the specified value + /// </summary> + /// <returns> + /// <c>true</c> if this instance can visualize the specified value; otherwise, <c>false</c>. + /// </returns> + /// <param name='val'> + /// The value + /// </param> + /// <remarks> + /// This method must check the value and return <c>true</v> if it is able to display that value. + /// Typically, this method will check the TypeName of the value. + /// </remarks> bool CanVisualize (ObjectValue val); + + /// <summary> + /// Gets a visualizer widget for a value + /// </summary> + /// <returns> + /// The visualizer widget. + /// </returns> + /// <param name='val'> + /// A value + /// </param> + /// <remarks> + /// This method is called to get a widget for displaying the specified value. + /// The method should create the widget and load the required information from + /// the value. Notice that the ObjectValue.Value property returns a string + /// representation of the value. If the visualizer needs to get values from + /// the object properties, it can use the ObjectValue.GetRawValue method. + /// </remarks> Gtk.Widget GetVisualizerWidget (ObjectValue val); + + /// <summary> + /// Saves changes done in the visualizer + /// </summary> + /// <returns> + /// <c>true</c> if the changes could be saved + /// </returns> + /// <param name='val'> + /// The value on which to store changes + /// </param> + /// <remarks> + /// This method is called to save changes done in the visualizer. + /// The implementation should use ObjectValue.SetRawValue to store the changes. + /// </remarks> bool StoreValue (ObjectValue val); + + /// <summary> + /// Determines whether this instance supports editing the specified value + /// </summary> + /// <returns> + /// <c>true</c> if this instance can edit the specified value; otherwise, <c>false</c>. + /// </returns> + /// <param name='val'> + /// The value + /// </param> + /// <remarks> + /// This method is called to determine if this visualizer supports value editing, + /// in addition to visualization. + /// The method is called only if CanVisualize returns <c>true</c> for the value, and + /// if the value doesn't have the ReadOnly flag. + /// Editing support is optional. + /// </remarks> + bool CanEdit (ObjectValue val); } } diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/PixbufVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/PixbufVisualizer.cs index 96e3a84967..d637512ba8 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/PixbufVisualizer.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/PixbufVisualizer.cs @@ -38,6 +38,11 @@ namespace MonoDevelop.Debugger.Visualizer return val.TypeName == "Gdk.Pixbuf"; } + public bool CanEdit (ObjectValue val) + { + return false; + } + public Gtk.Widget GetVisualizerWidget (ObjectValue val) { Gdk.Pixbuf pixbuf; diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/TextVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/TextVisualizer.cs index 707e6f8f78..44340b84dc 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/TextVisualizer.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/TextVisualizer.cs @@ -81,6 +81,11 @@ namespace MonoDevelop.Debugger.Visualizer val.SetRawValue (textView.Buffer.Text); return true; } + + public bool CanEdit (ObjectValue val) + { + return true; + } } } diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs index 112da52e56..0b8b2bc933 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Visualizer/ValueVisualizerDialog.cs @@ -23,9 +23,12 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. + using System; +using System.Linq; using System.Collections.Generic; using Mono.Debugging.Client; + namespace MonoDevelop.Debugger.Viewers { public partial class ValueVisualizerDialog : Gtk.Dialog @@ -50,7 +53,7 @@ namespace MonoDevelop.Debugger.Viewers foreach (IValueVisualizer vis in visualizers) comboVisualizers.AppendText (vis.Name); comboVisualizers.Active = 0; - if (val.IsReadOnly || visualizers.Count == 0) { + if (val.IsReadOnly || !visualizers.Where (v => v.CanEdit (val)).Any ()) { buttonCancel.Hide (); buttonOk.Label = Gtk.Stock.Close; } |