Author: jflesch
Date: 2006-12-03 01:10:09 +0000 (Sun, 03 Dec 2006)
New Revision: 11207
Added:
trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
Modified:
trunk/apps/Thaw/src/thaw/i18n/thaw.properties
trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.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/IndexCategory.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.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/Tables.java
Log:
Add a frame where are displayed all the new unknown link
Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-12-02 22:20:34 UTC
(rev 11206)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties 2006-12-03 01:10:09 UTC
(rev 11207)
@@ -251,3 +251,5 @@
thaw.plugin.index.addKeys=Add specific key(s)
thaw.plugin.index.changeIndexKeys=Change the index keys
+thaw.plugin.index.unknownIndexes=Unknown indexes:
+
Modified: trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-12-02 22:20:34 UTC
(rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/IndexBrowser.java 2006-12-03 01:10:09 UTC
(rev 11207)
@@ -70,18 +70,18 @@
button = new JButton(IconBox.indexReuse);
button.setToolTipText(I18n.getMessage("thaw.plugin.index.addAlreadyExistingIndex"));
- action = new IndexManagementHelper.IndexReuser(hsqldb,
core.getQueueManager(), browserPanel.getIndexTree(), button);
+ action = new IndexManagementHelper.IndexReuser(hsqldb,
core.getQueueManager(), browserPanel.getUnknownIndexList(),
browserPanel.getIndexTree(), button);
action.setTarget(browserPanel.getIndexTree().getRoot());
addButtonToTheToolbar(button);
button = new JButton(IconBox.indexNew);
button.setToolTipText(I18n.getMessage("thaw.plugin.index.createIndex"));
- action = new IndexManagementHelper.IndexCreator(hsqldb,
core.getQueueManager(), browserPanel.getIndexTree(), button);
+ action = new IndexManagementHelper.IndexCreator(hsqldb,
core.getQueueManager(), browserPanel.getUnknownIndexList(),
browserPanel.getIndexTree(), button);
action.setTarget(browserPanel.getIndexTree().getRoot());
addButtonToTheToolbar(button);
if (newDb) {
- IndexManagementHelper.addIndex(hsqldb,
core.getQueueManager(), browserPanel.getIndexTree(),
+ IndexManagementHelper.addIndex(hsqldb,
core.getQueueManager(), browserPanel.getUnknownIndexList(),
browserPanel.getIndexTree(),
browserPanel.getIndexTree().getRoot(), DEFAULT_INDEX);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-12-02 22:20:34 UTC
(rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2006-12-03 01:10:09 UTC
(rev 11207)
@@ -53,6 +53,7 @@
private FCPGenerateSSK sskGenerator;
private FCPQueueManager queueManager;
+ private UnknownIndexList uIndexList;
private FCPTransferQuery transfer = null;
private java.io.File targetFile = null;
@@ -71,12 +72,13 @@
* The bigest constructor of the world ...
* @param revision Ignored if the index is not modifiable (=> deduced
from the publicKey)
*/
- public Index(Hsqldb db, FCPQueueManager queueManager,
+ public Index(Hsqldb db, FCPQueueManager queueManager, UnknownIndexList
indexList,
int id, IndexCategory parent,
String realName, String displayName,
String publicKey, String privateKey,
int revision,
String author) {
+ this.uIndexList = indexList;
this.queueManager = queueManager;
this.treeNode = new DefaultMutableTreeNode(displayName, false);
@@ -621,6 +623,8 @@
save();
+ uIndexList.addLinks(this);
+
setChanged();
notifyObservers();
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-12-02 22:20:34 UTC (rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexBrowserPanel.java
2006-12-03 01:10:09 UTC (rev 11207)
@@ -17,6 +17,8 @@
public class IndexBrowserPanel implements
javax.swing.event.TreeSelectionListener, ActionListener {
private IndexTree indexTree;
+ private JSplitPane leftSplit;
+ private UnknownIndexList unknownList;
private JSplitPane split;
@@ -28,25 +30,32 @@
private FCPQueueManager queueManager;
private Config config;
+
+
public IndexBrowserPanel(Hsqldb db, FCPQueueManager queueManager,
Config config) {
this.db = db;
this.queueManager = queueManager;
this.config = config;
- this.indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.indexes"), false, queueManager,
db);
+ unknownList = new UnknownIndexList(db, queueManager);
+ indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.indexes"), false, queueManager,
unknownList, db);
+ unknownList.setIndexTree(indexTree); /* TODO: dirty => find a
better way */
+ leftSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+ indexTree.getPanel(),
+ unknownList.getPanel());
+
this.listAndDetails = new JPanel();
this.listAndDetails.setLayout(new BorderLayout(10, 10));
- this.tables = new Tables(false, db, queueManager,
this.indexTree, config);
+ this.tables = new Tables(false, db, queueManager, unknownList,
this.indexTree, config);
this.fileDetails = new FileDetailsEditor(false);
this.listAndDetails.add(this.tables.getPanel(),
BorderLayout.CENTER);
this.listAndDetails.add(this.fileDetails.getPanel(),
BorderLayout.SOUTH);
this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
- this.indexTree.getPanel(),
- this.listAndDetails);
+ leftSplit, listAndDetails);
this.indexTree.addTreeSelectionListener(this);
}
@@ -55,6 +64,17 @@
if (config.getValue("indexBrowserPanelSplitPosition") != null)
split.setDividerLocation(Integer.parseInt(this.config.getValue("indexBrowserPanelSplitPosition")));
+ leftSplit.setSize(150, MainWindow.DEFAULT_SIZE_Y - 150);
+ leftSplit.setResizeWeight(0.5);
+
+ if (config.getValue("indexTreeUnknownListSplitLocation") ==
null) {
+ leftSplit.setDividerLocation(((double)0.5));
+ } else {
+
leftSplit.setDividerLocation(Double.parseDouble(config.getValue("indexTreeUnknownListSplitLocation")));
+ }
+
+ leftSplit.setResizeWeight(0.5);
+
tables.restoreState();
}
@@ -66,6 +86,10 @@
return indexTree;
}
+ public UnknownIndexList getUnknownIndexList() {
+ return unknownList;
+ }
+
public JSplitPane getPanel() {
return this.split;
}
@@ -73,6 +97,13 @@
public void saveState() {
this.indexTree.save();
this.config.setValue("indexBrowserPanelSplitPosition",
Integer.toString(this.split.getDividerLocation()));
+ double splitLocation;
+
+ splitLocation = ((double)leftSplit.getDividerLocation() -
((double)leftSplit.getMinimumDividerLocation())) /
(((double)leftSplit.getMaximumDividerLocation()) -
((double)leftSplit.getMinimumDividerLocation()));
+
+ config.setValue("indexTreeUnknownListSplitLocation",
+ Double.toString(splitLocation));
+
this.tables.saveState();
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java 2006-12-02
22:20:34 UTC (rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexCategory.java 2006-12-03
01:10:09 UTC (rev 11207)
@@ -24,12 +24,14 @@
private Hsqldb db;
private FCPQueueManager queueManager;
+ private UnknownIndexList uIndexList;
- public IndexCategory(Hsqldb db, FCPQueueManager queueManager,
+ public IndexCategory(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uil,
int id, IndexCategory parent,
String name) {
super(name, true);
+ this.uIndexList = uil;
this.id = id;
this.name = name;
this.parent = parent;
@@ -302,7 +304,8 @@
String author = result.getString("author");
- Index index = new Index(db, queueManager, id,
this,
+ Index index = new Index(db, queueManager,
uIndexList,
+ id, this,
realName, displayName,
publicKey, privateKey,
revision,
@@ -344,7 +347,7 @@
int position = result.getInt("positionInTree");
String name = result.getString("name");
- IndexCategory cat = new IndexCategory(this.db,
this.queueManager, id, this, name);
+ IndexCategory cat = new IndexCategory(this.db,
this.queueManager, uIndexList, id, this, name);
cat.loadChildren();
this.set(children, position, cat);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2006-12-02 22:20:34 UTC (rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2006-12-03 01:10:09 UTC (rev 11207)
@@ -61,15 +61,17 @@
private Hsqldb db;
private IndexTree tree;
private FCPQueueManager queueManager;
+ private UnknownIndexList uIndexList;
private AbstractButton actionSource;
private IndexTreeNode target;
- public BasicIndexAction(Hsqldb db, FCPQueueManager
queueManager, IndexTree tree, AbstractButton actionSource) {
+ public BasicIndexAction(Hsqldb db, FCPQueueManager
queueManager, UnknownIndexList uIndexList, IndexTree tree, AbstractButton
actionSource) {
this.db = db;
this.tree = tree;
this.actionSource = actionSource;
this.target = null;
this.queueManager = queueManager;
+ this.uIndexList = uIndexList;
actionSource.addActionListener(this);
}
@@ -90,6 +92,10 @@
return queueManager;
}
+ public UnknownIndexList getUnknownIndexList() {
+ return uIndexList;
+ }
+
public IndexTreeNode getTarget() {
return target;
}
@@ -104,8 +110,8 @@
public static class IndexCreator extends BasicIndexAction {
- public IndexCreator(Hsqldb db, FCPQueueManager queueManager,
IndexTree tree, AbstractButton actionSource) {
- super(db, queueManager, tree, actionSource);
+ public IndexCreator(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, AbstractButton actionSource) {
+ super(db, queueManager, uIndexList, tree, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -120,15 +126,15 @@
if (name == null)
return;
- createIndex(getDb(), getQueueManager(), getTree(),
(IndexCategory)getTarget(), name);
+ createIndex(getDb(), getQueueManager(),
getUnknownIndexList(), getTree(), (IndexCategory)getTarget(), name);
}
}
- public static void createIndex(Hsqldb db, FCPQueueManager queueManager,
IndexTree tree, IndexCategory target, String name) {
+ public static void createIndex(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, IndexCategory target, String name)
{
if (target == null)
target = tree.getRoot();
- Index index = new Index(db, queueManager, -1, target, name,
name, null, null, 0, null);
+ Index index = new Index(db, queueManager, uIndexList, -1,
target, name, name, null, null, 0, null);
index.generateKeys();
index.create();
@@ -138,8 +144,8 @@
public static class IndexAdder extends BasicIndexAction {
- public IndexAdder(Hsqldb db, FCPQueueManager queueManager,
IndexTree tree, AbstractButton actionSource) {
- super(db, queueManager, tree, actionSource);
+ public IndexAdder(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList indexList, IndexTree tree, AbstractButton actionSource) {
+ super(db, queueManager, indexList, tree, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -150,7 +156,7 @@
public void actionPerformed(ActionEvent e) {
String key =
askAName(I18n.getMessage("thaw.plugin.index.indexKey"), "USK@");
- addIndex(getDb(), getQueueManager(), getTree(),
(IndexCategory)getTarget(), key);
+ addIndex(getDb(), getQueueManager(),
getUnknownIndexList(), getTree(), (IndexCategory)getTarget(), key);
}
}
@@ -158,7 +164,7 @@
/**
* Can be use directly
*/
- public static void addIndex(Hsqldb db, FCPQueueManager queueManager,
IndexTree tree, IndexCategory target, String publicKey) {
+ public static void addIndex(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList indexList, IndexTree tree, IndexCategory target, String
publicKey) {
publicKey = FreenetURIHelper.cleanURI(publicKey);
if (publicKey == null)
@@ -172,12 +178,14 @@
if (target == null)
target = tree.getRoot();
- Index index = new Index(db, queueManager, -2, target, name,
name, publicKey, null, 0, null);
+ Index index = new Index(db, queueManager, indexList, -2,
target, name, name, publicKey, null, 0, null);
if (tree.addToIndexCategory(target, index)) {
index.create();
index.updateFromFreenet(-1);
}
+
+ indexList.removeLink(index);
}
@@ -295,7 +303,7 @@
public static class IndexKeyModifier extends BasicIndexAction
implements Runnable {
public IndexKeyModifier(AbstractButton actionSource) {
- super(null, null, null, actionSource);
+ super(null, null, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -325,8 +333,8 @@
public static class IndexReuser extends BasicIndexAction implements
Runnable {
- public IndexReuser(Hsqldb db, FCPQueueManager queueManager,
IndexTree tree, AbstractButton actionSource) {
- super(db, queueManager, tree, actionSource);
+ public IndexReuser(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, AbstractButton actionSource) {
+ super(db, queueManager, uIndexList, tree, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -347,7 +355,7 @@
publicKey = keys[0];
privateKey = keys[1];
- reuseIndex(getDb(), getQueueManager(), getTree(),
(IndexCategory)getTarget(), publicKey, privateKey);
+ reuseIndex(getDb(), getQueueManager(),
getUnknownIndexList(), getTree(), (IndexCategory)getTarget(), publicKey,
privateKey);
}
public void actionPerformed(ActionEvent e) {
@@ -363,7 +371,7 @@
* Can be use directly
* @param privateKey Can be null
*/
- public static void reuseIndex(Hsqldb db, FCPQueueManager queueManager,
IndexTree tree, IndexCategory target,
+ public static void reuseIndex(Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uIndexList, IndexTree tree, IndexCategory target,
String publicKey, String privateKey) {
publicKey = FreenetURIHelper.cleanURI(publicKey);
@@ -381,7 +389,7 @@
else
parent = tree.getRoot();
- Index index = new Index(db, queueManager, -2, parent, name,
name, publicKey, privateKey, 0, null);
+ Index index = new Index(db, queueManager, uIndexList, -2,
parent, name, name, publicKey, privateKey, 0, null);
index.create();
@@ -390,14 +398,16 @@
parent.insert(index.getTreeNode(), 0);
tree.reloadModel(parent);
+
+ uIndexList.removeLink(index);
}
public static class IndexCategoryAdder extends BasicIndexAction {
- public IndexCategoryAdder(Hsqldb db, FCPQueueManager
queueManager, IndexTree tree, AbstractButton actionSource) {
- super(db, queueManager, tree, actionSource);
+ public IndexCategoryAdder(Hsqldb db, FCPQueueManager
queueManager, UnknownIndexList uil, IndexTree tree, AbstractButton
actionSource) {
+ super(db, queueManager, uil, tree, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -409,15 +419,15 @@
String name =
askAName(I18n.getMessage("thaw.plugin.index.categoryName"),
I18n.getMessage("thaw.plugin.index.newCategory"));
- addIndexCategory(getDb(), getQueueManager(), getTree(),
(IndexCategory)getTarget(), name);
+ addIndexCategory(getDb(), getQueueManager(),
getUnknownIndexList(), getTree(), (IndexCategory)getTarget(), name);
}
}
- public static void addIndexCategory(Hsqldb db, FCPQueueManager
queueManager, IndexTree tree, IndexCategory target, String name) {
+ public static void addIndexCategory(Hsqldb db, FCPQueueManager
queueManager, UnknownIndexList uIndexList, IndexTree tree, IndexCategory
target, String name) {
if (target == null)
target = tree.getRoot();
- IndexCategory newCat = new IndexCategory(db, queueManager, -2,
target, name);
+ IndexCategory newCat = new IndexCategory(db, queueManager,
uIndexList, -2, target, name);
newCat.create();
@@ -427,7 +437,7 @@
public static class IndexDownloader extends BasicIndexAction implements
Runnable {
public IndexDownloader(AbstractButton actionSource) {
- super(null, null, null, actionSource);
+ super(null, null, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -449,7 +459,7 @@
public static class IndexUploader extends BasicIndexAction implements
Runnable {
public IndexUploader(AbstractButton actionSource) {
- super(null, null, null, actionSource);
+ super(null, null, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -471,7 +481,7 @@
public static class PublicKeyCopier extends BasicIndexAction {
public PublicKeyCopier(AbstractButton actionSource) {
- super(null, null, null, actionSource);
+ super(null, null, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -498,7 +508,7 @@
public static class PrivateKeyCopier extends BasicIndexAction {
public PrivateKeyCopier(AbstractButton actionSource) {
- super(null, null, null, actionSource);
+ super(null, null, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -527,7 +537,7 @@
*/
public static class IndexRenamer extends BasicIndexAction {
public IndexRenamer(IndexTree tree, AbstractButton
actionSource) {
- super(null, null, tree, actionSource);
+ super(null, null, null, tree, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -570,7 +580,7 @@
*/
public static class IndexDeleter extends BasicIndexAction {
public IndexDeleter(IndexTree tree, AbstractButton
actionSource) {
- super(null, null, tree, actionSource);
+ super(null, null, null, tree, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -605,7 +615,7 @@
public static class FileInserterAndAdder extends BasicIndexAction {
public FileInserterAndAdder(Hsqldb db, FCPQueueManager
queueManager, AbstractButton actionSource) {
- super(db, queueManager, null, actionSource);
+ super(db, queueManager, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -634,7 +644,7 @@
public static class FileAdder extends BasicIndexAction {
public FileAdder(Hsqldb db, FCPQueueManager queueManager,
AbstractButton actionSource) {
- super(db, queueManager, null, actionSource);
+ super(db, queueManager, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -707,7 +717,7 @@
private JFrame frame = null;
public KeyAdder(Hsqldb db, AbstractButton actionSource) {
- super(db, null, null, actionSource);
+ super(db, null, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
@@ -804,7 +814,7 @@
private JFrame frame = null;
public LinkAdder(Hsqldb db, AbstractButton actionSource) {
- super(db, null, null, actionSource);
+ super(db, null, null, null, actionSource);
}
public void setTarget(IndexTreeNode node) {
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java 2006-12-02
22:20:34 UTC (rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexSelecter.java 2006-12-03
01:10:09 UTC (rev 11207)
@@ -68,7 +68,7 @@
upPanel = new JPanel();
Logger.info(this, "indexes");
- indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.yourIndexes"), true, null, db);
+ indexTree = new
IndexTree(I18n.getMessage("thaw.plugin.index.yourIndexes"), true, null, null,
db);
Logger.info(this, "plus indexes");
fieldPanel = new JPanel();
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-02
22:20:34 UTC (rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2006-12-03
01:10:09 UTC (rev 11207)
@@ -102,17 +102,20 @@
private DefaultTreeModel treeModel;
+ private UnknownIndexList uIndexList;
+
private Hsqldb db;
private FCPQueueManager queueManager;
-
/**
* @param queueManager Not used if selectionOnly is set to true
*/
public IndexTree(String rootName,
boolean selectionOnly,
FCPQueueManager queueManager,
+ UnknownIndexList uIndexList,
Hsqldb db) {
+ this.uIndexList = uIndexList;
this.queueManager = queueManager;
this.db = db;
@@ -122,7 +125,7 @@
panel.setLayout(new BorderLayout(10, 10));
- root = new IndexCategory(db, queueManager, -1, null, rootName);
+ root = new IndexCategory(db, queueManager, uIndexList, -1,
null, rootName);
root.loadChildren();
root.addObserver(this);
@@ -167,15 +170,15 @@
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.addAlreadyExistingIndex"));
indexCategoryMenu.add(item);
- indexCategoryActions.add(new
IndexManagementHelper.IndexReuser(db, queueManager, this, item));
+ indexCategoryActions.add(new
IndexManagementHelper.IndexReuser(db, queueManager, uIndexList, this, item));
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.addCategory"));
indexCategoryMenu.add(item);
- indexCategoryActions.add(new
IndexManagementHelper.IndexCategoryAdder(db, queueManager, this, item));
+ indexCategoryActions.add(new
IndexManagementHelper.IndexCategoryAdder(db, queueManager, uIndexList, this,
item));
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.createIndex"));
indexCategoryMenu.add(item);
- indexCategoryActions.add(new
IndexManagementHelper.IndexCreator(db, queueManager, this, item));
+ indexCategoryActions.add(new
IndexManagementHelper.IndexCreator(db, queueManager, uIndexList, this, item));
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.rename"));
indexCategoryMenu.add(item);
@@ -338,10 +341,14 @@
if(path == null)
return;
- this.selectedNode =
(IndexTreeNode)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
+ selectedNode =
(IndexTreeNode)((DefaultMutableTreeNode)path.getLastPathComponent()).getUserObject();
- this.setChanged();
- this.notifyObservers(this.selectedNode);
+ if (uIndexList != null && selectedNode instanceof Index) {
+ uIndexList.addLinks(((Index)selectedNode));
+ }
+
+ setChanged();
+ notifyObservers(this.selectedNode);
}
public IndexTreeNode getSelectedNode() {
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Link.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2006-12-02 22:20:34 UTC
(rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Link.java 2006-12-03 01:10:09 UTC
(rev 11207)
@@ -68,6 +68,28 @@
return key;
}
+ public boolean compare(Link l) {
+ if (l == null
+ || getPublicKey() == null
+ || l.getPublicKey() == null
+ || getPublicKey().length() < 40
+ || l.getPublicKey().length() < 40)
+ return false;
+
+ return (l.getPublicKey().substring(0,
40).equals(getPublicKey().substring(0, 40)));
+ }
+
+ public boolean compare(Index l) {
+ if (l == null
+ || getPublicKey() == null
+ || l.getPublicKey() == null
+ || getPublicKey().length() < 40
+ || l.getPublicKey().length() < 40)
+ return false;
+
+ return (l.getPublicKey().substring(0,
40).equals(getPublicKey().substring(0, 40)));
+ }
+
public void setParent(Index index) {
parent = index;
}
@@ -84,9 +106,13 @@
}
public String getIndexName() {
- return this.indexName;
+ return indexName;
}
+ public String toString() {
+ return getIndexName();
+ }
+
public void setIndexKey(String key) {
this.key = key;
@@ -140,7 +166,33 @@
}
+ 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(0, 40)+"%");
+
+ if(st.execute()) {
+ ResultSet result = st.getResultSet();
+ if (result != null && result.next()) {
+ return true;
+ }
+ }
+
+ } catch(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 (this.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-02 22:20:34 UTC (rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkManagementHelper.java
2006-12-03 01:10:09 UTC (rev 11207)
@@ -85,18 +85,22 @@
private Hsqldb db;
private FCPQueueManager queueManager;
private IndexTree tree;
+ private UnknownIndexList uil;
private AbstractButton src;
private Vector t;
public IndexAdder(AbstractButton actionSource,
- Hsqldb db, FCPQueueManager queueManager,
IndexTree tree) {
+ Hsqldb db, FCPQueueManager queueManager,
+ UnknownIndexList uil,
+ IndexTree tree) {
src = actionSource;
if (actionSource != null)
actionSource.addActionListener(this);
this.db = db;
this.queueManager = queueManager;
this.tree = tree;
+ this.uil = uil;
}
public void setTarget(Vector targets) {
@@ -108,7 +112,7 @@
for (Iterator it = t.iterator();
it.hasNext(); ) {
Link link = (Link)it.next();
- IndexManagementHelper.addIndex(db,
queueManager, tree, null,
+ IndexManagementHelper.addIndex(db,
queueManager, uil, tree, null,
link.getPublicKey());
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2006-12-02
22:20:34 UTC (rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/LinkTable.java 2006-12-03
01:10:09 UTC (rev 11207)
@@ -54,7 +54,7 @@
private int[] selectedRows;
- public LinkTable (Hsqldb db, FCPQueueManager queueManager, IndexTree
tree, Tables tables) {
+ public LinkTable (Hsqldb db, FCPQueueManager queueManager,
UnknownIndexList uil, IndexTree tree, Tables tables) {
this.queueManager = queueManager;
this.db = db;
@@ -80,7 +80,7 @@
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.addIndexesFromLink"));
rightClickMenu.add(item);
- rightClickActions.add(new LinkManagementHelper.IndexAdder(item,
db, queueManager, tree));
+ rightClickActions.add(new LinkManagementHelper.IndexAdder(item,
db, queueManager, uil, tree));
item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.copyKeys"));
rightClickMenu.add(item);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Tables.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Tables.java 2006-12-02 22:20:34 UTC
(rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Tables.java 2006-12-03 01:10:09 UTC
(rev 11207)
@@ -22,14 +22,14 @@
private JSplitPane split;
private Config config;
- public Tables(boolean modifiables, Hsqldb db, FCPQueueManager
queueManager, IndexTree tree, Config config) {
+ public Tables(boolean modifiables, Hsqldb db, FCPQueueManager
queueManager, UnknownIndexList uil, IndexTree tree, Config config) {
this.config = config;
this.panel = new JPanel();
this.panel.setLayout(new BorderLayout(10, 10));
this.fileTable = new FileTable(queueManager, tree, config,
this);
- this.linkTable = new LinkTable(db, queueManager, tree, this);
+ this.linkTable = new LinkTable(db, queueManager, uil, tree,
this);
this.searchBar = new SearchBar(db, tree, queueManager, this);
Added: trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
2006-12-02 22:20:34 UTC (rev 11206)
+++ trunk/apps/Thaw/src/thaw/plugins/index/UnknownIndexList.java
2006-12-03 01:10:09 UTC (rev 11207)
@@ -0,0 +1,196 @@
+package thaw.plugins.index;
+
+import javax.swing.JPanel;
+import javax.swing.JList;
+import javax.swing.JLabel;
+import javax.swing.JScrollPane;
+import java.awt.BorderLayout;
+
+import java.awt.event.MouseListener;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JPopupMenu;
+import javax.swing.JMenuItem;
+
+import java.util.Vector;
+import java.util.Iterator;
+
+import thaw.core.*;
+import thaw.plugins.Hsqldb;
+import thaw.fcp.FCPQueueManager;
+
+public class UnknownIndexList implements MouseListener {
+ public final static int MAX_INDEXES = 50;
+
+ private int offset;
+
+ private Link[] linkList;
+ private boolean full;
+ private Vector vList; /* only when < 50 */
+
+ private JPanel panel;
+ private JList list;
+
+ private JScrollPane scrollPane;
+
+ private JPopupMenu rightClickMenu = null;
+ private Vector rightClickActions = null;
+
+ private Hsqldb db;
+ private FCPQueueManager queueManager;
+ private IndexTree indexTree;
+
+ public UnknownIndexList(Hsqldb db, FCPQueueManager queueManager) {
+ this.db = db;
+ this.queueManager = queueManager;
+
+ offset = 0;
+ full = false;
+ vList = new Vector();
+ linkList = new Link[MAX_INDEXES];
+
+ for(int i = 0 ; i < linkList.length ; i++)
+ linkList[i] = null;
+
+ list = new JList(vList);
+
+
list.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+
+ panel = new JPanel(new BorderLayout());
+ panel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.unknownIndexes")),
+ BorderLayout.NORTH);
+ scrollPane = new JScrollPane(list);
+ panel.add(scrollPane);
+
+ list.addMouseListener(this);
+ }
+
+ public void setIndexTree(IndexTree tree) {
+ this.indexTree = tree;
+ }
+
+ public JPanel getPanel() {
+ return panel;
+ }
+
+ public boolean isInList(Link l) {
+ if (l == null)
+ return false;
+
+ for (int i = 0 ; i < linkList.length ; i++) {
+ if (l.compare(linkList[i]))
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean removeLink(Index index) {
+ boolean ret = false;
+
+ for (int i = 0 ; i < linkList.length ; i++) {
+ if (linkList[i] != null && linkList[i].compare(index)) {
+ if (!full)
+ vList.remove(linkList[i]);
+ linkList[i] = null;
+ ret = true;
+ }
+ }
+
+ return ret;
+ }
+
+ /**
+ * will check that the link link to an unknown index before adding
+ */
+ public boolean addLink(Link link) {
+ if (link == null || link.isIndexAlreadyKnown() ||
isInList(link))
+ return false;
+
+ linkList[linkList.length - 1 - offset] = link;
+
+ if (!full) {
+ vList.add(0, link);
+ list.setListData(vList);
+ } else {
+ list.setListData(linkList);
+ }
+
+ offset++;
+
+ if (offset >= MAX_INDEXES) {
+ offset = 0;
+ full = true;
+ }
+
+ return true;
+ }
+
+ /**
+ * will add the link from that index (if links link to unknown indexes)
+ */
+ public boolean addLinks(Index index) {
+ boolean ret = false;
+
+ Vector ll = index.getLinkList();
+
+ if (ll == null || ll.size() == 0)
+ return false;
+
+ for (Iterator it = ll.iterator();
+ it.hasNext();) {
+ if (addLink(((Link)it.next())))
+ ret = true;
+ }
+
+ return ret;
+ }
+
+
+ protected void updateRightClickMenu() {
+ if (rightClickMenu == null) {
+ rightClickMenu = new JPopupMenu();
+ rightClickActions = new Vector();
+ JMenuItem item;
+
+ item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.addIndexesFromLink"));
+ rightClickMenu.add(item);
+ rightClickActions.add(new
LinkManagementHelper.IndexAdder(item, db, queueManager, this, indexTree));
+
+ item = new
JMenuItem(I18n.getMessage("thaw.plugin.index.copyKeys"));
+ rightClickMenu.add(item);
+ rightClickActions.add(new
LinkManagementHelper.PublicKeyCopier(item));
+ }
+
+ Object[] sLink = list.getSelectedValues();
+ Vector vLink = new Vector();
+
+ for (int i = 0; i < sLink.length ; i++)
+ vLink.add(sLink[i]);
+
+ LinkManagementHelper.LinkAction action;
+
+ for(Iterator it = rightClickActions.iterator();
+ it.hasNext(); ) {
+ action = (LinkManagementHelper.LinkAction)it.next();
+ action.setTarget(vLink);
+ }
+ }
+
+
+ public void mouseClicked(MouseEvent e) {
+ if(e.getButton() == MouseEvent.BUTTON3
+ && this.linkList != null) {
+ updateRightClickMenu();
+ rightClickMenu.show(e.getComponent(), e.getX(),
e.getY());
+ }
+ }
+
+ public void mouseEntered(MouseEvent e) { }
+
+ public void mouseExited(MouseEvent e) { }
+
+ public void mousePressed(MouseEvent e) { }
+
+ public void mouseReleased(MouseEvent e) { }
+}