nbrugger-tgm / reactj

A reactive ui lib for easy MVC
LaTeX Project Public License v1.3c
10 stars 0 forks source link

[Feature] List Support #3

Closed nbrugger-tgm closed 3 years ago

nbrugger-tgm commented 3 years ago

It should be easy to create nested components.

For example: A task-list has tasks in it
You create a TaskListView and bind it to the Array of Tasks, Then you create a TaskView which should be bound to an element of the List

nbrugger-tgm commented 3 years ago

Event driven idea

Creating a wrapper class that catches add and remove operation on a list and binds such events to the regarding UI equivalents

Code in mind Usage:

ReactiveList<Task> todoList = ReactiveList.create(new ArrayList<>());
TodoListView view = new TodoListView();
view.setData(todoList);

UI:

ReactiveListModel<Task> listModel = new ReactiveListModel();`
JList<Task> taskList = new JList(listModel.swing());

Binding:

listModel.bind(binder);

ReactiveList would be an interface extending Reactable and List

Non swing usage

GenericPanel panel = . . . ;
ReactiveListModel<Task> listModel = new ReactiveListModel(panel::addEntry,panel::removeEntry);
nbrugger-tgm commented 3 years ago

Rework

I am myself not satisfied with the way list support was done. Working on a redesign at the branch list-rework.

Drop your ideas what to change and how to make the system better

nbrugger-tgm commented 3 years ago

Dedicated Components

Creating lists is now even easier!

Extending from the ReactiveListView class gives you a simple way for list support by just implementing the methods addElementAt createElement and removeElement!

nbrugger-tgm commented 3 years ago

Examples

The branch list-rework contains working list examples as of the 685ba94afa7b7c8f6864f681cbbbfbac50b97541 commit

nbrugger-tgm commented 3 years ago

Support Expansion

Branch list-rework now contains support for "basic lists" (for example with just strings in it) fd2c3f36e0f76bab8c15d879620f7562f037ec6b

Example

Found in src\test\java\com\niton\reactj\examples\simplelist\StringListApp.java


ReactiveList<String> someArray = ReactiveList.create(new ArrayList<>());

JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setLayout(new GridLayout());

SwingListView view = new SwingListView<>(JLabel::new); view.setList(someArray);

frame.add(view.getView()); frame.pack(); frame.setVisible(true);

someArray.add("Can you see me?");


This is *fully runnable* :)
nbrugger-tgm commented 3 years ago

Pre release

2.2.2 is now available as pre-release

nbrugger-tgm commented 3 years ago

Release

27 (v3.0.0) contains the release of the rework

nbrugger-tgm commented 3 years ago

Reopen

Due to #37 parts of the list system will be rewritten. It might just be a technical change but maybe it affects usage too

nbrugger-tgm commented 3 years ago

Update

The changes to the list system are sever, therefore usage will be affected.

After the next release the list system should perform better, be way more flexible and userfriendly

nbrugger-tgm commented 3 years ago

Done

List support is implemented as of v4.0.0b7. There are no MVC components implemented yet, but hence they do not belong to list support this feature is completed.

List MVC components will be part of the core-mvc rework