summaryrefslogtreecommitdiff
path: root/extras/tiopf
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-11-06 12:40:06 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-11-06 12:40:06 +0000
commit9acdfb0b471332c4336b2fadb2d3836a3b538e1e (patch)
tree329399f5d5b3c64e13d7da60b0eaeb2e35d527c8 /extras/tiopf
parent653e30e7372c3f958921737dee8dfaf5ec1160d6 (diff)
downloadfpGUI-9acdfb0b471332c4336b2fadb2d3836a3b538e1e.tar.xz
* Minor improvements to the tiMediators unit.
Diffstat (limited to 'extras/tiopf')
-rw-r--r--extras/tiopf/gui/tiMediators.pas27
1 files changed, 18 insertions, 9 deletions
diff --git a/extras/tiopf/gui/tiMediators.pas b/extras/tiopf/gui/tiMediators.pas
index ee5abb9c..df6a6f5b 100644
--- a/extras/tiopf/gui/tiMediators.pas
+++ b/extras/tiopf/gui/tiMediators.pas
@@ -156,7 +156,9 @@ type
{ TComboBox observing a list and setting a Object property }
TMediatorDynamicComboBoxView = class(TMediatorComboBoxView)
private
+ FDisplayFieldName: string;
FExternalOnChange: TNotifyEvent;
+ function GetDisplayFieldName: string;
procedure InternalListRefresh;
protected
procedure SetListObject(const AValue: TtiObjectList); override;
@@ -166,6 +168,7 @@ type
procedure DoObjectToGui; override;
public
procedure RefreshList; virtual;
+ property DisplayFieldName: string read GetDisplayFieldName write FDisplayFieldName;
end;
@@ -216,6 +219,9 @@ uses
const
cErrorListHasNotBeenAssigned = 'List has not been assigned';
+ cErrorPropertyNotClass = 'Property is not a class type!';
+ cErrorAddingItemToCombobox = 'Error adding list items to combobox ' +
+ 'Message: %s, Item Property Name: %s';
procedure RegisterFallBackMediators;
@@ -541,18 +547,21 @@ begin
try
for i := 0 to ValueList.Count - 1 do
- begin
- lItems.Add(ValueList.Items[i].Caption);
- end;
+ lItems.AddObject(GetStrProp(ValueList.Items[i], DisplayFieldName), ValueList.Items[i]);
except
on E: Exception do
- raise EMediator.CreateFmt('Error adding list items to combobox ' +
- 'Message: %s, Item Property Name: %s',
- [E.message, FieldName]);
+ RaiseMediatorError(cErrorAddingItemToCombobox,[E.message, FieldName]);
end;
ObjectToGui;
end;
+function TMediatorDynamicComboBoxView.GetDisplayFieldName: string;
+begin
+ Result := FDisplayFieldName;
+ if (Result = '') then
+ Result := 'Caption'; // Do not localize.
+end;
+
procedure TMediatorDynamicComboBoxView.SetOnChangeActive(AValue: Boolean);
begin
if AValue then
@@ -598,7 +607,7 @@ begin
if lPropType = tkClass then
typinfo.SetObjectProp(Subject, FieldName, lValue)
else
- raise EtiOPFProgrammerException.Create('Error property type not a Class');
+ RaiseMediatorError(cErrorPropertyNotClass);
end;
procedure TMediatorDynamicComboBoxView.DoObjectToGui;
@@ -615,13 +624,13 @@ begin
Exit; //==>
if not Assigned(ValueList) then
- raise EMediator.Create(cErrorListHasNotBeenAssigned);
+ RaiseMediatorError(cErrorListHasNotBeenAssigned);
lPropType := typinfo.PropType(Subject, FieldName);
if lPropType = tkClass then
lValue := TtiObject(typinfo.GetObjectProp(Subject, FieldName))
else
- raise EMediator.Create('Property is not a class type!');
+ RaiseMediatorError(cErrorPropertyNotClass);
for i := 0 to ValueList.Count - 1 do
if ValueList.Items[i] = lValue then