22 package com.realtime.crossfire.jxclient.items;
26 import java.util.Collection;
27 import java.util.HashSet;
28 import org.jetbrains.annotations.NotNull;
60 private final Object
sync =
new Object();
88 locationsListeners.
add(locationsListener);
96 locationsListeners.
remove(locationsListener);
104 locationListeners.
add(index, locationListener);
112 locationListeners.
remove(index, locationListener);
121 synchronized (
sync) {
122 for (
int i = firstIndex; i <= lastIndex; i++) {
123 modifiedSlots.add(i);
134 synchronized (
sync) {
135 modifiedSlots.add(index);
144 final Integer[] tmpModifiedSlots;
145 synchronized (
sync) {
146 tmpModifiedSlots = modifiedSlots.toArray(
new Integer[modifiedSlots.size()]);
147 modifiedSlots.clear();
149 if (tmpModifiedSlots.length > 0) {
151 locationsListener.locationsModified(tmpModifiedSlots);
153 for (
final int index : tmpModifiedSlots) {
155 locationListener.locationChanged();
final Collection< Integer > modifiedSlots
The pending modified floor slots to be reported to listeners.
void fireEvents()
Delivers outstanding change events.
final Runnable fireEventCallback
The event scheduler callback for delaying event generation.
Interface for listeners interested in changed items.
A list of event listeners.
void remove(final int index, @NotNull final T listener)
Removes a listener.
void removeLocationsListener(@NotNull final LocationsListener locationsListener)
Removes a LocationsListener to be notified when any displayed item has changed.the locations listener...
void start()
Activates this instance.
void deliverEvents()
Delivers all pending events.
void addModified(final int index)
Marks a slot as modified.
AbstractItemView()
Creates a new instance.
final IndexedEventListenerList< LocationListener > locationListeners
The registered ItemListeners to be notified about changes.
final Object sync
The synchronization object for accesses to modifiedSlots.
void removeLocationListener(final int index, @NotNull final LocationListener locationListener)
Removes a LocationListener to be notified when the item displayed in a floor slot has changed...
final EventListenerList2< LocationsListener > locationsListeners
The registered LocationsListeners to be notified about changes.
A scheduler for synchronous event notifications.
Interface for listeners interested in changed item locations.
void addModifiedRange(final int firstIndex, final int lastIndex)
Marks a range of slots as modified.
Iterable< T > getListeners(final int index)
Returns all the listeners by index.
void add(@NotNull final T listener)
Adds a listener.
void addLocationsListener(@NotNull final LocationsListener locationsListener)
Adds a LocationsListener to be notified when any displayed item has changed.the locations listener to...
void addLocationListener(final int index, @NotNull final LocationListener locationListener)
Adds a LocationListener to be notified when the item displayed in a floor slot has changed...
void add(final int index, @NotNull final T listener)
Adds a listener.
Abstract base class for ItemView implementing classes.
void trigger()
Notifies the callback.
void remove(@NotNull final T listener)
Removes a listener.
final EventScheduler fireEventScheduler
The EventScheduler for delaying event generation.