1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005, 2006 Grigor Kirilov Iliev |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
24 |
|
|
25 |
import java.util.Vector; |
import java.util.Vector; |
26 |
|
|
27 |
import org.jsampler.event.OrchestraListListener; |
import org.jsampler.event.ListEvent; |
28 |
import org.jsampler.event.OrchestraListEvent; |
import org.jsampler.event.ListListener; |
29 |
|
|
30 |
import org.w3c.dom.Document; |
import org.w3c.dom.Document; |
31 |
import org.w3c.dom.Element; |
import org.w3c.dom.Element; |
39 |
*/ |
*/ |
40 |
public class DefaultOrchestraListModel implements OrchestraListModel { |
public class DefaultOrchestraListModel implements OrchestraListModel { |
41 |
private final Vector<OrchestraModel> orchestras = new Vector<OrchestraModel>(); |
private final Vector<OrchestraModel> orchestras = new Vector<OrchestraModel>(); |
42 |
private final Vector<OrchestraListListener> listeners = new Vector<OrchestraListListener>(); |
private final Vector<ListListener<OrchestraModel>> listeners = |
43 |
|
new Vector<ListListener<OrchestraModel>>(); |
44 |
|
|
45 |
|
|
46 |
/** Creates a new instance of <code>DefaultOrchestraListModel</code>. */ |
/** Creates a new instance of <code>DefaultOrchestraListModel</code>. */ |
54 |
* @param l The <code>OrchestraListListener</code> to register. |
* @param l The <code>OrchestraListListener</code> to register. |
55 |
*/ |
*/ |
56 |
public void |
public void |
57 |
addOrchestraListListener(OrchestraListListener l) { listeners.add(l); } |
addOrchestraListListener(ListListener<OrchestraModel> l) { listeners.add(l); } |
58 |
|
|
59 |
/** |
/** |
60 |
* Removes the specified listener. |
* Removes the specified listener. |
61 |
* @param l The <code>OrchestraListListener</code> to remove. |
* @param l The <code>OrchestraListListener</code> to remove. |
62 |
*/ |
*/ |
63 |
public void |
public void |
64 |
removeOrchestraListListener(OrchestraListListener l) { listeners.remove(l); } |
removeOrchestraListListener(ListListener<OrchestraModel> l) { listeners.remove(l); } |
65 |
|
|
66 |
/** |
/** |
67 |
* Gets the current number of orchestras in the list. |
* Gets the current number of orchestras in the list. |
128 |
return b; |
return b; |
129 |
} |
} |
130 |
|
|
131 |
|
/** Removes all orchestras from the list. */ |
132 |
|
public void |
133 |
|
removeAllOrchestras() { |
134 |
|
for(int i = 0; i < getOrchestraCount(); i++) removeOrchestra(i); |
135 |
|
} |
136 |
|
|
137 |
/** |
/** |
138 |
* Gets the position of the specified orchestra in this orchestra list. |
* Gets the position of the specified orchestra in this orchestra list. |
139 |
* @param orchestra The orchestra whose index should be returned. |
* @param orchestra The orchestra whose index should be returned. |
272 |
/** Notifies listeners that an orchestra has been added to the list. */ |
/** Notifies listeners that an orchestra has been added to the list. */ |
273 |
private void |
private void |
274 |
fireOrchestraAdded(OrchestraModel orchestraModel) { |
fireOrchestraAdded(OrchestraModel orchestraModel) { |
275 |
OrchestraListEvent e = new OrchestraListEvent(this, orchestraModel); |
ListEvent<OrchestraModel> e = new ListEvent<OrchestraModel>(this, orchestraModel); |
276 |
for(OrchestraListListener l : listeners) l.orchestraAdded(e); |
for(ListListener<OrchestraModel> l : listeners) l.entryAdded(e); |
277 |
} |
} |
278 |
|
|
279 |
/** Notifies listeners that an orchestra has been removed from the list. */ |
/** Notifies listeners that an orchestra has been removed from the list. */ |
280 |
private void |
private void |
281 |
fireOrchestraRemoved(OrchestraModel orchestraModel) { |
fireOrchestraRemoved(OrchestraModel orchestraModel) { |
282 |
OrchestraListEvent e = new OrchestraListEvent(this, orchestraModel); |
ListEvent<OrchestraModel> e = new ListEvent<OrchestraModel>(this, orchestraModel); |
283 |
for(OrchestraListListener l : listeners) l.orchestraRemoved(e); |
for(ListListener<OrchestraModel> l : listeners) l.entryRemoved(e); |
284 |
} |
} |
285 |
} |
} |