]> git.mxchange.org Git - addressbook-lib.git/blob - Addressbook/src/org/mxchange/addressbook/model/BaseModel.java
54aa507680fd589db76fd277698339a3056984ea
[addressbook-lib.git] / Addressbook / src / org / mxchange / addressbook / model / BaseModel.java
1 /*\r
2  * Copyright (C) 2015 Roland Haeder\r
3  *\r
4  * This program is free software: you can redistribute it and/or modify\r
5  * it under the terms of the GNU General Public License as published by\r
6  * the Free Software Foundation, either version 3 of the License, or\r
7  * (at your option) any later version.\r
8  *\r
9  * This program is distributed in the hope that it will be useful,\r
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  * GNU General Public License for more details.\r
13  *\r
14  * You should have received a copy of the GNU General Public License\r
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
16  */\r
17 package org.mxchange.addressbook.model;\r
18 \r
19 import java.text.MessageFormat;\r
20 import javax.swing.event.EventListenerList;\r
21 import javax.swing.event.TableModelListener;\r
22 import org.mxchange.addressbook.BaseFrameworkSystem;\r
23 \r
24 /**\r
25  *\r
26  * @author Roland Haeder\r
27  */\r
28 public class BaseModel extends BaseFrameworkSystem {\r
29     /** List of listeners */\r
30     private final EventListenerList listenerList;\r
31 \r
32     /**\r
33      * Protected constructor\r
34      */\r
35     protected BaseModel () {\r
36         // Init listener list\r
37         this.listenerList = new EventListenerList();\r
38     }\r
39 \r
40     /**\r
41      * Adds a TableModel listener instance to the event list.\r
42      * \r
43      * @param listener Lister instance\r
44      */\r
45     public void addTableModelListener (final TableModelListener listener) {\r
46         // Debug message\r
47         this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass()));\r
48 \r
49         // Add listener\r
50         this.listenerList.add(TableModelListener.class, listener);\r
51     }\r
52 \r
53     /**\r
54      * Removes a TableModel listener instance from the event list.\r
55      * \r
56      * @param listener Listener instance\r
57      */\r
58     public void removeTableModelListener (final TableModelListener listener) {\r
59         // Debug message\r
60         this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass()));\r
61 \r
62         // Remove listener\r
63         this.listenerList.remove(TableModelListener.class, listener);\r
64     }\r
65 }\r