Bug 365538 - 'Move Bookmark(s)' UI in Places Organizer. r=sspitzer.

This commit is contained in:
mozilla.mano%sent.com 2007-01-09 23:00:23 +00:00
Родитель 78e609159c
Коммит 72f1a39287
9 изменённых файлов: 257 добавлений и 26 удалений

Просмотреть файл

@ -186,6 +186,7 @@ PlacesController.prototype = {
return PlacesUtils.tm.numberOfRedoItems > 0;
case "cmd_cut":
case "cmd_delete":
case "placesCmd_moveBookmarks":
return !this.rootNodeIsSelected() &&
!this._selectionOverlapsSystemArea() &&
this._hasRemovableSelection();
@ -340,6 +341,9 @@ PlacesController.prototype = {
case "placesCmd_show:info":
this.showBookmarkPropertiesForSelection();
break;
case "placesCmd_moveBookmarks":
this.moveSelectedBookmarks();
break;
#endif
}
},
@ -371,16 +375,15 @@ PlacesController.prototype = {
* are non-removable. We don't need to worry about recursion here since it
* is a policy decision that a removable item not be placed inside a non-
* removable item.
* @returns true if the selection contains no nodes that cannot be removed,
* false otherwise.
* @returns true if the there's a selection which has no nodes that cannot be removed,
* false otherwise.
*/
_hasRemovableSelection: function PC__hasRemovableSelection() {
var v = this._view;
NS_ASSERT(v, "No active view - cannot paste!");
if (!v)
if (!this._view.hasSelection)
return false;
var nodes = v.getSelectionNodes();
var root = v.getResult().root;
var nodes = this._view.getSelectionNodes();
var root = this._view.getResult().root;
for (var i = 0; i < nodes.length; ++i) {
var parent = nodes[i].parent || root;
@ -396,11 +399,9 @@ PlacesController.prototype = {
if (PlacesUtils.nodeIsFolder(parent)) {
var readOnly = PlacesUtils.bookmarks.getFolderReadonly(asFolder(parent).folderId);
if (readOnly)
return !readOnly;
return false;
}
}
if (!v.hasSelection)
return !PlacesUtils.nodeIsReadOnly(root);
return true;
},
@ -433,12 +434,8 @@ PlacesController.prototype = {
* Determines whether or not nodes can be inserted relative to the selection.
*/
_canInsert: function PC__canInsert() {
var v = this._view;
NS_ASSERT(v, "No active view - cannot insert!");
if (!v)
return false;
var nodes = v.getSelectionNodes();
var root = v.getResult().root;
var nodes = this._view.getSelectionNodes();
var root = this._view.getResult().root;
for (var i = 0; i < nodes.length; ++i) {
var parent = nodes[i].parent || root;
if (PlacesUtils.nodeIsReadOnly(parent))
@ -1114,6 +1111,15 @@ PlacesController.prototype = {
PlacesUtils.tm.doTransaction(txn);
},
/**
* Opens a dialog for moving the selected nodes.
*/
moveSelectedBookmarks: function PC_moveBookmarks() {
window.openDialog("chrome://browser/content/places/moveBookmarks.xul",
"", "chrome, modal",
this._view.getSelectionNodes(), PlacesUtils.tm);
},
/**
* Creates a set of transactions for the removal of a range of items. A range is
* an array of adjacent nodes in a view.
@ -2046,6 +2052,7 @@ function goUpdatePlacesCommands() {
goUpdateCommand("placesCmd_new:bookmark");
goUpdateCommand("placesCmd_new:separator");
goUpdateCommand("placesCmd_show:info");
goUpdateCommand("placesCmd_moveBookmarks");
// XXXmano todo: sort and livemarks commands handling
#endif
}

Просмотреть файл

@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Places Move Bookmarks Dialog.
*
* The Initial Developer of the Original Code is Mozilla Corporation.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Asaf Romano <mano@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
var gMoveBookmarksDialog = {
_nodes: null,
_tm: null,
_foldersTree: null,
get foldersTree() {
if (!this._foldersTree)
this._foldersTree = document.getElementById("foldersTree");
return this._foldersTree;
},
init: function() {
this._nodes = window.arguments[0];
this._tm = window.arguments[1];
},
onOK: function MBD_onOK(aEvent) {
var selectedNode = this.foldersTree.selectedNode;
if (!selectedNode) {
// XXXmano: the old dialog defaults to the the "Bookmarks" root folder
// for some reason. I'm pretty sure we don't want to that yet in Places,
// at least not until we make that folder node visible in the tree, if we
// ever do so
return;
}
var selectedFolderID = asFolder(selectedNode).folderId;
var transactions = [];
for (var i=0; i < this._nodes.length; i++) {
var parentId = asFolder(this._nodes[i].parent).folderId;
// Nothing to do if the node is already under the selected folder
if (parentId == selectedFolderID)
continue;
var nodeIndex = PlacesUtils.getIndexOfNode(this._nodes[i]);
if (PlacesUtils.nodeIsFolder(this._nodes[i])) {
// Disallow moving a folder into itself
if (asFolder(this._nodes[i]).folderId != selectedFolderID) {
transactions.push(new
PlacesMoveFolderTransaction(asFolder(this._nodes[i]).folderId,
parentId, nodeIndex,
selectedFolderID, -1));
}
}
else if (PlacesUtils.nodeIsBookmark(this._nodes[i])) {
transactions.push(new
PlacesMoveItemTransaction(PlacesUtils._uri(this._nodes[i].uri),
parentId, nodeIndex,
selectedFolderID, -1));
}
else if (PlacesUtils.nodeIsSeparator(this._nodes[i])) {
// See makeTransaction in utils.js
var removeTxn =
new PlacesRemoveSeparatorTransaction(parentId, nodeIndex);
var createTxn =
new PlacesCreateSeparatorTransaction(selectedFolderID, -1);
transactions.push(new
PlacesAggregateTransaction("SeparatorMove", [removeTxn, createTxn]));
}
}
if (transactions.length != 0) {
var txn = new PlacesAggregateTransaction("Move Items", transactions);
this._tm.doTransaction(txn);
}
},
newFolder: function MBD_newFolder() {
// The command is disabled when the tree is not focused
this.foldersTree.focus();
goDoCommand("placesCmd_new:folder");
}
};

Просмотреть файл

@ -0,0 +1,84 @@
<?xml version="1.0"?>
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Places Organizer.
#
# The Initial Developer of the Original Code is Google Inc.
# Portions created by the Initial Developer are Copyright (C) 2005-2006
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Asaf Romano <mano@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
<?xml-stylesheet href="chrome://global/skin/"?>
<?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
<?xml-stylesheet href="chrome://browser/content/places/places.css"?>
<?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % moveBookmarksDTD SYSTEM "chrome://browser/locale/places/moveBookmarks.dtd">
%moveBookmarksDTD;
]>
<dialog id="moveBookmarkDialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
ondialogaccept="return gMoveBookmarksDialog.onOK(event);"
title="&window.title;"
onload="gMoveBookmarksDialog.init();"
style="&window.style;"
screenX="24"
screenY="24"
persist="screenX screenY width height">
<script type="application/x-javascript"
src="chrome://browser/content/places/moveBookmarks.js"/>
<hbox flex="1">
<label id="movetolabel" value="&moveTo.label;"/>
<hbox flex="1">
<tree id="foldersTree"
class="placesTree"
flex="1"
type="places"
place="place:&amp;folder=1&amp;group=3&amp;excludeItems=1&amp;excludeQueries=1&amp;excludeReadOnlyFolders=1"
hidecolumnpicker="true">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren id="placesListChildren" view="placesList" flex="1"/>
</tree>
<vbox>
<button label="&newFolderButton.label;"
accesskey="&newFolderButton.accesskey;"
oncommand="gMoveBookmarksDialog.newFolder();"/>
</vbox>
</hbox>
</hbox>
</dialog>

Просмотреть файл

@ -218,11 +218,20 @@
<menuitem id="editFindCurrent"
command="OrganizerCommand_find:current"
key="placesKey_find:current"/>
#ifdef XP_MACOSX
<menuseparator/>
<menuitem command="placesCmd_moveBookmarks"
label="&cmd.moveBookmarks.menuLabel;"
accesskey="&cmd.moveBookmarks.menuAccesskey;"/>
<menuseparator/>
<menuitem id="properties"
command="placesCmd_show:info"
key="placesKey_show:info"/>
key="placesKey_show:info"
#ifdef XP_MACOSX
label="&cmd.show_infoMac.label;"
accesskey="&cmd.show_infoMac.accesskey;"/>
#else
label="&cmd.show_infoWin.label;"
accesskey="&cmd.show_infoWin.accesskey;"/>
#endif
</menupopup>
</menu>
@ -282,12 +291,11 @@
label="&cmd.new_separator.label;"
accesskey="&cmd.new_separator.accesskey;"/>
<toolbarseparator/>
<!-- Not yet implemented
<toolbarbutton id="moveBookmark" label="&command.moveBookmarkShort.label;"
accesskey="&command.moveBookmark.accesskey;"
command="cmd_bm_movebookmark"/>
<toolbarbutton id="moveBookmark"
command="placesCmd_moveBookmarks"
label="&cmd.moveBookmarks.label;"
accesskey="&cmd.moveBookmarks.accesskey;"/>
<toolbarseparator/>
-->
<toolbarbutton id="properties"
command="placesCmd_show:info"
#ifdef XP_MACOSX

Просмотреть файл

@ -80,14 +80,16 @@
oncommand="goDoCommand('placesCmd_new:separator');"/>
<command id="placesCmd_show:info"
oncommand="goDoCommand('placesCmd_show:info');"/>
<command id="placesCmd_rename"
oncommand="goDoCommand('placesCmd_show:info');"
observes="placesCmd_show:info"/>
<!-- XXXmano bug 364644: not yet supported -->
<command id="placesCmd_reload"
disabled="true"/>
<command id="placesCmd_sortby:name"/>
<command id="placesCmd_rename"
oncommand="goDoCommand('placesCmd_show:info');"
observes="placesCmd_show:info"/>
<command id="placesCmd_moveBookmarks"
oncommand="goDoCommand('placesCmd_moveBookmarks');"/>
#endif
</commandset>

Просмотреть файл

@ -23,3 +23,5 @@ browser.jar:
# to prevent having to worry about between versions of the browser
* content/browser/history/history-panel.xul (content/history-panel.xul)
* content/browser/places/history-panel.js (content/history-panel.js)
* content/browser/places/moveBookmarks.xul (content/moveBookmarks.xul)
* content/browser/places/moveBookmarks.js (content/moveBookmarks.js)

Просмотреть файл

@ -0,0 +1,5 @@
<!ENTITY window.title "Choose Folder">
<!ENTITY window.style "width: 36em; height: 18em;">
<!ENTITY moveTo.label "Move to:">
<!ENTITY newFolderButton.label "New Folder">
<!ENTITY newFolderButton.accesskey "N">

Просмотреть файл

@ -179,6 +179,16 @@
"Group by Post">
<!ENTITY cmd.groupby_post.accesskey
"P">
<!ENTITY cmd.moveBookmarks.label
"Move...">
<!ENTITY cmd.moveBookmarks.accesskey
"M">
<!ENTITY cmd.moveBookmarks.menuLabel
"Move Bookmark(s)...">
<!ENTITY cmd.moveBookmarks.menuAccesskey
"M">
<!ENTITY col.title.label
"Title">
<!ENTITY col.url.label

Просмотреть файл

@ -35,6 +35,7 @@
locale/browser/places/placesPopup.dtd (%chrome/browser/places/placesPopup.dtd)
locale/browser/places/placesPopup.properties (%chrome/browser/places/placesPopup.properties)
locale/browser/preferences/selectBookmark.dtd (%chrome/browser/preferences/selectBookmark.dtd)
locale/browser/places/moveBookmarks.dtd (%chrome/browser/places/moveBookmarks.dtd)
#else
* locale/browser/bookmarks/bookmarks.dtd (%chrome/browser/bookmarks/bookmarks.dtd)
* locale/browser/bookmarks/addBookmark.dtd (%chrome/browser/bookmarks/addBookmark.dtd)