API Reference 0.7.1rikulo_modelAbstractListModel<T>

AbstractListModel<T> abstract class

A skeletal implementation of ListModel. It handles the data events (ListDataEvent) and the selection (SelectionModel).

abstract class AbstractListModel<T> extends AbstractDataModel<T>
implements ListModel<T> {
 /** Constructor.
  *
  * + [selection]: if not null, it will be used to hold the selection.
  * Unlike [set selection], it won't make a copy.
  * + [disables]: if not null, it will be used to hold the list of disabled items.
  * Unlike [set disables], it won't make a copy.
  */
 AbstractListModel({Set<T> selection, Set<T> disables, bool multiple:false}):
 super(selection: selection, disables: disables, multiple: multiple);
}

Extends

DataModel > AbstractDataModel<T> > AbstractListModel<T>

Subclasses

DefaultListModel<T>

Implements

ListModel<T>

Constructors

new AbstractListModel({Set<T> selection, Set<T> disables, bool multiple: false}) #

Constructor.

  • selection: if not null, it will be used to hold the selection. Unlike set selection, it won't make a copy.

  • disables: if not null, it will be used to hold the list of disabled items. Unlike set disables, it won't make a copy.

AbstractListModel({Set<T> selection, Set<T> disables, bool multiple:false}):
super(selection: selection, disables: disables, multiple: multiple);

Properties

Set<T> get disables #

inherited from AbstractDataModel

Returns the current list of disabled objects. It is readonly. Don't modify it directly. Otherwise, UI won't be updated correctly.

docs inherited from DisablesModel<T>
Set<T> get disables => _disables;

void set disables(Iterable<T> disables) #

inherited from AbstractDataModel

Replace the current list of disabled objects with the given set.

Notice this method copies the content of disables, so it is OK to use it after the invocation.

docs inherited from DisablesModel<T>
void set disables(Iterable<T> disables) {
 if (!_equals(_disables, disables)) {
   _disables.clear();
   _disables.addAll(disables);
   _sendDisable();
 }
}

final bool isDisablesEmpty #

inherited from AbstractDataModel

Returns true if the list of the disabled objects is currently empty.

docs inherited from DisablesModel<T>
bool get isDisablesEmpty => _disables.isEmpty;

final bool isSelectionEmpty #

inherited from AbstractDataModel

Returns true if the selection is currently empty.

docs inherited from SelectionModel<T>
@override
bool get isSelectionEmpty => _selection.isEmpty;

final int length #

inherited from ListModel

Returns the length of the list.

int get length;

bool get multiple #

inherited from AbstractDataModel

Returns whether the current selection mode is multiple.

docs inherited from SelectionModel<T>
@override
bool get multiple => _multiple;

void set multiple(bool multiple) #

inherited from AbstractDataModel

Sets the selection mode to be multiple.

docs inherited from SelectionModel<T>
@override
void set multiple(bool multiple) {
 if (_multiple != multiple) {
   _multiple = multiple;
   sendEvent(new DataEvent(this, 'multiple'));

   if (!multiple && _selection.length > 1) {
     final T v = _selection.first;
     _selection.clear();
     _selection.add(v);
     _sendSelect();
   }
 }
}

final DataEvents on #

inherited from DataModel

Returns DataEvents for adding or removing event listeners.

DataEvents get on => _on;

final T selectedValue #

inherited from AbstractDataModel

Returns the first selected value, or null if none is selected.

docs inherited from SelectionModel<T>
T get selectedValue => _selection.isEmpty ? null: _selection.first;

Set<T> get selection #

inherited from AbstractDataModel

Returns the current selection. It is readonly. Don't modify it directly. Otherwise, UI won't be updated correctly.

docs inherited from SelectionModel<T>
Set<T> get selection => _selection;

void set selection(Iterable<T> selection) #

inherited from AbstractDataModel

Replace the current selection with the given set.

Notice this method copies the content of selection, so it is OK to use it after the invocation.

docs inherited from SelectionModel<T>
void set selection(Iterable<T> selection) {
 if (!_equals(_selection, selection)) {
   if (!_multiple && selection.length > 1)
     throw new ModelError("Only one selection is allowed, $selection");
   _selection.clear();
   _selection.addAll(selection);
   _sendSelect();
 }
}

Operators

abstract T operator [](int index) #

inherited from ListModel

Returns the value at the specified index.

Methods

void addEventListener(String type, DataEventListener listener) #

inherited from DataModel

Adds an event listener. addEventListener("select", listener) is the same as on.select.add(listener).

void addEventListener(String type, DataEventListener listener) {
 if (listener == null)
   throw new ArgumentError("listener");

 bool first = false;
 _listeners.putIfAbsent(type, () {
   first = true;
   return [];
 }).add(listener);
}

bool addToDisables(T obj) #

inherited from AbstractDataModel

Add the specified object into the current list of disabled objects. It returns whether it has been added successfully. Returns false if it is already disabled.

docs inherited from DisablesModel<T>
bool addToDisables(T obj) {
 if (_disables.contains(obj))
   return false;

 _disables.add(obj);
 _sendDisable();
 return true;
}

bool addToSelection(T obj) #

inherited from AbstractDataModel

Add the specified object into selection. It returns whether it has been added successfully. Returns false if it is already selected.

docs inherited from SelectionModel<T>
@override
bool addToSelection(T obj) {
 if (_selection.contains(obj))
   return false;

 if (!_multiple)
   _selection.clear();
 _selection.add(obj);
 _sendSelect();
 return true;
}

void clearDisables() #

inherited from AbstractDataModel

Change the current list of disabled objects to the empty set.

docs inherited from DisablesModel<T>
void clearDisables() {
 if (!_disables.isEmpty) {
   _disables.clear();
   _sendDisable();
 }
}

void clearSelection() #

inherited from AbstractDataModel

Change the selection to the empty set.

docs inherited from SelectionModel<T>
@override
void clearSelection() {
 if (!_selection.isEmpty) {
   _selection.clear();
   _sendSelect();
 }
}

bool isDisabled(Object obj) #

inherited from AbstractDataModel

Returns whether an object is disabled.

docs inherited from DisablesModel<T>
bool isDisabled(Object obj)  => _disables.contains(obj);

bool isSelected(Object obj) #

inherited from AbstractDataModel

Returns whether an object is selected.

docs inherited from SelectionModel<T>
@override
bool isSelected(Object obj)  => _selection.contains(obj);

void removeAllDisables(Iterable c) #

inherited from AbstractDataModel

Removes the given collection from the list of disabled object.

void removeAllDisables(Iterable c) {
 final int oldlen = _disables.length;
 _disables.removeAll(c);
 if (oldlen != _disables.length)
   _sendDisable();
}

void removeAllSelection(Iterable c) #

inherited from AbstractDataModel

Removes the given collection from the selection.

void removeAllSelection(Iterable c) {
 final int oldlen = _selection.length;
 _selection.removeAll(c);
 if (oldlen != _selection.length)
   _sendSelect();
}

void removeEventListener(String type, DataEventListener listener) #

inherited from DataModel

Removes an event listener. removeEventListener("select", listener) is the same as on.select.remove(listener).

void removeEventListener(String type, DataEventListener listener) {
 final list = _listeners[type];
 if (list != null)
   list.remove(listener);
}

bool removeFromDisables(Object obj) #

inherited from AbstractDataModel

Remove the specified object from the current list of disabled objects. It returns whether it is removed successfully. Returns false if it is not disabled.

docs inherited from DisablesModel<T>
bool removeFromDisables(Object obj) {
 if (_disables.remove(obj)) {
   _sendDisable();
   return true;
 }
 return false;
}

bool removeFromSelection(Object obj) #

inherited from AbstractDataModel

Remove the specified object from selection. It returns whether it is removed successfully. Returns false if it is not selected.

docs inherited from SelectionModel<T>
@override
bool removeFromSelection(Object obj) {
 if (_selection.remove(obj)) {
   _sendSelect();
   return true;
 }
 return false;
}

bool sendEvent(DataEvent event) #

inherited from DataModel

Sends an event to this model.

Example: `model.sendEvent(new ListDataEvent(model, "select"))</code>.

bool sendEvent(DataEvent event) {
 final bool
   b1 = _sendEvent(event, _listeners[event.type]),
   b2 = _sendEvent(event, _listeners['all']);
 return b1 || b2;
}