]> git.mxchange.org Git - addressbook-swing.git/blob - Addressbook/src/org/mxchange/addressbook/model/BaseModel.java
cc74cad8267c4203d6e8c28363f8604022b83516
[addressbook-swing.git] / Addressbook / src / org / mxchange / addressbook / model / BaseModel.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.addressbook.model;
18
19 import java.text.MessageFormat;
20 import javax.swing.event.EventListenerList;
21 import javax.swing.event.TableModelListener;
22 import org.mxchange.addressbook.BaseFrameworkSystem;
23
24 /**
25  *
26  * @author Roland Haeder
27  */
28 public class BaseModel extends BaseFrameworkSystem {
29
30         /**
31          * List of listeners
32          */
33         private final EventListenerList listenerList;
34
35         /**
36          * Protected constructor
37          */
38         protected BaseModel () {
39                 // Init listener list
40                 this.listenerList = new EventListenerList();
41         }
42
43         /**
44          * Adds a TableModel listener instance to the event list.
45          *
46          * @param listener Lister instance
47          */
48         public void addTableModelListener (final TableModelListener listener) {
49                 // Debug message
50                 this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass()));
51
52                 // Add listener
53                 this.listenerList.add(TableModelListener.class, listener);
54         }
55
56         /**
57          * Removes a TableModel listener instance from the event list.
58          *
59          * @param listener Listener instance
60          */
61         public void removeTableModelListener (final TableModelListener listener) {
62                 // Debug message
63                 this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass()));
64
65                 // Remove listener
66                 this.listenerList.remove(TableModelListener.class, listener);
67         }
68 }