From: <wp...@us...> - 2009-08-19 18:07:45
|
Revision: 851 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=851&view=rev Author: wp2udk Date: 2009-08-19 18:07:37 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Enhancements to the ModelExplorer and the introduction of the TInstantAttributeViewFrame as published in the Newsgroup Repository 11-10-2007 (ddmmyyy) didn't allow the user to create new attributes and there was too much copy/paste in the code. The TInstantClassEditorForm and TInstantModelExplorerForm is rewritten to use the TInstantAttributeViewFrame. It now shared the exact same code. Modified Paths: -------------- trunk/Source/Design/InstantAttributeView.pas trunk/Source/Design/InstantClassEditor.dfm trunk/Source/Design/InstantClassEditor.pas trunk/Source/Design/InstantModelExplorer.dfm trunk/Source/Design/InstantModelExplorer.pas Modified: trunk/Source/Design/InstantAttributeView.pas =================================================================== --- trunk/Source/Design/InstantAttributeView.pas 2009-08-19 16:06:24 UTC (rev 850) +++ trunk/Source/Design/InstantAttributeView.pas 2009-08-19 18:07:37 UTC (rev 851) @@ -25,7 +25,7 @@ * * Contributor(s): * David Moorhouse, Carlo Barazzetta, Adrea Petrelli, Steven Mitchell, - * Nando Dessena, David Taylor + * Nando Dessena, David Taylor, Brian Andersen * * ***** END LICENSE BLOCK ***** *) @@ -88,6 +88,8 @@ FNewAttributes: TList; FModel: TInstantCodeModel; FNameAttribute: TInstantCodeAttribute; + FWasAccepted: Boolean; + FOldSubjectName: string; procedure DeleteAttribute(Attribute: TInstantCodeAttribute); procedure FitColumns(View: TListView); function GetNameAttribute: TInstantCodeAttribute; @@ -97,26 +99,30 @@ procedure SetSubject(const Value: TInstantCodeClass); function GetFocusedAttribute: TInstantCodeAttribute; protected + property FocusedAttribute: TInstantCodeAttribute read GetFocusedAttribute; + property NameAttribute: TInstantCodeAttribute read GetNameAttribute; function AddAttributeToView(View: TListView; Attribute: TInstantCodeAttribute): TListItem; function EditAttribute(Attribute: TInstantCodeAttribute; Exists: Boolean; const Title: string = ''): Boolean; - procedure PopulateInheritedAttributes; - procedure PopulateIntroducedAttributes; - property NameAttribute: TInstantCodeAttribute read GetNameAttribute; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Clear; + procedure PopulateInheritedAttributes; + procedure PopulateIntroducedAttributes; procedure RestoreAttributes; - procedure UpdateActions; + procedure UpdateActions; procedure RestoreLayout; procedure StoreLayout; + property BackupAttributes: TObjectList read FBackupAttributes; property ChangedAttributes: TStringList read FChangedAttributes; - property FocusedAttribute: TInstantCodeAttribute read GetFocusedAttribute; property Model: TInstantCodeModel read FModel write SetModel; property NewAttributes: TList read FNewAttributes; property Subject: TInstantCodeClass read FSubject write SetSubject; + + property WasAccepted: Boolean read FWasAccepted; + property OldSubjectName: string read FOldSubjectName; end; implementation @@ -169,12 +175,18 @@ var Attribute: TInstantCodeAttribute; begin + FWasAccepted := False; + FOldSubjectName := Subject.Name; + with IntroducedAttributesView do if Assigned(ItemFocused) then begin Attribute := ItemFocused.Data; if not Confirm(Format(SConfirmDeleteAttribute, [Attribute.Name])) then Exit; + + FWasAccepted := True; + DeleteAttribute(Attribute); ItemFocused.Delete; if Assigned(ItemFocused) then @@ -183,13 +195,15 @@ end; end; -procedure TInstantAttributeViewFrame.AttributeEditActionExecute( - Sender: TObject); +procedure TInstantAttributeViewFrame.AttributeEditActionExecute(Sender: TObject); var OldName: string; Attribute: TInstantCodeAttribute; Exists: Boolean; begin + FWasAccepted := False; + FOldSubjectName := Subject.Name; + Attribute := FocusedAttribute; if not Assigned(Attribute) then Exit; @@ -199,6 +213,8 @@ Attribute.DetectMethodTypes; if EditAttribute(Attribute, Exists) then begin + FWasAccepted := True; + if Exists and (FChangedAttributes.IndexOfObject(Attribute) = -1) then FChangedAttributes.AddObject(OldName, Attribute); PopulateIntroducedAttributes; @@ -210,10 +226,15 @@ Attribute: TInstantCodeAttribute; NewItem: TListItem; begin + FWasAccepted := False; + FOldSubjectName := Subject.Name; + Attribute := Subject.AddAttribute; if not EditAttribute(Attribute, False, 'New Attribute') then Attribute.Free else begin + FWasAccepted := True; + FNewAttributes.Add(Attribute); with IntroducedAttributesView do begin @@ -239,6 +260,8 @@ begin InheritedAttributesView.Clear; IntroducedAttributesView.Clear; + FChangedAttributes.Clear; + FNewAttributes.Clear; end; constructor TInstantAttributeViewFrame.Create(AOwner: TComponent); Modified: trunk/Source/Design/InstantClassEditor.dfm =================================================================== --- trunk/Source/Design/InstantClassEditor.dfm 2009-08-19 16:06:24 UTC (rev 850) +++ trunk/Source/Design/InstantClassEditor.dfm 2009-08-19 18:07:37 UTC (rev 851) @@ -1,21 +1,25 @@ inherited InstantClassEditorForm: TInstantClassEditorForm Left = 319 Top = 196 - Width = 408 - Height = 399 Caption = 'Class Editor' + ClientHeight = 365 + ClientWidth = 400 OldCreateOrder = True OnCreate = FormCreate + ExplicitWidth = 408 + ExplicitHeight = 399 PixelsPerInch = 96 TextHeight = 13 inherited EditPanel: TPanel Width = 400 - Height = 341 + Height = 334 + ExplicitWidth = 400 + ExplicitHeight = 334 object PageControl: TPageControl Left = 4 Top = 4 Width = 392 - Height = 333 + Height = 326 ActivePage = ClassSheet Align = alClient TabOrder = 0 @@ -120,108 +124,48 @@ BorderWidth = 4 Caption = 'Attributes' ImageIndex = 1 - object AttributesSplitter: TSplitter + inline InstantAttributeViewFrame: TInstantAttributeViewFrame Left = 0 - Top = 165 - Width = 376 - Height = 3 - Cursor = crVSplit - Align = alBottom - end - object InheritedAttributesPanel: TPanel - Left = 0 - Top = 168 - Width = 376 - Height = 129 - Align = alBottom - BevelOuter = bvNone - TabOrder = 1 - object InheritedAttributesLabel: TLabel - Left = 0 - Top = 0 - Width = 376 - Height = 16 - Align = alTop - AutoSize = False - Caption = 'Inherited' - end - object InheritedAttributesView: TListView - Left = 0 - Top = 16 - Width = 376 - Height = 113 - Align = alClient - Columns = < - item - Caption = 'Name' - Width = 124 - end - item - Caption = 'Type' - Width = 124 - end - item - Caption = 'Storage Name' - Width = 124 - end> - ReadOnly = True - TabOrder = 0 - ViewStyle = vsReport - OnEdited = IntroducedAttributesViewEdited - end - end - object IntroducedAttributesPanel: TPanel - Left = 0 Top = 0 Width = 376 - Height = 165 + Height = 290 Align = alClient - BevelOuter = bvNone TabOrder = 0 - object IntroducedAttributesLabel: TLabel - Left = 0 - Top = 0 - Width = 376 - Height = 16 - Align = alTop - AutoSize = False - Caption = 'Introduced' + ExplicitHeight = 290 + inherited AttributesSplitter: TSplitter + Top = 186 + ExplicitTop = 186 end - object IntroducedAttributesView: TListView - Left = 0 - Top = 16 - Width = 376 - Height = 149 - Align = alClient - Columns = < - item - Caption = 'Name' - Width = 124 - end - item - Caption = 'Type' - Width = 124 - end - item - Caption = 'Storage Name' - Width = 124 - end> - ReadOnly = True - PopupMenu = AttributesMenu - TabOrder = 0 - ViewStyle = vsReport - OnDblClick = IntroducedAttributesViewDblClick - OnEdited = IntroducedAttributesViewEdited + inherited InheritedAttributesPanel: TPanel + Top = 190 + ExplicitTop = 190 end + inherited IntroducedAttributesPanel: TPanel + Height = 186 + ExplicitHeight = 186 + inherited IntroducedAttributesView: TListView + Height = 170 + ExplicitHeight = 170 + end + end end end end end inherited BottomPanel: TPanel - Top = 341 + Top = 334 Width = 400 + ExplicitTop = 334 + ExplicitWidth = 400 inherited ButtonPanel: TPanel Left = 240 + ExplicitLeft = 240 + inherited OkButton: TButton + Left = 1 + Top = 6 + ExplicitLeft = 1 + ExplicitTop = 6 + end end end inherited SubjectExposer: TInstantExposer @@ -232,57 +176,4 @@ inherited SubjectSource: TDataSource Top = 268 end - object AttributeImages: TImageList - Left = 68 - Top = 268 - end - object StateImages: TImageList - Left = 100 - Top = 268 - end - object AttributesMenu: TPopupMenu - Images = ActionImages - OnPopup = AttributesMenuPopup - Left = 164 - Top = 268 - object AttributeNewItem: TMenuItem - Action = AttributeNewAction - ShortCut = 45 - end - object AttributeDeleteItem: TMenuItem - Action = AttributeDeleteAction - ShortCut = 46 - end - object AttributeEditItem: TMenuItem - Action = AttributeEditAction - ShortCut = 32781 - end - end - object Actions: TActionList - Images = ActionImages - Left = 196 - Top = 268 - object AttributeNewAction: TAction - Caption = '&New' - Hint = 'New Attribute' - ImageIndex = 0 - OnExecute = AttributeNewActionExecute - end - object AttributeDeleteAction: TAction - Caption = '&Delete' - Hint = 'Delete' - ImageIndex = 1 - OnExecute = AttributeDeleteActionExecute - end - object AttributeEditAction: TAction - Caption = '&Edit' - Hint = 'Edit' - ImageIndex = 2 - OnExecute = AttributeEditActionExecute - end - end - object ActionImages: TImageList - Left = 132 - Top = 268 - end end Modified: trunk/Source/Design/InstantClassEditor.pas =================================================================== --- trunk/Source/Design/InstantClassEditor.pas 2009-08-19 16:06:24 UTC (rev 850) +++ trunk/Source/Design/InstantClassEditor.pas 2009-08-19 18:07:37 UTC (rev 851) @@ -24,7 +24,8 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Carlo Barazzetta, Adrea Petrelli, Steven Mitchell, Nando Dessena + * Carlo Barazzetta, Adrea Petrelli, Steven Mitchell, Nando Dessena, + * Brian Andersen * * ***** END LICENSE BLOCK ***** *) @@ -44,7 +45,7 @@ {$IFDEF MSWINDOWS} Windows, Messages, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, Mask, DBCtrls, - ImgList, ActnList, Menus; + ImgList, ActnList, Menus, InstantAttributeView; {$ENDIF} {$IFDEF LINUX} QActnList, QMenus, QTypes, QImgList, QComCtrls, QControls, QExtCtrls, @@ -53,17 +54,6 @@ type TInstantClassEditorForm = class(TInstantEditForm) - AttributeImages: TImageList; - StateImages: TImageList; - AttributesMenu: TPopupMenu; - Actions: TActionList; - ActionImages: TImageList; - AttributeNewAction: TAction; - AttributeDeleteAction: TAction; - AttributeNewItem: TMenuItem; - AttributeDeleteItem: TMenuItem; - AttributeEditAction: TAction; - AttributeEditItem: TMenuItem; PageControl: TPageControl; ClassSheet: TTabSheet; ClassNameLabel: TLabel; @@ -74,23 +64,11 @@ UnitEdit: TDBComboBox; StorageEdit: TDBEdit; AttributeSheet: TTabSheet; - AttributesSplitter: TSplitter; - InheritedAttributesPanel: TPanel; - InheritedAttributesLabel: TLabel; - InheritedAttributesView: TListView; - IntroducedAttributesPanel: TPanel; - IntroducedAttributesView: TListView; - IntroducedAttributesLabel: TLabel; StorageLabel: TLabel; PersistenceComboBox: TDBComboBox; PersistenceLabel: TLabel; - procedure AttributeNewActionExecute(Sender: TObject); - procedure AttributeDeleteActionExecute(Sender: TObject); - procedure AttributeEditActionExecute(Sender: TObject); + InstantAttributeViewFrame: TInstantAttributeViewFrame; procedure FormCreate(Sender: TObject); - procedure IntroducedAttributesViewDblClick(Sender: TObject); - procedure IntroducedAttributesViewEdited(Sender: TObject; Item: TListItem; - var S: String); procedure ClassNameEditChange(Sender: TObject); procedure SubjectExposerAfterPostField(Sender: TObject; Field: TField); procedure PersistenceComboBoxChange(Sender: TObject); @@ -98,47 +76,32 @@ var Value: Variant; Write: Boolean); procedure OkButtonClick(Sender: TObject); procedure CancelButtonClick(Sender: TObject); - procedure AttributesMenuPopup(Sender: TObject); procedure ClassSheetResize(Sender: TObject); private - FBackupAttributes: TObjectList; - FChangedAttributes: TStringList; - FNewAttributes: TList; FModel: TInstantCodeModel; - FNameAttribute: TInstantCodeAttribute; FTitle: string; FIsNew: Boolean; - procedure DeleteAttribute(Attribute: TInstantCodeAttribute); - procedure FitColumns(View: TListView); - function GetNameAttribute: TInstantCodeAttribute; function GetSubject: TInstantCodeClass; - procedure LoadAttributeView(View: TListView; AClass: TInstantCodeClass; - Recursive: Boolean); procedure SetModel(const Value: TInstantCodeModel); procedure SetSubject(const Value: TInstantCodeClass); - function GetFocusedAttribute: TInstantCodeAttribute; procedure SetIsNew(const Value: Boolean); + function GetChangedAttributes: TStringList; + function GetNewAttributes: TList; protected - function AddAttributeToView(View: TListView; - Attribute: TInstantCodeAttribute): TListItem; function EditAttribute(Attribute: TInstantCodeAttribute; Exists: Boolean; const Title: string = ''): Boolean; - procedure PopulateInheritedAttributes; - procedure PopulateIntroducedAttributes; procedure PopulateBaseClasses; procedure PopulateUnits; procedure UpdateActions; override; procedure UpdateCaption; procedure UpdateControls; - property NameAttribute: TInstantCodeAttribute read GetNameAttribute; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; - property ChangedAttributes: TStringList read FChangedAttributes; - property FocusedAttribute: TInstantCodeAttribute read GetFocusedAttribute; + property ChangedAttributes: TStringList read GetChangedAttributes; property IsNew: Boolean read FIsNew write SetIsNew; property Model: TInstantCodeModel read FModel write SetModel; - property NewAttributes: TList read FNewAttributes; + property NewAttributes: TList read GetNewAttributes; property Subject: TInstantCodeClass read GetSubject write SetSubject; end; @@ -155,112 +118,10 @@ { TInstantClassDesigner } -function TInstantClassEditorForm.AddAttributeToView( - View: TListView; Attribute: TInstantCodeAttribute): TListItem; -begin - Result := View.Items.Add; - with Result do - begin - with Attribute do - if (HostClass = Subject) or not Assigned(HostClass) then - Caption := Name else - Caption := HostClass.Name + '.' + Name; - Data := Attribute; - //Add Attribute Type - SubItems.Add(Attribute.AttributeTypeText); - //Add StorageName or ExternalStorageName - if Attribute.CanBeExternal and not Attribute.CanHaveStorageName then - SubItems.Add(Attribute.ExternalStorageName) - else - SubItems.Add(Attribute.StorageName); - case Attribute.AttributeType of - atReference: ImageIndex := 1; - atPart: ImageIndex := 2; - atReferences: ImageIndex := 3; - atParts: ImageIndex := 4; - else - ImageIndex := 0; - end; - if Attribute.HostClass <> Subject then - ImageIndex := ImageIndex + 5; - end; - FitColumns(View); -end; - -procedure TInstantClassEditorForm.AttributeDeleteActionExecute(Sender: TObject); -var - Attribute: TInstantCodeAttribute; -begin - with IntroducedAttributesView do - if Assigned(ItemFocused) then - begin - Attribute := ItemFocused.Data; - if not Confirm(Format(SConfirmDeleteAttribute, [Attribute.Name])) then - Exit; - DeleteAttribute(Attribute); - ItemFocused.Delete; - if Assigned(ItemFocused) then - ItemFocused.Selected := True; - FitColumns(IntroducedAttributesView); - end; -end; - -procedure TInstantClassEditorForm.AttributeEditActionExecute(Sender: TObject); -var - OldName: string; - Attribute: TInstantCodeAttribute; - Exists: Boolean; -begin - Attribute := FocusedAttribute; - if not Assigned(Attribute) then - Exit; - OldName := Attribute.Name; - Exists := FNewAttributes.IndexOf(Attribute) = -1; - if Exists then - Attribute.DetectMethodTypes; - if EditAttribute(Attribute, Exists) then - begin - if Exists and (FChangedAttributes.IndexOfObject(Attribute) = -1) then - FChangedAttributes.AddObject(OldName, Attribute); - PopulateIntroducedAttributes; - end; -end; - -procedure TInstantClassEditorForm.AttributeNewActionExecute( - Sender: TObject); -var - Attribute: TInstantCodeAttribute; - NewItem: TListItem; -begin - Attribute := Subject.AddAttribute; - if not EditAttribute(Attribute, False, 'New Attribute') then - Attribute.Free - else begin - FNewAttributes.Add(Attribute); - with IntroducedAttributesView do - begin - Items.BeginUpdate; - try - NewItem := AddAttributeToView(IntroducedAttributesView, Attribute); - NewItem.Focused := True; - Selected := NewItem; - finally - Items.EndUpdate; - end; - NewItem.MakeVisible{$IFDEF MSWINDOWS}(False){$ENDIF}; - end; - end; -end; - -procedure TInstantClassEditorForm.AttributesMenuPopup(Sender: TObject); -begin - UpdateActions; -end; - procedure TInstantClassEditorForm.CancelButtonClick(Sender: TObject); begin inherited; - Subject.AssignAttributes(FBackupAttributes); + Subject.AssignAttributes(InstantAttributeViewFrame.BackupAttributes); end; procedure TInstantClassEditorForm.ClassNameEditChange(Sender: TObject); @@ -274,30 +135,11 @@ constructor TInstantClassEditorForm.Create(AOwner: TComponent); begin inherited; - FBackupAttributes := TObjectList.Create; - FChangedAttributes := TStringList.Create; - FNewAttributes := TList.Create; + InstantAttributeViewFrame.Subject := Subject; end; -procedure TInstantClassEditorForm.DeleteAttribute( - Attribute: TInstantCodeAttribute); -var - Index: Integer; -begin - Index := FChangedAttributes.IndexOfObject(Attribute); - if Index <> -1 then - FChangedAttributes.Delete(Index); - FNewAttributes.Remove(Attribute); - Attribute.Delete; - Attribute.Free; -end; - destructor TInstantClassEditorForm.Destroy; begin - FNewAttributes.Free; - FChangedAttributes.Free; - FBackupAttributes.Free; - FNameAttribute.Free; inherited; end; @@ -331,125 +173,21 @@ end; end; -procedure TInstantClassEditorForm.FitColumns(View: TListView); -var - i : integer; +function TInstantClassEditorForm.GetChangedAttributes: TStringList; begin - //adjust Columns size to window width - for i := View.Columns.Count-1 downto 0 do - begin -{$IFDEF MSWINDOWS} - View.Columns[i].AutoSize := True; -{$ENDIF} -{$IFDEF LINUX} - View.Columns[i].Width := View.Width div View.Columns.Count; -{$ENDIF} - end; + Result := InstantAttributeViewFrame.ChangedAttributes; end; -function TInstantClassEditorForm.GetFocusedAttribute: TInstantCodeAttribute; +function TInstantClassEditorForm.GetNewAttributes: TList; begin - with IntroducedAttributesView do - if Assigned(ItemFocused) then - Result := ItemFocused.Data - else - Result := nil; + Result := InstantAttributeViewFrame.NewAttributes; end; -function TInstantClassEditorForm.GetNameAttribute: TInstantCodeAttribute; -begin - if not Assigned(FNameAttribute) and - Subject.DerivesFrom(TInstantObject.ClassName) then - begin - FNameAttribute := TInstantCodeAttribute.Create(nil); - FNameAttribute.Name := TInstantObject.ClassName + '.' + - InstantIdFieldName; - FNameAttribute.AttributeTypeName := 'String'; - end; - Result := FNameAttribute; -end; - function TInstantClassEditorForm.GetSubject: TInstantCodeClass; begin Result := inherited Subject as TInstantCodeClass; end; -procedure TInstantClassEditorForm.IntroducedAttributesViewDblClick( - Sender: TObject); -begin - AttributeEditAction.Execute; -end; - -procedure TInstantClassEditorForm.IntroducedAttributesViewEdited( - Sender: TObject; Item: TListItem; var S: String); -var - Attribute: TInstantCodeAttribute; -begin - Attribute := TInstantCodeAttribute(Item.Data); - if Assigned(Attribute) then - begin - Attribute.Name := S; - S := Attribute.Name; - end; -end; - -procedure TInstantClassEditorForm.LoadAttributeView(View: TListView; - AClass: TInstantCodeClass; Recursive: Boolean); -var - FocusedData: Pointer; - - procedure LoadClass(AClass: TInstantCodeClass); - var - I: Integer; - NewItem: TListItem; - FocusItem: TListItem; - begin - FocusItem := nil; - if Assigned(AClass) then - with AClass do - begin - for I := 0 to Pred(AttributeCount) do - begin - NewItem := AddAttributeToView(View, Attributes[I]); - if NewItem.Data = FocusedData then - FocusItem := NewItem; - end; - if Recursive then - LoadClass(BaseClass) - else begin - if not Assigned(FocusedData) and (View.Items.Count > 0) then - FocusItem := View.Items[0]; - if Assigned(FocusItem) then - begin - FocusItem.Focused := True; - View.Selected := FocusItem; - end; - end; - end; - end; - -begin - with View do - begin - if Assigned(ItemFocused) then - FocusedData := ItemFocused.Data else - FocusedData := nil; - with Items do - begin - BeginUpdate; - try - Clear; - if Recursive and Assigned(NameAttribute) then - AddAttributeToView(View, NameAttribute); - LoadClass(AClass); - finally - EndUpdate; - FitColumns(View); - end; - end; - end; -end; - procedure TInstantClassEditorForm.OkButtonClick(Sender: TObject); var I: Integer; @@ -511,16 +249,6 @@ end; end; -procedure TInstantClassEditorForm.PopulateInheritedAttributes; -begin - LoadAttributeView(InheritedAttributesView, Subject.BaseClass, True); -end; - -procedure TInstantClassEditorForm.PopulateIntroducedAttributes; -begin - LoadAttributeView(IntroducedAttributesView, Subject, False); -end; - procedure TInstantClassEditorForm.PopulateUnits; var I: Integer; @@ -563,12 +291,12 @@ if Value <> Subject then begin inherited Subject := Value; - Subject.CloneAttributes(FBackupAttributes); + InstantAttributeViewFrame.Subject := Subject; +// Subject.CloneAttributes(FBackupAttributes); + Subject.CloneAttributes(InstantAttributeViewFrame.BackupAttributes); with PersistenceComboBox do ItemIndex := SubjectExposer.GetFieldStrings(Field, Items); PopulateBaseClasses; - PopulateIntroducedAttributes; - PopulateInheritedAttributes; UpdateCaption; UpdateControls; end; @@ -579,8 +307,8 @@ begin if Field.FieldName = 'BaseClassName' then begin - FreeAndNil(FNameAttribute); - PopulateInheritedAttributes; +// FreeAndNil(FNameAttribute); + InstantAttributeViewFrame.PopulateInheritedAttributes; end; end; @@ -600,13 +328,8 @@ end; procedure TInstantClassEditorForm.UpdateActions; -var - Attribute: TInstantCodeAttribute; begin inherited; - Attribute := FocusedAttribute; - AttributeEditAction.Enabled := Assigned(Attribute); - AttributeDeleteAction.Enabled := Assigned(Attribute); end; procedure TInstantClassEditorForm.UpdateCaption; @@ -630,19 +353,6 @@ procedure TInstantClassEditorForm.FormCreate(Sender: TObject); begin - LoadMultipleImages(AttributeImages, 'IO_CLASSEDITORATTRIBUTEIMAGES', HInstance); - LoadMultipleImages(StateImages, 'IO_CLASSEDITORSTATEIMAGES', HInstance); - LoadMultipleImages(ActionImages, 'IO_CLASSEDITORACTIONIMAGES', HInstance); -{$IFDEF MSWINDOWS} - BorderStyle := bsSizeable; - IntroducedAttributesView.SmallImages := AttributeImages; - InheritedAttributesView.SmallImages := AttributeImages; -{$ENDIF} -{$IFDEF LINUX} - BorderStyle := fbsSizeable; - IntroducedAttributesView.Images := AttributeImages; - InheritedAttributesView.Images := AttributeImages; -{$ENDIF} FTitle := Caption; PageControl.ActivePage := ClassSheet; ActiveControl := ClassNameEdit; Modified: trunk/Source/Design/InstantModelExplorer.dfm =================================================================== --- trunk/Source/Design/InstantModelExplorer.dfm 2009-08-19 16:06:24 UTC (rev 850) +++ trunk/Source/Design/InstantModelExplorer.dfm 2009-08-19 18:07:37 UTC (rev 851) @@ -30,9 +30,9 @@ end object ModelPanel: TPanel Left = 0 - Top = 27 + Top = 29 Width = 410 - Height = 228 + Height = 226 Align = alClient BevelOuter = bvNone Constraints.MinHeight = 20 @@ -45,7 +45,6 @@ Height = 29 BorderWidth = 1 ButtonHeight = 23 - Flat = True Images = ActionImages ParentShowHint = False ShowHint = True @@ -121,6 +120,65 @@ ParentFont = False end end + inline InstantAttributeViewFrame: TInstantAttributeViewFrame + Left = 0 + Top = 25 + Width = 410 + Height = 218 + Align = alClient + TabOrder = 1 + ExplicitTop = 25 + ExplicitWidth = 410 + ExplicitHeight = 218 + inherited AttributesSplitter: TSplitter + Top = 114 + Width = 410 + ExplicitTop = 114 + ExplicitWidth = 410 + end + inherited InheritedAttributesPanel: TPanel + Top = 118 + Width = 410 + ExplicitTop = 118 + ExplicitWidth = 410 + inherited InheritedAttributesLabel: TLabel + Width = 410 + ExplicitWidth = 410 + end + inherited InheritedAttributesView: TListView + Width = 410 + Font.Pitch = fpVariable + ExplicitWidth = 410 + end + end + inherited IntroducedAttributesPanel: TPanel + Width = 410 + Height = 114 + ExplicitWidth = 410 + ExplicitHeight = 114 + inherited IntroducedAttributesLabel: TLabel + Width = 410 + ExplicitWidth = 410 + end + inherited IntroducedAttributesView: TListView + Width = 410 + Height = 98 + ExplicitWidth = 410 + ExplicitHeight = 98 + end + end + inherited Actions: TActionList + inherited AttributeNewAction: TAction + OnExecute = InstantAttributeViewFrameAttributeNewActionExecute + end + inherited AttributeDeleteAction: TAction + OnExecute = InstantAttributeViewFrameAttributeDeleteActionExecute + end + inherited AttributeEditAction: TAction + OnExecute = InstantAttributeViewFrameAttributeEditActionExecute + end + end + end end object ModelImages: TImageList Left = 104 Modified: trunk/Source/Design/InstantModelExplorer.pas =================================================================== --- trunk/Source/Design/InstantModelExplorer.pas 2009-08-19 16:06:24 UTC (rev 850) +++ trunk/Source/Design/InstantModelExplorer.pas 2009-08-19 18:07:37 UTC (rev 851) @@ -131,6 +131,7 @@ ViewAttributeButton: TToolButton; ViewAttributesAction: TAction; ViewAttributes: TMenuItem; + InstantAttributeViewFrame: TInstantAttributeViewFrame; procedure AboutActionExecute(Sender: TObject); procedure BuildDatabaseActionExecute(Sender: TObject); procedure CollapseAllActionExecute(Sender: TObject); @@ -151,11 +152,17 @@ procedure ViewRelationsActionExecute(Sender: TObject); procedure ViewSourceActionExecute(Sender: TObject); procedure ImportModelActionExecute(Sender: TObject); + procedure InstantAttributeViewFrameAttributeNewActionExecute( + Sender: TObject); + procedure InstantAttributeViewFrameAttributeDeleteActionExecute( + Sender: TObject); + procedure InstantAttributeViewFrameAttributeEditActionExecute( + Sender: TObject); private FError: TInstantModelError; FModel: TInstantCodeModel; FModelView: TModelTreeView; - FAttributeFrame: TInstantAttributeViewFrame; +// FAttributeFrame: TInstantAttributeViewFrame; FSelectedNode: TTreeNode; FStyle: TInstantModelStyle; FOnApplyClass: TInstantCodeClassApplyEvent; @@ -174,6 +181,7 @@ procedure ApplyClass(AClass: TInstantCodeClass; ChangeType: TInstantCodeChangeType; OldName: string = ''; ChangedAttributes: TStringList = nil; NewAttributes: TList = nil); + procedure ApplyClassFromView(AView: TInstantAttributeViewFrame); function ClassFromNode(Node: TTreeNode): TInstantCodeClass; procedure DoApplyClass(AClass: TInstantCodeClass; ChangeInfo: TInstantCodeClassChangeInfo); @@ -272,6 +280,15 @@ end; end; +procedure TInstantModelExplorerForm.ApplyClassFromView( + AView: TInstantAttributeViewFrame); +begin + if InstantAttributeViewFrame.WasAccepted then + ApplyClass(FocusedClass, ctEdit, InstantAttributeViewFrame.OldSubjectName, + InstantAttributeViewFrame.ChangedAttributes, + InstantAttributeViewFrame.NewAttributes); +end; + procedure TInstantModelExplorerForm.BuildDatabaseActionExecute( Sender: TObject); begin @@ -332,12 +349,12 @@ OnGetImageIndex := ModelViewGetImageIndex; end; - FAttributeFrame := TInstantAttributeViewFrame.Create(Self); - with FAttributeFrame do - begin - Parent := AttributePanel; - Align := alClient; - end; +// FAttributeFrame := TInstantAttributeViewFrame.Create(Self); +// with FAttributeFrame do +// begin +// Parent := AttributePanel; +// Align := alClient; +// end; FModel := TInstantCodeModel.Create; DesignModel := @FModel; @@ -402,20 +419,23 @@ ChangeTypes: array[Boolean] of TInstantCodeChangeType = (ctEdit, ctNew); var OldName: string; + EditorForm: TInstantClassEditorForm; begin OldName := AClass.Name; - with TInstantClassEditorForm.Create(nil) do + EditorForm := TInstantClassEditorForm.Create(nil); try - IsNew := New; - Model := Self.Model; - Subject := AClass; - Result := ShowModal = mrOk; + EditorForm.IsNew := New; + EditorForm.Model := Self.Model; + EditorForm.Subject := AClass; + Result := EditorForm.ShowModal = mrOk; if Result then ApplyClass(AClass, ChangeTypes[New], OldName, - FAttributeFrame.ChangedAttributes, - FAttributeFrame.NewAttributes); +// FAttributeFrame.ChangedAttributes, +// FAttributeFrame.NewAttributes); + EditorForm.ChangedAttributes, + EditorForm.NewAttributes); finally - Free; + EditorForm.Free; end; end; @@ -519,6 +539,31 @@ Refresh; end; +procedure TInstantModelExplorerForm.InstantAttributeViewFrameAttributeDeleteActionExecute( + Sender: TObject); +begin + InstantAttributeViewFrame.AttributeDeleteActionExecute(Sender); + ApplyClassFromView(InstantAttributeViewFrame); +end; + +procedure TInstantModelExplorerForm.InstantAttributeViewFrameAttributeEditActionExecute( + Sender: TObject); +begin + InstantAttributeViewFrame.AttributeEditActionExecute(Sender); + ApplyClassFromView(InstantAttributeViewFrame); +end; + +procedure TInstantModelExplorerForm.InstantAttributeViewFrameAttributeNewActionExecute( + Sender: TObject); +//var +// AClass: TInstantCodeClass; +// OldName: string; +begin +// OldName := AClass.Name; + InstantAttributeViewFrame.AttributeNewActionExecute(Sender); + ApplyClassFromView(InstantAttributeViewFrame); +end; + procedure TInstantModelExplorerForm.ExportModelActionExecute( Sender: TObject); begin @@ -853,7 +898,8 @@ I: Integer; Level: Integer; begin - FAttributeFrame.Clear; + //FAttributeFrame.Clear; + InstantAttributeViewFrame.Clear; DisableViewUpdate; @@ -927,7 +973,8 @@ procedure TInstantModelExplorerForm.ViewClassAttributes(AClass: TInstantCodeClass); begin - FAttributeFrame.Subject := AClass; +// FAttributeFrame.Subject := AClass; + InstantAttributeViewFrame.Subject := AClass; end; procedure TInstantModelExplorerForm.RestoreLayout; @@ -938,7 +985,8 @@ if OpenKey('Software\InstantObjects.org\Layout\ClassAttributes', False) then begin SetAttributePanelVisible(ReadBool('ShowAttributes')); AttributePanel.Height := ReadInteger('AttributePanelHeight'); - FAttributeFrame.InheritedAttributesPanel.Height := ReadInteger('InheritedAttributeHeight'); +// FAttributeFrame.InheritedAttributesPanel.Height := ReadInteger('InheritedAttributeHeight'); + InstantAttributeViewFrame.InheritedAttributesPanel.Height := ReadInteger('InheritedAttributeHeight'); end; finally Free; @@ -955,7 +1003,8 @@ if OpenKey('Software\InstantObjects.org\Layout\ClassAttributes', True) then begin WriteBool('ShowAttributes', ViewAttributeButton.Down); WriteInteger('AttributePanelHeight', AttributePanel.Height); - WriteInteger('InheritedAttributeHeight', FAttributeFrame.InheritedAttributesPanel.Height); +// WriteInteger('InheritedAttributeHeight', FAttributeFrame.InheritedAttributesPanel.Height); + WriteInteger('InheritedAttributeHeight', InstantAttributeViewFrame.InheritedAttributesPanel.Height); end; finally Free; |