From: Roland Haeder Date: Thu, 23 Jul 2015 06:02:32 +0000 (+0200) Subject: Added missing class X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=96f983a87fcbfede5a1adf43d9f1f635ca4c9f61;p=jaddressbook-share-lib.git Added missing class Signed-off-by:Roland Häder --- 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); + } +}