From aceb2c77c6d89ba4be84e925b5c9c869df9e7391 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 2 Sep 2015 14:31:47 +0200 Subject: [PATCH] =?utf8?q?Moved=20Swing=20stuff=20to=20jswingcore=20Signed?= =?utf8?q?-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../jcore/client/gui/ClientFrame.java | 79 ---------- .../application/ApplicationManager.java | 2 +- src/org/mxchange/jcore/model/BaseModel.java | 146 ------------------ .../swing/contact/ContactTableModel.java | 123 --------------- 4 files changed, 1 insertion(+), 349 deletions(-) delete mode 100644 src/org/mxchange/jcore/client/gui/ClientFrame.java delete mode 100644 src/org/mxchange/jcore/model/BaseModel.java delete mode 100644 src/org/mxchange/jcore/model/swing/contact/ContactTableModel.java diff --git a/src/org/mxchange/jcore/client/gui/ClientFrame.java b/src/org/mxchange/jcore/client/gui/ClientFrame.java deleted file mode 100644 index 8674d68..0000000 --- a/src/org/mxchange/jcore/client/gui/ClientFrame.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.jcore.client.gui; - -import java.io.IOException; -import org.mxchange.jcore.FrameworkInterface; -import org.mxchange.jcore.client.Client; -import org.mxchange.jcore.contact.Contact; -import org.mxchange.jcore.exceptions.BadTokenException; -import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException; - -/** - * An interface for applications with a frame - * - * @author Roland Haeder - */ -public interface ClientFrame extends FrameworkInterface { - - /** - * Shows the user the "add contact" form with some special text - * - * @return Contact instance - */ - public Contact doEnterOwnData (); - - /** - * Shutdown this frame - */ - public void doShutdown (); - - /** - * Enables main window (frame) - */ - public void enableMainWindow (); - - /** - * Setups the frame (and starts it). You have to call init() before you can - * call this method. - * - * @param client Client instance - * @throws java.io.IOException If an IO error was found - * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found - */ - public void setupFrame (final Client client) throws IOException, BadTokenException; - - /** - * Initializes frame - * - * @throws org.mxchange.jcore.exceptions.FrameAlreadyInitializedException If this method has been called twice - */ - public void init () throws FrameAlreadyInitializedException; - - /** - * Returns field isInitialized. This flag indicates whether this frame has - * been initialized or not. - * - * @return Field isInitialized - */ - public boolean isInitialized (); - - /** - * Shuts down application - */ - public void shutdownApplication (); -} diff --git a/src/org/mxchange/jcore/manager/application/ApplicationManager.java b/src/org/mxchange/jcore/manager/application/ApplicationManager.java index 37baa43..11c5ea6 100644 --- a/src/org/mxchange/jcore/manager/application/ApplicationManager.java +++ b/src/org/mxchange/jcore/manager/application/ApplicationManager.java @@ -30,7 +30,7 @@ public class ApplicationManager extends BaseManager implements ManageableApplica * Getter for application manager * * @param application An instance of a Application class - * @return + * @return Get a managable application */ public static final ManageableApplication getManager (final Application application) { // Application instance must be set diff --git a/src/org/mxchange/jcore/model/BaseModel.java b/src/org/mxchange/jcore/model/BaseModel.java deleted file mode 100644 index 5caaba8..0000000 --- a/src/org/mxchange/jcore/model/BaseModel.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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.jcore.model; - -import java.text.MessageFormat; -import javax.swing.event.EventListenerList; -import javax.swing.event.ListDataListener; -import javax.swing.event.TableModelListener; -import org.mxchange.jcore.BaseFrameworkSystem; - -/** - * - * @author Roland Haeder - */ -public class BaseModel extends BaseFrameworkSystem { - - /** - * List of event listeners - */ - private final EventListenerList eventListenerList; - - /** - * Protected constructor - */ - protected BaseModel () { - // Trace message - this.getLogger().trace("CALLED!"); //NOI18N - - // Init listener list - this.eventListenerList = new EventListenerList(); - } - - /** - * Adds a lister of this type to the list - * - * @param listener Listener instance - */ - public void addListDataListener (final ListDataListener listener) { - // Trace message - this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N - - // Listener must not be null - if (null == listener) { - // Abort here - throw new NullPointerException("listener is null"); - } - - // Debug message - this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); - - // Remove listener - this.eventListenerList.add(ListDataListener.class, listener); - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } - - /** - * Adds a TableModel listener instance to the event list. - * - * @param listener Lister instance - */ - public void addTableModelListener (final TableModelListener listener) { - // Trace message - this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N - - // Listener must not be null - if (null == listener) { - // Abort here - throw new NullPointerException("listener is null"); - } - - // Debug message - this.getLogger().debug(MessageFormat.format("Adding listener {0} ...", listener.getClass())); - - // Add listener - this.eventListenerList.add(TableModelListener.class, listener); - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } - - /** - * Removes given listener - * - * @param listener Listener instance - */ - public void removeListDataListener (final ListDataListener listener) { - // Trace message - this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N - - // Listener must not be null - if (null == listener) { - // Abort here - throw new NullPointerException("listener is null"); - } - - // Debug message - this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); - - // Remove listener - this.eventListenerList.remove(ListDataListener.class, listener); - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } - - /** - * Removes a TableModel listener instance from the event list. - * - * @param listener Listener instance - */ - public void removeTableModelListener (final TableModelListener listener) { - // Trace message - this.getLogger().trace("listener=" + listener + " - CALLED!"); //NOI18N - - // Listener must not be null - if (null == listener) { - // Abort here - throw new NullPointerException("listener is null"); - } - - // Debug message - this.getLogger().debug(MessageFormat.format("Removing listener {0} ...", listener.getClass())); - - // Remove listener - this.eventListenerList.remove(TableModelListener.class, listener); - - // Trace message - this.getLogger().trace("EXIT!"); //NOI18N - } -} diff --git a/src/org/mxchange/jcore/model/swing/contact/ContactTableModel.java b/src/org/mxchange/jcore/model/swing/contact/ContactTableModel.java deleted file mode 100644 index 67061c4..0000000 --- a/src/org/mxchange/jcore/model/swing/contact/ContactTableModel.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.jcore.model.swing.contact; - -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; -import javax.swing.table.TableModel; -import org.mxchange.jcore.client.Client; -import org.mxchange.jcore.manager.database.ManageableDatabase; -import org.mxchange.jcore.model.BaseModel; - -/** - * A table model for contacts - * - * @author Roland Haeder - */ -public class ContactTableModel extends BaseModel implements TableModel { - - /** - * Constructor with Client instance which holds the contact manager - * - * @param client Client instance - */ - public ContactTableModel (final Client client) { - // Trace message - this.getLogger().trace(MessageFormat.format("client={1} - CALLED!", client)); //NOI18N - - // Client must not be null - if (null == client) { - // Abort here - throw new NullPointerException("client is null"); //NOI18N - } - - // Set client - this.setClient(client); - } - - @Override - public Class getColumnClass (final int columnIndex) { - // All is the same - return Object.class; - } - - @Override - public int getColumnCount () { - // Get manager - ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); - - // Deligate this call to contact manager - return manager.getColumnCount(); - } - - @Override - public String getColumnName (final int columnIndex) { - // Get manager - ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); - - // Deligate this call to contact manager - return manager.getTranslatedColumnName(columnIndex); - } - - @Override - public int getRowCount () { - // Get manager - ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); - - try { - // Deligate this call to contact manager - return manager.size(); - } catch (final IOException ex) { - // Log warning - this.logException(ex); - - // Return zero - return 0; - } - } - - @Override - public Object getValueAt (final int rowIndex, final int columnIndex) { - // Get manager - ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager(); - - // Init value - Object value = null; - - try { - // Deligate this call to contact manager - value = manager.getValueFromRowColumn(rowIndex, columnIndex); - } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { - // Abort here - this.abortProgramWithException(ex); - } - - // Return it - return value; - } - - @Override - public boolean isCellEditable (final int rowIndex, final int columnIndex) { - throw new UnsupportedOperationException("Not supported yet. rowIndex=" + rowIndex + ",columnIndex=" + columnIndex); //To change body of generated methods, choose Tools | Templates. - } - - @Override - public void setValueAt (final Object value, final int rowIndex, final int columnIndex) { - throw new UnsupportedOperationException("Not supported yet. value=" + value + ",rowIndex=" + rowIndex + ",columnIndex=" + columnIndex); //To change body of generated methods, choose Tools | Templates. - } -} -- 2.39.5