Author: jflesch
Date: 2007-04-19 16:12:47 +0000 (Thu, 19 Apr 2007)
New Revision: 12802
Modified:
trunk/apps/Thaw/src/thaw/fcp/FreenetURIHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java
trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.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/IndexTreeNode.java
Log:
Thaw can now fetch the comments (but is still unable to display them)
Modified: trunk/apps/Thaw/src/thaw/fcp/FreenetURIHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FreenetURIHelper.java 2007-04-18 22:45:49 UTC
(rev 12801)
+++ trunk/apps/Thaw/src/thaw/fcp/FreenetURIHelper.java 2007-04-19 16:12:47 UTC
(rev 12802)
@@ -165,7 +165,7 @@
}
- protected static String changeRev(final String revStr, final int rev,
final int offset) {
+ private static String changeRev(final String revStr, final int rev,
final int offset) {
if (offset == 0)
return Integer.toString(rev);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-04-18
22:45:49 UTC (rev 12801)
+++ trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-04-19
16:12:47 UTC (rev 12802)
@@ -82,6 +82,11 @@
public int updateNext(int lastIdx) {
+ if (browserPanel.getIndexTree().numberOfUpdatingIndexes() >=
nmbIndexesPerInterval) {
+ Logger.notice(this, "Too many indexes are updating ;
won't auto-update another one");
+ return lastIdx;
+ }
+
try {
Connection c = db.getConnection();
PreparedStatement st;
@@ -118,7 +123,7 @@
results.getInt("revision"),
results.getString("privateKey"),
results.getString("displayName"),
- false);
+ false, false);
index.downloadFromFreenet(this,
browserPanel.getIndexTree(), queueManager);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Comment.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-18 22:45:49 UTC
(rev 12801)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Comment.java 2007-04-19 16:12:47 UTC
(rev 12802)
@@ -43,6 +43,13 @@
import javax.xml.parsers.SAXParser;
+
+/* SQL */
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
/* Thaw */
import thaw.core.Config;
@@ -54,19 +61,26 @@
import thaw.fcp.FCPClientPut;
import thaw.fcp.FCPQueueManager;
+import thaw.plugins.Hsqldb;
+
/**
* Will use, from the configuration:
* 'userNickname' as the author name
*/
-public class Comment implements Observer {
+public class Comment extends Observable implements Observer {
public final static int MAX_SIZE = 16384;
private String author;
private String comment;
+
private Index index;
+ private Hsqldb db;
+
private int rev;
+ private boolean newComment = false;
+
private Comment() {
}
@@ -77,13 +91,20 @@
* @param rev revision of the comment (-1) if not inserted at the moment
* @param comment comment inside the comment ... :)
*/
- public Comment(Index index, int rev, String author, String comment) {
+ public Comment(Hsqldb db, Index index, int rev, String author, String
comment) {
+ this.db = db;
this.author = author;
this.comment = comment;
this.index = index;
this.rev = rev;
}
+
+ public JPanel createPanel() {
+
+ }
+
+
/**
* Will write it in a temporary file
*/
@@ -198,18 +219,230 @@
2, false, 0);
put.addObserver(this);
- return queueManager.addQueryToTheRunningQueue(put, false);
+ return queueManager.addQueryToTheRunningQueue(put, true);
}
+
+ protected class CommentHandler extends DefaultHandler {
+ private Locator locator = null;
+
+ public CommentHandler() {
+
+ }
+
+ /**
+ * @see
org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
+ */
+ public void setDocumentLocator(Locator value) {
+ locator = value;
+ }
+
+
+ /**
+ * Called when parsing is started
+ * @see org.xml.sax.ContentHandler#startDocument()
+ */
+ public void startDocument() throws SAXException {
+
+ }
+
+
+ /**
+ * Called when starting to parse in a specific name space
+ * @param prefix name space prefix
+ * @param URI name space URI
+ * @see
org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String,
java.lang.String)
+ */
+ public void startPrefixMapping(String prefix, String URI)
throws SAXException {
+ /* \_o< */
+ }
+
+ /**
+ * @param prefix name space prefix
+ * @see
org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
+ */
+ public void endPrefixMapping(String prefix) throws SAXException
{
+ /* \_o< */
+ }
+
+
+ private boolean authorTag;
+ private boolean textTag;
+
+
+ /**
+ * Called when the parsed find an opening tag
+ * @param localName local tag name
+ * @param rawName rawName (the one used here)
+ * @see
org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String,
java.lang.String, org.xml.sax.Attributes)
+ */
+ public void startElement(String nameSpaceURI, String localName,
+ String rawName, Attributes attrs)
throws SAXException {
+ if (rawName == null) {
+ rawName = localName;
+ }
+
+ if (rawName == null)
+ return;
+
+ if ("author".equals(rawName))
+ authorTag = true;
+
+ if ("text".equals(rawName))
+ textTag = true;
+ }
+
+
+ /**
+ * Called when a closing tag is met
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
java.lang.String, java.lang.String)
+ */
+ public void endElement(String nameSpaceURI, String localName,
+ String rawName) throws SAXException {
+ if (rawName == null) {
+ rawName = localName;
+ }
+
+ if (rawName == null)
+ return;
+
+ if ("author".equals(rawName))
+ authorTag = false;
+
+ if ("text".equals(rawName))
+ textTag = false;
+ }
+
+ /**
+ * Called when a text between two tag is met
+ * @param ch text
+ * @param start position
+ * @param end position
+ * @see org.xml.sax.ContentHandler#characters(char[], int, int)
+ */
+ public void characters(char[] ch, int start, int end) throws
SAXException {
+ String txt = new String(ch, start, end);
+
+ if (authorTag) author = txt;
+ if (textTag) comment = txt;
+ }
+
+ public void ignorableWhitespace(char[] ch, int start, int end)
throws SAXException {
+
+ }
+
+ public void processingInstruction(String target, String data)
throws SAXException {
+
+ }
+
+ /**
+ * @see
org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
+ */
+ public void skippedEntity(String arg0) throws SAXException {
+
+ }
+
+ /**
+ * Called when parsing is finished
+ * @see org.xml.sax.ContentHandler#endDocument()
+ */
+ public void endDocument() throws SAXException {
+
+ }
+ }
+
+
+ /**
+ * @return false if already in the bdd or if there is any error
+ */
public boolean parseComment(java.io.File xmlFile) {
+ Logger.info(this, "Parsing comment ...");
+ FileInputStream in;
+
+ try {
+ in = new FileInputStream(xmlFile);
+ } catch(final java.io.FileNotFoundException e) {
+ Logger.error(this, "Unable to load XML:
FileNotFoundException ('"+xmlFile.getPath()+"') ! : "+e.toString());
+ return false;
+ }
+
+ CommentHandler handler = new CommentHandler();
+
+ try {
+ // Use the default (non-validating) parser
+ SAXParserFactory factory =
SAXParserFactory.newInstance();
+
+ // Parse the input
+ SAXParser saxParser = factory.newSAXParser();
+ saxParser.parse(in, handler);
+ } catch(javax.xml.parsers.ParserConfigurationException e) {
+ Logger.error(this, "Error (1) while parsing index:
"+e.toString());
+ } catch(org.xml.sax.SAXException e) {
+ Logger.error(this, "Error (2) while parsing index:
"+e.toString());
+ } catch(java.io.IOException e) {
+ Logger.error(this, "Error (3) while parsing index:
"+e.toString());
+ }
+
+ if (comment != null && author != null) {
+ Logger.info(this, "Parsing done");
+
+ try {
+ synchronized(db.dbLock) {
+ PreparedStatement st;
+
+ st =
db.getConnection().prepareStatement("SELECT id FROM indexComments "+
+
"WHERE indexId = ? AND author = ? "+
+
"AND text = ?");
+
+ st.setInt(1, index.getId());
+ st.setString(2, author);
+ st.setString(3, comment);
+
+ ResultSet set = st.executeQuery();
+
+ if (set.next()) {
+ Logger.debug(this, "Comment
already in db");
+ return false;
+ }
+
+ newComment = true;
+
+ st =
db.getConnection().prepareStatement("INSERT INTO indexComments "+
+
"(author, text, rev, indexId) "+
+
"VALUES (?, ?, ?, ?)");
+ st.setString(1, author);
+ st.setString(2, comment);
+ st.setInt(3, rev);
+ st.setInt(4, index.getId());
+
+ st.execute();
+
+ return true;
+ }
+ } catch(SQLException e) {
+ Logger.error(this, "Unable to add comment in
the db because: "+e.toString());
+ }
+ }
+
return false;
}
+ public boolean exists() {
+ return (comment != null && author != null);
+ }
+
+ public boolean isNew() {
+ return newComment;
+ }
+
+
public boolean fetchComment(FCPQueueManager queueManager) {
+ newComment = false;
+
this.queueManager = queueManager;
String publicKey = index.getCommentPublicKey(); /* should be an
SSK */
@@ -230,6 +463,8 @@
public void update(Observable o, Object param) {
if (o instanceof FCPTransferQuery) {
+ if (((FCPTransferQuery)o).isFinished())
+ ((Observable)o).deleteObserver(this);
if (o instanceof FCPClientPut) {
FCPClientPut put = (FCPClientPut)o;
@@ -247,6 +482,7 @@
if (get.isFinished() && get.isSuccessful()) {
parseComment(new
java.io.File(get.getPath()));
}
+
}
FCPTransferQuery q = ((FCPTransferQuery)o);
@@ -257,6 +493,11 @@
file.delete();
}
+ if (q.isFinished()) {
+ setChanged();
+ notifyObservers();
+ }
+
}
if (o instanceof FCPTransferQuery) {
Modified: trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-04-18
22:45:49 UTC (rev 12801)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DetailPanel.java 2007-04-19
16:12:47 UTC (rev 12802)
@@ -14,6 +14,8 @@
import thaw.core.Logger;
import thaw.core.Config;
+import thaw.gui.IconBox;
+
import thaw.fcp.FCPQueueManager;
@@ -37,11 +39,13 @@
buttonActions = new Vector(2);
JButton button;
- button = new
JButton(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
"0"));
+ button = new
JButton(I18n.getMessage("thaw.plugin.index.comment.comments").replaceAll("\\?",
"0"),
+ IconBox.minReadComments);
buttonActions.add(new
IndexManagementHelper.IndexCommentViewer(button));
buttonPanel.add(button);
- button = new
JButton(I18n.getMessage("thaw.plugin.index.comment.add"));
+ button = new
JButton(I18n.getMessage("thaw.plugin.index.comment.add"),
+ IconBox.minAddComment);
buttonActions.add(new
IndexManagementHelper.IndexCommentAdder(config, queueManager, indexBrowser,
button));
buttonPanel.add(button);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-18 22:45:49 UTC
(rev 12801)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-04-19 16:12:47 UTC
(rev 12802)
@@ -83,12 +83,19 @@
private int rev = -1;
private String displayName = null;
private boolean hasChanged = false;
+ private boolean newComment = false;
/* loaded only if asked explictly */
private String realName = null;
+ /* when all the comment fetching will failed,
+ loading will stop */
+ public final static int COMMENT_FETCHING_RUNNING_AT_THE_SAME_TIME = 5;
+ private int lastCommentRev = 0;
+ private int nmbFailedCommentFetching = 0;
+
/**
* @deprecated Just don't use it !
*/
@@ -104,7 +111,7 @@
/**
* Use it when you can have these infos easily ; else let the index do
the job
*/
- public Index(Hsqldb db, int id, TreeNode parentNode, String publicKey,
int rev, String privateKey, String displayName, boolean hasChanged) {
+ public Index(Hsqldb db, int id, TreeNode parentNode, String publicKey,
int rev, String privateKey, String displayName, boolean hasChanged, boolean
newComment) {
this(db, id);
this.parentNode = parentNode;
this.privateKey = privateKey;
@@ -112,6 +119,7 @@
this.rev = rev;
this.displayName = displayName;
this.hasChanged = hasChanged;
+ this.newComment = newComment;
}
@@ -711,12 +719,15 @@
* if true, when the transfer will finish, the index public key will be
updated
*/
private boolean rewriteKey = true;
+ private FCPQueueManager queueManager;
public int downloadFromFreenet(Observer o, IndexTree tree,
FCPQueueManager queueManager, int specificRev) {
FCPClientGet clientGet;
String publicKey;
+ this.queueManager = queueManager;
+
int rev = getRevision();
indexTree = tree;
@@ -758,6 +769,19 @@
rewriteKey = false;
Logger.info(this, "Updating index ...");
+
+ /*
+ if (key.startsWith("USK")) {
+ int negRev = 0;
+
+ if ((negRev = FreenetURIHelper.getUSKRevision(key)) >
0) {
+ negRev = -1 * negRev;
+ key = FreenetURIHelper.changeUSKRevision(key,
negRev, 0);
+ }
+ }
+ */
+
+
Logger.debug(this, "Key asked: "+key);
@@ -806,16 +830,56 @@
if (path != null) {
loadXML(path);
+
+ if (getCommentPublicKey() != null)
+ loadComments(queueManager);
+ else if (indexTree != null)
+
indexTree.removeUpdatingIndex(this);
} else
Logger.error(this, "No path specified
in transfer ?!");
}
}
+ if (o instanceof FCPClientPut) {
+ /* TODO : check if it's successful, else merge if it's
due to a collision */
- /* nothing special to do if it is an insert */
- /* TODO : check if it's successful, else merge if it's due to a
collision */
+ if (indexTree != null)
+ indexTree.removeUpdatingIndex(this);
+ }
+ if (o instanceof Comment) {
+ Comment c = (Comment)o;
+
+ if (c.exists()) {
+ nmbFailedCommentFetching = 0;
+
+ if (c.isNew()) {
+ setNewCommentFlag(true);
+
+ setChanged();
+ notifyObservers();
+ }
+
+ } else {
+ nmbFailedCommentFetching++;
+ }
+
+ if (nmbFailedCommentFetching >
COMMENT_FETCHING_RUNNING_AT_THE_SAME_TIME +1) {
+ if (indexTree != null) {
+ Logger.info(this, "All the comments
should be fetched");
+ indexTree.removeUpdatingIndex(this);
+ }
+ }
+ else {
+ lastCommentRev++;
+ Comment comment = new Comment(db, this,
lastCommentRev, null, null);
+ comment.addObserver(this);
+ comment.fetchComment(queueManager);
+ }
+
+ }
+
if (o instanceof FCPTransferQuery) {
FCPTransferQuery transfer = (FCPTransferQuery)o;
@@ -1322,6 +1386,13 @@
*/
public void endElement(String nameSpaceURI, String localName,
String rawName) throws SAXException {
+ if (rawName == null) {
+ rawName = localName;
+ }
+
+ if (rawName == null)
+ return;
+
if ("owner".equals(rawName)) {
ownerTag = false;
return;
@@ -1513,13 +1584,27 @@
return hasChanged;
}
+ public boolean hasNewComment() {
+ if (publicKey == null) {
+ Logger.debug(this, "hasNewComment() => loadData()");
+ loadData();
+ }
+ return newComment;
+ }
+
+
public boolean setHasChangedFlagInMem(boolean flag) {
hasChanged = flag;
return true;
}
+ public boolean setNewCommentFlagInMem(boolean flag) {
+ newComment = flag;
+ return true;
+ }
+
/**
* @return true if a change was done
*/
@@ -1547,6 +1632,33 @@
}
+ /**
+ * @return true if a change was done
+ */
+ public boolean setNewCommentFlag(boolean flag) {
+ setNewCommentFlagInMem(flag);
+
+ synchronized(db.dbLock) {
+ try {
+ PreparedStatement st;
+
+ st =
db.getConnection().prepareStatement("UPDATE indexes SET newComment = ? "+
+ "WHERE
id = ?");
+
+ st.setBoolean(1, flag);
+ st.setInt(2, id);
+ if (st.executeUpdate() > 0)
+ return true;
+ return false;
+ } catch(SQLException e) {
+ Logger.error(this, "Unable to change
'newComment' flag because: "+e.toString());
+ }
+ }
+
+ return false;
+ }
+
+
public Element do_export(Document xmlDoc, boolean withContent) {
Element e = xmlDoc.createElement("fullIndex");
@@ -1706,8 +1818,29 @@
return false;
}
- Comment comment = new Comment(this, -1, author, msg);
+ Comment comment = new Comment(db, this, -1, author, msg);
return comment.insertComment(queueManager);
}
+
+
+ public void loadComments(FCPQueueManager queueManager) {
+ String pubKey;
+
+ if ((pubKey = getCommentPublicKey()) == null)
+ return;
+
+ if (queueManager == null) {
+ Logger.warning(this, "Can't load comments !
QueueManager is not set for this index !");
+ return;
+ }
+
+ for (lastCommentRev = 0 ;
+ lastCommentRev < COMMENT_FETCHING_RUNNING_AT_THE_SAME_TIME;
+ lastCommentRev++) {
+ Comment comment = new Comment(db, this, lastCommentRev,
null, null);
+ comment.addObserver(this);
+ comment.fetchComment(queueManager);
+ }
+ }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java 2007-04-18
22:45:49 UTC (rev 12801)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java 2007-04-19
16:12:47 UTC (rev 12802)
@@ -79,7 +79,8 @@
else
n = new Index(db, set.getInt("id"), this,
set.getString("publicKey"),
set.getInt("revision"),
set.getString("privateKey"),
- set.getString("displayName"),
set.getBoolean("newRev"));
+ set.getString("displayName"),
set.getBoolean("newRev"),
+ set.getBoolean("newComment"));
int pos = set.getInt("positionInTree");
@@ -134,11 +135,11 @@
if (id >= 0) {
- st =
db.getConnection().prepareStatement("SELECT id, positionInTree, displayName,
publicKey, privateKey, revision, newRev FROM indexes "
+ st =
db.getConnection().prepareStatement("SELECT id, positionInTree, displayName,
publicKey, privateKey, revision, newRev, newComment FROM indexes "
+ "WHERE parent = ? ORDER BY positionInTree");
st.setInt(1, id);
} else {
- st =
db.getConnection().prepareStatement("SELECT id, positionInTree, displayName,
publicKey, privateKey, revision, newRev FROM indexes "
+ st =
db.getConnection().prepareStatement("SELECT id, positionInTree, displayName,
publicKey, privateKey, revision, newRev, newComment FROM indexes "
+ "WHERE parent IS NULL ORDER BY positionInTree");
}
@@ -1131,6 +1132,38 @@
return true;
}
+
+
+ public boolean setNewCommentFlag(boolean flag) {
+ setNewCommentFlagInMem(flag);
+
+ synchronized(db.dbLock) {
+ try {
+ PreparedStatement st;
+ if (id > 0) {
+ st =
db.getConnection().prepareStatement("UPDATE indexes "+
+
"SET newComment = ? "+
+
"WHERE id IN "+
+
"(SELECT indexParents.indexId FROM indexParents WHERE indexParents.folderId =
?)");
+ st.setInt(2, id);
+ } else {
+ st =
db.getConnection().prepareStatement("UPDATE indexes "+
+
"SET newComment = ?");
+ }
+ st.setBoolean(1, flag);
+
+ st.execute();
+ } catch(SQLException e) {
+ Logger.error(this, "Error while changing
'newComment' flag: "+e.toString());
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+
public boolean setHasChangedFlagInMem(boolean flag) {
if (children != null) {
@@ -1147,7 +1180,24 @@
return true;
}
+ public boolean setNewCommentFlagInMem(boolean flag) {
+ if (children != null) {
+ synchronized(children) {
+ for (Iterator it = children.iterator();
+ it.hasNext();) {
+ IndexTreeNode child =
(IndexTreeNode)it.next();
+
+ child.setNewCommentFlagInMem(flag);
+ }
+ }
+ }
+
+ return true;
+ }
+
+
+
private boolean lastHasChangedValue = false;
private boolean hasLastHasChangedValueBeenSet = false;
@@ -1166,6 +1216,7 @@
hasChanged();
}
+
public boolean hasChanged() {
if (children != null) {
@@ -1214,6 +1265,58 @@
return false;
}
+
+
+ public boolean hasNewComment() {
+ if (children != null) {
+
+ synchronized(children) {
+ for (Iterator it = children.iterator();
+ it.hasNext();) {
+ IndexTreeNode child =
(IndexTreeNode)it.next();
+
+ if (child.hasNewComment())
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ /* It's dirty and will probably cause graphical bug :/ */
+ if (hasLastHasChangedValueBeenSet)
+ return lastHasChangedValue;
+
+ synchronized(db.dbLock) {
+ try {
+ PreparedStatement st;
+
+ st =
db.getConnection().prepareStatement("SELECT indexes.id "+
+ "FROM
indexes JOIN indexParents ON indexes.id = indexParents.indexId "+
+ "WHERE
indexParents.folderId = ? AND indexes.newComment = TRUE LIMIT 1");
+ st.setInt(1, id);
+
+ ResultSet set = st.executeQuery();
+
+ boolean ret;
+
+ ret = set.next();
+
+ lastHasChangedValue = ret;
+ hasLastHasChangedValueBeenSet = true;
+
+ return ret;
+
+ } catch(SQLException e) {
+ Logger.error(this, "Error while trying to see
if there is any new comment: "+e.toString());
+ }
+ }
+
+ return false;
+ }
+
+
+
/**
* Will export private keys too !<br/>
* TODO: Improve perfs
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-04-18 22:45:49 UTC (rev 12801)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-04-19 16:12:47 UTC (rev 12802)
@@ -194,7 +194,7 @@
"(id, originalName, displayName, "+
" publicKey, privateKey, author, "+
" positionInTree, revision, "+
-
" newRev, parent) "+
+
" newRev, newComment, parent) "+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
/* TODO : Author */
@@ -214,17 +214,18 @@
st.setInt(7, 0 /* positionInTree */);
st.setInt(8, 0 /* revision */);
st.setBoolean(9, false);
+ st.setBoolean(10, false);
if (getTarget().getId() >= 0)
- st.setInt(10,
getTarget().getId());
+ st.setInt(11,
getTarget().getId());
else
- st.setNull(10, Types.INTEGER);
+ st.setNull(11, Types.INTEGER);
st.execute();
Index index = new Index(db, id,
(TreeNode)getTarget(),
sskGenerator.getPublicKey(), 0, sskGenerator.getPrivateKey(),
- name, false);
+ name, false,
false);
((MutableTreeNode)getTarget()).insert((index), 0);
@@ -626,7 +627,7 @@
index = new Index(db, id, parent,
publicKey, revision,
privateKey,
- name, false);
+ name, false, false);
} catch(SQLException e) {
Logger.error(new IndexManagementHelper(),
"Error while adding index: "+e.toString());
@@ -731,6 +732,7 @@
public void apply() {
getTarget().setHasChangedFlag(false);
+ getTarget().setNewCommentFlag(false);
getIndexBrowserPanel().getIndexTree().redraw(getTarget());
}
}
@@ -1563,8 +1565,8 @@
I18n.getMessage("thaw.plugin.index.comment.add"));
JLabel headerLabel = new
JLabel(I18n.getMessage("thaw.plugin.index.comment.comment"),
- IconBox.addComment,
- JLabel.LEFT);
+ IconBox.addComment,
+ JLabel.CENTER);
JPanel authorPanel = new JPanel(new BorderLayout(5, 5));
authorPanel.add(new
JLabel(I18n.getMessage("thaw.plugin.index.comment.author")),
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-04-18
22:45:49 UTC (rev 12801)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-04-19
16:12:47 UTC (rev 12802)
@@ -472,6 +472,11 @@
((Index)selectedNode).setHasChangedFlag(false);
redraw(path);
}
+
+ if (((Index)selectedNode).hasNewComment()) {
+
((Index)selectedNode).setNewCommentFlag(false);
+ redraw(path);
+ }
}
}
@@ -668,7 +673,7 @@
}
public java.awt.Component getTreeCellRendererComponent(final
JTree tree,
- final
Object value,
+ Object
value,
final
boolean selected,
final
boolean expanded,
final
boolean leaf,
@@ -710,6 +715,7 @@
((IndexTreeNode)o).forceHasChangedReload();
boolean hasChanged =
((IndexTreeNode)o).hasChanged();
+ boolean newComment =
((IndexTreeNode)o).hasNewComment();
int style = 0;
@@ -722,6 +728,9 @@
style = Font.PLAIN;
setFont(new Font("Dialog", style, 12));
+
+ if (newComment)
+ value = o.toString() + "*";
}
}
@@ -817,6 +826,10 @@
updatingIndexes.remove(new Integer(index.getId()));
}
+ public int numberOfUpdatingIndexes() {
+ return updatingIndexes.size();
+ }
+
public boolean isIndexUpdating(Index index) {
return (updatingIndexes.indexOf(new Integer(index.getId())) >=
0);
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java 2007-04-18
22:45:49 UTC (rev 12801)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java 2007-04-19
16:12:47 UTC (rev 12802)
@@ -43,13 +43,18 @@
public String getPrivateKey();
public boolean isModifiable();
+
public boolean hasChanged();
+ public boolean hasNewComment();
+
public boolean setHasChangedFlag(boolean flag);
+ public boolean setNewCommentFlag(boolean flag);
/**
* for internal use only !
*/
public boolean setHasChangedFlagInMem(boolean flag);
+ public boolean setNewCommentFlagInMem(boolean flag);
/**
* Will export private keys too !
@@ -65,5 +70,8 @@
public int downloadFromFreenet(Observer o, IndexTree indexTree,
FCPQueueManager queueManager, int rev);
+ /**
+ * Will also force newComment flag reloading
+ */
public void forceHasChangedReload();
}