From: Roland Haeder Date: Sat, 5 Sep 2015 10:21:40 +0000 (+0200) Subject: Introduced interface Model + ignored strings for internationalization X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9e2880a7be3fad3c85288d2dc721047dee8737ef;p=jcore-swing.git Introduced interface Model + ignored strings for internationalization Signed-off-by:Roland Haeder --- diff --git a/src/org/mxchange/jswingcore/model/BaseModel.java b/src/org/mxchange/jswingcore/model/BaseModel.java index 78b0e3e..18d6bf7 100644 --- a/src/org/mxchange/jswingcore/model/BaseModel.java +++ b/src/org/mxchange/jswingcore/model/BaseModel.java @@ -26,7 +26,7 @@ import org.mxchange.jcore.BaseFrameworkSystem; * * @author Roland Haeder */ -public class BaseModel extends BaseFrameworkSystem { +public class BaseModel extends BaseFrameworkSystem implements Model { /** * List of event listeners @@ -44,23 +44,19 @@ public class BaseModel extends BaseFrameworkSystem { this.eventListenerList = new EventListenerList(); } - /** - * Adds a lister of this type to the list - * - * @param listener Listener instance - */ + @Override public void addListDataListener (final ListDataListener listener) { // Trace message - this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N + this.getLogger().trace(MessageFormat.format("listener={0}", listener)); //NOI18N // Listener must not be null if (null == listener) { // Abort here - throw new NullPointerException("listener is null"); + throw new NullPointerException("listener is null"); //NOI18N } // Debug message - this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); + this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); //NOI18N // Remove listener this.eventListenerList.add(ListDataListener.class, listener); @@ -69,23 +65,19 @@ public class BaseModel extends BaseFrameworkSystem { this.getLogger().trace("EXIT!"); //NOI18N } - /** - * Adds a TableModel listener instance to the event list. - * - * @param listener Lister instance - */ + @Override public void addTableModelListener (final TableModelListener listener) { // Trace message - this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N + this.getLogger().trace(MessageFormat.format("listener={0}", listener)); //NOI18N // Listener must not be null if (null == listener) { // Abort here - throw new NullPointerException("listener is null"); + throw new NullPointerException("listener is null"); //NOI18N } // Debug message - this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); + this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); //NOI18N // Add listener this.eventListenerList.add(TableModelListener.class, listener); @@ -94,23 +86,19 @@ public class BaseModel extends BaseFrameworkSystem { this.getLogger().trace("EXIT!"); //NOI18N } - /** - * Removes given listener - * - * @param listener Listener instance - */ + @Override public void removeListDataListener (final ListDataListener listener) { // Trace message - this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N + this.getLogger().trace(MessageFormat.format("listener={0}", listener)); //NOI18N // Listener must not be null if (null == listener) { // Abort here - throw new NullPointerException("listener is null"); + throw new NullPointerException("listener is null"); //NOI18N } // Debug message - this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); + this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); //NOI18N // Remove listener this.eventListenerList.remove(ListDataListener.class, listener); @@ -119,23 +107,19 @@ public class BaseModel extends BaseFrameworkSystem { this.getLogger().trace("EXIT!"); //NOI18N } - /** - * Removes a TableModel listener instance from the event list. - * - * @param listener Listener instance - */ + @Override public void removeTableModelListener (final TableModelListener listener) { // Trace message - this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N + this.getLogger().trace(MessageFormat.format("listener={0}", listener)); //NOI18N // Listener must not be null if (null == listener) { // Abort here - throw new NullPointerException("listener is null"); + throw new NullPointerException("listener is null"); //NOI18N } // Debug message - this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); + this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); //NOI18N // Remove listener this.eventListenerList.remove(TableModelListener.class, listener); diff --git a/src/org/mxchange/jswingcore/model/Model.java b/src/org/mxchange/jswingcore/model/Model.java new file mode 100644 index 0000000..b044a3f --- /dev/null +++ b/src/org/mxchange/jswingcore/model/Model.java @@ -0,0 +1,57 @@ +/* + * 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.jswingcore.model; + +import javax.swing.event.ListDataListener; +import javax.swing.event.TableModelListener; +import org.mxchange.jcore.FrameworkInterface; + +/** + * A general interface for models + * + * @author Roland Haeder + */ +public interface Model extends FrameworkInterface { + + /** + * Adds a lister of this type to the list + * + * @param listener Listener instance + */ + public void addListDataListener (final ListDataListener listener); + + /** + * Adds a TableModel listener instance to the event list. + * + * @param listener Lister instance + */ + public void addTableModelListener (final TableModelListener listener); + + /** + * Removes given listener + * + * @param listener Listener instance + */ + public void removeListDataListener (final ListDataListener listener); + + /** + * Removes a TableModel listener instance from the event list. + * + * @param listener Listener instance + */ + public void removeTableModelListener (final TableModelListener listener); +} diff --git a/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java b/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java index 8e442f8..90b3ccc 100644 --- a/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java +++ b/src/org/mxchange/jswingcore/model/swing/contact/ContactTableModel.java @@ -23,13 +23,14 @@ import javax.swing.table.TableModel; import org.mxchange.jcore.client.Client; import org.mxchange.jcore.model.contact.Contact; import org.mxchange.jswingcore.model.BaseModel; +import org.mxchange.jswingcore.model.Model; /** * A table model for contacts * * @author Roland Haeder */ -public class ContactTableModel extends BaseModel implements TableModel { +public class ContactTableModel extends BaseModel implements Model, TableModel { /** * Constructor with Client instance which holds the contact manager