From 96f983a87fcbfede5a1adf43d9f1f635ca4c9f61 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Thu, 23 Jul 2015 08:02:32 +0200 Subject: [PATCH] =?utf8?q?Added=20missing=20class=20Signed-off-by:Roland?= =?utf8?q?=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../mxchange/addressbook/model/BaseModel.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/org/mxchange/addressbook/model/BaseModel.java diff --git a/src/org/mxchange/addressbook/model/BaseModel.java b/src/org/mxchange/addressbook/model/BaseModel.java new file mode 100644 index 0000000..54aa507 --- /dev/null +++ b/src/org/mxchange/addressbook/model/BaseModel.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.addressbook.model; + +import java.text.MessageFormat; +import javax.swing.event.EventListenerList; +import javax.swing.event.TableModelListener; +import org.mxchange.addressbook.BaseFrameworkSystem; + +/** + * + * @author Roland Haeder + */ +public class BaseModel extends BaseFrameworkSystem { + /** List of listeners */ + private final EventListenerList listenerList; + + /** + * Protected constructor + */ + protected BaseModel () { + // Init listener list + this.listenerList = new EventListenerList(); + } + + /** + * Adds a TableModel listener instance to the event list. + * + * @param listener Lister instance + */ + public void addTableModelListener (final TableModelListener listener) { + // Debug message + this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); + + // Add listener + this.listenerList.add(TableModelListener.class, listener); + } + + /** + * Removes a TableModel listener instance from the event list. + * + * @param listener Listener instance + */ + public void removeTableModelListener (final TableModelListener listener) { + // Debug message + this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); + + // Remove listener + this.listenerList.remove(TableModelListener.class, listener); + } +} -- 2.39.5