|
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
|