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;
/** 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.
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);
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);
}
+++ /dev/null
-/*
- * 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<Request> requests = Collections.synchronizedList(new ArrayList<Request>());
-
- //
- // 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);
- }
- }
- }
-
-}
/** The list of all defined nodes. */
private List<Node> nodeList = Collections.synchronizedList(new ArrayList<Node>());
- /** The request table model. */
- private RequestTableModel requestTableModel = new RequestTableModel();
-
//
// CONFIGURATION
//
return deleteProjectAction;
}
- /**
- * Returns the request table model.
- *
- * @return The request table model
- */
- RequestTableModel getRequestTableModel() {
- return requestTableModel;
- }
-
//
// ACTIONS
//
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 */
}
//