📄 jvpluginwizard.pas
字号:
{-----------------------------------------------------------------------------
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/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvPluginWizard.PAS, released on 1999-09-06.
The Initial Developer of the Original Code is Tim Sullivan [timatt uil dott net]
Portions created by Tim Sullivan are Copyright (C) 1999 Tim Sullivan.
All Rights Reserved.
Contributor(s):
Ralf Steinhaeusser [ralfiii att gmx dott net].
Steefan Lesage - converted to use new OTA
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
Todo : I don't know why but IDE does not not navigate correctly here...
Todo : Creates code with #10#13 instead of the other way ound (#13#10 is correct)
History:
V 09 : inserted TYPE-decaration, IDE navigation works now
rewrote ProjectCreate (100 times), seems to work now except a AV when
creating a DLL-project. May have to do with ressources
V 08 : Setting the pluginname works fine after A LOT of trying...
V 07 : #10#13 -> #13#10 corrected
V 06 : Wizard-Form added, lets select Plugin-Type and Object-name
V 05 : uses-list minimized
-----------------------------------------------------------------------------}
// $Id: JvPluginWizard.pas,v 1.31 2005/02/26 06:58:52 marquardt Exp $
unit JvPluginWizard;
{$I jvcl.inc}
interface
uses
Windows, ToolsAPI,
JvTypes;
type
TJvPluginWizard = class(TNotifierObject, IOTAWizard, IOTARepositoryWizard,
IOTAMenuWizard, IOTAProjectWizard)
public
PluginMainMenu: IOTAComponent;
{ IOTAWizard Methods }
function GetIDString: string; virtual;
function GetName: string; virtual;
function GetState: TWizardState; virtual;
procedure Execute; virtual;
{ IOTARepositoryWizard Methods }
function GetAuthor: string; virtual;
function GetComment: string; virtual;
function GetPage: string; virtual;
function GetGlyph: {$IFDEF COMPILER6_UP} Cardinal; {$ELSE} HICON; {$ENDIF} virtual;
{ IOTAMenuWizard methods }
function GetMenuText: string; virtual;
end;
TJvPluginProjectCreator = class(TInterfacedObject, IOTACreator, IOTAProjectCreator) // both interfaces needed !!!!
public
Wizard: TJvPluginWizard;
{ 0 = dll; 1 = dpk }
PlugType: Integer;
{ Private variables which will be used to store some properties for
the TJvPlugin }
PlugName: string;
PlugDesc: string;
PlugAuth: string;
PlugCopy: string;
PlugUID: string;
Project: IOTAModule;
function GetFileName: string;
function GetOptionFileName: string;
function GetShowSource: Boolean;
procedure NewDefaultModule;
function NewOptionSource(const ProjectName: string): IOTAFile;
procedure NewProjectResource(const Project: IOTAProject);
function NewProjectSource(const ProjectName: string): IOTAFile;
function GetCreatorType: string;
function GetExisting: Boolean;
function GetFileSystem: string;
function GetOwner: IOTAModule;
function GetUnnamed: Boolean;
end;
TJvPluginModuleCreator = class(TInterfacedObject, IOTACreator, IOTAModuleCreator)
public
Wizard: TJvPluginWizard;
{ 0 = dll; 1 = dpk }
PlugType: Integer;
Project: IOTAModule;
{ Private variables which will be used to store some properties for
the TJvPlugin }
PlugName: string;
PlugDesc: string;
PlugAuth: string;
PlugCopy: string;
PlugUID: string;
function GetCreatorType: string;
function GetExisting: Boolean;
function GetFileSystem: string;
function GetOwner: IOTAModule;
function GetUnnamed: Boolean;
function GetAncestorName: string;
function GetImplFileName: string;
function GetIntfFileName: string;
function GetFormName: string;
function GetMainForm: Boolean;
function GetShowForm: Boolean;
function GetShowSource: Boolean;
function NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile;
function NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;
function NewIntfSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;
procedure FormCreated(const FormEditor: IOTAFormEditor);
end;
// from http://www.gexperts.org/opentools/GXModuleCreator.pas
TJvOTAFile = class(TInterfacedObject, IOTAFile)
private
FSource: string;
public
constructor Create(const Source: string);
function GetSource: string;
function GetAge: TDateTime;
end;
implementation
uses
Controls, SysUtils, Dialogs, Classes, ActnList, Menus,
{$IFDEF COMPILER6_UP}
DesignIntf, DesignEditors,
{$ELSE}
DsgnIntf,
{$ENDIF COMPILER6_UP}
JclFileUtils,
JvPlugin, JvPluginParamsForm, JvConsts, JvDsgnConsts;
{$IFDEF MSWINDOWS}
{$R ..\Resources\JvPluginWiz.res}
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
{$R ../Resources/JvPluginWiz.res}
{$ENDIF UNIX}
const
CrLf = sLineBreak;
CrLf2 = CrLf + CrLf;
cPlgPrefix = 'Plg';
cPluginPrefix = 'Plugin';
(* make Delphi 5 compiler happy // andreas
function GetFormEditorFromModule(
IModule: IOTAModule): IOTAFormEditor;
var
i: Integer;
IEditor: IOTAEditor;
begin
Result := nil;
if IModule = nil then
Exit;
for i := 0 to IModule.GetModuleFileCount - 1 do
begin
IEditor := IModule.GetModuleFileEditor(i);
if Supports(IEditor, IOTAFormEditor, Result) then
Break;
end;
end;
*)
//=== { TJvPluginWizard } ====================================================
function TJvPluginWizard.GetIDString: string;
begin
Result := RsPluginWizardIDString;
end;
function TJvPluginWizard.GetState: TWizardState;
begin
Result := [wsEnabled];
end;
function TJvPluginWizard.GetMenuText: string;
begin
Result := RsJediPluginWizard;
end;
function TJvPluginWizard.GetName: string;
begin
Result := RsJvPluginWizard;
end;
function TJvPluginWizard.GetPage: string;
begin
Result := RsProjects;
end;
function TJvPluginWizard.GetAuthor: string;
begin
Result := 'MPL';
end;
function TJvPluginWizard.GetComment: string;
begin
Result := RsNewPlugin;
end;
function TJvPluginWizard.GetGlyph: {$IFDEF COMPILER6_UP} Cardinal; {$ELSE} HICON; {$ENDIF}
begin
Result := LoadIcon(HInstance, 'XJVPLUGINWIZ');
end;
procedure TJvPluginWizard.Execute;
var
ModuleServices: IOTAModuleServices;
ProjectCreator: TJvPluginProjectCreator;
begin
with TfrmPluginParams.Create(nil) do
try
if ShowModal = mrOk then
begin
if Assigned(BorlandIDEServices) and
(BorlandIDEServices.QueryInterface(IOTAModuleServices, ModuleServices) = S_OK) then
begin
ProjectCreator := TJvPluginProjectCreator.Create;
ProjectCreator.Wizard := Self;
{ rbDll checked => dll => PlugType = 0 = Ord(False)
rbPackage checked => package => PlugType = 1 = Ord(True)
}
ProjectCreator.PlugType := Ord(rbPackage.Checked); // radPluginType.ItemIndex;
ProjectCreator.PlugName := Trim(edtPluginName.Text);
ProjectCreator.PlugAuth := Trim(edtPluginAuthor.Text);
ProjectCreator.PlugCopy := Trim(edtPluginCopyright.Text);
ProjectCreator.PlugDesc := Trim(mmoDescripton.Text);
ProjectCreator.PlugUID := Trim(edtPluginUID.Text);
ModuleServices.CreateModule(ProjectCreator);
end;
end;
finally
Free;
end;
end;
//=== { TJvPluginProjectCreator } ============================================
// left empty this makes problems !!
function TJvPluginProjectCreator.GetFileName: string;
begin
{ 0 = dll; 1 = dpk }
if PlugType = 0 then
Result := GetCurrentDir + PathSeparator + cPlgPrefix + PlugName + '.dpr'
else
Result := GetCurrentDir + PathSeparator + cPlgPrefix + PlugName + '.dpk';
end;
function TJvPluginProjectCreator.GetOptionFileName: string;
begin
Result := '';
end;
function TJvPluginProjectCreator.GetShowSource: Boolean;
begin
Result := True;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -