Tortoisesvn2ide. Pas source code

Source: Internet
Author: User
Tags tortoisesvn

Unit tortoisesvn2ide;

{$ R 'icons'. res '}

Interface

Uses toolsapi, sysutils, windows, dialogs, menus, registry, shellapi,
Classes, controls, graphics, imglist, extctrls, actnlist, forms; // added references to forms units.

Const
Svn_project_explorer = 0;
Svn_log = 1;
Svn_check_modifications = 2;
Svn_add = 3;
Svn_update = 4;
Svn_commit = 5;
Svn_diff = 6;
Svn_revert = 7;
Svn_repository_browser = 8;
Svn_settings = 9;
Svn_about = 10;
Svn_verb_count = 11;

Type ttortoisesvn = Class (tnotifierobject, iotanotifier, iotawizard)
Private
Timer: ttimer;
Tsvnmenu: tmenuitem;
Tsvnpath: string;
Procedure tick (Sender: tobject );
Procedure tsvnexec (Params: string );
Function getbitmapname (Index: integer): string;
Function getverb (Index: integer): string;
Function getverbstate (Index: integer): word;
Procedure executeverb (Index: integer );
Procedure createmenu;
Procedure updateaction (Sender: tobject );
Procedure executeaction (Sender: tobject );
Public
Constructor create;
Destructor destroy; override;
Function getidstring: string;
Function getname: string;
Function getstate: twizardstate;
Procedure execute;
End;

{$ Ifndef dll_mode}

Procedure register;

{$ Else}

Function initwizard (const borlandideservices: iborlandideservices;
Registerproc: twizardregisterproc;
VaR terminate: twizardterminateproc): Boolean; stdcall;

{$ Endif}

Implementation

Function getcurrentproject: iotaproject;
VaR
Modservices: iotamoduleservices;
Module: iotamodule;
Project: iotaproject;
Projectgroup: iotaprojectgroup;
I: integer;
Begin
Result: = nil;
Modservices: = borlandideservices as iotamoduleservices;
If modservices <> nil then
For I: = 0 to modservices. modulecount-1 do
Begin
Module: = modservices. modules [I];
If supports (module, iotaprojectgroup, projectgroup) then
Begin
Result: = projectgroup. activeproject;
Exit;
End
Else if supports (module, iotaproject, Project) then
Begin // In the case of unbound packages, return the 1st
If result = nil then
Result: = project;
End;
End;
End;

Function getcurrentfilename: string;
VaR Editor: iotaeditorservices;
Begin
Result: = '';
Editor: = borlandideservices as iotaeditorservices;
If Editor <> nil then begin
If editor. topbuffer <> nil then
Result: = editor. topbuffer. filename;
End;
End;

Constructor ttortoisesvn. Create;
VaR REG: Tregistry;
Begin
Reg: = Tregistry. Create;
Try
Reg. rootkey: = HKEY_LOCAL_MACHINE;
If Reg. openkeyreadonly ('\ Software \ tortoisesvn') then
Tsvnpath: = reg. readstring ('cpath ');
Finally
Reg. closekey;
Reg. Free;
End;

Tsvnmenu: = nil;

Timer: = ttimer. Create (NiL );
Timer. interval: = 200;
Timer. ontimer: = tick;
Timer. Enabled: = true;

End;

Procedure ttortoisesvn. Tick (Sender: tobject );
VaR INTF: intaservices;
Begin
If borlandideservices. QueryInterface (intaservices, INTF) = s_ OK then begin
Self. createmenu;
Timer. Free;
Timer: = nil;
End;
End;

Procedure ttortoisesvn. createmenu;
VaR mainmenu: tmainmenu;
Item: tmenuitem;
I: integer;
BMP: tbitmap;
Action: taction;
Begin
If tsvnmenu <> nil then exit;

Tsvnmenu: = tmenuitem. Create (NiL );
Tsvnmenu. Caption: = 'tortoisesvn ';

For I: = 0 to a SVN_VERB_COUNT-1 do begin

BMP: = tbitmap. Create;
try
BMP. loadfromresourcename (hinstance, getbitmapname (I);
begin t end;

action: = taction. create (NiL);
action. actionlist: = (borlandideservices as intaservices ). actionlist;
action. caption: = getverb (I);
action. hint: = getverb (I);
If (BMP. width = 16) and (BMP. height = 16) Then
action. imageindex: = (borlandideservices as intaservices ). addmasked (BMP, clblack);
BMP. free;
action. onupdate: = updateaction;
action. onexecute: = executeaction;
action. tag: = I;

Item: = tmenuitem. Create (tsvnmenu );
Item. Action: = action;

Tsvnmenu. Add (item );
End;

Mainmenu: = (borlandideservices as intaservices). mainmenu;
Mainmenu. Items. insert (mainmenu. Items. Count-1, tsvnmenu );
End;

Destructor ttortoisesvn. Destroy;
Begin
If tsvnmenu <> nil then begin
Tsvnmenu. Free;
End;
Inherited;
End;

Function ttortoisesvn. getbitmapname (Index: integer): string;
Begin
Case index
Svn_project_explorer:
Result: = 'explorer ';
Svn_log:
Result: = 'log ';
Svn_check_modifications:
Result: = 'check ';
Svn_add:
Result: = 'add ';
Svn_update:
Result: = 'update ';
Svn_commit:
Result: = 'commit ';
Svn_diff:
Result: = 'diff ';
Svn_revert:
Result: = 'revert ';
Svn_repository_browser:
Result: = 'repository ';
Svn_settings:
Result: = 'settings ';
Svn_about:
Result: = 'about ';
End;
End;

Function ttortoisesvn. getverb (Index: integer): string;
Begin
Case index
Svn_project_explorer:
Result: = 'browse project folder [& P]... '; //' & Project explorer ...';
Svn_log:
Result: = 'Log [& L]... '; //' & log ...';
Svn_check_modifications:
Result: = 'check for updates [& M]... '; // 'check & modifications ...';
Svn_add:
Result: = 'add [& A]... '; //' & add ...';
Svn_update:
Result: = 'Update to a certain version [& U]... '; //' & Update to revision ...';
Svn_commit:
Result: = 'submit [& C]... '; //' & commit ...';
Svn_diff:
Result: = 'difference comparison [& D]... '; //' & diff ...';
Svn_revert:
Result: = 'Restore [& R]... '; //' & Revert ...';
Svn_repository_browser:
Result: = 'browse version Library [& B]... '; // 'repository & browser ...';
Svn_settings:
Result: = 'set [& S]... '; //' & settings ...';
Svn_about:
Result: = 'about [& A]... '; //' & about ...';
End;
End;

Const vsenabled = 1;

Function ttortoisesvn. getverbstate (Index: integer): word;
Begin
Result: = 0;
Case index
Svn_project_explorer:
If getcurrentproject <> nil then
Result: = vsenabled;
Svn_log:
If getcurrentproject <> nil then
Result: = vsenabled;
Svn_check_modifications:
If getcurrentproject <> nil then
Result: = vsenabled;
Svn_add:
If getcurrentproject <> nil then
Result: = vsenabled;
Svn_update:
If getcurrentproject <> nil then
Result: = vsenabled;
Svn_commit:
If getcurrentproject <> nil then
Result: = vsenabled;
Svn_diff:
If getcurrentfilename <> ''then
Result: = vsenabled;
Svn_revert:
If getcurrentproject <> nil then
Result: = vsenabled;
Svn_repository_browser:
Result: = vsenabled;
Svn_settings:
Result: = vsenabled;
Svn_about:
Result: = vsenabled;
End;
End;

Procedure ttortoisesvn. tsvnexec (Params: string );
Begin
Winexec (pchar (tsvnpath + ''+ Params), sw_show );
End;

Procedure ttortoisesvn. executeverb (Index: integer );
VaR project: iotaproject;
Filename: string;
Begin
Project: = getcurrentproject ();
Filename: = getcurrentfilename ();
Case index
Svn_project_explorer:
If project <> nil then
ShellExecute (0, 'open', pchar (extractfilepath (project. getfilename), '','', sw_shownormal );
Svn_log:
If project <> nil then
Tsvnexec ('/command: log/notempfile/path:' + ansiquotedstr (extractfilepath (project. getfilename ),'"'));
Svn_check_modifications:
If project <> nil then
Tsvnexec ('/command: repostatus/notempfile/path:' + ansiquotedstr (extractfilepath (project. getfilename ),'"'));
Svn_add:
If project <> nil then
Tsvnexec ('/command: Add/notempfile/path:' + ansiquotedstr (extractfilepath (project. getfilename ),'"'));
Svn_update:
If project <> nil then

If application. MessageBox ('before the update, all project files will be saved. Continue? ',' Hint ', mb_yesno + mb_iconquestion) = idyes then begin
// If messagedlg ('before the update, all project files will be saved. Continue? ', Mtconfirmation, [mbyes, mbno], 0) = mryes then begin
(Borlandideservices as iotamoduleservices). saveall;
Tsvnexec ('/command: update/Rev/notempfile/path:' + ansiquotedstr (extractfilepath (project. getfilename ),'"'));
End;
Svn_commit:
If project <> nil then
If application. MessageBox ('before committing, all project files will be saved. Continue? ',' Hint ', mb_yesno + mb_iconquestion) = idyes then begin
// If messagedlg ('all project files will be saved before submission. Continue? ', Mtconfirmation, [mbyes, mbno], 0) = mryes then begin
(Borlandideservices as iotamoduleservices). saveall;
Tsvnexec ('/command: commit/notempfile/path:' + ansiquotedstr (extractfilepath (project. getfilename ),'"'));
End;
Svn_diff:
If filename <> ''then
Tsvnexec ('/command: Diff/notempfile/path:' + ansiquotedstr (filename ,'"'));
Svn_revert:
If project <> nil then
Tsvnexec ('/command: Revert/notempfile/path:' + ansiquotedstr (extractfilepath (project. getfilename ),'"'));
Svn_repository_browser:
If project <> nil then
Tsvnexec ('/command: repobrowser/notempfile/path:' + ansiquotedstr (extractfilepath (project. getfilename ),'"'))
Else
Tsvnexec ('/command: repobrowser ');
Svn_settings:
Tsvnexec ('/command: settings ');
Svn_about:
Tsvnexec ('/command: about ');
End;
End;

Procedure ttortoisesvn. updateaction (Sender: tobject );
VaR action: taction;
Begin
Action: = sender as taction;
Action. Enabled: = getverbstate (action. Tag) = vsenabled;
End;

Procedure ttortoisesvn. executeaction (Sender: tobject );
VaR action: taction;
Begin
Action: = sender as taction;
Executeverb (action. Tag );
End;

Function ttortoisesvn. getidstring: string;
Begin
Result: = 'subversion. tortoisesvn ';
End;

Function ttortoisesvn. getname: string;
Begin
Result: = 'tortoisesvn add-in ';
End;

Function ttortoisesvn. getstate: twizardstate;
Begin
Result: = [wsenabled];
End;

Procedure ttortoisesvn. Execute;
Begin
End;

 

{$ Ifndef dll_mode}

Procedure register;
Begin
Registerpackagewizard (ttortoisesvn. Create );
End;

{$ Else}

VaR wizardid: integer;

Procedure finalizewizard;
VaR
Wizardservices: iotawizardservices;
Begin
Assert (assigned (borlandideservices ));

Wizardservices: = borlandideservices as iotawizardservices;
Assert (assigned (wizardservices ));

Wizardservices. removewizard (wizardid );

End;

Function initwizard (const borlandideservices: iborlandideservices;
Registerproc: twizardregisterproc;
VaR terminate: twizardterminateproc): Boolean; stdcall;
VaR
Wizardservices: iotawizardservices;
Begin
Assert (borlandideservices <> nil );
Assert (toolsapi. borlandideservices = borlandideservices );

Terminate: = finalizewizard;

Wizardservices: = borlandideservices as iotawizardservices;
Assert (assigned (wizardservices ));

Wizardid: = wizardservices. addwizard (ttortoisesvn. Create as iotawizard );

Result: = wizardid> = 0;
End;

Exports
Initwizard name wizardentrypoint;

{$ Endif}

 

End.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.