From: David ‘Bombe’ Roden Date: Thu, 22 May 2008 19:26:58 +0000 (+0000) Subject: remove request table X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=aa1515aa54583b8e46d90581df4ae7f247f6ccab;p=jSite2.git remove request table git-svn-id: http://trooper/svn/projects/jSite/trunk@929 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/jsite/gui/MainWindow.java b/src/net/pterodactylus/jsite/gui/MainWindow.java index 7eea5cf..cd6b210 100644 --- a/src/net/pterodactylus/jsite/gui/MainWindow.java +++ b/src/net/pterodactylus/jsite/gui/MainWindow.java @@ -40,9 +40,7 @@ import javax.swing.JFrame; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; -import javax.swing.JScrollPane; import javax.swing.JTabbedPane; -import javax.swing.JTable; import javax.swing.JToolBar; import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; @@ -117,9 +115,6 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop /** The project overview panel. */ private Box projectOverviewPanel; - /** The request table. */ - private JTable requestTable; - /** * Creates a new main window that redirects all actions to the given swing * interface. @@ -346,14 +341,9 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop private void initComponents() { super.getContentPane().add(statusBar, BorderLayout.PAGE_END); - /* - * the main window consists of two panels which are vertically oriented. - * the upper panel contains of a tabbed pane, the lower panel consists - * of a table that lists the running requests. - */ - + /* TODO - remove upper panel */ JPanel upperPanel = new JPanel(new BorderLayout(12, 12)); - getContentPane().add(upperPanel, BorderLayout.PAGE_START); + getContentPane().add(upperPanel, BorderLayout.CENTER); contentPane.setBorder(new EmptyBorder(12, 12, 12, 12)); projectPane = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT); @@ -369,9 +359,6 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop projectOverviewPanel.add(addProjectButton); projectOverviewPanel.add(Box.createVerticalGlue()); - requestTable = new JTable(swingInterface.getRequestTableModel()); - getContentPane().add(new JScrollPane(requestTable), BorderLayout.CENTER); - // JPanel lowerPanel = new JPanel(new BorderLayout(12, 12)); // getContentPane().add(lowerPanel, BorderLayout.CENTER); } diff --git a/src/net/pterodactylus/jsite/gui/RequestTableModel.java b/src/net/pterodactylus/jsite/gui/RequestTableModel.java deleted file mode 100644 index 1c37437..0000000 --- a/src/net/pterodactylus/jsite/gui/RequestTableModel.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * jSite2 - RequestTableModel.java - * Copyright © 2008 David Roden - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.gui; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.logging.Logger; - -import javax.swing.table.AbstractTableModel; - -import net.pterodactylus.jsite.core.Request; -import net.pterodactylus.jsite.core.Request.Type; -import net.pterodactylus.util.logging.Logging; - -/** - * The request table model is the table model backing the request table. It - * registers itself as a {@link PropertyChangeListener} with every - * {@link Request} that is added to it so that it can track progress of the - * requests on its own. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ - */ -public class RequestTableModel extends AbstractTableModel implements PropertyChangeListener { - - /** Logger. */ - private static final Logger logger = Logging.getLogger(RequestTableModel.class.getName()); - - /** The column names. */ - private static final String[] COLUMN_NAMES = new String[] { "ID", "Progress", "Type" }; - - /** The requests. */ - private final List requests = Collections.synchronizedList(new ArrayList()); - - // - // ACTIONS - // - - /** - * Adds a request to the model. - * - * @param request - * The request to add - */ - public void addRequest(Request request) { - requests.add(request); - request.addPropertyChangeListener(this); - fireTableRowsInserted(requests.size() - 1, requests.size() - 1); - } - - /** - * Removes a request from the model. - * - * @param request - * The request to remove - */ - public void removeRequest(Request request) { - int requestIndex = requests.indexOf(request); - request.removePropertyChangeListener(this); - if (requestIndex != -1) { - requests.remove(request); - fireTableRowsDeleted(requestIndex, requestIndex); - } - } - - // - // INTERFACE TableModel - // - - /** - * @see javax.swing.table.AbstractTableModel#getColumnName(int) - */ - @Override - public String getColumnName(int column) { - return COLUMN_NAMES[column]; - } - - /** - * @see javax.swing.table.TableModel#getColumnCount() - */ - public int getColumnCount() { - return COLUMN_NAMES.length; - } - - /** - * @see javax.swing.table.TableModel#getRowCount() - */ - public int getRowCount() { - return requests.size(); - } - - /** - * @see javax.swing.table.TableModel#getValueAt(int, int) - */ - public Object getValueAt(int rowIndex, int columnIndex) { - Request request = requests.get(rowIndex); - switch (columnIndex) { - case 0: - return request.getIdentifier(); - case 1: - if (request.getRequiredBlocks() == 0) { - return "unknown"; - } - return String.valueOf((request.getSuccessfulBlocks() * 10000 / request.getRequiredBlocks()) / 100.0) + "%"; - case 2: - return ((request.getType() != null) ? request.getType() : Type.unknown).name(); - } - return null; - } - - // - // INTERFACE PropertyChangeListener - // - - /** - * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent propertyChangeEvent) { - Object eventSource = propertyChangeEvent.getSource(); - if (eventSource instanceof Request) { - Request sourceRequest = (Request) eventSource; - int requestIndex = requests.indexOf(sourceRequest); - if (requestIndex == -1) { - logger.warning("got request without index: " + sourceRequest); - return; - } - String propertyName = propertyChangeEvent.getPropertyName(); - if (Request.PROPERTY_REQUIRED_BLOCKS.equals(propertyName)) { - fireTableCellUpdated(requestIndex, 1); - } else if (Request.PROPERTY_SUCCESSFUL_BLOCKS.equals(propertyName)) { - fireTableCellUpdated(requestIndex, 1); - } - } - } - -} diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index 10e6532..9d31479 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -146,9 +146,6 @@ public class SwingInterface implements CoreListener, LoggingListener { /** The list of all defined nodes. */ private List nodeList = Collections.synchronizedList(new ArrayList()); - /** The request table model. */ - private RequestTableModel requestTableModel = new RequestTableModel(); - // // CONFIGURATION // @@ -375,15 +372,6 @@ public class SwingInterface implements CoreListener, LoggingListener { return deleteProjectAction; } - /** - * Returns the request table model. - * - * @return The request table model - */ - RequestTableModel getRequestTableModel() { - return requestTableModel; - } - // // ACTIONS // @@ -995,21 +983,20 @@ public class SwingInterface implements CoreListener, LoggingListener { public void requestAdded(Request request) { logger.log(Level.INFO, "request added to node: " + request + ", " + request.getNode()); /* TODO - implement */ - requestTableModel.addRequest(request); } /** * {@inheritDoc} */ public void requestProgressed(Request request) { - /* TODO - update table model */ + /* TODO - implement */ } /** * @see net.pterodactylus.jsite.core.CoreListener#requestRemoved(net.pterodactylus.jsite.core.Request) */ public void requestRemoved(Request request) { - requestTableModel.removeRequest(request); + /* TODO - implement */ } //