From: <wp...@us...> - 2009-07-08 06:35:10
|
Revision: 804 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=804&view=rev Author: wp2udk Date: 2009-07-08 06:34:35 +0000 (Wed, 08 Jul 2009) Log Message: ----------- Import a model from an existing .res or .xml file and generate the equivalent Delphi source code. Added Paths: ----------- trunk/Source/Design/InstantModelImport.dfm trunk/Source/Design/InstantModelImport.pas Added: trunk/Source/Design/InstantModelImport.dfm =================================================================== --- trunk/Source/Design/InstantModelImport.dfm (rev 0) +++ trunk/Source/Design/InstantModelImport.dfm 2009-07-08 06:34:35 UTC (rev 804) @@ -0,0 +1,87 @@ +inherited InstantImportModelForm: TInstantImportModelForm + Caption = 'Import Model' + ClientHeight = 120 + ClientWidth = 416 + ExplicitWidth = 424 + ExplicitHeight = 154 + PixelsPerInch = 96 + TextHeight = 13 + object Label1: TLabel [0] + Left = 16 + Top = 19 + Width = 78 + Height = 13 + Caption = 'Import to module' + end + object Label2: TLabel [1] + Left = 16 + Top = 46 + Width = 45 + Height = 13 + Caption = 'File name' + end + inherited ButtonPanel: TPanel + Top = 79 + Width = 416 + ExplicitTop = 79 + ExplicitWidth = 416 + inherited ButtonBevel: TBevel + Width = 416 + ExplicitWidth = 416 + end + object ImportButton: TButton + Left = 246 + Top = 8 + Width = 75 + Height = 25 + Caption = '&Import' + Default = True + ModalResult = 1 + TabOrder = 0 + end + object CancelButton: TButton + Left = 327 + Top = 8 + Width = 75 + Height = 25 + Cancel = True + Caption = 'Cancel' + ModalResult = 2 + TabOrder = 1 + end + end + object ImportModuleCombo: TComboBox + Left = 103 + Top = 16 + Width = 299 + Height = 21 + Style = csDropDownList + ItemHeight = 13 + TabOrder = 1 + OnChange = ImportModuleComboChange + end + object FileNameEdit: TEdit + Left = 103 + Top = 43 + Width = 275 + Height = 21 + TabOrder = 2 + OnChange = FileNameEditChange + end + object FileNameButton: TButton + Left = 381 + Top = 43 + Width = 21 + Height = 21 + Caption = '...' + TabOrder = 3 + OnClick = FileNameButtonClick + end + object OpenDialog: TOpenDialog + Filter = 'Resource Model (*.mdr)|*.mdr|XML Model (*.xml)|*.xml' + Options = [ofHideReadOnly, ofPathMustExist, ofNoNetworkButton, ofEnableSizing] + Title = 'Select model' + Left = 16 + Top = 80 + end +end Property changes on: trunk/Source/Design/InstantModelImport.dfm ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/Source/Design/InstantModelImport.pas =================================================================== --- trunk/Source/Design/InstantModelImport.pas (rev 0) +++ trunk/Source/Design/InstantModelImport.pas 2009-07-08 06:34:35 UTC (rev 804) @@ -0,0 +1,145 @@ +(* + * InstantObjects + * Import Model + *) + +(* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is: Seleqt InstantObjects + * + * The Initial Developer of the Original Code is: Seleqt + * + * Portions created by the Initial Developer are Copyright (C) 2001-2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Brian Andersen + * + * ***** END LICENSE BLOCK ***** *) + + unit InstantModelImport; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, InstantDialog, ExtCtrls, StdCtrls, InstantCode, InstantClasses; + +type + TInstantImportModelForm = class(TInstantDialogForm) + ImportButton: TButton; + ImportModuleCombo: TComboBox; + Label1: TLabel; + FileNameEdit: TEdit; + FileNameButton: TButton; + Label2: TLabel; + CancelButton: TButton; + OpenDialog: TOpenDialog; + procedure FileNameButtonClick(Sender: TObject); + procedure ImportModuleComboChange(Sender: TObject); + procedure FileNameEditChange(Sender: TObject); + private + FModel: TInstantCodeModel; + FSelectedModule: TInstantCodeModule; + FSelectedFileName: string; + procedure LoadModules; + procedure UpdateControls; + function GetSelectedFileType: TInstantStreamFormat; + public + function Execute(AModel: TInstantCodeModel): Boolean; + + property Model: TInstantCodeModel read FModel; + + property SelectedModule: TInstantCodeModule read FSelectedModule; + property SelectedFileName: string read FSelectedFileName; + property SelectedFileType: TInstantStreamFormat read GetSelectedFileType; + end; + +var + InstantImportModelForm: TInstantImportModelForm; + +implementation + +{$R *.dfm} + +{ TInstantImportModelForm } + +function TInstantImportModelForm.Execute(AModel: TInstantCodeModel): Boolean; +begin + FModel := AModel; + + LoadModules; + UpdateControls; + + Result := ShowModal = mrOK; + + if Result then + begin + with ImportModuleCombo do + FSelectedModule := Items.Objects[ItemIndex] as TInstantCodeModule; + FSelectedFileName := FileNameEdit.Text; + end else + begin + FSelectedModule := nil; + FSelectedFileName := ''; + end; +end; + +procedure TInstantImportModelForm.FileNameButtonClick(Sender: TObject); +begin + inherited; + + OpenDialog.FileName := FileNameEdit.Text; + if OpenDialog.Execute then + FileNameEdit.Text := OpenDialog.FileName; +end; + +procedure TInstantImportModelForm.LoadModules; +var + I: Integer; + Module: TInstantCodeModule; +begin + ImportModuleCombo.Clear; + for I := 0 to FModel.ModuleCount - 1 do + begin + Module := FModel.Modules[I]; + ImportModuleCombo.Items.AddObject(Module.UnitName, Module) + end; +end; + +procedure TInstantImportModelForm.UpdateControls; +begin + ImportButton.Enabled := (FileNameEdit.Text <> '') and (ImportModuleCombo.ItemIndex <> -1); +end; + +function TInstantImportModelForm.GetSelectedFileType: TInstantStreamFormat; +begin + if CompareText(ExtractFileExt(SelectedFileName), '.mdr') = 0 then + Result := sfBinary else + Result := sfXML; +end; + +procedure TInstantImportModelForm.ImportModuleComboChange(Sender: TObject); +begin + inherited; + UpdateControls; +end; + +procedure TInstantImportModelForm.FileNameEditChange(Sender: TObject); +begin + inherited; + UpdateControls; +end; + +end. Property changes on: trunk/Source/Design/InstantModelImport.pas ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native |
From: <wp...@us...> - 2009-07-08 07:24:50
|
Revision: 806 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=806&view=rev Author: wp2udk Date: 2009-07-08 07:24:46 +0000 (Wed, 08 Jul 2009) Log Message: ----------- Changing the name of the form in InstantModelImport.pas to comply with IO naming conversion. Modified Paths: -------------- trunk/Source/Design/InstantModelExplorer.pas trunk/Source/Design/InstantModelImport.dfm trunk/Source/Design/InstantModelImport.pas Modified: trunk/Source/Design/InstantModelExplorer.pas =================================================================== --- trunk/Source/Design/InstantModelExplorer.pas 2009-07-08 06:55:49 UTC (rev 805) +++ trunk/Source/Design/InstantModelExplorer.pas 2009-07-08 07:24:46 UTC (rev 806) @@ -399,7 +399,7 @@ NewClass: TInstantCodeClass; NewAttribute: TInstantCodeAttribute; begin - with TInstantImportModelForm.Create(nil) do + with TInstantModelImportForm.Create(nil) do try if Execute(FModel) then begin Modified: trunk/Source/Design/InstantModelImport.dfm =================================================================== --- trunk/Source/Design/InstantModelImport.dfm 2009-07-08 06:55:49 UTC (rev 805) +++ trunk/Source/Design/InstantModelImport.dfm 2009-07-08 07:24:46 UTC (rev 806) @@ -1,4 +1,4 @@ -inherited InstantImportModelForm: TInstantImportModelForm +inherited InstantModelImportForm: TInstantModelImportForm Caption = 'Import Model' ClientHeight = 120 ClientWidth = 416 Modified: trunk/Source/Design/InstantModelImport.pas =================================================================== --- trunk/Source/Design/InstantModelImport.pas 2009-07-08 06:55:49 UTC (rev 805) +++ trunk/Source/Design/InstantModelImport.pas 2009-07-08 07:24:46 UTC (rev 806) @@ -37,7 +37,7 @@ Dialogs, InstantDialog, ExtCtrls, StdCtrls, InstantCode, InstantClasses; type - TInstantImportModelForm = class(TInstantDialogForm) + TInstantModelImportForm = class(TInstantDialogForm) ImportButton: TButton; ImportModuleCombo: TComboBox; Label1: TLabel; @@ -67,7 +67,7 @@ end; var - InstantImportModelForm: TInstantImportModelForm; + InstantModelImportForm: TInstantModelImportForm; implementation @@ -75,7 +75,7 @@ { TInstantImportModelForm } -function TInstantImportModelForm.Execute(AModel: TInstantCodeModel): Boolean; +function TInstantModelImportForm.Execute(AModel: TInstantCodeModel): Boolean; begin FModel := AModel; @@ -96,7 +96,7 @@ end; end; -procedure TInstantImportModelForm.FileNameButtonClick(Sender: TObject); +procedure TInstantModelImportForm.FileNameButtonClick(Sender: TObject); begin inherited; @@ -105,7 +105,7 @@ FileNameEdit.Text := OpenDialog.FileName; end; -procedure TInstantImportModelForm.LoadModules; +procedure TInstantModelImportForm.LoadModules; var I: Integer; Module: TInstantCodeModule; @@ -118,25 +118,25 @@ end; end; -procedure TInstantImportModelForm.UpdateControls; +procedure TInstantModelImportForm.UpdateControls; begin ImportButton.Enabled := (FileNameEdit.Text <> '') and (ImportModuleCombo.ItemIndex <> -1); end; -function TInstantImportModelForm.GetSelectedFileType: TInstantStreamFormat; +function TInstantModelImportForm.GetSelectedFileType: TInstantStreamFormat; begin if CompareText(ExtractFileExt(SelectedFileName), '.mdr') = 0 then Result := sfBinary else Result := sfXML; end; -procedure TInstantImportModelForm.ImportModuleComboChange(Sender: TObject); +procedure TInstantModelImportForm.ImportModuleComboChange(Sender: TObject); begin inherited; UpdateControls; end; -procedure TInstantImportModelForm.FileNameEditChange(Sender: TObject); +procedure TInstantModelImportForm.FileNameEditChange(Sender: TObject); begin inherited; UpdateControls; |
From: <wp...@us...> - 2009-08-11 17:45:50
|
Revision: 820 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=820&view=rev Author: wp2udk Date: 2009-08-11 17:45:41 +0000 (Tue, 11 Aug 2009) Log Message: ----------- * D2009: DclIOCore_D12 has only two warnings left that FileAge is deprecated. - InstantOTA ReadEditorSource and WriteEditorSource can now read UTF8 encoded source code. Modified Paths: -------------- trunk/Source/Design/InstantModelExpert.pas trunk/Source/Design/InstantOTA.pas Modified: trunk/Source/Design/InstantModelExpert.pas =================================================================== --- trunk/Source/Design/InstantModelExpert.pas 2009-08-10 21:21:19 UTC (rev 819) +++ trunk/Source/Design/InstantModelExpert.pas 2009-08-11 17:45:41 UTC (rev 820) @@ -24,7 +24,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Nando Dessena, Steven Mitchell + * Nando Dessena, Steven Mitchell, Brian Andersen * * ***** END LICENSE BLOCK ***** *) @@ -1000,7 +1000,7 @@ Editor := FIDEInterface.SourceEditor(Module); {$IFDEF D12+} - Source := UTF8ToUnicodeString(FIDEInterface.ReadEditorSource(Editor)); + Source := FIDEInterface.ReadEditorSource(Editor); Stream := TStringStream.Create(Source, TEncoding.Unicode); {$ELSE} Source := FIDEInterface.ReadEditorSource(Editor); Modified: trunk/Source/Design/InstantOTA.pas =================================================================== --- trunk/Source/Design/InstantOTA.pas 2009-08-10 21:21:19 UTC (rev 819) +++ trunk/Source/Design/InstantOTA.pas 2009-08-11 17:45:41 UTC (rev 820) @@ -24,7 +24,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Nando Dessena, Steven Mitchell + * Nando Dessena, Steven Mitchell, Brian Andersen * * ***** END LICENSE BLOCK ***** *) @@ -42,6 +42,13 @@ Classes, ToolsAPI, InstantTypes, Forms; type +{$IFDEF D12+} + InstantOTAString = UTF8String; +{$ELSE} + InstantOTAString = string; +{$ENDIF} + PInstantOTAString = ^InstantOTAString; + TInstantOTAIDEInterface = class; {$IFDEF D9+} TInstantOTAIDENotifier8 = class; @@ -106,11 +113,11 @@ function CurrentModule: IOTAModule; function FindModule(const Name: string): IOTAModule; procedure GotoFilePos(const FileName: string; Line, Column: Integer); - function ReadEditorSource(Editor: IOTASourceEditor): AnsiString; - function ReadModuleSource(Module: IOTAModule): AnsiString; + function ReadEditorSource(Editor: IOTASourceEditor): string; + function ReadModuleSource(Module: IOTAModule): string; procedure ShowMessages; function SourceEditor(Module: IOTAModule): IOTASourceEditor; - procedure WriteEditorSource(Editor: IOTASourceEditor; const Source: AnsiString; + procedure WriteEditorSource(Editor: IOTASourceEditor; const Source: string; ReplaceLen: Integer; Undoable: Boolean = False); property EditActions: IOTAEditActions read GetEditActions; property MessageServices: IOTAMessageServices read GetMessageServices; @@ -496,10 +503,10 @@ end; function TInstantOTAIDEInterface.ReadEditorSource( - Editor: IOTASourceEditor): AnsiString; + Editor: IOTASourceEditor): string; var Reader: IOTAEditReader; - Buffer: AnsiString; + Buffer: InstantOTAString; BufferLen, ReadLen, Position: Integer; begin if Assigned(Editor) then @@ -511,18 +518,19 @@ repeat SetLength(Buffer, BufferLen); ReadLen := Reader.GetText(Position, PAnsiChar(Buffer), BufferLen); - if ReadLen < BufferLen then - Dec(ReadLen, 2); + if ReadLen < BufferLen then // ?? What does these two lines do?? + Dec(ReadLen, 2); // ?? SetLength(Buffer, ReadLen); - Result := Result + Buffer; + Result := Result + string(Buffer); Inc(Position, ReadLen); until ReadLen < BufferLen - 1; end else Result := ''; +// ShowMessage(Result); end; function TInstantOTAIDEInterface.ReadModuleSource( - Module: IOTAModule): AnsiString; + Module: IOTAModule): string; begin Result := ReadEditorSource(SourceEditor(Module)); end; @@ -585,7 +593,7 @@ end; procedure TInstantOTAIDEInterface.WriteEditorSource( - Editor: IOTASourceEditor; const Source: AnsiString; ReplaceLen: Integer; + Editor: IOTASourceEditor; const Source: string; ReplaceLen: Integer; Undoable: Boolean); var Writer: IOTAEditWriter; @@ -596,7 +604,7 @@ Writer := Editor.CreateUndoableWriter else Writer := Editor.CreateWriter; Writer.DeleteTo(ReplaceLen); - Writer.Insert(PAnsiChar(Source)); + Writer.Insert(PAnsiChar(InstantOTAString(Source))); end; { TInstantOTAIDENotifier5 } |
From: <dav...@us...> - 2009-08-16 06:01:59
|
Revision: 829 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=829&view=rev Author: davidvtaylor Date: 2009-08-16 06:01:49 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Merged changes to show an attributes pane in Model Explorer (code provided by David MoorHouse) See thread in repository forum: "Enhancement: Show Attributes in the IO Model Explorer" 10-10-2007 - Cleaned up code a bit, adjusted default sizing/positioning and added control size constraints - Fixed an AV when switching between projects in the IDE (caused by model reloading) - Added the new InstantAttributeView frame to the IDE design packages (only D2009 tested. D5,D6,K3 ignored) Modified Paths: -------------- trunk/Source/Design/D2005/DclIOCore.dpk trunk/Source/Design/D2006/DclIOCore.dpk trunk/Source/Design/D2007/DclIOCore.dpk trunk/Source/Design/D2007/DclIOCore.dproj trunk/Source/Design/D2009/DclIOCore.dpk trunk/Source/Design/D2009/DclIOCore.dproj trunk/Source/Design/D7/DclIOCore.dpk trunk/Source/Design/InstantModelExplorer.dfm trunk/Source/Design/InstantModelExplorer.pas Added Paths: ----------- trunk/Source/Design/InstantAttributeView.dfm trunk/Source/Design/InstantAttributeView.pas Modified: trunk/Source/Design/D2005/DclIOCore.dpk =================================================================== --- trunk/Source/Design/D2005/DclIOCore.dpk 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/D2005/DclIOCore.dpk 2009-08-16 06:01:49 UTC (rev 829) @@ -58,7 +58,9 @@ InstantReg in '..\InstantReg.pas', InstantUnitSelect in '..\InstantUnitSelect.pas' {InstantUnitSelectForm}, InstantAttributeEditor in '..\InstantAttributeEditor.pas' {InstantAttributeEditorForm}, - InstantAbout in '..\InstantAbout.pas' {InstantAboutForm}; + InstantAbout in '..\InstantAbout.pas' {InstantAboutForm}, + InstantModelImport in '..\InstantModelImport.pas' {InstantImportModelForm}, + InstantAttributeView in '..\InstantAttributeView.pas' {InstantAttributeViewFrame: TFrame}; end. Modified: trunk/Source/Design/D2006/DclIOCore.dpk =================================================================== --- trunk/Source/Design/D2006/DclIOCore.dpk 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/D2006/DclIOCore.dpk 2009-08-16 06:01:49 UTC (rev 829) @@ -58,7 +58,8 @@ InstantUnitSelect in '..\InstantUnitSelect.pas' {InstantUnitSelectForm}, InstantAttributeEditor in '..\InstantAttributeEditor.pas' {InstantAttributeEditorForm}, InstantAbout in '..\InstantAbout.pas' {InstantAboutForm}, - InstantModelImport in '..\InstantModelImport.pas' {InstantImportModelForm}; + InstantModelImport in '..\InstantModelImport.pas' {InstantImportModelForm}, + InstantAttributeView in '..\InstantAttributeView.pas' {InstantAttributeViewFrame: TFrame}; end. Modified: trunk/Source/Design/D2007/DclIOCore.dpk =================================================================== --- trunk/Source/Design/D2007/DclIOCore.dpk 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/D2007/DclIOCore.dpk 2009-08-16 06:01:49 UTC (rev 829) @@ -54,7 +54,8 @@ InstantUnitSelect in '..\InstantUnitSelect.pas' {InstantUnitSelectForm}, InstantAttributeEditor in '..\InstantAttributeEditor.pas' {InstantAttributeEditorForm}, InstantAbout in '..\InstantAbout.pas' {InstantAboutForm}, - InstantModelImport in '..\InstantModelImport.pas'; + InstantModelImport in '..\InstantModelImport.pas', + InstantAttributeView in '..\InstantAttributeView.pas' {InstantAttributeViewFrame: TFrame}; end. Modified: trunk/Source/Design/D2007/DclIOCore.dproj =================================================================== --- trunk/Source/Design/D2007/DclIOCore.dproj 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/D2007/DclIOCore.dproj 2009-08-16 06:01:49 UTC (rev 829) @@ -43,6 +43,10 @@ <DCCReference Include="..\InstantAbout.pas"> <Form>InstantAboutForm</Form> </DCCReference> + <DCCReference Include="..\InstantAttributeView.pas"> + <Form>InstantAttributeViewFrame</Form> + <DesignClass>TFrame</DesignClass> + </DCCReference> <DCCReference Include="..\InstantAttributeEditor.pas"> <Form>InstantAttributeEditorForm</Form> </DCCReference> Modified: trunk/Source/Design/D2009/DclIOCore.dpk =================================================================== --- trunk/Source/Design/D2009/DclIOCore.dpk 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/D2009/DclIOCore.dpk 2009-08-16 06:01:49 UTC (rev 829) @@ -58,7 +58,8 @@ InstantReg in '..\InstantReg.pas', InstantUnitSelect in '..\InstantUnitSelect.pas' {InstantUnitSelectForm}, InstantAttributeEditor in '..\InstantAttributeEditor.pas' {InstantAttributeEditorForm}, - InstantAbout in '..\InstantAbout.pas' {InstantAboutForm}; + InstantAbout in '..\InstantAbout.pas' {InstantAboutForm}, + InstantAttributeView in '..\InstantAttributeView.pas' {InstantAttributeViewFrame: TFrame}; end. Modified: trunk/Source/Design/D2009/DclIOCore.dproj =================================================================== --- trunk/Source/Design/D2009/DclIOCore.dproj 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/D2009/DclIOCore.dproj 2009-08-16 06:01:49 UTC (rev 829) @@ -103,6 +103,10 @@ <DCCReference Include="..\InstantAbout.pas"> <Form>InstantAboutForm</Form> </DCCReference> + <DCCReference Include="..\InstantAttributeView.pas"> + <Form>InstantAttributeViewFrame</Form> + <DesignClass>TFrame</DesignClass> + </DCCReference> <DCCReference Include="..\..\Core\InstantPresentation.dcr"/> <DCCReference Include="..\..\Core\InstantExplorer.dcr"/> <DCCReference Include="..\..\Core\InstantPersistence.dcr"/> Modified: trunk/Source/Design/D7/DclIOCore.dpk =================================================================== --- trunk/Source/Design/D7/DclIOCore.dpk 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/D7/DclIOCore.dpk 2009-08-16 06:01:49 UTC (rev 829) @@ -58,7 +58,8 @@ InstantReg in '..\InstantReg.pas', InstantUnitSelect in '..\InstantUnitSelect.pas' {InstantUnitSelectForm}, InstantAttributeEditor in '..\InstantAttributeEditor.pas' {InstantAttributeEditorForm}, - InstantAbout in '..\InstantAbout.pas' {InstantAboutForm}; + InstantAbout in '..\InstantAbout.pas' {InstantAboutForm}, + InstantAttributeView in '..\InstantAttributeView.pas' {InstantAttributeViewFrame: TFrame}; end. Added: trunk/Source/Design/InstantAttributeView.dfm =================================================================== --- trunk/Source/Design/InstantAttributeView.dfm (rev 0) +++ trunk/Source/Design/InstantAttributeView.dfm 2009-08-16 06:01:49 UTC (rev 829) @@ -0,0 +1,166 @@ +object InstantAttributeViewFrame: TInstantAttributeViewFrame + Left = 0 + Top = 0 + Width = 376 + Height = 188 + TabOrder = 0 + object AttributesSplitter: TSplitter + Left = 0 + Top = 84 + Width = 376 + Height = 4 + Cursor = crVSplit + Align = alBottom + Constraints.MinHeight = 4 + end + object InheritedAttributesPanel: TPanel + Left = 0 + Top = 88 + Width = 376 + Height = 100 + Align = alBottom + BevelOuter = bvNone + Constraints.MinHeight = 60 + 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 = 84 + Align = alClient + Columns = < + item + Caption = 'Name' + Width = 124 + end + item + Caption = 'Type' + Width = 124 + end + item + Caption = 'Storage Name' + Width = 124 + end> + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + ReadOnly = True + ParentFont = False + PopupMenu = AttributesMenu + TabOrder = 0 + ViewStyle = vsReport + end + end + object IntroducedAttributesPanel: TPanel + Left = 0 + Top = 0 + Width = 376 + Height = 84 + Align = alClient + BevelOuter = bvNone + Constraints.MinHeight = 60 + TabOrder = 0 + object IntroducedAttributesLabel: TLabel + Left = 0 + Top = 0 + Width = 376 + Height = 16 + Align = alTop + AutoSize = False + Caption = 'Introduced' + end + object IntroducedAttributesView: TListView + Left = 0 + Top = 16 + Width = 376 + Height = 68 + 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 + end + end + object SubjectSource: TDataSource + Left = 76 + Top = 132 + end + object AttributeImages: TImageList + Left = 108 + Top = 132 + end + object StateImages: TImageList + Left = 140 + Top = 132 + end + object AttributesMenu: TPopupMenu + Images = ActionImages + OnPopup = AttributesMenuPopup + Left = 204 + Top = 132 + 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 = 236 + Top = 132 + 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 = 172 + Top = 132 + end +end Property changes on: trunk/Source/Design/InstantAttributeView.dfm ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/Source/Design/InstantAttributeView.pas =================================================================== --- trunk/Source/Design/InstantAttributeView.pas (rev 0) +++ trunk/Source/Design/InstantAttributeView.pas 2009-08-16 06:01:49 UTC (rev 829) @@ -0,0 +1,506 @@ +(* + * InstantObjects + * Attribute View Frame + *) + +(* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is: Seleqt InstantObjects + * + * The Initial Developer of the Original Code is: Seleqt + * + * Portions created by the Initial Developer are Copyright (C) 2001-2003 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * David Moorhouse, Carlo Barazzetta, Adrea Petrelli, Steven Mitchell, + * Nando Dessena, David Taylor + * + * ***** END LICENSE BLOCK ***** *) + +unit InstantAttributeView; + +{$IFDEF LINUX} +{$I '../InstantDefines.inc'} +{$ELSE} +{$I '..\InstantDefines.inc'} +{$ENDIF} + +interface + +uses + SysUtils, Classes, DB, Contnrs, InstantPresentation, + InstantPersistence, InstantCode, InstantEdit, +{$IFDEF MSWINDOWS} + Windows, Messages, Graphics, Controls, Forms, Dialogs, + StdCtrls, ComCtrls, ExtCtrls, Mask, DBCtrls, + ImgList, ActnList, Menus, Buttons; +{$ENDIF} +{$IFDEF LINUX} + QActnList, QMenus, QTypes, QImgList, QComCtrls, QControls, QExtCtrls, + QStdCtrls, QDBCtrls, QMask, QForms; +{$ENDIF} + +type + TInstantAttributeViewFrame = class(TFrame) + SubjectSource: TDataSource; + AttributeImages: TImageList; + StateImages: TImageList; + AttributesMenu: TPopupMenu; + Actions: TActionList; + ActionImages: TImageList; + AttributeNewAction: TAction; + AttributeDeleteAction: TAction; + AttributeNewItem: TMenuItem; + AttributeDeleteItem: TMenuItem; + AttributeEditAction: TAction; + AttributeEditItem: TMenuItem; + AttributesSplitter: TSplitter; + InheritedAttributesPanel: TPanel; + InheritedAttributesLabel: TLabel; + InheritedAttributesView: TListView; + IntroducedAttributesPanel: TPanel; + IntroducedAttributesView: TListView; + IntroducedAttributesLabel: TLabel; + procedure AttributeNewActionExecute(Sender: TObject); + procedure AttributeDeleteActionExecute(Sender: TObject); + procedure AttributeEditActionExecute(Sender: TObject); + procedure IntroducedAttributesViewDblClick(Sender: TObject); + procedure IntroducedAttributesViewEdited(Sender: TObject; Item: TListItem; + var S: String); + procedure SubjectExposerAfterPostField(Sender: TObject; Field: TField); + procedure AttributesMenuPopup(Sender: TObject); + private + FSubject: TInstantCodeClass; + FBackupAttributes: TObjectList; + FChangedAttributes: TStringList; + FNewAttributes: TList; + FModel: TInstantCodeModel; + FNameAttribute: TInstantCodeAttribute; + procedure DeleteAttribute(Attribute: TInstantCodeAttribute); + procedure FitColumns(View: TListView); + function GetNameAttribute: TInstantCodeAttribute; + procedure LoadAttributeView(View: TListView; AClass: TInstantCodeClass; + Recursive: Boolean); + procedure SetModel(const Value: TInstantCodeModel); + procedure SetSubject(const Value: TInstantCodeClass); + function GetFocusedAttribute: TInstantCodeAttribute; + protected + 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 RestoreAttributes; + procedure UpdateActions; + procedure RestoreLayout; + procedure StoreLayout; + 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; + end; + +implementation + +uses + InstantAttributeEditor, InstantDesignUtils, InstantConsts, InstantRtti, + TypInfo, InstantImageUtils, InstantTypes, Registry; + +{$R *.dfm} + +resourcestring + SConfirmDeleteAttribute = 'Delete attribute ''%s''?'; + +{ TInstantAttributeViewFrame } + +function TInstantAttributeViewFrame.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 TInstantAttributeViewFrame.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 TInstantAttributeViewFrame.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 TInstantAttributeViewFrame.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 TInstantAttributeViewFrame.AttributesMenuPopup(Sender: TObject); +begin + UpdateActions; +end; + +procedure TInstantAttributeViewFrame.Clear; +begin + InheritedAttributesView.Clear; + IntroducedAttributesView.Clear; +end; + +constructor TInstantAttributeViewFrame.Create(AOwner: TComponent); +begin + inherited; + FBackupAttributes := TObjectList.Create; + FChangedAttributes := TStringList.Create; + FNewAttributes := TList.Create; + LoadMultipleImages(AttributeImages, 'IO_CLASSEDITORATTRIBUTEIMAGES', HInstance); +{$IFDEF MSWINDOWS} + IntroducedAttributesView.SmallImages := AttributeImages; + InheritedAttributesView.SmallImages := AttributeImages; +{$ENDIF} +{$IFDEF LINUX} + IntroducedAttributesView.Images := AttributeImages; + InheritedAttributesView.Images := AttributeImages; +{$ENDIF} +end; + +procedure TInstantAttributeViewFrame.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 TInstantAttributeViewFrame.Destroy; +begin + FNewAttributes.Free; + FChangedAttributes.Free; + FBackupAttributes.Free; + FNameAttribute.Free; + inherited; +end; + +function TInstantAttributeViewFrame.EditAttribute(Attribute: TInstantCodeAttribute; + Exists: Boolean; const Title: string): Boolean; + + function GetClassStorageName: String; + begin + if Attribute.Metadata.ClassMetadata.StorageName <> '' then + Result := Attribute.Metadata.ClassMetadata.StorageName + else + Result := Remove_T_FromClassName(Attribute.Metadata.ClassMetadata.Name); + end; + +begin + with TInstantAttributeEditorForm.Create(nil) do + try + if Title <> '' then + Caption := Title; + Model := Self.Model; + BaseClassStorageName := GetClassStorageName; + Limited := Exists; + Subject := Attribute; + Result := ShowModal = mrOk; + if Result then + Attribute.Realize; + finally + Free; + end; +end; + +procedure TInstantAttributeViewFrame.FitColumns(View: TListView); +var + i : integer; +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; +end; + +function TInstantAttributeViewFrame.GetFocusedAttribute: TInstantCodeAttribute; +begin + with IntroducedAttributesView do + if Assigned(ItemFocused) then + Result := ItemFocused.Data + else + Result := nil; +end; + +function TInstantAttributeViewFrame.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; + +procedure TInstantAttributeViewFrame.IntroducedAttributesViewDblClick( + Sender: TObject); +begin + AttributeEditAction.Execute; +end; + +procedure TInstantAttributeViewFrame.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 TInstantAttributeViewFrame.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 TInstantAttributeViewFrame.PopulateInheritedAttributes; +begin + LoadAttributeView(InheritedAttributesView, Subject.BaseClass, True); +end; + +procedure TInstantAttributeViewFrame.PopulateIntroducedAttributes; +begin + LoadAttributeView(IntroducedAttributesView, Subject, False); +end; + +procedure TInstantAttributeViewFrame.RestoreLayout; +begin + with TRegistry.Create do try + RootKey := HKEY_CURRENT_USER; + if OpenKey('Software\InstantObjects.org\Layout', False) then begin + if not ReadBool('Default') then Exit; + InheritedAttributesPanel.Height := ReadInteger('Splitter'); + end; + finally + Free; + end; +end; + +procedure TInstantAttributeViewFrame.SetModel(const Value: TInstantCodeModel); +begin + if Value <> FModel then + begin + FModel := Value; + end; +end; + +procedure TInstantAttributeViewFrame.SetSubject(const Value: TInstantCodeClass); +begin + if Value <> Subject then + begin + FSubject := Value; + if Subject <> nil then + Subject.CloneAttributes(FBackupAttributes); + PopulateIntroducedAttributes; + PopulateInheritedAttributes; + end; +end; + +procedure TInstantAttributeViewFrame.StoreLayout; +begin + with TRegistry.Create do try + RootKey := HKEY_CURRENT_USER; + if OpenKey('Software\InstantObjects.org\Layout', True) then begin + WriteInteger('Splitter', InheritedAttributesPanel.Height); + end; + finally + Free; + end; +end; + +procedure TInstantAttributeViewFrame.SubjectExposerAfterPostField( + Sender: TObject; Field: TField); +begin + if Field.FieldName = 'BaseClassName' then + begin + FreeAndNil(FNameAttribute); + PopulateInheritedAttributes; + end; +end; + +procedure TInstantAttributeViewFrame.UpdateActions; +var + Attribute: TInstantCodeAttribute; +begin + inherited; + Attribute := FocusedAttribute; + AttributeEditAction.Enabled := Assigned(Attribute); + AttributeDeleteAction.Enabled := Assigned(Attribute); +end; + +procedure TInstantAttributeViewFrame.RestoreAttributes; +begin + Subject.AssignAttributes(FBackupAttributes); +end; + + +end. Property changes on: trunk/Source/Design/InstantAttributeView.pas ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/Source/Design/InstantModelExplorer.dfm =================================================================== --- trunk/Source/Design/InstantModelExplorer.dfm 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/InstantModelExplorer.dfm 2009-08-16 06:01:49 UTC (rev 829) @@ -1,8 +1,8 @@ object InstantModelExplorerForm: TInstantModelExplorerForm Left = 385 Top = 186 - Width = 259 - Height = 433 + Width = 418 + Height = 536 VertScrollBar.Range = 20 Caption = 'InstantObjects Model Explorer' Color = clBtnFace @@ -18,19 +18,30 @@ OnShow = FormShow PixelsPerInch = 96 TextHeight = 13 + object AttributeSplitter: TSplitter + Left = 0 + Top = 255 + Width = 410 + Height = 4 + Cursor = crVSplit + Align = alBottom + Constraints.MinHeight = 4 + Visible = False + end object ModelPanel: TPanel Left = 0 Top = 27 - Width = 251 - Height = 372 + Width = 410 + Height = 228 Align = alClient BevelOuter = bvNone + Constraints.MinHeight = 20 TabOrder = 0 end object ToolBar: TToolBar Left = 0 Top = 0 - Width = 251 + Width = 410 Height = 27 BorderWidth = 1 ButtonHeight = 23 @@ -61,7 +72,57 @@ Top = 0 Action = ViewRelationsAction end + object ToolSep2: TToolButton + Left = 77 + Top = 0 + Width = 8 + Caption = 'ToolSep2' + ImageIndex = 4 + Style = tbsSeparator + end + object ViewAttributeButton: TToolButton + Left = 85 + Top = 0 + Action = ViewAttributesAction + end end + object AttributePanel: TPanel + Left = 0 + Top = 259 + Width = 410 + Height = 243 + Align = alBottom + BevelOuter = bvNone + Constraints.MinHeight = 45 + Padding.Left = 3 + Padding.Right = 3 + Padding.Bottom = 3 + TabOrder = 2 + Visible = False + object AttributeCaptionPanel: TPanel + Left = 3 + Top = 0 + Width = 404 + Height = 25 + Align = alTop + BevelOuter = bvLowered + TabOrder = 0 + object AttributeCaptionLabel: TLabel + Left = 12 + Top = 6 + Width = 89 + Height = 13 + Caption = 'Class Attributes' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = 11 + Font.Name = 'MS Sans Serif' + Font.Pitch = fpVariable + Font.Style = [fsBold] + ParentFont = False + end + end + end object ModelImages: TImageList Left = 104 Top = 40 @@ -83,6 +144,9 @@ object ViewSourceItem: TMenuItem Action = ViewSourceAction end + object ViewAttributes: TMenuItem + Action = ViewAttributesAction + end object N1: TMenuItem Caption = '-' end @@ -206,6 +270,12 @@ Hint = 'About InstantObjects' OnExecute = AboutActionExecute end + object ViewAttributesAction: TAction + Caption = 'View Attributes' + Hint = 'View Class Attributes' + ImageIndex = 11 + OnExecute = ViewAttributesActionExecute + end end object AttributeImages: TImageList Left = 136 Modified: trunk/Source/Design/InstantModelExplorer.pas =================================================================== --- trunk/Source/Design/InstantModelExplorer.pas 2009-08-16 05:23:17 UTC (rev 828) +++ trunk/Source/Design/InstantModelExplorer.pas 2009-08-16 06:01:49 UTC (rev 829) @@ -25,7 +25,7 @@ * * Contributor(s): * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Steven Mitchell, - * Brian Andersen + * Brian Andersen, David Moorhouse, David Taylor * * ***** END LICENSE BLOCK ***** *) @@ -48,7 +48,7 @@ {$IFDEF LINUX} QForms, QActnList, QMenus, QTypes, QImgList, QComCtrls, QControls, QExtCtrls, {$ENDIF} - InstantCode; + InstantCode, InstantAttributeView; type TInstantModelStyle = (msInheritance, msRelations); @@ -123,6 +123,14 @@ ViewSourceItem: TMenuItem; ImportModelItem: TMenuItem; ImportModelAction: TAction; + AttributePanel: TPanel; + AttributeSplitter: TSplitter; + AttributeCaptionPanel: TPanel; + AttributeCaptionLabel: TLabel; + ToolSep2: TToolButton; + ViewAttributeButton: TToolButton; + ViewAttributesAction: TAction; + ViewAttributes: TMenuItem; procedure AboutActionExecute(Sender: TObject); procedure BuildDatabaseActionExecute(Sender: TObject); procedure CollapseAllActionExecute(Sender: TObject); @@ -138,6 +146,7 @@ procedure RefreshActionExecute(Sender: TObject); procedure SelectUnitsActionExecute(Sender: TObject); procedure TreeMenuPopup(Sender: TObject); + procedure ViewAttributesActionExecute(Sender: TObject); procedure ViewInheritanceActionExecute(Sender: TObject); procedure ViewRelationsActionExecute(Sender: TObject); procedure ViewSourceActionExecute(Sender: TObject); @@ -146,15 +155,21 @@ FError: TInstantModelError; FModel: TInstantCodeModel; FModelView: TModelTreeView; + FAttributeFrame: TInstantAttributeViewFrame; FSelectedNode: TTreeNode; FStyle: TInstantModelStyle; FOnApplyClass: TInstantCodeClassApplyEvent; FOnGotoSource: TInstantGotoSourceEvent; FOnLoadModel: TInstantCodeModelEvent; + FViewUpdateDisableCount: Integer; function GetFocusedClass: TInstantCodeClass; function GetSelectedNode: TTreeNode; procedure SetError(E: Exception); procedure SetStyle(const Value: TInstantModelStyle); + procedure ViewClassAttributes(AClass: TInstantCodeClass); + procedure SetAttributePanelVisible(Visible: Boolean); + procedure RestoreLayout; + procedure StoreLayout; protected procedure ApplyClass(AClass: TInstantCodeClass; ChangeType: TInstantCodeChangeType; OldName: string = ''; @@ -162,6 +177,9 @@ function ClassFromNode(Node: TTreeNode): TInstantCodeClass; procedure DoApplyClass(AClass: TInstantCodeClass; ChangeInfo: TInstantCodeClassChangeInfo); + procedure DisableViewUpdate; + procedure EnableViewUpdate; + function ViewUpdateEnabled: boolean; function EditClass(AClass: TInstantCodeClass; New: Boolean): Boolean; procedure GotoNodeSource(Node: TTreeNode); procedure GotoSource(const FileName: string; Pos: TInstantCodePos); @@ -199,7 +217,7 @@ InstantModelExpert, {$ENDIF} InstantDesignUtils, InstantPersistence, InstantDesignHook, InstantAbout, - InstantImageUtils, InstantMetadata, InstantModelImport; + InstantImageUtils, InstantMetadata, InstantModelImport, Registry; resourcestring SDeleteClass = 'Delete Class ''%s''?'; @@ -305,6 +323,7 @@ Images := ModelImages; PopupMenu := TreeMenu; ReadOnly := True; + HideSelection := False; {$IFDEF MSWINDOWS} RightClickSelect := True; {$ENDIF} @@ -312,6 +331,14 @@ OnNodeDblClick := ModelViewNodeDblClick; OnGetImageIndex := ModelViewGetImageIndex; end; + + FAttributeFrame := TInstantAttributeViewFrame.Create(Self); + with FAttributeFrame do + begin + Parent := AttributePanel; + Align := alClient; + end; + FModel := TInstantCodeModel.Create; DesignModel := @FModel; {$IFDEF MSWINDOWS} @@ -319,6 +346,8 @@ AutoSave := True; {$ENDIF} ModelExplorer := Self; + SetAttributePanelVisible(True); + RestoreLayout; Refresh; end; @@ -337,6 +366,7 @@ destructor TInstantModelExplorerForm.Destroy; begin + StoreLayout; ModelExplorer := nil; FModel.Free; FError.Free; @@ -350,6 +380,22 @@ FOnApplyClass(Self, AClass, ChangeInfo); end; +procedure TInstantModelExplorerForm.DisableViewUpdate; + begin + inc(FViewUpdateDisableCount); + end; + +procedure TInstantModelExplorerForm.EnableViewUpdate; + begin + if (FViewUpdateDisableCount > 0) then + dec(FViewUpdateDisableCount); + end; + +function TInstantModelExplorerForm.ViewUpdateEnabled: boolean; + begin + Result := (FViewUpdateDisableCount = 0); + end; + function TInstantModelExplorerForm.EditClass(AClass: TInstantCodeClass; New: Boolean): Boolean; const @@ -365,8 +411,9 @@ Subject := AClass; Result := ShowModal = mrOk; if Result then - ApplyClass(AClass, ChangeTypes[New], OldName, ChangedAttributes, - NewAttributes); + ApplyClass(AClass, ChangeTypes[New], OldName, + FAttributeFrame.ChangedAttributes, + FAttributeFrame.NewAttributes); finally Free; end; @@ -520,7 +567,7 @@ Pos: TInstantCodePos); begin if Assigned(FOnGotoSource) then - FOnGotoSource(Self, FileName, Pos); + FOnGotoSource(Self, FileName, Pos); end; procedure TInstantModelExplorerForm.LoadModel; @@ -548,6 +595,8 @@ Node: TTreeNode); begin FSelectedNode := nil; + if (ViewUpdateEnabled) then + ViewClassAttributes(FocusedClass); end; procedure TInstantModelExplorerForm.ModelViewGetImageIndex(Sender: TObject; @@ -639,6 +688,13 @@ ModelExpert.SelectUnits; end; +procedure TInstantModelExplorerForm.SetAttributePanelVisible(Visible: Boolean); +begin + AttributePanel.Visible := Visible; + AttributeSplitter.Visible := Visible; + ViewAttributeButton.Down := Visible; +end; + procedure TInstantModelExplorerForm.SetError(E: Exception); begin FreeAndNil(FError); @@ -666,7 +722,7 @@ procedure TInstantModelExplorerForm.TreeMenuPopup(Sender: TObject); begin - FSelectedNode := ModelView.Selected; + FSelectedNode := ModelView.Selected; end; procedure TInstantModelExplorerForm.UpdateActions; @@ -797,42 +853,50 @@ I: Integer; Level: Integer; begin - Level := 0; - FSelectedNode := nil; - ModelView.Items.BeginUpdate; + FAttributeFrame.Clear; + + DisableViewUpdate; + try - if Assigned(FError) then - begin - ModelView.Items.Clear; -{$IFDEF MSWINDOWS} - ModelView.ShowRoot := False; -{$ENDIF} - ModelView.Items.AddObject(nil, FError.Text, FError) - end else - begin - Nodes := TList.Create; - try -{$IFDEF MSWINDOWS} - ModelView.ShowRoot := True; -{$ENDIF} - for I := 0 to Pred(Model.ClassCount) do - begin - AClass := Model.Classes[I]; - if (Style = msRelations) or not Assigned(AClass.BaseClass) then - Nodes.Add(AddClass(nil, AClass, '', Level)); + Level := 0; + FSelectedNode := nil; + ModelView.Items.BeginUpdate; + try + if Assigned(FError) then + begin + ModelView.Items.Clear; + {$IFDEF MSWINDOWS} + ModelView.ShowRoot := False; + {$ENDIF} + ModelView.Items.AddObject(nil, FError.Text, FError) + end else + begin + Nodes := TList.Create; + try + {$IFDEF MSWINDOWS} + ModelView.ShowRoot := True; + {$ENDIF} + for I := 0 to Pred(Model.ClassCount) do + begin + AClass := Model.Classes[I]; + if (Style = msRelations) or not Assigned(AClass.BaseClass) then + Nodes.Add(AddClass(nil, AClass, '', Level)); + end; + ModelView.AlphaSort; + RemoveInvalidNodes(nil, Nodes); + FirstNode := ModelView.Items.GetFirstNode; + if Assigned(FirstNode) and (FirstNode.GetNextSibling = nil) then + FirstNode.Expand(False); + finally + Nodes.Free; end; - ModelView.AlphaSort; - RemoveInvalidNodes(nil, Nodes); - FirstNode := ModelView.Items.GetFirstNode; - if Assigned(FirstNode) and (FirstNode.GetNextSibling = nil) then - FirstNode.Expand(False); - finally - Nodes.Free; end; + finally; + ModelView.Items.EndUpdate; + ModelView.Repaint; end; - finally; - ModelView.Items.EndUpdate; - ModelView.Repaint; + finally + EnableViewUpdate; end; end; @@ -856,6 +920,49 @@ GotoNodeSource(SelectedNode); end; +procedure TInstantModelExplorerForm.ViewAttributesActionExecute(Sender: TObject); +begin + SetAttributePanelVisible(not AttributePanel.Visible); +end; + +procedure TInstantModelExplorerForm.ViewClassAttributes(AClass: TInstantCodeClass); +begin + FAttributeFrame.Subject := AClass; +end; + +procedure TInstantModelExplorerForm.RestoreLayout; +begin + try + with TRegistry.Create do try + RootKey := HKEY_CURRENT_USER; + if OpenKey('Software\InstantObjects.org\Layout\ClassAttributes', False) then begin + SetAttributePanelVisible(ReadBool('ShowAttributes')); + AttributePanel.Height := ReadInteger('AttributePanelHeight'); + FAttributeFrame.InheritedAttributesPanel.Height := ReadInteger('InheritedAttributeHeight'); + end; + finally + Free; + end; + except + // silently swallow exception + end; +end; + +procedure TInstantModelExplorerForm.StoreLayout; +begin + with TRegistry.Create do try + RootKey := HKEY_CURRENT_USER; + if OpenKey('Software\InstantObjects.org\Layout\ClassAttributes', True) then begin + WriteBool('ShowAttributes', ViewAttributeButton.Down); + WriteInteger('AttributePanelHeight', AttributePanel.Height); + WriteInteger('InheritedAttributeHeight', FAttributeFrame.InheritedAttributesPanel.Height); + end; + finally + Free; + end; +end; + + initialization ModelExplorer := nil; RegisterFieldAddress('InstantModelExplorer', @ModelExplorer); |
From: <dav...@us...> - 2009-08-17 08:27:28
|
Revision: 837 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=837&view=rev Author: davidvtaylor Date: 2009-08-17 08:27:21 +0000 (Mon, 17 Aug 2009) Log Message: ----------- New custom made icon for Model Explorer attribute toggle. Bitmap also upgraded from 4-bit to 8-bit Modified Paths: -------------- trunk/Source/Design/InstantModelExplorer.dfm trunk/Source/Design/iodesimages.res Modified: trunk/Source/Design/InstantModelExplorer.dfm =================================================================== --- trunk/Source/Design/InstantModelExplorer.dfm 2009-08-17 08:05:05 UTC (rev 836) +++ trunk/Source/Design/InstantModelExplorer.dfm 2009-08-17 08:27:21 UTC (rev 837) @@ -84,6 +84,7 @@ Left = 85 Top = 0 Action = ViewAttributesAction + ImageIndex = 12 end end object AttributePanel: TPanel Modified: trunk/Source/Design/iodesimages.res =================================================================== (Binary files differ) |
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; |
From: <dav...@us...> - 2009-08-19 20:25:22
|
Revision: 852 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=852&view=rev Author: davidvtaylor Date: 2009-08-19 20:25:12 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Fix for update problem with the attribute view feature on Model Explorer - Added checks for null Subject to avoid AV when switching projects - Reworked and simplified attribute view refresh logic - Remove ExplictXXX properties for forms for older Delphi versions Modified Paths: -------------- trunk/Source/Design/InstantAttributeEditor.pas trunk/Source/Design/InstantAttributeView.pas trunk/Source/Design/InstantClassEditor.dfm trunk/Source/Design/InstantModelExplorer.dfm trunk/Source/Design/InstantModelExplorer.pas Modified: trunk/Source/Design/InstantAttributeEditor.pas =================================================================== --- trunk/Source/Design/InstantAttributeEditor.pas 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantAttributeEditor.pas 2009-08-19 20:25:12 UTC (rev 852) @@ -263,8 +263,11 @@ begin inherited; - LoadOptions; - LoadMethods; + if (assigned(Subject)) then + begin + LoadOptions; + LoadMethods; + end; end; procedure TInstantAttributeEditorForm.LoadEnums(TypeInfo: PTypeInfo; Modified: trunk/Source/Design/InstantAttributeView.pas =================================================================== --- trunk/Source/Design/InstantAttributeView.pas 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantAttributeView.pas 2009-08-19 20:25:12 UTC (rev 852) @@ -447,12 +447,14 @@ procedure TInstantAttributeViewFrame.PopulateInheritedAttributes; begin - LoadAttributeView(InheritedAttributesView, Subject.BaseClass, True); + if (assigned(Subject)) then + LoadAttributeView(InheritedAttributesView, Subject.BaseClass, True); end; procedure TInstantAttributeViewFrame.PopulateIntroducedAttributes; begin - LoadAttributeView(IntroducedAttributesView, Subject, False); + if (assigned(Subject)) then + LoadAttributeView(IntroducedAttributesView, Subject, False); end; procedure TInstantAttributeViewFrame.RestoreLayout; Modified: trunk/Source/Design/InstantClassEditor.dfm =================================================================== --- trunk/Source/Design/InstantClassEditor.dfm 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantClassEditor.dfm 2009-08-19 20:25:12 UTC (rev 852) @@ -6,15 +6,11 @@ ClientWidth = 400 OldCreateOrder = True OnCreate = FormCreate - ExplicitWidth = 408 - ExplicitHeight = 399 PixelsPerInch = 96 TextHeight = 13 inherited EditPanel: TPanel Width = 400 Height = 334 - ExplicitWidth = 400 - ExplicitHeight = 334 object PageControl: TPageControl Left = 4 Top = 4 @@ -131,21 +127,16 @@ Height = 290 Align = alClient TabOrder = 0 - ExplicitHeight = 290 inherited AttributesSplitter: TSplitter Top = 186 - ExplicitTop = 186 end 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 @@ -155,16 +146,11 @@ inherited BottomPanel: TPanel 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 Modified: trunk/Source/Design/InstantModelExplorer.dfm =================================================================== --- trunk/Source/Design/InstantModelExplorer.dfm 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantModelExplorer.dfm 2009-08-19 20:25:12 UTC (rev 852) @@ -127,44 +127,30 @@ 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 Modified: trunk/Source/Design/InstantModelExplorer.pas =================================================================== --- trunk/Source/Design/InstantModelExplorer.pas 2009-08-19 18:07:37 UTC (rev 851) +++ trunk/Source/Design/InstantModelExplorer.pas 2009-08-19 20:25:12 UTC (rev 852) @@ -168,7 +168,6 @@ FOnApplyClass: TInstantCodeClassApplyEvent; FOnGotoSource: TInstantGotoSourceEvent; FOnLoadModel: TInstantCodeModelEvent; - FViewUpdateDisableCount: Integer; function GetFocusedClass: TInstantCodeClass; function GetSelectedNode: TTreeNode; procedure SetError(E: Exception); @@ -185,14 +184,12 @@ function ClassFromNode(Node: TTreeNode): TInstantCodeClass; procedure DoApplyClass(AClass: TInstantCodeClass; ChangeInfo: TInstantCodeClassChangeInfo); - procedure DisableViewUpdate; - procedure EnableViewUpdate; - function ViewUpdateEnabled: boolean; function EditClass(AClass: TInstantCodeClass; New: Boolean): Boolean; procedure GotoNodeSource(Node: TTreeNode); procedure GotoSource(const FileName: string; Pos: TInstantCodePos); procedure LoadModel; procedure UpdateActions; override; + procedure RefreshAttributeView; property SelectedNode: TTreeNode read GetSelectedNode; public constructor Create(AOwner: TComponent); override; @@ -397,22 +394,6 @@ FOnApplyClass(Self, AClass, ChangeInfo); end; -procedure TInstantModelExplorerForm.DisableViewUpdate; - begin - inc(FViewUpdateDisableCount); - end; - -procedure TInstantModelExplorerForm.EnableViewUpdate; - begin - if (FViewUpdateDisableCount > 0) then - dec(FViewUpdateDisableCount); - end; - -function TInstantModelExplorerForm.ViewUpdateEnabled: boolean; - begin - Result := (FViewUpdateDisableCount = 0); - end; - function TInstantModelExplorerForm.EditClass(AClass: TInstantCodeClass; New: Boolean): Boolean; const @@ -640,8 +621,7 @@ Node: TTreeNode); begin FSelectedNode := nil; - if (ViewUpdateEnabled) then - ViewClassAttributes(FocusedClass); + RefreshAttributeView; end; procedure TInstantModelExplorerForm.ModelViewGetImageIndex(Sender: TObject; @@ -738,6 +718,7 @@ AttributePanel.Visible := Visible; AttributeSplitter.Visible := Visible; ViewAttributeButton.Down := Visible; + RefreshAttributeView; end; procedure TInstantModelExplorerForm.SetError(E: Exception); @@ -791,6 +772,12 @@ CollapseAllAction.Enabled := AtClass; end; +procedure TInstantModelExplorerForm.RefreshAttributeView; + begin + if (AttributePanel.Visible) then + ViewClassAttributes(FocusedClass); + end; + procedure TInstantModelExplorerForm.UpdateModel; function FindClassNode(Parent: TTreeNode; @@ -901,49 +888,44 @@ //FAttributeFrame.Clear; InstantAttributeViewFrame.Clear; - DisableViewUpdate; - + Level := 0; + FSelectedNode := nil; + ModelView.Items.BeginUpdate; try - Level := 0; - FSelectedNode := nil; - ModelView.Items.BeginUpdate; - try - if Assigned(FError) then - begin - ModelView.Items.Clear; - {$IFDEF MSWINDOWS} - ModelView.ShowRoot := False; - {$ENDIF} - ModelView.Items.AddObject(nil, FError.Text, FError) - end else - begin - Nodes := TList.Create; - try - {$IFDEF MSWINDOWS} - ModelView.ShowRoot := True; - {$ENDIF} - for I := 0 to Pred(Model.ClassCount) do - begin - AClass := Model.Classes[I]; - if (Style = msRelations) or not Assigned(AClass.BaseClass) then - Nodes.Add(AddClass(nil, AClass, '', Level)); - end; - ModelView.AlphaSort; - RemoveInvalidNodes(nil, Nodes); - FirstNode := ModelView.Items.GetFirstNode; - if Assigned(FirstNode) and (FirstNode.GetNextSibling = nil) then - FirstNode.Expand(False); - finally - Nodes.Free; + if Assigned(FError) then + begin + ModelView.Items.Clear; +{$IFDEF MSWINDOWS} + ModelView.ShowRoot := False; +{$ENDIF} + ModelView.Items.AddObject(nil, FError.Text, FError) + end else + begin + Nodes := TList.Create; + try +{$IFDEF MSWINDOWS} + ModelView.ShowRoot := True; +{$ENDIF} + for I := 0 to Pred(Model.ClassCount) do + begin + AClass := Model.Classes[I]; + if (Style = msRelations) or not Assigned(AClass.BaseClass) then + Nodes.Add(AddClass(nil, AClass, '', Level)); end; + ModelView.AlphaSort; + RemoveInvalidNodes(nil, Nodes); + FirstNode := ModelView.Items.GetFirstNode; + if Assigned(FirstNode) and (FirstNode.GetNextSibling = nil) then + FirstNode.Expand(False); + finally + Nodes.Free; end; - finally; - ModelView.Items.EndUpdate; - ModelView.Repaint; end; - finally - EnableViewUpdate; + finally; + ModelView.Items.EndUpdate; + ModelView.Repaint; end; + RefreshAttributeView; end; procedure TInstantModelExplorerForm.ViewInheritanceActionExecute( |