--- jsampler/trunk/src/org/jsampler/DefaultSamplerModel.java 2007/12/06 19:25:36 1566 +++ jsampler/trunk/src/org/jsampler/DefaultSamplerModel.java 2007/12/06 19:37:41 1567 @@ -81,6 +81,8 @@ private final EventListenerList listenerList = new EventListenerList(); + private boolean modified = false; + /** Creates a new instance of DefaultSamplerModel */ public @@ -882,6 +884,18 @@ } /** + * Determines whether the sampler configuration is modified. + */ + public boolean + isModified() { return modified; } + + /** + * Sets whether the sampler configuration is modified. + */ + public void + setModified(boolean b) { modified = b; } + + /** * Notifies listeners that a sampler channel has been added. * This method can be invoked outside the event-dispatching thread. * @param channelModel A SamplerChannelModel instance. @@ -900,6 +914,7 @@ */ private void fireSamplerChannelAdded(SamplerChannelListEvent e) { + setModified(true); Object[] listeners = listenerList.getListenerList(); for(int i = listeners.length - 2; i >= 0; i -= 2) { @@ -929,6 +944,7 @@ */ private void fireSamplerChannelRemoved(SamplerChannelListEvent e) { + setModified(true); Object[] listeners = listenerList.getListenerList(); for(int i = listeners.length - 2; i >= 0; i -= 2) { @@ -957,6 +973,7 @@ */ private void fireMidiDeviceAdded(MidiDeviceListEvent e) { + setModified(true); Object[] listeners = listenerList.getListenerList(); for(int i = listeners.length - 2; i >= 0; i -= 2) { @@ -986,6 +1003,7 @@ */ private void fireMidiDeviceRemoved(MidiDeviceListEvent e) { + setModified(true); Object[] listeners = listenerList.getListenerList(); for(int i = listeners.length - 2; i >= 0; i -= 2) { @@ -1015,6 +1033,7 @@ */ private void fireAudioDeviceAdded(ListEvent e) { + setModified(true); Object[] listeners = listenerList.getListenerList(); for(int i = listeners.length - 2; i >= 0; i -= 2) { @@ -1040,6 +1059,22 @@ } /** + * Notifies listeners that an audio device has been removed. + * This method should be invoked from the event-dispatching thread. + */ + private void + fireAudioDeviceRemoved(ListEvent e) { + setModified(true); + Object[] listeners = listenerList.getListenerList(); + + for(int i = listeners.length - 2; i >= 0; i -= 2) { + if(listeners[i] == ListListener.class) { + ((ListListener)listeners[i + 1]).entryRemoved(e); + } + } + } + + /** * Notifies listeners that a MIDI instrument map has been added to the list. * This method can be invoked outside the event-dispatching thread. */ @@ -1056,6 +1091,7 @@ /** Notifies listeners that a MIDI instrument map has been added to the list. */ private void fireMidiInstrumentMapAdded(ListEvent e) { + setModified(true); for(ListListener l : mapsListeners) l.entryAdded(e); } @@ -1075,25 +1111,10 @@ /** Notifies listeners that a MIDI instrument map has been removed from the list. */ private void fireMidiInstrumentMapRemoved(ListEvent e) { + setModified(true); for(ListListener l : mapsListeners) l.entryRemoved(e); } - - /** - * Notifies listeners that an audio device has been removed. - * This method should be invoked from the event-dispatching thread. - */ - private void - fireAudioDeviceRemoved(ListEvent e) { - Object[] listeners = listenerList.getListenerList(); - - for(int i = listeners.length - 2; i >= 0; i -= 2) { - if(listeners[i] == ListListener.class) { - ((ListListener)listeners[i + 1]).entryRemoved(e); - } - } - } - /** * Notifies listeners that the global volume has changed. * This method can be invoked outside the event-dispatching thread. @@ -1113,6 +1134,7 @@ */ private void fireVolumeChanged(SamplerEvent e) { + setModified(true); for(SamplerListener l : listeners) l.volumeChanged(e); } @@ -1161,7 +1183,7 @@ } /** - * Notifies listeners that the global volume has changed. + * Notifies listeners that the default MIDI instrument map is changed. */ private void fireDefaultMapChanged() {