Author: fred
Date: 2007-04-25 15:47:59 +0000 (Wed, 25 Apr 2007)
New Revision: 12941
Added:
trunk/freenet/src/freenet/clients/http/staticfiles/icon/cut.png
trunk/freenet/src/freenet/clients/http/staticfiles/icon/paste.png
Removed:
trunk/freenet/src/freenet/clients/http/staticfiles/icon/edit-delete.png
Modified:
trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
Log:
Old bookmarks are now imported in the 'Imported' category. Cut/Paste tools for
the bookmarks editor
Modified: trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
2007-04-25 13:52:23 UTC (rev 12940)
+++ trunk/freenet/src/freenet/clients/http/BookmarkEditorToadlet.java
2007-04-25 15:47:59 UTC (rev 12941)
@@ -30,6 +30,7 @@
private final Node node;
private final NodeClientCore core;
private final BookmarkManager bookmarkManager;
+ private String cutedPath;
BookmarkEditorToadlet(HighLevelSimpleClient client, Node node)
@@ -37,7 +38,8 @@
super(client);
this.node = node;
this.core = node.clientCore;
- this.bookmarkManager = core.bookmarkManager;
+ this.bookmarkManager = core.bookmarkManager;
+ this.cutedPath = "";
}
private void addCategoryToList(BookmarkCategory cat, String path,
HTMLNode list)
@@ -53,6 +55,8 @@
actions.addChild("a", "href", "?action=edit&bookmark="
+ itemPath).addChild("img", new String[] {"src", "alt", "title"}, new String[]
{"/static/icon/edit.png", "edit", "Edit"});
actions.addChild("a", "href", "?action=del&bookmark=" +
itemPath).addChild("img", new String[] {"src", "alt", "title"}, new String[]
{"/static/icon/delete.png", "delete", "Delete"});
+
+ actions.addChild("a", "href", "?action=cut&bookmark=" +
itemPath).addChild("img", new String[] {"src", "alt", "title"}, new String[]
{"/static/icon/cut.png", "cut", "Cut"});
if(i != 0)
actions.addChild("a", "href",
"?action=up&bookmark=" + itemPath).addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/go-up.png", "up", "Go up"});
@@ -80,12 +84,17 @@
actions.addChild("a", "href",
"?action=addItem&bookmark=" + catPath).addChild("img", new String[] {"src",
"alt", "title"}, new String[] {"/static/icon/bookmark-new.png", "add bookmark",
"Add bookmark"});
actions.addChild("a", "href",
"?action=addCat&bookmark=" + catPath).addChild("img", new String[] {"src",
"alt", "title"}, new String[] {"/static/icon/folder-new.png", "add category",
"Add category"});
+
+ actions.addChild("a", "href", "?action=cut&bookmark=" +
catPath).addChild("img", new String[] {"src", "alt", "title"}, new String[]
{"/static/icon/cut.png", "cut", "Cut"});
if(i != 0)
actions.addChild("a", "href",
"?action=up&bookmark=" + catPath).addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/go-up.png", "up", "Go up"});
if(i != cats.size() -1)
actions.addChild("a", "href",
"?action=down&bookmark=" + catPath).addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/go-down.png", "down", "Go down"});
+
+ if(! "".equals(cutedPath) && !
catPath.equals(cutedPath))
+ actions.addChild("a", "href",
"?action=paste&bookmark=" + catPath).addChild("img", new String[] {"src",
"alt", "title"}, new String[] {"/static/icon/paste.png", "paste", "Paste"});
subCat.addChild(actions);
if(cats.get(i).size() != 0)
@@ -101,8 +110,11 @@
HTMLNode actions = new HTMLNode("span", "class", "actions");
actions.addChild("a", "href",
"?action=addItem&bookmark=/").addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/bookmark-new.png", "add bookmark", "Add
bookmark"});
actions.addChild("a", "href",
"?action=addCat&bookmark=/").addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/folder-new.png", "add category", "Add
category"});
+
+ if(! "".equals(cutedPath))
+ actions.addChild("a", "href",
"?action=paste&bookmark=/").addChild("img", new String[] {"src", "alt",
"title"}, new String[] {"/static/icon/paste.png", "paste", "Paste"});
+
root.addChild(actions);
-
addCategoryToList(bookmarkManager.getMainCategory(), "/",
root.addChild("li").addChild("ul"));
return bookmarks;
@@ -144,7 +156,16 @@
confirmForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "hidden", "bookmark", bookmarkPath});
confirmForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "cancel", "Cancel" });
confirmForm.addChild("input", new String[] {
"type", "name", "value" }, new String[] { "submit", "confirmdelete", "Delete"
});
+
+ } else if (action.equals("cut")) {
+
+ cutedPath = bookmarkPath;
+
+ } else if ("paste".equals(action) && !
"".equals(cutedPath)) {
+ bookmarkManager.addBookmark(bookmarkPath,
bookmarkManager.getBookmarkByPath(cutedPath), false);
+ bookmarkManager.removeBookmark(cutedPath, true);
+ cutedPath = "";
} else if (action.equals("edit") ||
action.equals("addItem") || action.equals("addCat")) {
@@ -185,6 +206,13 @@
}
}
+
+ if(! "".equals(cutedPath)) {
+ HTMLNode infoBox =
content.addChild(ctx.getPageMaker().getInfobox("infobox-normal", "Cut/Paste"));
+ infoBox.addChild("#","Click on a paste icon or
cancel.");
+ HTMLNode cancelForm =
ctx.addFormChild(infoBox.addChild("p"), "", "cancelCutForm");
+ cancelForm.addChild("input", new String[] { "type",
"name", "value" }, new String[] { "submit", "cancelCut", "Cancel cut" });
+ }
HTMLNode bookmarksBox =
content.addChild(ctx.getPageMaker().getInfobox("infobox-normal", "My
Bookmarks"));
bookmarksBox.addChild(getBookmarksList());
@@ -221,6 +249,9 @@
HTMLNode successBox =
content.addChild(ctx.getPageMaker().getInfobox("infobox-success", "Delete
succeeded"));
successBox.addChild("p", "The bookmark has been
deleted successfully");
+ } else if (req.isPartSet("cancelCut")) {
+ cutedPath = "";
+
} else if (action.equals("edit") ||
action.equals("addItem") || action.equals("addCat")) {
String name = "unnamed";
Modified: trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
2007-04-25 13:52:23 UTC (rev 12940)
+++ trunk/freenet/src/freenet/clients/http/bookmark/BookmarkManager.java
2007-04-25 15:47:59 UTC (rev 12941)
@@ -184,14 +184,15 @@
for (int i = 0; i < strs.length; i++) {
Matcher matcher = pattern.matcher (strs[i]);
if (matcher.matches () && matcher.groupCount () == 2) {
+ if(getCategoryByPath("/Imported/") == null)
+ addBookmark ("/",new BookmarkCategory("Imported"),
false);
try {
- addBookmark ("/",
+ addBookmark ("/Imported/",
new BookmarkItem (new FreenetURI (matcher.group (1)),
matcher.group (2), node.alerts),
false);
}
- catch (MalformedURLException mue) {
- }
+ catch (MalformedURLException mue) { }
}
else
return false;
Added: trunk/freenet/src/freenet/clients/http/staticfiles/icon/cut.png
===================================================================
(Binary files differ)
Property changes on:
trunk/freenet/src/freenet/clients/http/staticfiles/icon/cut.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: trunk/freenet/src/freenet/clients/http/staticfiles/icon/edit-delete.png
===================================================================
(Binary files differ)
Added: trunk/freenet/src/freenet/clients/http/staticfiles/icon/paste.png
===================================================================
(Binary files differ)
Property changes on:
trunk/freenet/src/freenet/clients/http/staticfiles/icon/paste.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream