| 5 |
|
uses |
| 6 |
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
| 7 |
|
Dialogs, ExtCtrls, StdCtrls, StrUtils, |
| 8 |
< |
ConnectionManager, {Functions,} Data, TypeDefs, Menus, Buttons; |
| 8 |
> |
Data, TypeDefs, Menus, Buttons; |
| 9 |
|
|
| 10 |
|
type |
| 11 |
|
TNewFileSelectedEvent = procedure(FileInfo: TFileInfo) of object; |
| 12 |
|
TNewConnectionEvent = procedure(Connection: Integer) of object; |
| 13 |
+ |
TCheckCloseableEvent = function: Boolean of object; |
| 14 |
|
|
| 15 |
|
TForm_ToolTemplate = class(TForm) |
| 16 |
|
panel_files: TPanel; |
| 40 |
|
Label3: TLabel; |
| 41 |
|
combo_connection: TComboBox; |
| 42 |
|
Bevel1: TBevel; |
| 43 |
< |
procedure RecreateList; |
| 44 |
< |
procedure UpdateList; |
| 43 |
> |
popup_linkshere: TMenuItem; |
| 44 |
> |
popup_separator2: TMenuItem; |
| 45 |
|
procedure RecreateExtList; |
| 46 |
+ |
procedure UpdateConList; |
| 47 |
|
procedure LoadFileNames; |
| 48 |
< |
procedure SelectFileName(connection: Integer; FileName: String); |
| 49 |
< |
procedure SelectFileID(connection: Integer; FileID: Integer); |
| 48 |
> |
procedure SelectFileName(ConnectionID: Integer; FileName: String); |
| 49 |
> |
procedure SelectFileID(ConnectionID, FileID: Integer); |
| 50 |
> |
procedure SelectConnection(ConnectionID: Integer); |
| 51 |
|
procedure check_filternameClick(Sender: TObject); |
| 52 |
|
procedure check_zerobyteClick(Sender: TObject); |
| 53 |
|
procedure combo_extensionClick(Sender: TObject); |
| 55 |
|
procedure listMouseDown(Sender: TObject; Button: TMouseButton; |
| 56 |
|
Shift: TShiftState; X, Y: Integer); |
| 57 |
|
|
| 55 |
– |
procedure FormResize(Sender: TObject); |
| 56 |
– |
procedure FormCreate(Sender: TObject); |
| 58 |
|
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
| 59 |
|
procedure popup_importClick(Sender: TObject); |
| 60 |
|
procedure popup_exportClick(Sender: TObject); |
| 63 |
|
procedure btn_sortClick(Sender: TObject); |
| 64 |
|
procedure FormActivate(Sender: TObject); |
| 65 |
|
procedure combo_connectionChange(Sender: TObject); |
| 66 |
+ |
procedure popup_linkshereClick(Sender: TObject); |
| 67 |
|
private |
| 68 |
|
FSortBy: TSortType; |
| 69 |
|
FOnNewFileSelected: TNewFileSelectedEvent; |
| 70 |
|
FOnNewConnection: TNewConnectionEvent; |
| 71 |
+ |
FOnCheckCloseable: TCheckCloseableEvent; |
| 72 |
|
FAllowedExts: String; |
| 73 |
|
FAllowMultiSelect: Boolean; |
| 74 |
|
FSelectedFile: TFileInfo; |
| 75 |
< |
FConnection: Integer; |
| 75 |
> |
FConnectionID: Integer; |
| 76 |
|
procedure SetAllowedExts(exts: String); |
| 77 |
|
procedure SetMultiSelect(allow: Boolean); |
| 78 |
+ |
function GetToolCloseable: Boolean; |
| 79 |
|
public |
| 80 |
|
constructor Create(AOwner: TComponent); override; |
| 81 |
|
procedure SetFileFilters(pattern, extension: String; zerobytes: Boolean); |
| 82 |
|
published |
| 83 |
|
property OnNewFileSelected: TNewFileSelectedEvent read FOnNewFileSelected write FOnNewFileSelected; |
| 84 |
|
property OnNewConnection: TNewConnectionEvent read FOnNewConnection write FOnNewConnection; |
| 85 |
+ |
property OnCheckCloseable: TCheckCloseableEvent read FOnCheckCloseable write FOnCheckCloseable; |
| 86 |
|
property AllowedExts: String read FAllowedExts write SetAllowedExts; |
| 87 |
|
property AllowMultiSelect: Boolean read FAllowMultiSelect write SetMultiSelect; |
| 88 |
|
property SelectedFile: TFileInfo read FSelectedFile; |
| 89 |
< |
property Connection: Integer read FConnection; |
| 89 |
> |
property ConnectionID: Integer read FConnectionID; |
| 90 |
> |
property Closeable: Boolean read GetToolCloseable; |
| 91 |
|
end; |
| 92 |
|
|
| 93 |
|
var |
| 96 |
|
|
| 97 |
|
implementation |
| 98 |
|
{$R *.dfm} |
| 99 |
< |
uses Main, Exporters; |
| 99 |
> |
uses Main, ConnectionManager, Exporters, Functions, WhatLinksHere; |
| 100 |
|
|
| 101 |
|
|
| 102 |
< |
procedure TForm_ToolTemplate.UpdateList; |
| 102 |
> |
procedure TForm_ToolTemplate.UpdateConList; |
| 103 |
|
var |
| 104 |
|
i: Integer; |
| 105 |
|
fn, datatype, boxstring: String; |
| 106 |
|
level: Integer; |
| 101 |
– |
oldcon: String; |
| 107 |
|
begin |
| 103 |
– |
oldcon := combo_connection.Items.Strings[combo_connection.ItemIndex]; |
| 108 |
|
combo_connection.ItemIndex := -1; |
| 109 |
|
combo_connection.Items.Clear; |
| 110 |
< |
if Length(DataConnections) > 0 then |
| 110 |
> |
if ConManager.Count > 0 then |
| 111 |
|
begin |
| 112 |
< |
for i := 0 to High(DataConnections) do |
| 112 |
> |
for i := 0 to ConManager.Count - 1 do |
| 113 |
|
begin |
| 114 |
< |
level := DataConnections[i].LevelInfo.LevelNumber; |
| 115 |
< |
fn := ExtractFileName(DataConnections[i].FileName); |
| 116 |
< |
if DataConnections[i].Backend = ODB_Dat then |
| 114 |
> |
level := ConManager.ConnectionByIndex[i].LevelNumber; |
| 115 |
> |
fn := ExtractFileName(ConManager.ConnectionByIndex[i].FileName); |
| 116 |
> |
if ConManager.ConnectionByIndex[i].Backend = DB_ONI then |
| 117 |
|
datatype := 'ONI-.dat: ' |
| 118 |
< |
else if DataConnections[i].Backend = ODB_ADB then |
| 118 |
> |
else if ConManager.ConnectionByIndex[i].Backend = DB_ADB then |
| 119 |
|
datatype := 'OUP-DB: ' |
| 120 |
|
else |
| 121 |
|
datatype := 'Unknown: '; |
| 122 |
< |
boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ')'; |
| 122 |
> |
boxstring := datatype + fn + ' (Level: ' + IntToStr(level) + ') [' + IntToStr(ConManager.ConnectionByIndex[i].ConnectionID) + ']'; |
| 123 |
|
combo_connection.Items.Add(boxstring); |
| 124 |
< |
if oldcon = boxstring then |
| 124 |
> |
if ConManager.ConnectionByIndex[i].ConnectionID = FConnectionID then |
| 125 |
|
combo_connection.ItemIndex := combo_connection.Items.Count - 1; |
| 126 |
|
end; |
| 127 |
|
if combo_connection.ItemIndex = -1 then |
| 132 |
|
end |
| 133 |
|
else |
| 134 |
|
begin |
| 135 |
< |
FConnection := nil; |
| 135 |
> |
FConnectionID := 0; |
| 136 |
|
filelist.Items.Clear; |
| 137 |
|
combo_extension.Items.Clear; |
| 138 |
|
combo_connectionChange(Self); |
| 139 |
< |
FSelectedFile := GetEmptyFileInfo; |
| 139 |
> |
FSelectedFile.ID := -1; |
| 140 |
|
if Assigned(FOnNewFileSelected) then |
| 141 |
|
FOnNewFileSelected(FSelectedFile); |
| 142 |
|
end; |
| 143 |
|
end; |
| 144 |
|
|
| 141 |
– |
procedure TForm_ToolTemplate.RecreateList; |
| 142 |
– |
var |
| 143 |
– |
i: Integer; |
| 144 |
– |
fn, datatype: String; |
| 145 |
– |
level: Integer; |
| 146 |
– |
begin |
| 147 |
– |
combo_connection.Items.Clear; |
| 148 |
– |
if Length(DataConnections) > 0 then |
| 149 |
– |
begin |
| 150 |
– |
for i := 0 to High(DataConnections) do |
| 151 |
– |
begin |
| 152 |
– |
level := DataConnections[i].LevelInfo.LevelNumber; |
| 153 |
– |
fn := ExtractFileName(DataConnections[i].FileName); |
| 154 |
– |
if DataConnections[i].Backend = ODB_Dat then |
| 155 |
– |
datatype := 'ONI-.dat: ' |
| 156 |
– |
else if DataConnections[i].Backend = ODB_ADB then |
| 157 |
– |
datatype := 'OUP-DB: ' |
| 158 |
– |
else |
| 159 |
– |
datatype := 'Unknown: '; |
| 160 |
– |
combo_connection.Items.Add(datatype + fn + ' (Level: ' + IntToStr(level) + ')'); |
| 161 |
– |
end; |
| 162 |
– |
FConnection := DataConnections[0]; |
| 163 |
– |
combo_connection.ItemIndex := 0; |
| 164 |
– |
combo_connectionChange(Self); |
| 165 |
– |
end |
| 166 |
– |
else |
| 167 |
– |
begin |
| 168 |
– |
FConnection := nil; |
| 169 |
– |
filelist.Items.Clear; |
| 170 |
– |
combo_extension.Items.Clear; |
| 171 |
– |
combo_connectionChange(Self); |
| 172 |
– |
end; |
| 173 |
– |
end; |
| 174 |
– |
|
| 145 |
|
procedure TForm_ToolTemplate.RecreateExtList; |
| 146 |
|
var |
| 147 |
< |
i: LongWord; |
| 148 |
< |
exts: TStringArray; |
| 147 |
> |
i: Integer; |
| 148 |
> |
exts: TStrings; |
| 149 |
|
begin |
| 150 |
|
combo_extension.Items.Clear; |
| 151 |
< |
if FConnection <> nil then |
| 151 |
> |
if FConnectionID > -1 then |
| 152 |
|
begin |
| 153 |
|
combo_extension.Items.Add('_All files_ (' + |
| 154 |
< |
IntToStr(FConnection.GetFilesCount) + ')'); |
| 155 |
< |
exts := FConnection.GetExtensionsList; |
| 156 |
< |
for i := 0 to High(exts) do |
| 154 |
> |
IntToStr(ConManager.Connection[FConnectionID].GetFileCount) + ')'); |
| 155 |
> |
exts := nil; |
| 156 |
> |
exts := ConManager.Connection[FConnectionID].GetExtensionsList(EF_ExtCount); |
| 157 |
> |
for i := 0 to exts.Count - 1 do |
| 158 |
|
if Length(FAllowedExts) > 0 then |
| 159 |
|
begin |
| 160 |
< |
if Pos(MidStr(exts[i],1,4), FAllowedExts) > 0 then |
| 161 |
< |
begin |
| 162 |
< |
combo_extension.Items.Add(exts[i]); |
| 163 |
< |
end; |
| 164 |
< |
end else |
| 194 |
< |
combo_extension.Items.Add(exts[i]); |
| 160 |
> |
if Pos(MidStr(exts.Strings[i],1,4), FAllowedExts) > 0 then |
| 161 |
> |
combo_extension.Items.Add(exts.Strings[i]); |
| 162 |
> |
end |
| 163 |
> |
else |
| 164 |
> |
combo_extension.Items.Add(exts.Strings[i]); |
| 165 |
|
combo_extension.ItemIndex := 0; |
| 166 |
|
combo_extensionClick(Self); |
| 167 |
+ |
exts.Free; |
| 168 |
|
end; |
| 169 |
|
end; |
| 170 |
|
|
| 176 |
|
Extension: String; |
| 177 |
|
no_zero_bytes: Boolean; |
| 178 |
|
pattern: String; |
| 179 |
< |
files: TStringArray; |
| 209 |
< |
i: LongWord; |
| 179 |
> |
files: TStrings; |
| 180 |
|
begin |
| 181 |
< |
if FConnection <> nil then |
| 181 |
> |
if FConnectionID > -1 then |
| 182 |
|
begin |
| 183 |
|
Extension := MidStr(combo_extension.Items.Strings[combo_extension.ItemIndex], 1, 4); |
| 184 |
|
no_zero_bytes := not check_zerobyte.Checked; |
| 191 |
|
else |
| 192 |
|
Extension := ''; |
| 193 |
|
|
| 194 |
< |
files := FConnection.GetFilesList(extension, pattern, no_zero_bytes, FSortBy); |
| 194 |
> |
files := nil; |
| 195 |
> |
files := ConManager.Connection[FConnectionID].GetFilesList(extension, pattern, no_zero_bytes, FSortBy); |
| 196 |
|
|
| 197 |
|
filelist.Visible := False; |
| 198 |
|
filelist.Items.Clear; |
| 199 |
< |
if Length(files) > 0 then |
| 200 |
< |
for i := 0 to High(files) do |
| 230 |
< |
filelist.Items.Add(files[i]); |
| 199 |
> |
if files.Count > 0 then |
| 200 |
> |
filelist.Items.AddStrings(files); |
| 201 |
|
filelist.Visible := True; |
| 202 |
|
end; |
| 203 |
|
end; |
| 208 |
|
id: Integer; |
| 209 |
|
ext: String; |
| 210 |
|
begin |
| 211 |
< |
id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]); |
| 211 |
> |
id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); |
| 212 |
|
ext := RightStr(filelist.Items.Strings[filelist.ItemIndex], 4); |
| 213 |
|
exportd.Filter := 'Files of matching extension (*.' + ext + ')|*.' + ext + '|All files|*.*'; |
| 214 |
|
exportd.DefaultExt := ext; |
| 215 |
|
if exportd.Execute then |
| 216 |
< |
ExportDatFile(FConnection, id, exportd.FileName); |
| 216 |
> |
ExportDatFile(FConnectionID, id, exportd.FileName); |
| 217 |
|
end; |
| 218 |
|
|
| 219 |
|
procedure TForm_ToolTemplate.popup_importClick(Sender: TObject); |
| 221 |
|
id: Integer; |
| 222 |
|
finfo: TFileInfo; |
| 223 |
|
fs: TFileStream; |
| 254 |
– |
data: TData; |
| 224 |
|
begin |
| 225 |
< |
id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]); |
| 226 |
< |
finfo := FConnection.GetFileInfo(id); |
| 225 |
> |
if CR_EditDat in ConManager.Connection[FConnectionID].ChangeRights then |
| 226 |
> |
begin |
| 227 |
> |
id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); |
| 228 |
> |
finfo := ConManager.Connection[FConnectionID].GetFileInfo(id); |
| 229 |
|
|
| 230 |
< |
importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' + |
| 231 |
< |
finfo.Extension + '|All files|*.*'; |
| 232 |
< |
if importd.Execute then |
| 233 |
< |
begin |
| 234 |
< |
fs := TFileStream.Create(importd.FileName, fmOpenRead); |
| 235 |
< |
if fs.Size <> finfo.Size then |
| 236 |
< |
ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) + |
| 237 |
< |
', file has to have same size as file in .dat.' + CrLf + |
| 238 |
< |
'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf + |
| 239 |
< |
'Size of chosen file: ' + FormatFileSize(fs.Size)) |
| 240 |
< |
else begin |
| 241 |
< |
SetLength(data, fs.Size); |
| 242 |
< |
fs.Read(data[0], fs.Size); |
| 243 |
< |
FConnection.UpdateDatFile(id, data); |
| 230 |
> |
importd.Filter := 'Files of matching extension (*.' + finfo.Extension + ')|*.' + |
| 231 |
> |
finfo.Extension + '|All files|*.*'; |
| 232 |
> |
if importd.Execute then |
| 233 |
> |
begin |
| 234 |
> |
fs := TFileStream.Create(importd.FileName, fmOpenRead); |
| 235 |
> |
if fs.Size <> finfo.Size then |
| 236 |
> |
begin |
| 237 |
> |
if not (CR_ResizeDat in ConManager.Connection[FConnectionID].ChangeRights) then |
| 238 |
> |
begin |
| 239 |
> |
ShowMessage('Can''t import ' + ExtractFilename(importd.FileName) + |
| 240 |
> |
', file has to have same size as file in .dat with this backend.' + CrLf + |
| 241 |
> |
'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf + |
| 242 |
> |
'Size of chosen file: ' + FormatFileSize(fs.Size)); |
| 243 |
> |
Exit; |
| 244 |
> |
end else begin |
| 245 |
> |
if MessageBox(Self.Handle, |
| 246 |
> |
PChar('File has different size from the file in the .dat.' + CrLf + |
| 247 |
> |
'Size of file in .dat: ' + FormatFileSize(finfo.Size) + CrLf + |
| 248 |
> |
'Size of chosen file: ' + FormatFileSize(fs.Size) + CrLf + |
| 249 |
> |
'Replace anyway?'), PChar('Different size'), MB_YESNO + MB_ICONWARNING) = ID_NO then |
| 250 |
> |
begin |
| 251 |
> |
Exit; |
| 252 |
> |
end; |
| 253 |
> |
end; |
| 254 |
> |
end; |
| 255 |
> |
ConManager.Connection[FConnectionID].UpdateDatFile(id, fs); |
| 256 |
|
Self.listClick(Self); |
| 257 |
+ |
fs.Free; |
| 258 |
|
end; |
| 259 |
< |
fs.Free; |
| 259 |
> |
end else begin |
| 260 |
> |
ShowMessage('Editing .dat-contents not allowed with this backend.'); |
| 261 |
|
end; |
| 262 |
|
end; |
| 263 |
|
|
| 264 |
+ |
procedure TForm_ToolTemplate.popup_linkshereClick(Sender: TObject); |
| 265 |
+ |
begin |
| 266 |
+ |
Form_WhatLinksHere.ConID := FConnectionID; |
| 267 |
+ |
Form_WhatLinksHere.FileID := FSelectedFile.ID; |
| 268 |
+ |
Form_WhatLinksHere.SenderForm := Self; |
| 269 |
+ |
Form_WhatLinksHere.Show; |
| 270 |
+ |
end; |
| 271 |
+ |
|
| 272 |
|
procedure TForm_ToolTemplate.popup_opentool(Sender: TObject); |
| 273 |
|
var |
| 274 |
|
sender_name, context: String; |
| 275 |
|
id: Integer; |
| 276 |
|
begin |
| 277 |
|
sender_name := TComponent(Sender).Name; |
| 278 |
< |
id := FConnection.ExtractFileID(filelist.Items.Strings[filelist.ItemIndex]); |
| 278 |
> |
id := ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[filelist.ItemIndex]); |
| 279 |
|
context := MidStr(sender_name, Pos('_', sender_name) + 1, Length(sender_name) - Pos('_', sender_name)); |
| 280 |
< |
Form_Main.open_child(context, FConnection, id); |
| 280 |
> |
Form_Main.open_child(context, FConnectionID, id); |
| 281 |
|
end; |
| 282 |
|
|
| 283 |
|
procedure TForm_ToolTemplate.combo_connectionChange(Sender: TObject); |
| 284 |
|
var |
| 285 |
|
name: String; |
| 293 |
– |
nstart, nend: Integer; |
| 294 |
– |
i: Integer; |
| 286 |
|
begin |
| 287 |
|
if combo_connection.ItemIndex >= 0 then |
| 288 |
|
begin |
| 289 |
|
name := combo_connection.Items.Strings[combo_connection.ItemIndex]; |
| 290 |
< |
nstart := Pos(' ', name) + 1; |
| 291 |
< |
nend := Pos('(', name) - 1; |
| 292 |
< |
name := MidStr(name, nstart, nend - nstart); |
| 293 |
< |
|
| 294 |
< |
for i := 0 to High(DataConnections) do |
| 295 |
< |
begin |
| 296 |
< |
if ExtractFileName(DataConnections[i].FileName) = name then |
| 306 |
< |
begin |
| 307 |
< |
FConnection := DataConnections[i]; |
| 308 |
< |
Break; |
| 309 |
< |
end; |
| 310 |
< |
end; |
| 311 |
< |
if i = Length(DataConnections) then |
| 312 |
< |
FConnection := nil; |
| 313 |
< |
|
| 314 |
< |
RecreateExtList; |
| 315 |
< |
if Assigned(FOnNewConnection) then |
| 316 |
< |
FOnNewConnection(FConnection); |
| 317 |
< |
end; |
| 290 |
> |
FConnectionID := StrToInt(MidStr(name, Pos('[', name) + 1, Pos(']', name) - Pos('[', name) - 1)); |
| 291 |
> |
end |
| 292 |
> |
else |
| 293 |
> |
FConnectionID := -1; |
| 294 |
> |
RecreateExtList; |
| 295 |
> |
if Assigned(FOnNewConnection) then |
| 296 |
> |
FOnNewConnection(FConnectionID); |
| 297 |
|
end; |
| 298 |
|
|
| 299 |
|
procedure TForm_ToolTemplate.combo_extensionClick(Sender: TObject); |
| 308 |
|
item: TMenuItem; |
| 309 |
|
begin |
| 310 |
|
inherited; |
| 311 |
< |
RecreateList; |
| 312 |
< |
FSelectedFile := GetEmptyFileInfo; |
| 311 |
> |
Self.Width := 260; |
| 312 |
> |
Self.Height := 300; |
| 313 |
> |
FAllowedExts := ''; |
| 314 |
> |
FAllowMultiSelect := False; |
| 315 |
> |
FOnNewFileSelected := nil; |
| 316 |
> |
FOnNewConnection := nil; |
| 317 |
> |
FOnCheckCloseable := nil; |
| 318 |
> |
FConnectionID := -1; |
| 319 |
> |
FSelectedFile.ID := -1; |
| 320 |
> |
UpdateConList; |
| 321 |
|
if Length(ToolList) > 0 then |
| 322 |
|
begin |
| 323 |
|
for i := 0 to High(ToolList) do |
| 354 |
|
procedure TForm_ToolTemplate.btn_sortClick(Sender: TObject); |
| 355 |
|
begin |
| 356 |
|
if btn_sort_id_asc.Down then |
| 357 |
< |
FSortBy := stIDAsc |
| 357 |
> |
FSortBy := ST_IDAsc |
| 358 |
|
else if btn_sort_id_desc.Down then |
| 359 |
< |
FSortBy := stIDDesc |
| 359 |
> |
FSortBy := ST_IDDesc |
| 360 |
|
else if btn_sort_name_asc.Down then |
| 361 |
< |
FSortBy := stNameAsc |
| 361 |
> |
FSortBy := ST_NameAsc |
| 362 |
|
else if btn_sort_name_desc.Down then |
| 363 |
< |
FSortBy := stNameDesc |
| 363 |
> |
FSortBy := ST_NameDesc |
| 364 |
|
else if btn_sort_ext_asc.Down then |
| 365 |
< |
FSortBy := stExtAsc |
| 365 |
> |
FSortBy := ST_ExtAsc |
| 366 |
|
else if btn_sort_ext_desc.Down then |
| 367 |
< |
FSortBy := stExtDesc; |
| 367 |
> |
FSortBy := ST_ExtDesc; |
| 368 |
|
LoadFileNames; |
| 369 |
|
end; |
| 370 |
|
|
| 380 |
|
begin |
| 381 |
|
if filelist.ItemIndex > -1 then |
| 382 |
|
begin |
| 383 |
< |
fileid := FConnection.ExtractFileID( |
| 383 |
> |
fileid := ConManager.Connection[FConnectionID].ExtractFileIDOfName( |
| 384 |
|
filelist.Items.Strings[filelist.ItemIndex]); |
| 385 |
< |
FSelectedFile := FConnection.GetFileInfo(fileid); |
| 385 |
> |
FSelectedFile := ConManager.Connection[FConnectionID].GetFileInfo(fileid); |
| 386 |
|
if Assigned(FOnNewFileSelected) then |
| 387 |
|
FOnNewFileSelected(FSelectedFile); |
| 388 |
|
end; |
| 395 |
|
begin |
| 396 |
|
pt.X := x; |
| 397 |
|
pt.Y := y; |
| 398 |
< |
// filelist.ItemIndex := filelist.ItemAtPos(pt, true); |
| 399 |
< |
// Self.listClick(Self); |
| 398 |
> |
if Shift = [ssRight] then |
| 399 |
> |
begin |
| 400 |
> |
filelist.ItemIndex := filelist.ItemAtPos(pt, true); |
| 401 |
> |
Self.listClick(Self); |
| 402 |
> |
end; |
| 403 |
|
end; |
| 404 |
|
|
| 405 |
|
|
| 406 |
|
|
| 407 |
< |
procedure TForm_ToolTemplate.SelectFileID(connection: TOniData; id: Integer); |
| 418 |
< |
var |
| 419 |
< |
i: Integer; |
| 420 |
< |
name: String; |
| 421 |
< |
nstart, nend: Integer; |
| 407 |
> |
procedure TForm_ToolTemplate.SelectConnection(ConnectionID: Integer); |
| 408 |
|
begin |
| 409 |
< |
for i := 0 to combo_connection.Items.Count - 1 do |
| 409 |
> |
if FConnectionID <> ConnectionID then |
| 410 |
|
begin |
| 411 |
< |
name := combo_connection.Items.Strings[i]; |
| 412 |
< |
nstart := Pos(' ', name) + 1; |
| 427 |
< |
nend := Pos('(', name) - 1; |
| 428 |
< |
name := MidStr(name, nstart, nend - nstart); |
| 429 |
< |
|
| 430 |
< |
if ExtractFileName(connection.FileName) = name then |
| 431 |
< |
begin |
| 432 |
< |
combo_connection.ItemIndex := i; |
| 433 |
< |
combo_connectionChange(Self); |
| 434 |
< |
end; |
| 411 |
> |
combo_connection.ItemIndex := ConManager.ConnectionIndexByID[ConnectionID]; |
| 412 |
> |
combo_connectionChange(Self); |
| 413 |
|
end; |
| 414 |
+ |
end; |
| 415 |
+ |
|
| 416 |
+ |
procedure TForm_ToolTemplate.SelectFileID(ConnectionID, FileID: Integer); |
| 417 |
+ |
var |
| 418 |
+ |
i: Integer; |
| 419 |
+ |
begin |
| 420 |
+ |
if FConnectionID <> ConnectionID then |
| 421 |
+ |
SelectConnection(ConnectionID); |
| 422 |
|
|
| 423 |
|
filelist.ItemIndex := -1; |
| 424 |
|
if filelist.Items.Count > 0 then |
| 425 |
|
for i := 0 to filelist.Items.Count - 1 do |
| 426 |
< |
if FConnection.ExtractFileID(filelist.Items.Strings[i]) = id then |
| 426 |
> |
if ConManager.Connection[FConnectionID].ExtractFileIDOfName(filelist.Items.Strings[i]) = FileID then |
| 427 |
|
begin |
| 428 |
|
filelist.ItemIndex := i; |
| 429 |
|
Break; |
| 431 |
|
Self.listClick(Self); |
| 432 |
|
end; |
| 433 |
|
|
| 434 |
< |
procedure TForm_ToolTemplate.SelectFileName(connection: TOniData; filename: String); |
| 434 |
> |
procedure TForm_ToolTemplate.SelectFileName(ConnectionID: Integer; filename: String); |
| 435 |
|
var |
| 436 |
|
i: Integer; |
| 451 |
– |
name: String; |
| 452 |
– |
nstart, nend: Integer; |
| 437 |
|
begin |
| 438 |
< |
for i := 0 to combo_connection.Items.Count - 1 do |
| 439 |
< |
begin |
| 456 |
< |
name := combo_connection.Items.Strings[i]; |
| 457 |
< |
nstart := Pos(' ', name) + 1; |
| 458 |
< |
nend := Pos('(', name) - 1; |
| 459 |
< |
name := MidStr(name, nstart, nend - nstart); |
| 460 |
< |
|
| 461 |
< |
if ExtractFileName(connection.FileName) = name then |
| 462 |
< |
begin |
| 463 |
< |
combo_connection.ItemIndex := i; |
| 464 |
< |
combo_connectionChange(Self); |
| 465 |
< |
end; |
| 466 |
< |
end; |
| 438 |
> |
if FConnectionID <> ConnectionID then |
| 439 |
> |
SelectConnection(ConnectionID); |
| 440 |
|
|
| 441 |
|
filelist.ItemIndex := -1; |
| 442 |
|
if filelist.Items.Count > 0 then |
| 481 |
|
end; |
| 482 |
|
|
| 483 |
|
|
| 484 |
< |
procedure TForm_ToolTemplate.FormResize(Sender: TObject); |
| 484 |
> |
function TForm_ToolTemplate.GetToolCloseable: Boolean; |
| 485 |
|
begin |
| 486 |
< |
if Self.Width < 300 then |
| 487 |
< |
Self.Width := 300; |
| 488 |
< |
if Self.Height < 200 then |
| 489 |
< |
Self.Height := 200; |
| 517 |
< |
end; |
| 518 |
< |
|
| 519 |
< |
|
| 520 |
< |
|
| 521 |
< |
procedure TForm_ToolTemplate.FormCreate(Sender: TObject); |
| 522 |
< |
begin |
| 523 |
< |
Self.Width := 260; |
| 524 |
< |
Self.Height := 300; |
| 525 |
< |
FOnNewFileSelected := nil; |
| 526 |
< |
FOnNewConnection := nil; |
| 527 |
< |
FAllowedExts := ''; |
| 528 |
< |
FAllowMultiSelect := False; |
| 486 |
> |
if Assigned(FOnCheckCloseable) then |
| 487 |
> |
Result := FOnCheckCloseable |
| 488 |
> |
else |
| 489 |
> |
Result := True; |
| 490 |
|
end; |
| 491 |
|
|
| 492 |
|
procedure TForm_ToolTemplate.FormActivate(Sender: TObject); |