* 「このツリーを再読み込み」「このタブの子タブをすべて再読み込み」追加

* タブのコンテキストメニューに挿入されるメニュー項目の並びがおかしくなっていたのを修正

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4635 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-07-06 09:21:06 +00:00
parent a4d2e907f1
commit 24874a4402
14 changed files with 164 additions and 117 deletions

View File

@ -180,6 +180,12 @@
<preference id="extensions.treestyletab.show.openSelectionLinks"
name="extensions.treestyletab.show.openSelectionLinks"
type="bool"/>
<preference id="extensions.treestyletab.show.context-item-reloadTabSubTree"
name="extensions.treestyletab.show.context-item-reloadTabSubTree"
type="bool"/>
<preference id="extensions.treestyletab.show.context-item-reloadDescendantTabs"
name="extensions.treestyletab.show.context-item-reloadDescendantTabs"
type="bool"/>
<preference id="extensions.treestyletab.show.context-item-removeTabSubTree"
name="extensions.treestyletab.show.context-item-removeTabSubTree"
type="bool"/>
@ -210,6 +216,14 @@
<groupbox orient="vertical">
<caption label="&config.show.tabContextMenu.caption;"/>
<hbox align="center">
<checkbox id="extensions.treestyletab.show.context-item-reloadTabSubTree-check"
preference="extensions.treestyletab.show.context-item-reloadTabSubTree"
label="&context.reloadTabSubTree.label;"/>
<checkbox id="extensions.treestyletab.show.context-item-reloadDescendantTabs-check"
preference="extensions.treestyletab.show.context-item-reloadDescendantTabs"
label="&context.reloadDescendantTabs.label;"/>
</hbox>
<hbox align="center">
<checkbox id="extensions.treestyletab.show.context-item-removeTabSubTree-check"
preference="extensions.treestyletab.show.context-item-removeTabSubTree"

View File

@ -2035,26 +2035,11 @@ catch(e) {
removeTabSubTree : function(aTabOrTabs, aOnlyChildren)
{
var tabs = aTabOrTabs;
if (!(tabs instanceof Array)) {
tabs = [aTabOrTabs];
}
var b = this.getTabBrowserFromChild(tabs[0]);
var descendant = [];
for (var i = 0, maxi = tabs.length; i < maxi; i++)
{
descendant = descendant.concat(b.treeStyleTab.getDescendantTabs(tabs[i]));
}
if (aOnlyChildren)
tabs = this.cleanUpTabsArray(descendant);
else
tabs = this.cleanUpTabsArray(tabs.concat(descendant));
var tabs = this._normalizeToTabs(aTabOrTabs, aOnlyChildren);
if (!this.warnAboutClosingTabs(tabs.length))
return;
var b = this.getTabBrowserFromChild(tabs[0]);
for (var i = tabs.length-1; i > -1; i--)
{
b.removeTab(tabs[i]);
@ -2087,6 +2072,28 @@ catch(e) {
return shouldClose;
},
_normalizeToTabs : function(aTabOrTabs, aOnlyChildren)
{
var tabs = aTabOrTabs;
if (!(tabs instanceof Array)) {
tabs = [aTabOrTabs];
}
var b = this.getTabBrowserFromChild(tabs[0]);
var descendant = [];
for (var i = 0, maxi = tabs.length; i < maxi; i++)
{
descendant = descendant.concat(b.treeStyleTab.getDescendantTabs(tabs[i]));
}
if (aOnlyChildren)
tabs = this.cleanUpTabsArray(descendant);
else
tabs = this.cleanUpTabsArray(tabs.concat(descendant));
return tabs;
},
cleanUpTabsArray : function(aTabs)
{
var newTabs = [];
@ -2100,6 +2107,16 @@ catch(e) {
return newTabs;
},
reloadTabSubTree : function(aTabOrTabs, aOnlyChildren)
{
var tabs = this._normalizeToTabs(aTabOrTabs, aOnlyChildren);
var b = this.getTabBrowserFromChild(tabs[0]);
for (var i = tabs.length-1; i > -1; i--)
{
b.reloadTab(tabs[i]);
}
},
bookmarkTabSubTree : function(aTabOrTabs)
{
var tabs = aTabOrTabs;

View File

@ -55,6 +55,31 @@
<popupset id="mainPopupSet">
<menupopup id="multipletab-tabcontext-menu-template">
<menuitem id="context-item-reloadTabSubTree"
label="&context.reloadTabSubTree.label;"
accesskey="&context.reloadTabSubTree.accesskey;"
oncommand="TreeStyleTabService.reloadTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"
onclick="if (event.button == 1 || (event.button == 0 &amp;&amp; TreeStyleTabService.isAccelKeyPressed(event))) {
TreeStyleTabService.reloadTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab, true);
event.stopPropagation();
this.parentNode.hidePopup();
}"
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
&quot;descendant::*[starts-with(@id, 'context_reloadTab')][1]&quot;
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
<menuitem id="context-item-reloadDescendantTabs"
label="&context.reloadDescendantTabs.label;"
accesskey="&context.reloadDescendantTabs.accesskey;"
oncommand="TreeStyleTabService.reloadTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab, true);"
onclick="if (event.button == 1 || (event.button == 0 &amp;&amp; TreeStyleTabService.isAccelKeyPressed(event))) {
TreeStyleTabService.reloadTabSubTree(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);
event.stopPropagation();
this.parentNode.hidePopup();
}"
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
&quot;descendant::*[starts-with(@id, 'context-item-reloadTabSubTree')][1]&quot;
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
<menuitem id="context-item-removeTabSubTree"
label="&context.removeTabSubTree.label;"
accesskey="&context.removeTabSubTree.accesskey;"

View File

@ -9,6 +9,8 @@ function TreeStyleTabBrowser(aTabBrowser)
TreeStyleTabBrowser.prototype = {
kMENUITEM_RELOADSUBTREE : 'context-item-reloadTabSubTree',
kMENUITEM_RELOADCHILDREN : 'context-item-reloadDescendantTabs',
kMENUITEM_REMOVESUBTREE : 'context-item-removeTabSubTree',
kMENUITEM_REMOVECHILDREN : 'context-item-removeDescendantTabs',
kMENUITEM_COLLAPSEEXPAND_SEPARATOR : 'context-separator-collapseExpandAll',
@ -522,6 +524,8 @@ TreeStyleTabBrowser.prototype = {
window.setTimeout(function(aSelf, aTabBrowser, aPopup) {
let suffix = '-tabbrowser-'+(aTabBrowser.id || 'instance-'+parseInt(Math.random() * 65000));
[
aSelf.kMENUITEM_RELOADSUBTREE,
aSelf.kMENUITEM_RELOADCHILDREN,
aSelf.kMENUITEM_REMOVESUBTREE,
aSelf.kMENUITEM_REMOVECHILDREN,
aSelf.kMENUITEM_COLLAPSEEXPAND_SEPARATOR,
@ -555,9 +559,12 @@ TreeStyleTabBrowser.prototype = {
}
aPopup.insertBefore(item, refNode || null);
});
tabContextMenu = null;
}, 0, this, b, tabContextMenu);
}
tabContextMenu = null;
else {
tabContextMenu = null;
}
}
let (allTabPopup) {
@ -2025,30 +2032,32 @@ TreeStyleTabBrowser.prototype = {
initTabContextMenu : function(aEvent)
{
var b = this.mTabBrowser;
var item, sep;
var sep, items = {};
// remove subtree
item = this.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_REMOVESUBTREE+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
if (this.getTreePref('show.'+this.kMENUITEM_REMOVESUBTREE))
item.removeAttribute('hidden');
else
item.setAttribute('hidden', true);
this.showHideSubTreeMenuItem(item, [b.mContextTab]);
item = this.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_REMOVECHILDREN+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
if (this.getTreePref('show.'+this.kMENUITEM_REMOVECHILDREN))
item.removeAttribute('hidden');
else
item.setAttribute('hidden', true);
this.showHideSubTreeMenuItem(item, [b.mContextTab]);
[
this.kMENUITEM_RELOADSUBTREE,
this.kMENUITEM_RELOADCHILDREN,
this.kMENUITEM_REMOVESUBTREE,
this.kMENUITEM_REMOVECHILDREN,
this.kMENUITEM_COLLAPSE,
this.kMENUITEM_EXPAND,
this.kMENUITEM_AUTOHIDE,
this.kMENUITEM_FIXED,
this.kMENUITEM_POSITION,
this.kMENUITEM_BOOKMARKSUBTREE
].forEach(function(aID) {
let item = this.evaluateXPath(
'descendant::xul:*[starts-with(@id, "'+aID+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
items[aID] = item;
if (this.getTreePref('show.'+aID))
item.removeAttribute('hidden');
else
item.setAttribute('hidden', true);
this.showHideSubTreeMenuItem(item, [b.mContextTab]);
}, this);
// collapse/expand all
sep = this.evaluateXPath(
@ -2056,51 +2065,27 @@ TreeStyleTabBrowser.prototype = {
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
var collapseItem = this.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_COLLAPSE+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
var expanndItem = this.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_EXPAND+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
var collapseItem = items[this.kMENUITEM_COLLAPSE];
var expanndItem = items[this.kMENUITEM_EXPAND];
if (this.evaluateXPath(
'child::xul:tab[@'+this.kCHILDREN+']',
b.mTabContainer
).snapshotLength) {
if (this.getTreePref('show.'+this.kMENUITEM_COLLAPSE)) {
collapseItem.removeAttribute('hidden');
if (this.evaluateXPath(
'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kSUBTREE_COLLAPSED+'="true")]',
b.mTabContainer
).snapshotLength) {
collapseItem.removeAttribute('disabled');
}
else {
collapseItem.setAttribute('disabled', true);
}
}
else {
collapseItem.setAttribute('hidden', true);
}
if (this.evaluateXPath(
'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kSUBTREE_COLLAPSED+'="true")]',
b.mTabContainer
).snapshotLength)
collapseItem.removeAttribute('disabled');
else
collapseItem.setAttribute('disabled', true);
if (this.getTreePref('show.'+this.kMENUITEM_EXPAND)) {
expanndItem.removeAttribute('hidden');
if (this.evaluateXPath(
'child::xul:tab[@'+this.kCHILDREN+' and @'+this.kSUBTREE_COLLAPSED+'="true"]',
b.mTabContainer
).snapshotLength) {
expanndItem.removeAttribute('disabled');
}
else {
expanndItem.setAttribute('disabled', true);
}
}
else {
expanndItem.setAttribute('hidden', true);
}
if (this.evaluateXPath(
'child::xul:tab[@'+this.kCHILDREN+' and @'+this.kSUBTREE_COLLAPSED+'="true"]',
b.mTabContainer
).snapshotLength)
expanndItem.removeAttribute('disabled');
else
expanndItem.setAttribute('disabled', true);
}
else {
collapseItem.setAttribute('hidden', true);
@ -2115,15 +2100,10 @@ TreeStyleTabBrowser.prototype = {
}
// auto hide
var autohide = this.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_AUTOHIDE+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
var autohide = items[this.kMENUITEM_AUTOHIDE];
var pos = b.getAttribute(this.kTABBAR_POSITION);
if (this.getTreePref('show.'+this.kMENUITEM_AUTOHIDE)/* &&
(pos == 'left' || pos == 'right')*/) {
autohide.removeAttribute('hidden');
if (this.autoHideMode != this.kAUTOHIDE_MODE_DISABLED)
autohide.setAttribute('checked', true);
else
@ -2134,14 +2114,9 @@ TreeStyleTabBrowser.prototype = {
}
// fix
var fixed = this.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_FIXED+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
var fixed = items[this.kMENUITEM_FIXED];
if (this.getTreePref('show.'+this.kMENUITEM_FIXED) &&
(pos == 'left' || pos == 'right')) {
fixed.removeAttribute('hidden');
if (this.getTreePref('tabbar.fixed'))
fixed.setAttribute('checked', true);
else
@ -2152,18 +2127,8 @@ TreeStyleTabBrowser.prototype = {
}
// position
var position = this.evaluateXPath(
'descendant::xul:menu[starts-with(@id, "'+this.kMENUITEM_POSITION+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
if (this.getTreePref('show.'+this.kMENUITEM_POSITION)) {
position.removeAttribute('hidden');
position.getElementsByAttribute('value', pos)[0].setAttribute('checked', true);
}
else {
position.setAttribute('hidden', true);
}
var position = items[this.kMENUITEM_POSITION];
position.getElementsByAttribute('value', pos)[0].setAttribute('checked', true);
sep = this.evaluateXPath(
'descendant::xul:menuseparator[starts-with(@id, "'+this.kMENUITEM_AUTOHIDE_SEPARATOR+'")]',
@ -2178,18 +2143,6 @@ TreeStyleTabBrowser.prototype = {
else {
sep.setAttribute('hidden', true);
}
// bookmark
item = this.evaluateXPath(
'descendant::xul:menuitem[starts-with(@id, "'+this.kMENUITEM_BOOKMARKSUBTREE+'")]',
aEvent.currentTarget,
XPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
if (this.getTreePref('show.'+this.kMENUITEM_BOOKMARKSUBTREE))
item.removeAttribute('hidden');
else
item.setAttribute('hidden', true);
this.showHideSubTreeMenuItem(item, [b.mContextTab]);
},
initAllTabsPopup : function(aEvent)

View File

@ -57,6 +57,8 @@ pref("extensions.treestyletab.twisty.expandSensitiveArea", true);
pref("extensions.treestyletab.clickOnIndentSpaces.enabled", true);
pref("extensions.treestyletab.show.openSelectionLinks", true);
pref("extensions.treestyletab.show.context-item-reloadTabSubTree", true);
pref("extensions.treestyletab.show.context-item-reloadDescendantTabs", false);
pref("extensions.treestyletab.show.context-item-removeTabSubTree", true);
pref("extensions.treestyletab.show.context-item-removeDescendantTabs", false);
pref("extensions.treestyletab.show.context-item-collapseAllSubtree", true);

View File

@ -137,6 +137,10 @@
<!ENTITY selection.removeTabSubTree.label "Ausgewählte Zweige schließen">
<!ENTITY selection.removeTabSubTree.accesskey "s">
<!ENTITY context.reloadTabSubTree.label "Reload this Tree">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "Reload Children">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "Diesen Zweig schließen">
<!ENTITY context.removeTabSubTree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Untergeordnete Tabs schließen">

View File

@ -139,6 +139,10 @@
<!ENTITY selection.removeTabSubTree.label "Close Selected Trees">
<!ENTITY selection.removeTabSubTree.accesskey "s">
<!ENTITY context.reloadTabSubTree.label "Reload this Tree">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "Reload Children">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "Close this Tree">
<!ENTITY context.removeTabSubTree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Close Children">

View File

@ -138,6 +138,10 @@
<!ENTITY selection.removeTabSubTree.label "Cerrar árboles seleccionados">
<!ENTITY selection.removeTabSubTree.accesskey "s">
<!ENTITY context.reloadTabSubTree.label "Reload this Tree">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "Reload Children">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "Cerrar este árbol">
<!ENTITY context.removeTabSubTree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Cerrar hija">

View File

@ -138,6 +138,10 @@
<!ENTITY selection.removeTabSubTree.label "Chiudi i sottoalberi selezionati">
<!ENTITY selection.removeTabSubTree.accesskey "s">
<!ENTITY context.reloadTabSubTree.label "Reload this Tree">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "Reload Children">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "Chiudi questo sottoalbero">
<!ENTITY context.removeTabSubTree.accesskey "u">
<!ENTITY context.removeDescendantTabs.label "Chiudi sottoschede">

View File

@ -137,6 +137,10 @@
<!ENTITY selection.removeTabSubTree.label "すべてのサブツリーを閉じる">
<!ENTITY selection.removeTabSubTree.accesskey "s">
<!ENTITY context.reloadTabSubTree.label "このサブツリーを再読み込み">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "このタブの子タブをすべて再読み込み">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "このサブツリーを閉じる">
<!ENTITY context.removeTabSubTree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "このタブの子タブをすべて閉じる">

View File

@ -137,6 +137,10 @@
<!ENTITY selection.removeTabSubTree.label "Zamknij wybrane drzewa">
<!ENTITY selection.removeTabSubTree.accesskey "M">
<!ENTITY context.reloadTabSubTree.label "Reload this Tree">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "Reload Children">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "Zamknij to drzewo">
<!ENTITY context.removeTabSubTree.accesskey "T">
<!ENTITY context.removeDescendantTabs.label "Zamknij potomne">

View File

@ -137,6 +137,10 @@
<!ENTITY selection.removeTabSubTree.label "Закрыть выбранные деревья">
<!ENTITY selection.removeTabSubTree.accesskey "s">
<!ENTITY context.reloadTabSubTree.label "Reload this Tree">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "Reload Children">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "Закрыть это дерево">
<!ENTITY context.removeTabSubTree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "Закрыть дочерние вкладки">

View File

@ -137,6 +137,10 @@
<!ENTITY selection.removeTabSubTree.label "关闭所选的树">
<!ENTITY selection.removeTabSubTree.accesskey "s">
<!ENTITY context.reloadTabSubTree.label "Reload this Tree">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "Reload Children">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "关闭此树">
<!ENTITY context.removeTabSubTree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "关闭子标签">

View File

@ -134,6 +134,10 @@
<!ENTITY selection.removeTabSubTree.label "關閉所有選取的樹">
<!ENTITY selection.removeTabSubTree.accesskey "s">
<!ENTITY context.reloadTabSubTree.label "Reload this Tree">
<!ENTITY context.reloadTabSubTree.accesskey "r">
<!ENTITY context.reloadDescendantTabs.label "Reload Children">
<!ENTITY context.reloadDescendantTabs.accesskey "r">
<!ENTITY context.removeTabSubTree.label "關閉此樹">
<!ENTITY context.removeTabSubTree.accesskey "s">
<!ENTITY context.removeDescendantTabs.label "關閉所有子分頁">