2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.model;
19 import java.text.MessageFormat;
20 import javax.swing.event.EventListenerList;
21 import javax.swing.event.ListDataListener;
22 import javax.swing.event.TableModelListener;
23 import org.mxchange.addressbook.BaseFrameworkSystem;
27 * @author Roland Haeder
29 public class BaseModel extends BaseFrameworkSystem {
32 * List of event listeners
34 private final EventListenerList eventListenerList;
37 * Protected constructor
39 protected BaseModel () {
41 this.getLogger().trace("CALLED!"); //NOI18N
44 this.eventListenerList = new EventListenerList();
48 * Adds a lister of this type to the list
50 * @param listener Listener instance
52 public void addListDataListener (final ListDataListener listener) {
54 this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
56 // Listener must not be null
57 if (listener == null) {
59 throw new NullPointerException("listener is null");
63 this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass()));
66 this.eventListenerList.add(ListDataListener.class, listener);
69 this.getLogger().trace("EXIT!"); //NOI18N
73 * Adds a TableModel listener instance to the event list.
75 * @param listener Lister instance
77 public void addTableModelListener (final TableModelListener listener) {
79 this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
81 // Listener must not be null
82 if (listener == null) {
84 throw new NullPointerException("listener is null");
88 this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass()));
91 this.eventListenerList.add(TableModelListener.class, listener);
94 this.getLogger().trace("EXIT!"); //NOI18N
98 * Removes given listener
100 * @param listener Listener instance
102 public void removeListDataListener (final ListDataListener listener) {
104 this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
106 // Listener must not be null
107 if (listener == null) {
109 throw new NullPointerException("listener is null");
113 this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass()));
116 this.eventListenerList.remove(ListDataListener.class, listener);
119 this.getLogger().trace("EXIT!"); //NOI18N
123 * Removes a TableModel listener instance from the event list.
125 * @param listener Listener instance
127 public void removeTableModelListener (final TableModelListener listener) {
129 this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N
131 // Listener must not be null
132 if (listener == null) {
134 throw new NullPointerException("listener is null");
138 this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass()));
141 this.eventListenerList.remove(TableModelListener.class, listener);
144 this.getLogger().trace("EXIT!"); //NOI18N