Author: jflesch
Date: 2006-12-31 19:36:46 +0000 (Sun, 31 Dec 2006)
New Revision: 11536
Added:
trunk/apps/Thaw/images/addToIndex.png
Modified:
trunk/apps/Thaw/images/application-internet.png
trunk/apps/Thaw/images/key.png
trunk/apps/Thaw/src/thaw/core/IconBox.java
trunk/apps/Thaw/src/thaw/core/MainWindow.java
trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
trunk/apps/Thaw/src/thaw/plugins/index/Link.java
trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
Log:
Adding various buttons to the index toolbar
Added: trunk/apps/Thaw/images/addToIndex.png
===================================================================
(Binary files differ)
Property changes on: trunk/apps/Thaw/images/addToIndex.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/apps/Thaw/images/application-internet.png
===================================================================
(Binary files differ)
Modified: trunk/apps/Thaw/images/key.png
===================================================================
(Binary files differ)
Modified: trunk/apps/Thaw/src/thaw/core/IconBox.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-12-31 14:11:37 UTC (rev
11535)
+++ trunk/apps/Thaw/src/thaw/core/IconBox.java 2006-12-31 19:36:46 UTC (rev
11536)
@@ -125,7 +125,7 @@
IconBox.minIndexEditor =
IconBox.loadIcon("min-edit-find-replace.png");
IconBox.indexBrowser = IconBox.loadIcon("edit-find.png");
IconBox.minIndexBrowser = IconBox.loadIcon("min-edit-find.png");
- IconBox.addToIndexAction = IconBox.loadIcon("folder.png");
+ IconBox.addToIndexAction = IconBox.loadIcon("addToIndex.png");
IconBox.insertAndAddToIndexAction =
IconBox.loadIcon("folder-new.png");
IconBox.makeALinkAction =
IconBox.loadIcon("application-internet.png");
IconBox.reconnectAction = IconBox.loadIcon("view-refresh.png");
Modified: trunk/apps/Thaw/src/thaw/core/MainWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-12-31 14:11:37 UTC
(rev 11535)
+++ trunk/apps/Thaw/src/thaw/core/MainWindow.java 2006-12-31 19:36:46 UTC
(rev 11536)
@@ -200,6 +200,7 @@
/**
* @param modifier Correspond to the caller object: it's a security to
avoid that a modifier wipe out the buttons from another one
+ * @param newButtons JButton vector : if null, then it means to remove
the buttons from the toolbar. Only the object having currently its buttons
displayed will be able to remove them, other will simply be ignored.
*/
public void changeButtonsInTheToolbar(final Object modifier, final
Vector newButtons) {
JToolBar newToolBar;
@@ -238,11 +239,16 @@
newToolBar.add(quitButton);
newToolBar.setFloatable(false);
- if (toolBar != null)
+ if (toolBar != null) {
mainWindow.getContentPane().remove(toolBar);
+ mainWindow.getContentPane().validate();
+ }
+
toolBar = newToolBar;
+
mainWindow.getContentPane().add(toolBar, BorderLayout.NORTH);
updateToolBar();
+ mainWindow.getContentPane().validate();
}
public void resetLastKnowToolBarModifier() {
Modified: trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java 2006-12-31 14:11:37 UTC
(rev 11535)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPConnection.java 2006-12-31 19:36:46 UTC
(rev 11536)
@@ -238,9 +238,6 @@
return true;
}
- /**
- * @return true if it must wait on this FCPConnection object
- */
public void addToWriterQueue() {
synchronized(monitor) {
writersWaiting++;
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2006-12-31 14:11:37 UTC
(rev 11535)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties 2006-12-31 19:36:46 UTC
(rev 11536)
@@ -195,7 +195,7 @@
thaw.plugin.index.addIndex=Ajouter un index de fichiers
thaw.plugin.index.createIndex=Cr?er un nouvel index de fichiers
-thaw.plugin.index.addCategory=Ajouter un r?pertoire
+thaw.plugin.index.addCategory=Ajouter un dossier
thaw.plugin.index.rename=Renommer
thaw.plugin.index.delete=Effacer
thaw.plugin.index.insertIndex=Ins?rer / mettre ? jour cet index sur Freenet
Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java
2006-12-31 14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/FileManagementHelper.java
2006-12-31 19:36:46 UTC (rev 11536)
@@ -26,7 +26,7 @@
/**
* Can disable the abstract button if required
- * @param node can be null
+ * @param files can be null
*/
public void setTarget(Vector files);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2006-12-31
14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/FileTable.java 2006-12-31
19:36:46 UTC (rev 11536)
@@ -19,6 +19,7 @@
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTable;
+import javax.swing.JButton;
import javax.swing.event.TableModelEvent;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
@@ -27,11 +28,14 @@
import thaw.core.Config;
import thaw.core.I18n;
import thaw.core.Logger;
+import thaw.core.IconBox;
+import thaw.plugins.ToolbarModifier;
import thaw.fcp.FCPClientGet;
import thaw.fcp.FCPClientPut;
import thaw.fcp.FCPQueueManager;
import thaw.fcp.FCPTransferQuery;
+
public class FileTable implements MouseListener, KeyListener, ActionListener {
private final JPanel panel;
@@ -53,6 +57,9 @@
// Remove
// Copy file keys
+ private final ToolbarModifier toolbarModifier;
+ private final Vector toolbarActions;
+
private int[] selectedRows;
private IndexBrowserPanel indexBrowser;
@@ -81,21 +88,42 @@
rightClickMenu = new JPopupMenu();
rightClickActions = new Vector();
+
+ toolbarModifier = new
ToolbarModifier(indexBrowser.getMainWindow());
+ toolbarActions = new Vector();
+
+ JButton button;
JMenuItem item;
item = new
JMenuItem(I18n.getMessage("thaw.common.action.download"));
+ button = new JButton(IconBox.downloads);
+
button.setToolTipText(I18n.getMessage("thaw.common.action.download"));
+ toolbarActions.add(new
FileManagementHelper.FileDownloader(config, queueManager, button));
+ toolbarModifier.addButtonToTheToolbar(button);
rightClickMenu.add(item);
rightClickActions.add(new
FileManagementHelper.FileDownloader(config, queueManager, item));
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.insert"));
+ button = new JButton(IconBox.insertions);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.insert"));
+ toolbarActions.add(new
FileManagementHelper.FileInserter(queueManager, button));
+ toolbarModifier.addButtonToTheToolbar(button);
rightClickMenu.add(item);
rightClickActions.add(new
FileManagementHelper.FileInserter(queueManager, item));
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.recalculateKeys"));
+ button = new JButton(IconBox.key);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.recalculateKeys"));
+ toolbarActions.add(new
FileManagementHelper.FileKeyComputer(queueManager, button));
+ toolbarModifier.addButtonToTheToolbar(button);
rightClickMenu.add(item);
rightClickActions.add(new
FileManagementHelper.FileKeyComputer(queueManager, item));
item = new JMenuItem(I18n.getMessage("thaw.common.remove"));
+ button = new JButton(IconBox.delete);
+ button.setToolTipText(I18n.getMessage("thaw.common.remove"));
+ toolbarActions.add(new
FileManagementHelper.FileRemover(queueManager, button));
+ toolbarModifier.addButtonToTheToolbar(button);
rightClickMenu.add(item);
rightClickActions.add(new
FileManagementHelper.FileRemover(queueManager, item));
@@ -110,6 +138,9 @@
updateRightClickMenu(null);
}
+ public ToolbarModifier getToolbarModifier() {
+ return toolbarModifier;
+ }
public JPanel getPanel() {
return panel;
@@ -127,6 +158,16 @@
gotoItem.setEnabled((fileList != null) && !(fileList instanceof
Index));
}
+ protected void updateToolbar(final Vector selectedFiles) {
+ FileManagementHelper.FileAction action;
+
+ for(final Iterator it = toolbarActions.iterator();
+ it.hasNext();) {
+ action = (FileManagementHelper.FileAction)it.next();
+ action.setTarget(selectedFiles);
+ }
+ }
+
protected Vector getSelectedFiles(final int[] selectedRows) {
final Vector srcList = fileList.getFileList();
final Vector files = new Vector();
@@ -155,13 +196,26 @@
public void mouseClicked(final MouseEvent e) {
+ Vector selection;
+
if (fileList instanceof Index)
((Index)fileList).setChanged(false);
- if((e.getButton() == MouseEvent.BUTTON3)
- && (fileList != null)) {
- selectedRows = table.getSelectedRows();
- updateRightClickMenu(getSelectedFiles(selectedRows));
+ if (fileList == null) {
+ selectedRows = null;
+ return;
+ }
+
+ selectedRows = table.getSelectedRows();
+ selection = getSelectedFiles(selectedRows);
+
+ if (e.getButton() == MouseEvent.BUTTON1) {
+ updateToolbar(selection);
+ toolbarModifier.displayButtonsInTheToolbar();
+ }
+
+ if (e.getButton() == MouseEvent.BUTTON3) {
+ updateRightClickMenu(selection);
rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-12-31 14:11:37 UTC
(rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-12-31 19:36:46 UTC
(rev 11536)
@@ -72,6 +72,16 @@
private boolean updateWhenKeyAreAvailable = false;
/**
+ * @deprecated Just don't use it !
+ */
+ public Index() {
+ db = null;
+ queueManager = null;
+ indexBrowser = null;
+ }
+
+
+ /**
* The bigest constructor of the world ...
* @param revision Ignored if the index is not modifiable (=> deduced
from the publicKey)
*/
@@ -1238,4 +1248,31 @@
return fileList.contains(file);
}
+
+ public static boolean isAlreadyKnown(Hsqldb db, String key) {
+ if (key.length() < 40) {
+ Logger.error(new Index(), "isAlreadyKnown: Invalid key:
"+key);
+ return false;
+ }
+
+ try {
+ PreparedStatement st;
+
+ st = db.getConnection().prepareStatement("SELECT
publicKey from indexes WHERE publicKey LIKE ?");
+
+ st.setString(1, "%"+key.substring(3, 40)+"%");
+
+ if(st.execute()) {
+ final ResultSet result = st.getResultSet();
+ if ((result != null) && result.next())
+ return true;
+ }
+
+ } catch(final SQLException e) {
+ Logger.error(new Index(), "isAlreadyKnown: Unable to
check if link '"+key+"' point to a know index because: "+e.toString());
+ }
+
+ return false;
+ }
+
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-12-31 14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-12-31 19:36:46 UTC (rev 11536)
@@ -171,12 +171,12 @@
}
if (node instanceof FileList) {
- Logger.info(this, "FileList !");
+ Logger.debug(this, "FileList !");
setFileList((FileList)node);
}
if (node instanceof LinkList) {
- Logger.info(this, "LinkList !");
+ Logger.debug(this, "LinkList !");
setLinkList((LinkList)node);
}
@@ -189,6 +189,12 @@
public void isVisible(boolean visibility) {
if (visibility) {
indexTree.getToolbarModifier().displayButtonsInTheToolbar();
+ } else {
+ // one of these foor may be the buttons owner ?
+
indexTree.getToolbarModifier().hideButtonsInTheToolbar();
+
tables.getLinkTable().getToolbarModifier().hideButtonsInTheToolbar();
+
tables.getFileTable().getToolbarModifier().hideButtonsInTheToolbar();
+
unknownList.getToolbarModifier().hideButtonsInTheToolbar();
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2006-12-31 14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2006-12-31 19:36:46 UTC (rev 11536)
@@ -379,6 +379,11 @@
if (publicKey == null)
return;
+ if (Index.isAlreadyKnown(indexBrowser.getDb(), publicKey)) {
+ Logger.notice(new IndexManagementHelper(), "Index
already added !");
+ return;
+ }
+
final String name = Index.getNameFromKey(publicKey);
IndexCategory parent;
@@ -389,6 +394,7 @@
parent = indexBrowser.getIndexTree().getRoot();
final Index index = new Index(queueManager, indexBrowser, -2,
parent, name, name, publicKey, privateKey, 0, null);
+
indexBrowser.getUnknownIndexList().removeLink(index);
index.create();
@@ -941,9 +947,6 @@
}
}
- /**
- * @param keys => String
- */
public static void addLink(final IndexBrowserPanel indexBrowser, final
Index target, final String linkKey) {
if ((target == null) || (linkKey == null))
return;
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-31
14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-31
19:36:46 UTC (rev 11536)
@@ -279,6 +279,20 @@
toolbarModifier.addButtonToTheToolbar(button);
toolbarActions.add(action);
+ button = new JButton(IconBox.addToIndexAction);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addFilesWithoutInserting"));
+ action = new IndexManagementHelper.FileAdder(config,
queueManager, indexBrowser, button);
+ action.setTarget(null);
+ toolbarModifier.addButtonToTheToolbar(button);
+ toolbarActions.add(action);
+
+ button = new JButton(IconBox.makeALinkAction);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addLink"));
+ action = new IndexManagementHelper.LinkAdder(indexBrowser,
button);
+ action.setTarget(getRoot());
+ toolbarModifier.addButtonToTheToolbar(button);
+ toolbarActions.add(action);
+
button = new JButton(IconBox.delete);
button.setToolTipText(I18n.getMessage("thaw.plugin.index.delete"));
action = new IndexManagementHelper.IndexDeleter(indexBrowser,
button);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Link.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2006-12-31 14:11:37 UTC
(rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2006-12-31 19:36:46 UTC
(rev 11536)
@@ -167,32 +167,6 @@
}
}
- public boolean isIndexAlreadyKnown() {
- if (key.length() < 40) {
- Logger.error(this, "Invalid key: "+key);
- return false;
- }
-
- try {
- PreparedStatement st;
-
- st = db.getConnection().prepareStatement("SELECT
publicKey from indexes WHERE publicKey LIKE ?");
-
- st.setString(1, "%"+key.substring(3, 40)+"%");
-
- if(st.execute()) {
- final ResultSet result = st.getResultSet();
- if ((result != null) && result.next())
- return true;
- }
-
- } catch(final SQLException e) {
- Logger.error(this, "Unable to check if link '"+key+"'
point to a know index because: "+e.toString());
- }
-
- return false;
- }
-
public boolean isInTheDatabase() {
if (parent == null) {
Logger.notice(this, "isInTheDatabase(): No parent !");
Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
2006-12-31 14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
2006-12-31 19:36:46 UTC (rev 11536)
@@ -18,7 +18,7 @@
/**
* Can disable the abstract button if required
- * @param node can be null
+ * @param links can be null
*/
public void setTarget(Vector links);
}
@@ -28,9 +28,6 @@
private AbstractButton actionSource;
private Vector target;
- /**
- * @param queueManager is used to stop transfers if needed
- */
public LinkRemover(final AbstractButton actionSource) {
this.actionSource = actionSource;
if (actionSource != null)
Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2006-12-31
14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2006-12-31
19:36:46 UTC (rev 11536)
@@ -17,11 +17,14 @@
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
+import javax.swing.JButton;
import javax.swing.event.TableModelEvent;
import javax.swing.tree.TreePath;
import thaw.core.I18n;
import thaw.core.Logger;
+import thaw.core.IconBox;
+import thaw.plugins.ToolbarModifier;
import thaw.fcp.FCPQueueManager;
import thaw.plugins.Hsqldb;
@@ -42,6 +45,9 @@
private Vector rightClickActions;
private JMenuItem gotoItem;
+ private ToolbarModifier toolbarModifier;
+ private Vector toolbarActions;
+
private int[] selectedRows;
public LinkTable (final FCPQueueManager queueManager, IndexBrowserPanel
indexBrowser) {
@@ -62,9 +68,19 @@
rightClickMenu = new JPopupMenu();
rightClickActions = new Vector();
+ toolbarModifier = new
ToolbarModifier(indexBrowser.getMainWindow());
+ toolbarActions = new Vector();
+
JMenuItem item;
+ JButton button;
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.addIndexesFromLink"));
+ button = new JButton(IconBox.indexReuse);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addIndexesFromLink"));
+ toolbarActions.add(new LinkManagementHelper.IndexAdder(button,
queueManager,
+
indexBrowser));
+
+ toolbarModifier.addButtonToTheToolbar(button);
rightClickMenu.add(item);
rightClickActions.add(new LinkManagementHelper.IndexAdder(item,
queueManager,
indexBrowser));
@@ -74,6 +90,10 @@
rightClickActions.add(new
LinkManagementHelper.PublicKeyCopier(item));
item = new JMenuItem(I18n.getMessage("thaw.common.remove"));
+ button = new JButton(IconBox.delete);
+ button.setToolTipText(I18n.getMessage("thaw.common.remove"));
+ toolbarActions.add(new
LinkManagementHelper.LinkRemover(button));
+ toolbarModifier.addButtonToTheToolbar(button);
rightClickMenu.add(item);
rightClickActions.add(new
LinkManagementHelper.LinkRemover(item));
@@ -84,6 +104,10 @@
updateRightClickMenu(null);
}
+ public ToolbarModifier getToolbarModifier() {
+ return toolbarModifier;
+ }
+
public JPanel getPanel() {
return panel;
}
@@ -100,6 +124,16 @@
gotoItem.setEnabled((linkList != null) && !(linkList instanceof
Index));
}
+ protected void updateToolbar(final Vector selectedLinks) {
+ LinkManagementHelper.LinkAction action;
+
+ for (final Iterator it = toolbarActions.iterator();
+ it.hasNext(); ) {
+ action = (LinkManagementHelper.LinkAction)it.next();
+ action.setTarget(selectedLinks);
+ }
+ }
+
protected Vector getSelectedLinks(final int[] selectedRows) {
final Vector srcList = linkList.getLinkList();
final Vector links = new Vector();
@@ -127,13 +161,27 @@
}
public void mouseClicked(final MouseEvent e) {
+ Vector selection;
+
if (linkList instanceof Index)
((Index)linkList).setChanged(false);
- if((e.getButton() == MouseEvent.BUTTON3)
+ if (linkList == null) {
+ selectedRows = null;
+ return;
+ }
+
+ selectedRows = table.getSelectedRows();
+ selection = getSelectedLinks(selectedRows);
+
+ if ((e.getButton() == MouseEvent.BUTTON1) && linkList != null) {
+ updateToolbar(selection);
+ toolbarModifier.displayButtonsInTheToolbar();
+ }
+
+ if ((e.getButton() == MouseEvent.BUTTON3)
&& (linkList != null)) {
- selectedRows = table.getSelectedRows();
- updateRightClickMenu(getSelectedLinks(selectedRows));
+ updateRightClickMenu(selection);
rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
2006-12-31 14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
2006-12-31 19:36:46 UTC (rev 11536)
@@ -12,8 +12,11 @@
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
+import javax.swing.JButton;
import thaw.core.I18n;
+import thaw.core.IconBox;
+import thaw.plugins.ToolbarModifier;
import thaw.fcp.FCPQueueManager;
import thaw.plugins.Hsqldb;
@@ -34,6 +37,9 @@
private JPopupMenu rightClickMenu = null;
private Vector rightClickActions = null;
+ private ToolbarModifier toolbarModifier;
+ private Vector toolbarActions;
+
private FCPQueueManager queueManager;
private IndexBrowserPanel indexBrowser;
@@ -59,9 +65,23 @@
scrollPane = new JScrollPane(list);
panel.add(scrollPane);
+ JButton button;
+
+ toolbarModifier = new
ToolbarModifier(indexBrowser.getMainWindow());
+ toolbarActions = new Vector();
+
+ button = new JButton(IconBox.indexReuse);
+
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addIndexesFromLink"));
+ toolbarActions.add(new LinkManagementHelper.IndexAdder(button,
queueManager, indexBrowser));
+ toolbarModifier.addButtonToTheToolbar(button);
+
list.addMouseListener(this);
}
+ public ToolbarModifier getToolbarModifier() {
+ return toolbarModifier;
+ }
+
public JPanel getPanel() {
return panel;
}
@@ -100,7 +120,7 @@
* will check that the link link to an unknown index before adding
*/
public boolean addLink(final Link link) {
- if ((link == null) || link.isIndexAlreadyKnown() ||
isInList(link))
+ if ((link == null) ||
Index.isAlreadyKnown(indexBrowser.getDb(), link.getPublicKey()) ||
isInList(link))
return false;
linkList[linkList.length - 1 - offset] = link;
@@ -143,7 +163,7 @@
}
- protected void updateRightClickMenu() {
+ protected void updateRightClickMenu(Vector links) {
if (rightClickMenu == null) {
rightClickMenu = new JPopupMenu();
rightClickActions = new Vector();
@@ -158,26 +178,53 @@
rightClickActions.add(new
LinkManagementHelper.PublicKeyCopier(item));
}
- final Object[] sLink = list.getSelectedValues();
- final Vector vLink = new Vector();
+ LinkManagementHelper.LinkAction action;
- for (int i = 0; i < sLink.length ; i++)
- vLink.add(sLink[i]);
+ for(final Iterator it = rightClickActions.iterator();
+ it.hasNext(); ) {
+ action = (LinkManagementHelper.LinkAction)it.next();
+ action.setTarget(links);
+ }
+ }
+ public void updateToolbar(Vector links) {
LinkManagementHelper.LinkAction action;
- for(final Iterator it = rightClickActions.iterator();
+ for(final Iterator it = toolbarActions.iterator();
it.hasNext(); ) {
action = (LinkManagementHelper.LinkAction)it.next();
- action.setTarget(vLink);
+ action.setTarget(links);
}
}
+ public Vector getSelectedLinks() {
+ final Object[] sLink = list.getSelectedValues();
+ final Vector vLink = new Vector();
+ for (int i = 0; i < sLink.length ; i++)
+ vLink.add(sLink[i]);
+
+ return vLink;
+ }
+
+
public void mouseClicked(final MouseEvent e) {
- if((e.getButton() == MouseEvent.BUTTON3)
- && (linkList != null)) {
- updateRightClickMenu();
+ Vector selection;
+
+ if (linkList == null) {
+ selection = null;
+ return;
+ }
+
+ selection = getSelectedLinks();
+
+ if (e.getButton() == MouseEvent.BUTTON1) {
+ updateToolbar(selection);
+ toolbarModifier.displayButtonsInTheToolbar();
+ }
+
+ if (e.getButton() == MouseEvent.BUTTON3) {
+ updateRightClickMenu(selection);
rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-12-31 14:11:37 UTC (rev 11535)
+++ trunk/apps/Thaw/src/thaw/plugins/queueWatcher/QueuePanel.java
2006-12-31 19:36:46 UTC (rev 11536)
@@ -476,6 +476,13 @@
if(action == ACTION_RESTART_SELECTED) {
query.stop(core.getQueueManager());
+ if ((query instanceof FCPClientGet) &&
query.getPath() != null) {
+ File target = new
File(query.getPath());
+
+ if (target.exists())
+ target.delete();
+ }
+
if(query.getMaxAttempt() >= 0)
query.setAttempt(0);