provide a way for FileSystem DataFormats to present DataFormat-specific additional details per file in the FileSystem Editor
This commit is contained in:
parent
114190a016
commit
fd26b2570d
@ -364,5 +364,7 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public FileAdditionalDetailValue.FileAdditionalDetailValueCollection AdditionalDetails { get; } = new FileAdditionalDetailValue.FileAdditionalDetailValueCollection();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
//
|
||||
// FileAdditionalDetail.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2020 Mike Becker
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
namespace UniversalEditor.ObjectModels.FileSystem
|
||||
{
|
||||
public class FileAdditionalDetail
|
||||
{
|
||||
public class FileAdditionalDetailCollection
|
||||
: System.Collections.ObjectModel.Collection<FileAdditionalDetail>
|
||||
{
|
||||
private System.Collections.Generic.Dictionary<string, FileAdditionalDetail> _itemsByName = new System.Collections.Generic.Dictionary<string, FileAdditionalDetail>();
|
||||
public FileAdditionalDetail this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_itemsByName.ContainsKey(name))
|
||||
return _itemsByName[name];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public bool Contains(string name)
|
||||
{
|
||||
return _itemsByName.ContainsKey(name);
|
||||
}
|
||||
|
||||
protected override void ClearItems()
|
||||
{
|
||||
base.ClearItems();
|
||||
_itemsByName.Clear();
|
||||
}
|
||||
protected override void InsertItem(int index, FileAdditionalDetail item)
|
||||
{
|
||||
base.InsertItem(index, item);
|
||||
_itemsByName[item.Name] = item;
|
||||
}
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
if (_itemsByName.ContainsKey(this[index].Name))
|
||||
_itemsByName.Remove(this[index].Name);
|
||||
base.RemoveItem(index);
|
||||
}
|
||||
|
||||
public FileAdditionalDetail Add(string name, string title)
|
||||
{
|
||||
FileAdditionalDetail item = new FileAdditionalDetail();
|
||||
item.Name = name;
|
||||
item.Title = title;
|
||||
Add(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get; set; } = null;
|
||||
public string Title { get; set; } = null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
//
|
||||
// FileAdditionalDetailValue.cs
|
||||
//
|
||||
// Author:
|
||||
// Mike Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2020 Mike Becker
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.FileSystem
|
||||
{
|
||||
public class FileAdditionalDetailValue
|
||||
{
|
||||
public class FileAdditionalDetailValueCollection
|
||||
: System.Collections.ObjectModel.Collection<FileAdditionalDetailValue>
|
||||
{
|
||||
private Dictionary<FileAdditionalDetail, FileAdditionalDetailValue> _itemsByDetail = new Dictionary<FileAdditionalDetail, FileAdditionalDetailValue>();
|
||||
public FileAdditionalDetailValue Add(FileAdditionalDetail detail, string value)
|
||||
{
|
||||
FileAdditionalDetailValue item = new FileAdditionalDetailValue();
|
||||
item.Detail = detail;
|
||||
item.Value = value;
|
||||
Add(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public FileAdditionalDetailValue this[FileAdditionalDetail detail]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_itemsByDetail.ContainsKey(detail))
|
||||
return _itemsByDetail[detail];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public bool Contains(FileAdditionalDetail detail)
|
||||
{
|
||||
return _itemsByDetail.ContainsKey(detail);
|
||||
}
|
||||
|
||||
protected override void ClearItems()
|
||||
{
|
||||
base.ClearItems();
|
||||
_itemsByDetail.Clear();
|
||||
}
|
||||
protected override void InsertItem(int index, FileAdditionalDetailValue item)
|
||||
{
|
||||
base.InsertItem(index, item);
|
||||
_itemsByDetail[item.Detail] = item;
|
||||
}
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
if (_itemsByDetail.ContainsKey(this[index].Detail))
|
||||
_itemsByDetail.Remove(this[index].Detail);
|
||||
base.RemoveItem(index);
|
||||
}
|
||||
}
|
||||
|
||||
private FileAdditionalDetailValue()
|
||||
{
|
||||
}
|
||||
|
||||
public FileAdditionalDetail Detail { get; set; } = null;
|
||||
public string Value { get; set; } = null;
|
||||
}
|
||||
}
|
||||
@ -321,7 +321,7 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
File file = mvarFiles[i];
|
||||
files.Add(file);
|
||||
}
|
||||
for (int i = 0; i < mvarFolders.Count; i++ )
|
||||
for (int i = 0; i < mvarFolders.Count; i++)
|
||||
{
|
||||
Folder folder = mvarFolders[i];
|
||||
GetAllFilesRecursively(folder, ref files, folder.Name, pathSeparator);
|
||||
@ -434,5 +434,7 @@ namespace UniversalEditor.ObjectModels.FileSystem
|
||||
{
|
||||
return FileSystemObjectModel.GetNewFolderName(this);
|
||||
}
|
||||
|
||||
public FileAdditionalDetail.FileAdditionalDetailCollection AdditionalDetails { get; } = new FileAdditionalDetail.FileAdditionalDetailCollection();
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,6 +197,8 @@
|
||||
<Compile Include="ObjectModels\Project\IProjectItemContainer.cs" />
|
||||
<Compile Include="DataFormats\AbstractSyntax\DER\DERTypeTag.cs" />
|
||||
<Compile Include="DataFormats\Binary\PEM\PEMDataFormat.cs" />
|
||||
<Compile Include="ObjectModels\FileSystem\FileAdditionalDetail.cs" />
|
||||
<Compile Include="ObjectModels\FileSystem\FileAdditionalDetailValue.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\UniversalEditor.Core\UniversalEditor.Core.csproj">
|
||||
|
||||
@ -311,6 +311,7 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
/// <param name="fso">Fso.</param>
|
||||
private TreeModelRow UIGetTreeModelRowForFileSystemObject(IFileSystemObject fso, bool recurse = true)
|
||||
{
|
||||
FileSystemObjectModel fsom = (ObjectModel as FileSystemObjectModel);
|
||||
TreeModelRow r = null;
|
||||
if (fso is Folder)
|
||||
{
|
||||
@ -351,6 +352,11 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
});
|
||||
r.RowColumns[1].RawValue = f.Size;
|
||||
r.RowColumns[3].RawValue = f.ModificationTimestamp.ToBinary();
|
||||
|
||||
for (int i = 0; i < f.AdditionalDetails.Count; i++)
|
||||
{
|
||||
r.RowColumns.Add(new TreeModelRowColumn(tmTreeView.Columns[4 + fsom.AdditionalDetails.IndexOf(f.AdditionalDetails[i].Detail)], f.AdditionalDetails[i].Value));
|
||||
}
|
||||
}
|
||||
r.SetExtraData<IFileSystemObject>("item", fso);
|
||||
return r;
|
||||
@ -467,9 +473,20 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
{
|
||||
base.OnObjectModelChanged(e);
|
||||
|
||||
for (int i = 4; i < tmTreeView.Columns.Count; i++)
|
||||
{
|
||||
tmTreeView.Columns.RemoveAt(i);
|
||||
}
|
||||
|
||||
FileSystemObjectModel fsom = (ObjectModel as FileSystemObjectModel);
|
||||
if (fsom == null) return;
|
||||
|
||||
for (int i = 0; i < fsom.AdditionalDetails.Count; i++)
|
||||
{
|
||||
tmTreeView.Columns.Add(new TreeModelColumn(typeof(string)));
|
||||
tv.Columns.Add(new ListViewColumnText(tmTreeView.Columns[tmTreeView.Columns.Count - 1], fsom.AdditionalDetails[i].Title));
|
||||
}
|
||||
|
||||
foreach (Folder f in fsom.Folders)
|
||||
{
|
||||
RecursiveAddFolder(f, null);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user