Author: jflesch
Date: 2006-12-30 18:53:01 +0000 (Sat, 30 Dec 2006)
New Revision: 11531
Modified:
trunk/apps/Thaw/src/thaw/core/IconBox.java
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
Log:
Add a 'remove selected transfers' button to the toolbar when the user is on the
'state' tab
Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-12-29 22:15:37 UTC (rev
11530)
+++ trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-12-30 18:53:01 UTC (rev
11531)
@@ -45,7 +45,7 @@
public static ImageIcon indexNew;
public static ImageIcon indexReuse;
- public static ImageIcon indexDelete;
+ public static ImageIcon delete;
public static ImageIcon error;
public static ImageIcon ok;
@@ -135,7 +135,7 @@
IconBox.minQuitAction =
IconBox.loadIcon("min-system-log-out.png");
IconBox.search = IconBox.loadIcon("system-search.png");
IconBox.key = IconBox.loadIcon("key.png");
- IconBox.indexDelete = IconBox.loadIcon("x_red.png");
+ IconBox.delete = IconBox.loadIcon("x_red.png");
IconBox.error = IconBox.loadIcon("min-x_red.png");
IconBox.ok = IconBox.loadIcon("min-v_green.png");
}
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-12-29 22:15:37 UTC
(rev 11530)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-12-30 18:53:01 UTC
(rev 11531)
@@ -53,7 +53,7 @@
thaw.common.priority=Priority
thaw.common.clearFinished=Remove finished transfers
-thaw.common.removeFromTheList=Cancel selected transfers
+thaw.common.removeFromTheList=Cancel and remove selected transfers
thaw.common.cancel=Cancel
thaw.common.delay=Delay
thaw.common.copyKeysToClipboard=Copy keys to clipboard
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2006-12-29 22:15:37 UTC
(rev 11530)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2006-12-30 18:53:01 UTC
(rev 11531)
@@ -50,7 +50,7 @@
thaw.common.priority=Priorit?
thaw.common.clearFinished=Enlever les transferts finis
-thaw.common.removeFromTheList=Annuler les transferts s?lectionn?s
+thaw.common.removeFromTheList=Annuler et enlever les transferts s?lectionn?s
thaw.common.cancel=Annuler
thaw.common.delay=D?lai
thaw.common.copyKeysToClipboard=Copier les cl?s vers le presse papiers
Modified: trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-12-29 22:15:37 UTC
(rev 11530)
+++ trunk/apps/Thaw/src/thaw/plugins/FetchPlugin.java 2006-12-30 18:53:01 UTC
(rev 11531)
@@ -67,7 +67,7 @@
queueWatcher =
(QueueWatcher)core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher");
- queueWatcher.addButtonToTheToolbar(buttonInToolBar);
+ queueWatcher.addButtonToTheToolbar(buttonInToolBar, 0);
queueWatcher.addMenuItemToTheDownloadTable(menuItem);
queueWatcher.addButtonListener(QueueWatcher.DOWNLOAD_PANEL,
this);
Modified: trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-12-29 22:15:37 UTC
(rev 11530)
+++ trunk/apps/Thaw/src/thaw/plugins/InsertPlugin.java 2006-12-30 18:53:01 UTC
(rev 11531)
@@ -78,7 +78,7 @@
queueWatcher =
(QueueWatcher)core.getPluginManager().getPlugin("thaw.plugins.QueueWatcher");
- queueWatcher.addButtonToTheToolbar(buttonInToolBar);
+ queueWatcher.addButtonToTheToolbar(buttonInToolBar, 1);
queueWatcher.addMenuItemToTheInsertionTable(menuItem);
queueWatcher.addButtonListener(QueueWatcher.INSERTION_PANEL,
this);
Modified: trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-12-29 22:15:37 UTC
(rev 11530)
+++ trunk/apps/Thaw/src/thaw/plugins/QueueWatcher.java 2006-12-30 18:53:01 UTC
(rev 11531)
@@ -1,6 +1,7 @@
package thaw.plugins;
import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Iterator;
@@ -9,6 +10,7 @@
import javax.swing.JSplitPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import javax.swing.JButton;
import thaw.core.Core;
import thaw.core.I18n;
@@ -20,7 +22,7 @@
import thaw.plugins.queueWatcher.DragAndDropManager;
import thaw.plugins.queueWatcher.QueuePanel;
-public class QueueWatcher extends ToolbarModifier implements thaw.core.Plugin,
PropertyChangeListener, ChangeListener {
+public class QueueWatcher extends ToolbarModifier implements thaw.core.Plugin,
PropertyChangeListener, ChangeListener, ActionListener {
private Core core;
//private JPanel mainPanel;
@@ -43,6 +45,9 @@
private java.awt.Container panelAdded;
+ private JButton removeSelectedButton;
+
+
public boolean run(final Core core) {
this.core = core;
@@ -50,8 +55,8 @@
detailPanel = new DetailPanel();
- queuePanels[QueueWatcher.DOWNLOAD_PANEL] = new QueuePanel(core,
detailPanel, false); /* download */
- queuePanels[QueueWatcher.INSERTION_PANEL] = new
QueuePanel(core, detailPanel, true); /* upload */
+ queuePanels[QueueWatcher.DOWNLOAD_PANEL] = new QueuePanel(core,
this, detailPanel, false); /* download */
+ queuePanels[QueueWatcher.INSERTION_PANEL] = new
QueuePanel(core, this, detailPanel, true); /* upload */
split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
queuePanels[0].getPanel(),
@@ -109,10 +114,16 @@
stateChanged(null);
+ removeSelectedButton = new JButton(IconBox.delete);
+
removeSelectedButton.setToolTipText(I18n.getMessage("thaw.common.removeFromTheList"));
+ removeSelectedButton.addActionListener(this);
+ addButtonToTheToolbar(removeSelectedButton);
+
return true;
}
/**
+ * See the button 'download' and 'insertion' on each panel
* @param panel see DOWNLOAD_PANEL and INSERTION_PANEL
*/
public void addButtonListener(final int panel, final ActionListener
listener) {
@@ -149,6 +160,13 @@
queuePanels[1].addMenuItem(item);
}
+ public void unselectAllExcept(int panel_exception) {
+ if (panel_exception == DOWNLOAD_PANEL)
+ queuePanels[INSERTION_PANEL].unselectAll();
+ else
+ queuePanels[DOWNLOAD_PANEL].unselectAll();
+ }
+
public String getNameForUser() {
return I18n.getMessage("thaw.common.status");
}
@@ -219,4 +237,11 @@
hideButtonsInTheToolbar();
}
}
+
+ public void actionPerformed(ActionEvent event) {
+ if (event.getSource() == removeSelectedButton) {
+ queuePanels[INSERTION_PANEL].removeSelectedTransfers();
+ queuePanels[DOWNLOAD_PANEL].removeSelectedTransfers();
+ }
+ }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-12-29
22:15:37 UTC (rev 11530)
+++ trunk/apps/Thaw/src/thaw/plugins/ToolbarModifier.java 2006-12-30
18:53:01 UTC (rev 11531)
@@ -33,8 +33,21 @@
}
public void addButtonToTheToolbar(final JButton button) {
- buttons.add(button);
+ addButtonToTheToolbar(button, -1);
+ }
+ /**
+ * @param position if == -1, then the button is put at the end
+ */
+ public void addButtonToTheToolbar(final JButton button, int position) {
+ if (position < 0)
+ buttons.add(button);
+ else {
+ if (position > buttons.size())
+ buttons.setSize(position);
+ buttons.add(position, button);
+ }
+
if (areDisplayed) {
areDisplayed = false;
displayButtonsInTheToolbar();
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-29
22:15:37 UTC (rev 11530)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-30
18:53:01 UTC (rev 11531)
@@ -279,7 +279,7 @@
toolbarModifier.addButtonToTheToolbar(button);
toolbarActions.add(action);
- button = new JButton(IconBox.indexDelete);
+ button = new JButton(IconBox.delete);
button.setToolTipText(I18n.getMessage("thaw.plugin.index.delete"));
action = new IndexManagementHelper.IndexDeleter(indexBrowser,
button);
action.setTarget(getRoot());
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-12-29 22:15:37 UTC (rev 11530)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-12-30 18:53:01 UTC (rev 11531)
@@ -41,8 +41,19 @@
import thaw.core.Logger;
import thaw.fcp.FCPTransferQuery;
import thaw.fcp.FCPClientGet;
+import thaw.plugins.QueueWatcher;
+
public class QueuePanel implements MouseListener, ActionListener, KeyListener {
+ public final static int ACTION_REMOVE_FINISHED = 0;
+ public final static int ACTION_DOWNLOAD_SELECTED = 1; /* locally
*/
+ public final static int ACTION_REMOVE_SELECTED = 2;
+ public final static int ACTION_CANCEL_SELECTED = 3;
+ public final static int ACTION_DELAY_SELECTED = 4;
+ public final static int ACTION_RESTART_SELECTED = 5;
+ public final static int ACTION_COPY_KEYS_SELECTED = 6;
+ public final static int ACTION_CHANGE_PRIORITY_SELECTED = 7;
+
private Core core;
private JButton button;
@@ -74,9 +85,14 @@
private boolean insertionQueue = false;
- public QueuePanel(final Core core, final DetailPanel detailPanel,
+ public QueueWatcher queueWatcher;
+
+ public QueuePanel(final Core core, final QueueWatcher queueWatcher,
+ final DetailPanel detailPanel,
boolean isForInsertionQueue) {
+ this.queueWatcher = queueWatcher;
+
insertionQueue = isForInsertionQueue;
this.core = core;
@@ -370,26 +386,52 @@
}
- private class ActionReplier implements Runnable, ClipboardOwner {
- ActionEvent e;
- Vector queries;
+ public void unselectAll() {
+ table.clearSelection();
+ selectedRows = null;
+ }
- public ActionReplier(final ActionEvent e, final Vector queries)
{
- this.e = e;
- this.queries = queries;
+ public void removeSelected() {
+
+ }
+
+
+ public class ActionReplier implements Runnable, ClipboardOwner {
+ private int action;
+ private int new_priority;
+ private Vector queries;
+
+ public ActionReplier(final int action, final int new_priority) {
+ this.action = action;
+ this.queries = getSelectedQueries();
+
+ this.new_priority = (action ==
ACTION_CHANGE_PRIORITY_SELECTED) ? new_priority : -1;
}
public void run() {
+
final Toolkit tk = Toolkit.getDefaultToolkit();
String keys = "";
File dir = null;
- if(e.getSource() == clearFinishedItem) {
- removeAllFinishedTransfers();
+ if(action == ACTION_REMOVE_FINISHED) {
+ final Vector qs = tableModel.getQueries();
+
+ for(final Iterator it = qs.iterator();
+ it.hasNext(); ) {
+ final FCPTransferQuery query =
(FCPTransferQuery)it.next();
+ if(query.isFinished() &&
+ (!(query instanceof FCPClientGet) ||
(!query.isSuccessful() || ((FCPClientGet)query).isWritingSuccessful()))) {
+
if(query.stop(core.getQueueManager())) {
+
core.getQueueManager().remove(query);
+ }
+ }
+ }
+
return;
}
- if(e.getSource() == downloadItem) {
+ if(action == ACTION_DOWNLOAD_SELECTED) {
final FileChooser fileChooser = new
FileChooser();
fileChooser.setTitle(I18n.getMessage("thaw.common.downloadLocally"));
fileChooser.setDirectoryOnly(true);
@@ -400,51 +442,38 @@
return;
}
- int prioritySelected = 0;
-
- for(prioritySelected = 0;
- prioritySelected <= MIN_PRIORITY;
- prioritySelected++) {
- if(priorityRadioButton[prioritySelected] ==
e.getSource()) {
- break;
- }
- }
-
- if(prioritySelected > MIN_PRIORITY)
- prioritySelected = -1;
-
for(final Iterator queryIt = queries.iterator() ;
queryIt.hasNext() ;) {
final FCPTransferQuery query =
(FCPTransferQuery)queryIt.next();
if(query == null)
continue;
- if(prioritySelected >= 0) {
+ if(new_priority >= 0) {
if(query.isPersistent()) {
-
query.setFCPPriority(prioritySelected);
+
query.setFCPPriority(new_priority);
query.updatePersistentRequest(false);
}
}
- if(e.getSource() == removeItem) {
+ if(action == ACTION_REMOVE_SELECTED) {
if(query.stop(core.getQueueManager())) {
core.getQueueManager().remove(query);
}
}
- if(e.getSource() == cancelItem) {
+ if(action == ACTION_CANCEL_SELECTED) {
query.stop(core.getQueueManager());
}
- if(e.getSource() == delayItem) {
+ if(action == ACTION_DELAY_SELECTED) {
if(query.isRunning() &&
!query.isFinished()) {
query.pause(core.getQueueManager());
core.getQueueManager().moveFromRunningToPendingQueue(query);
}
}
- if(e.getSource() == forceRestartItem) {
+ if(action == ACTION_RESTART_SELECTED) {
query.stop(core.getQueueManager());
if(query.getMaxAttempt() >= 0)
@@ -453,13 +482,13 @@
query.start(core.getQueueManager());
}
- if(e.getSource() == copyKeysItem) {
+ if (action == ACTION_COPY_KEYS_SELECTED) {
if((query.getFileKey() != null)
&& !"".equals( query.getFileKey() ))
keys = keys +
query.getFileKey() + "\n";
}
- if((e.getSource() == downloadItem)
+ if (action == ACTION_DOWNLOAD_SELECTED
&& (dir != null)) {
if(query.isPersistent()) {
@@ -472,7 +501,7 @@
} /* for i in selectedRows */
- if(e.getSource() == copyKeysItem) {
+ if (action == ACTION_COPY_KEYS_SELECTED) {
final StringSelection st = new
StringSelection(keys);
final Clipboard cp = tk.getSystemClipboard();
cp.setContents(st, this);
@@ -483,33 +512,52 @@
public void lostOwnership(final Clipboard clipboard, final
java.awt.datatransfer.Transferable contents) {
/* we dont care */
}
+ }
+
+ public void removeSelectedTransfers() {
+ Thread th = new Thread(new
ActionReplier(ACTION_REMOVE_SELECTED, -1));
+ th.start();
}
public void removeAllFinishedTransfers() {
- final Vector queries = tableModel.getQueries();
-
- for(final Iterator it = queries.iterator();
- it.hasNext(); ) {
- final FCPTransferQuery query =
(FCPTransferQuery)it.next();
- if(query.isFinished() &&
- (!(query instanceof FCPClientGet) ||
(!query.isSuccessful() || ((FCPClientGet)query).isWritingSuccessful()))) {
-
- if(query.stop(core.getQueueManager())) {
- core.getQueueManager().remove(query);
-
- }
- }
- }
+ Thread th = new Thread(new
ActionReplier(ACTION_REMOVE_FINISHED, -1));
+ th.start();
}
/**
* Manage it on a different thread to avoid UI freeze.
*/
public void actionPerformed(final ActionEvent e) {
- final Thread action = new Thread(new ActionReplier(e,
getSelectedQueries()));
+ int prioritySelected = 0;
+ int action = ACTION_CHANGE_PRIORITY_SELECTED;
- action.start();
+ for(prioritySelected = 0;
+ prioritySelected <= MIN_PRIORITY;
+ prioritySelected++) {
+ if(priorityRadioButton[prioritySelected] ==
e.getSource()) {
+ break;
+ }
+ }
+
+ if(prioritySelected > MIN_PRIORITY) {
+ prioritySelected = -1;
+
+ if (e.getSource() == clearFinishedItem) action =
ACTION_REMOVE_FINISHED;
+ else if (e.getSource() == removeItem) action =
ACTION_REMOVE_SELECTED;
+ else if (e.getSource() == cancelItem) action =
ACTION_CANCEL_SELECTED;
+ else if (e.getSource() == delayItem) action =
ACTION_DELAY_SELECTED;
+ else if (e.getSource() == downloadItem) action =
ACTION_DOWNLOAD_SELECTED;
+ else if (e.getSource() == forceRestartItem) action =
ACTION_RESTART_SELECTED;
+ else if (e.getSource() == copyKeysItem) action =
ACTION_COPY_KEYS_SELECTED;
+ else {
+ Logger.error(this, "Unknow action ?!");
+ return;
+ }
+ }
+
+ final Thread actionTh = new Thread(new ActionReplier(action,
prioritySelected));
+ actionTh.start();
}
public void mouseClicked(final MouseEvent e) {
@@ -520,6 +568,7 @@
}
if(e.getButton() == MouseEvent.BUTTON1) {
+ queueWatcher.unselectAllExcept(insertionQueue ?
QueueWatcher.INSERTION_PANEL : QueueWatcher.DOWNLOAD_PANEL);
refreshDetailPanel();
}
}