List objects UI:s are used to manage global objects that are "flat", i.e. not categorized or structured in a way that would make a tree and list UI more suitable
To create a tool like this we can use the Visual Studio template Dynamix 6 - List Manage Objects Ui.
The template creates a class that inherits from Dynamix.Ui6.Dialogs.ListObjectsUi. It wraps this UI-class inside a DialogDescriptor.
public class MyListDialog : DialogDescriptor
{
public MyListDialog()
{
Title = "My list tool";
OpenMode = DialogOpenMode.Window;
}
protected override PageDescriptor GetPage()
{
return PageDescriptor.Get<MyListUi>();
}
private class MyListUi : ListObjectsUi
{
}
}
Customizing the list
By default a grid view of the type ListObjectUi.ManageObjectsGridView is created. To customize columns or other functionality you can override the method CreateListView
private class MyListUi : ListObjectsUi {
// ...
protected override ListView CreateListView()
{
return new MyGridView();
}
private class MyGridView : ManageObjectsGridView {
public override IEnumerable<IGridViewColumn> GetColumns()
{
foreach( var baseCol in base.GetColumns() )
{
yield return baseCol;
}
yield return new DateTimeGridViewColumn<MySite.NewsItem>
{
HeaderText = "Date",
GetDate = n => n.Date
};
yield return new TextGridViewColumn<MySite.NewsItem> {
HeaderText = "Headline",
GetText = n => n.Headline
};
}
}
The standard way to tell lists in management UI's which items to display is to override the method GetListItems in MyListUi.
protected override IEnumerable<object> GetListItems()
{
return Object.GetAll<MySite.NewsItem>().OrderByDesc( o => o.Date );
}
Customizing the toolbar and functionality
By default buttons are created for New, Edit/Properties, Delete, Clipboard (Copy,Cut,Paste) and Refresh.
To remove one or more of the standard buttons you can override HasAddNew, HasEdit, HasDelete, HasClipboard or HasUpdate to return false.
To customize which types of objects that can be created from the New-button override the GetObjectTypesForAdd method
protected override IEnumerable<TypeInformation> GetObjectTypesForAdd()
{
yield return new TypeInformation( typeof( MySite.NewsItem ), true );
}
The UI will let the editor choose from all non-abstract types inheriting from NewsItem that they are allowed to create.