2007-12-09 12:02:11 +00:00
|
|
|
unit CmpSwObjects;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
ToolsAPI,
|
|
|
|
|
|
|
|
BaseSwObjects;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TCmpSwComponent = class(TBaseSwItem)
|
|
|
|
private
|
2007-12-10 16:13:05 +00:00
|
|
|
FComponent: IOTAComponent;
|
|
|
|
FComponentClass: String;
|
|
|
|
FName: String;
|
2007-12-09 12:02:11 +00:00
|
|
|
protected
|
|
|
|
function GetName(): String; override;
|
|
|
|
public
|
|
|
|
constructor Create(AComponent: IOTAComponent);
|
2007-12-10 16:13:05 +00:00
|
|
|
class function TryCreate(AComponent: IOTAComponent): TCmpSwComponent;
|
2007-12-09 12:02:11 +00:00
|
|
|
|
2007-12-10 16:13:05 +00:00
|
|
|
procedure Activate(const AClearSelection: Boolean);
|
2007-12-09 12:02:11 +00:00
|
|
|
|
2007-12-10 16:13:05 +00:00
|
|
|
property ComponentClass: String read FComponentClass;
|
2007-12-09 12:02:11 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
SysUtils;
|
|
|
|
|
|
|
|
|
|
|
|
{ TCmpSwComponent }
|
|
|
|
class function TCmpSwComponent.TryCreate(AComponent: IOTAComponent): TCmpSwComponent;
|
|
|
|
begin
|
|
|
|
Result := TCmpSwComponent.Create(AComponent);
|
|
|
|
if Length(Result.Name) = 0 then
|
|
|
|
FreeAndNil(Result);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TCmpSwComponent.Create(AComponent: IOTAComponent);
|
|
|
|
begin
|
|
|
|
inherited Create();
|
|
|
|
|
2007-12-10 16:13:05 +00:00
|
|
|
FComponent := AComponent;
|
2007-12-09 12:02:11 +00:00
|
|
|
FComponent.GetPropValueByName('Name', FName);
|
2007-12-10 16:13:05 +00:00
|
|
|
FComponentClass := FComponent.GetComponentType();
|
2007-12-09 12:02:11 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TCmpSwComponent.Activate(const AClearSelection: Boolean);
|
|
|
|
begin
|
|
|
|
FComponent.Select(not AClearSelection);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TCmpSwComponent.GetName(): String;
|
|
|
|
begin
|
|
|
|
Result := FName;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|