-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileItemsManager.lua
68 lines (53 loc) · 1.57 KB
/
FileItemsManager.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local IManager = require('ItemsManager')
local FItem = require('common/FileItem');
local FileInfoPanel = require('FileInfoPanel');
local DecoderInfoPanel = require('DecoderInfoPanel');
local fim = IManager:subclass("FileItemsManager");
local function windowContent(item)
FileInfoPanel(item.file, "FileInfo");
Slab.Separator();
DecoderInfoPanel(item.decoder, "DecoderInfo");
end
function fim:initialize()
IManager.initialize(self, "files",
{ name = "file", names = "files", title = "File", titles = "Files"},
FItem, windowContent);
end
function fim:itemContextMenu(item)
if Slab.MenuItem("New source") then
self.child:openNewItemDialog(item);
end
IManager.itemContextMenu(self, item);
end
function fim:contextMenu()
if Slab.MenuItem("Add files") then
self:openFileDialog();
end
end
function fim:addFiles(paths)
for key, fpath in pairs(paths) do
if fpath ~= nil then
self:createItem(fpath, true);
end
end
end
function fim:openNewItemDialog()
self:openFileDialog();
end
function fim:updateOpenFileDialog()
if self._openFileDialog then
local result = Slab.FileDialog({ Type = "openfile" })
if result.Button == "OK" then
self:addFiles(result.Files);
end
if result.Button ~= "" then self._openFileDialog = false; end
end
end
function fim:openFileDialog()
self._openFileDialog = true;
end
function fim:updateDialogs()
IManager.updateDialogs(self);
self:updateOpenFileDialog();
end
return fim;