[107] | 1 | unit WhatLinksHere;
|
---|
| 2 | interface
|
---|
| 3 | uses
|
---|
| 4 | Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
[114] | 5 | Dialogs, StdCtrls, Template, ExtCtrls;
|
---|
[107] | 6 |
|
---|
| 7 | type
|
---|
| 8 | TForm_WhatLinksHere = class(TForm)
|
---|
[114] | 9 | Panel1: TPanel;
|
---|
| 10 | list_from: TListBox;
|
---|
[107] | 11 | label_what: TLabel;
|
---|
[114] | 12 | Panel2: TPanel;
|
---|
| 13 | label_to: TLabel;
|
---|
| 14 | list_to: TListBox;
|
---|
| 15 | Splitter1: TSplitter;
|
---|
[107] | 16 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
---|
| 17 | procedure FormShow(Sender: TObject);
|
---|
[114] | 18 | procedure list_fromDblClick(Sender: TObject);
|
---|
[107] | 19 | private
|
---|
| 20 | public
|
---|
| 21 | SenderForm: TForm_ToolTemplate;
|
---|
| 22 | ConID: Integer;
|
---|
| 23 | FileID: Integer;
|
---|
| 24 | end;
|
---|
| 25 |
|
---|
| 26 | var
|
---|
| 27 | Form_WhatLinksHere: TForm_WhatLinksHere;
|
---|
| 28 |
|
---|
| 29 | implementation
|
---|
| 30 | {$R *.dfm}
|
---|
| 31 | uses ConnectionManager, Access_OUP_ADB, TypeDefs, Functions, Main;
|
---|
| 32 |
|
---|
| 33 | { TForm_WhatLinksHere }
|
---|
| 34 |
|
---|
| 35 | procedure TForm_WhatLinksHere.FormCloseQuery(Sender: TObject;
|
---|
| 36 | var CanClose: Boolean);
|
---|
| 37 | begin
|
---|
| 38 | Form_Main.Enabled := True;
|
---|
| 39 | Visible := False;
|
---|
| 40 | CanClose := False;
|
---|
| 41 | end;
|
---|
| 42 |
|
---|
| 43 | procedure TForm_WhatLinksHere.FormShow(Sender: TObject);
|
---|
| 44 | var
|
---|
| 45 | fileinfo: TFileInfo;
|
---|
| 46 | links: TLinks;
|
---|
| 47 | i: Integer;
|
---|
| 48 | fullname: String;
|
---|
[114] | 49 | links_to: TDatLinkList;
|
---|
[107] | 50 | begin
|
---|
| 51 | Form_Main.Enabled := False;
|
---|
[114] | 52 | list_from.Items.Clear;
|
---|
| 53 | list_to.Items.Clear;
|
---|
[107] | 54 | fileinfo := ConManager.Connection[ConID].GetFileInfo(FileID);
|
---|
| 55 | label_what.Caption := FormatNumber(fileinfo.ID, 5, '0') + '-' +
|
---|
| 56 | fileinfo.Name + '.' + fileinfo.Extension;
|
---|
[114] | 57 | links_to := ConManager.Connection[ConID].GetDatLinks(fileinfo.ID);
|
---|
| 58 | if ConManager.Connection[ConID] is TAccess_OUP_ADB then begin
|
---|
| 59 | links := TAccess_OUP_ADB(ConManager.Connection[ConID]).GetLinksToFile(fileinfo.ID);
|
---|
| 60 | if Length(links.ByID) > 0 then
|
---|
| 61 | for i := 0 to High(links.ByID) do
|
---|
| 62 | begin
|
---|
| 63 | fileinfo := ConManager.Connection[ConID].GetFileInfo(links.ByID[i].Destination);
|
---|
| 64 | fullname := FormatNumber(fileinfo.ID, 5, '0') + '-' + fileinfo.Name + '.' + fileinfo.Extension;
|
---|
| 65 | list_from.Items.Add(fullname + ' (Offset 0x' + IntToHex(links.ByID[i].SrcOffset, 8) + ')');
|
---|
| 66 | end;
|
---|
| 67 | end;
|
---|
| 68 | if Length(links_to) > 0 then
|
---|
| 69 | begin
|
---|
| 70 | for i := 0 to High(links_to) do
|
---|
[107] | 71 | begin
|
---|
[114] | 72 | if links_to[i].DestID >= 0 then
|
---|
| 73 | begin
|
---|
| 74 | fileinfo := ConManager.Connection[ConID].GetFileInfo(links_to[i].DestID);
|
---|
| 75 | fullname := FormatNumber(fileinfo.ID, 5, '0') + '-' + fileinfo.Name + '.' + fileinfo.Extension;
|
---|
| 76 | end else
|
---|
| 77 | fullname := 'no link';
|
---|
| 78 | list_to.Items.Add(fullname + ' (Offset 0x' + IntToHex(links_to[i].SrcOffset, 8) + ')');
|
---|
[107] | 79 | end;
|
---|
[114] | 80 | end;
|
---|
[107] | 81 | end;
|
---|
| 82 |
|
---|
[114] | 83 | procedure TForm_WhatLinksHere.list_fromDblClick(Sender: TObject);
|
---|
[107] | 84 | var
|
---|
| 85 | id: Integer;
|
---|
[114] | 86 | box: TListBox;
|
---|
| 87 | name: String;
|
---|
[107] | 88 | begin
|
---|
[114] | 89 | box := TListBox(Sender);
|
---|
| 90 | name := box.Items.Strings[box.ItemIndex];
|
---|
| 91 | if Pos('no link', name) > 0 then
|
---|
| 92 | Exit
|
---|
| 93 | else
|
---|
| 94 | id := ConManager.Connection[ConID].ExtractFileIDOfName(name);
|
---|
[107] | 95 | SenderForm.SelectFileID(ConID, id);
|
---|
| 96 | Form_Main.Enabled := True;
|
---|
| 97 | Visible := False;
|
---|
| 98 | end;
|
---|
| 99 |
|
---|
| 100 | end.
|
---|