Author: jflesch
Date: 2007-03-24 22:13:17 +0000 (Sat, 24 Mar 2007)
New Revision: 12350
Modified:
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
Log:
Rename 'go to the corresponding index' option into 'go to the index parent',
and create an option to go from a link to the corresponding index (if in tree)
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-03-24 21:58:01 UTC
(rev 12349)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2007-03-24 22:13:17 UTC
(rev 12350)
@@ -270,7 +270,8 @@
thaw.plugin.index.selectIndex=Select an index or specify the key
-thaw.plugin.index.gotoIndex=Go to the corresponding index
+thaw.plugin.index.gotoIndex=Go to the index containing this entry
+thaw.plugin.index.gotoCorrespondingIndex=Go to the corresponding index
thaw.plugin.index.addKeys=Add specific key(s)
thaw.plugin.index.changeIndexKeys=Change the index keys
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-03-24 21:58:01 UTC
(rev 12349)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-03-24 22:13:17 UTC
(rev 12350)
@@ -1360,10 +1360,13 @@
}
- public static boolean isAlreadyKnown(Hsqldb db, String key) {
+ /**
+ * @return the index id if found ; -1 else
+ */
+ public static int isAlreadyKnown(Hsqldb db, String key) {
if (key.length() < 40) {
- Logger.error(new Index(), "isAlreadyKnown: Invalid key:
"+key);
- return false;
+ Logger.error(new Index(), "isAlreadyKnown(): Invalid
key: "+key);
+ return -1;
}
key = key.replaceAll(".xml", ".frdx");
@@ -1372,7 +1375,7 @@
try {
PreparedStatement st;
- st =
db.getConnection().prepareStatement("SELECT publicKey from indexes WHERE
LOWER(publicKey) LIKE ?");
+ st =
db.getConnection().prepareStatement("SELECT id, publicKey from indexes WHERE
LOWER(publicKey) LIKE ?");
st.setString(1,
FreenetURIHelper.getComparablePart(key) +"%");
@@ -1382,18 +1385,18 @@
String pubKey =
res.getString("publicKey").replaceAll(".xml", ".frdx");
if
(FreenetURIHelper.compareKeys(pubKey, key)) {
- return true;
+ return res.getInt("id");
}
}
- return false;
+ return -1;
} 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;
+ return -1;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-03-24 21:58:01 UTC (rev 12349)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-03-24 22:13:17 UTC (rev 12350)
@@ -529,7 +529,7 @@
if (privateKey != null && privateKey.equals(""))
privateKey = null;
- if (Index.isAlreadyKnown(indexBrowser.getDb(), publicKey)) {
+ if (Index.isAlreadyKnown(indexBrowser.getDb(), publicKey) >= 0)
{
Logger.notice(new IndexManagementHelper(), "Index
already added !");
return null;
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2007-03-24
21:58:01 UTC (rev 12349)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2007-03-24
22:13:17 UTC (rev 12350)
@@ -43,6 +43,7 @@
private JPopupMenu rightClickMenu;
private Vector rightClickActions;
private JMenuItem gotoItem;
+ private JMenuItem gotoCorrespondingItem;
private ToolbarModifier toolbarModifier;
private Vector toolbarActions;
@@ -50,6 +51,7 @@
private int[] selectedRows;
private Link firstSelectedLink = null;
+ private int firstSelectedLinkCorrespondingIndexId = -1; /* hmm .. I
should make it shorter ... */
public LinkTable (final FCPQueueManager queueManager, IndexBrowserPanel
indexBrowser) {
@@ -104,6 +106,10 @@
rightClickMenu.add(gotoItem);
gotoItem.addActionListener(this);
+ gotoCorrespondingItem = new
JMenuItem(I18n.getMessage("thaw.plugin.index.gotoCorrespondingIndex"));
+ rightClickMenu.add(gotoCorrespondingItem);
+ gotoCorrespondingItem.addActionListener(this);
+
updateRightClickMenu(null);
}
@@ -127,6 +133,17 @@
}
gotoItem.setEnabled((linkList != null) && !(linkList instanceof
Index));
+
+ if (firstSelectedLink != null)
+ firstSelectedLinkCorrespondingIndexId =
+ Index.isAlreadyKnown(indexBrowser.getDb(),
+
firstSelectedLink.getPublicKey());
+ else
+ firstSelectedLinkCorrespondingIndexId = -1;
+
+ gotoCorrespondingItem.setEnabled((linkList != null)
+ && !(linkList instanceof Index)
+ &&
firstSelectedLinkCorrespondingIndexId >= 0);
}
protected void updateToolbar(final Vector selectedLinks) {
@@ -216,6 +233,15 @@
return;
}
+
+ if (e.getSource() == gotoCorrespondingItem) {
+ if (selectedRows.length <= 0)
+ return;
+
+ if (firstSelectedLinkCorrespondingIndexId > 0) {
+
indexBrowser.selectIndex(firstSelectedLinkCorrespondingIndexId);
+ }
+ }
}
public void refresh() {
Modified: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
2007-03-24 21:58:01 UTC (rev 12349)
+++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
2007-03-24 22:13:17 UTC (rev 12350)
@@ -136,7 +136,9 @@
* will check that the link link to an unknown index before adding
*/
public boolean addLink(final Link link) {
- if ((link == null) ||
Index.isAlreadyKnown(indexBrowser.getDb(), link.getPublicKey()) ||
isInList(link))
+ if ((link == null)
+ || Index.isAlreadyKnown(indexBrowser.getDb(),
link.getPublicKey()) >= 0
+ || isInList(link))
return false;
makePlace(0);