Debugger: Implement value editor hook for more handlers.

{Bool,Enumeration}ValueHandler:
- Implement GetTableCellValueEditor() hook.
This commit is contained in:
Rene Gollent
2015-07-24 17:08:52 -04:00
parent 1f3db0d0d6
commit 55d4f9ff18
4 changed files with 75 additions and 1 deletions
@@ -11,6 +11,7 @@
#include "BoolValue.h"
#include "BoolValueFormatter.h"
#include "TableCellBoolEditor.h"
#include "TableCellFormattedValueRenderer.h"
@@ -62,7 +63,7 @@ BoolValueHandler::GetTableCellValueRenderer(Value* value,
return B_BAD_VALUE;
ValueFormatter* formatter = NULL;
if (GetValueFormatter(value, formatter))
if (GetValueFormatter(value, formatter) != B_OK)
return B_NO_MEMORY;
BReference<ValueFormatter> formatterReference(formatter, true);
@@ -75,3 +76,33 @@ BoolValueHandler::GetTableCellValueRenderer(Value* value,
_renderer = renderer;
return B_OK;
}
status_t
BoolValueHandler::GetTableCellValueEditor(Value* _value, Settings* settings,
TableCellValueEditor*& _editor)
{
BoolValue* value = dynamic_cast<BoolValue*>(_value);
if (value == NULL)
return B_BAD_VALUE;
ValueFormatter* formatter;
status_t error = GetValueFormatter(value, formatter);
if (error != B_OK)
return error;
BReference<ValueFormatter> formatterReference(formatter, true);
TableCellBoolEditor* editor = new(std::nothrow)
TableCellBoolEditor(value, formatter);
if (editor == NULL)
return B_NO_MEMORY;
BReference<TableCellBoolEditor> editorReference(editor, true);
error = editor->Init();
if (error != B_OK)
return error;
editorReference.Detach();
_editor = editor;
return B_OK;
}
@@ -21,6 +21,9 @@ public:
ValueFormatter*& _formatter);
virtual status_t GetTableCellValueRenderer(Value* value,
TableCellValueRenderer*& _renderer);
virtual status_t GetTableCellValueEditor(Value* _value,
Settings* settings,
TableCellValueEditor*& _editor);
};
@@ -11,6 +11,7 @@
#include "EnumerationValue.h"
#include "EnumerationValueFormatter.h"
#include "TableCellEnumerationEditor.h"
#include "TableCellFormattedValueRenderer.h"
#include "Type.h"
@@ -64,6 +65,42 @@ EnumerationValueHandler::GetValueFormatter(Value* _value,
}
status_t
EnumerationValueHandler::GetTableCellValueEditor(Value* _value,
Settings* settings, TableCellValueEditor*& _editor)
{
EnumerationValue* value = dynamic_cast<EnumerationValue*>(_value);
if (value == NULL)
return B_BAD_VALUE;
IntegerValueFormatter::Config* config = NULL;
status_t error = CreateIntegerFormatterConfig(value, config);
if (error != B_OK)
return error;
BReference<IntegerValueFormatter::Config> configReference(config, true);
ValueFormatter* formatter;
error = CreateValueFormatter(config, formatter);
if (error != B_OK)
return error;
BReference<ValueFormatter> formatterReference(formatter, true);
TableCellEnumerationEditor* editor = new(std::nothrow)
TableCellEnumerationEditor(value, formatter);
if (editor == NULL)
return B_NO_MEMORY;
BReference<TableCellEnumerationEditor> editorReference(editor, true);
error = editor->Init();
if (error != B_OK)
return error;
editorReference.Detach();
_editor = editor;
return B_OK;
}
integer_format
EnumerationValueHandler::DefaultIntegerFormat(IntegerValue* _value)
{
@@ -19,6 +19,9 @@ public:
virtual float SupportsValue(Value* value);
virtual status_t GetValueFormatter(Value* value,
ValueFormatter*& _formatter);
virtual status_t GetTableCellValueEditor(Value* value,
Settings* settings,
TableCellValueEditor*& _editor);
protected:
virtual integer_format DefaultIntegerFormat(IntegerValue* value);