mirror of
https://github.com/apache/struts.git
synced 2026-09-11 08:39:39 +00:00
WW-1883 Deprecate topic attributes in Tree tag
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@529800 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -77,9 +77,9 @@ public class Tree extends ClosingUIBean {
|
||||
private static final String OPEN_TEMPLATE = "tree";
|
||||
|
||||
private String toggle = "fade";
|
||||
private String treeSelectedTopic;
|
||||
private String treeExpandedTopic;
|
||||
private String treeCollapsedTopic;
|
||||
private String selectedNotifyTopics;
|
||||
private String expandedNotifyTopics;
|
||||
private String collapsedNotifyTopics;
|
||||
protected String rootNodeAttr;
|
||||
protected String childCollectionProperty;
|
||||
protected String nodeTitleProperty;
|
||||
@@ -127,16 +127,16 @@ public class Tree extends ClosingUIBean {
|
||||
addParameter("toggle", findString(toggle));
|
||||
}
|
||||
|
||||
if (treeSelectedTopic != null) {
|
||||
addParameter("treeSelectedTopic", findString(treeSelectedTopic));
|
||||
if (selectedNotifyTopics != null) {
|
||||
addParameter("selectedNotifyTopics", findString(selectedNotifyTopics));
|
||||
}
|
||||
|
||||
if (treeExpandedTopic != null) {
|
||||
addParameter("treeExpandedTopic", findString(treeExpandedTopic));
|
||||
if (expandedNotifyTopics != null) {
|
||||
addParameter("expandedNotifyTopics", findString(expandedNotifyTopics));
|
||||
}
|
||||
|
||||
if (treeCollapsedTopic != null) {
|
||||
addParameter("treeCollapsedTopic", findString(treeCollapsedTopic));
|
||||
if (collapsedNotifyTopics != null) {
|
||||
addParameter("collapsedNotifyTopics", findString(collapsedNotifyTopics));
|
||||
}
|
||||
|
||||
if (rootNodeAttr != null) {
|
||||
@@ -242,31 +242,19 @@ public class Tree extends ClosingUIBean {
|
||||
this.toggle = toggle;
|
||||
}
|
||||
|
||||
public String getTreeSelectedTopic() {
|
||||
return treeSelectedTopic;
|
||||
@StrutsTagAttribute(description="Deprecated. Use 'selectedNotifyTopics' instead.")
|
||||
public void setTreeSelectedTopic(String selectedNotifyTopic) {
|
||||
this.selectedNotifyTopics = selectedNotifyTopic;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="The treeSelectedTopic property")
|
||||
public void setTreeSelectedTopic(String treeSelectedTopic) {
|
||||
this.treeSelectedTopic = treeSelectedTopic;
|
||||
@StrutsTagAttribute(description="Deprecated. Use 'expandedNotifyTopics' instead.")
|
||||
public void setTreeExpandedTopics(String expandedNotifyTopic) {
|
||||
this.expandedNotifyTopics = expandedNotifyTopic;
|
||||
}
|
||||
|
||||
public String getTreeExpandedTopic() {
|
||||
return treeExpandedTopic;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="The treeExpandedTopic property.")
|
||||
public void setTreeExpandedTopic(String treeExpandedTopic) {
|
||||
this.treeExpandedTopic = treeExpandedTopic;
|
||||
}
|
||||
|
||||
public String getTreeCollapsedTopic() {
|
||||
return treeCollapsedTopic;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="The treeCollapsedTopic property.")
|
||||
public void setTreeCollapsedTopic(String treeCollapsedTopic) {
|
||||
this.treeCollapsedTopic = treeCollapsedTopic;
|
||||
@StrutsTagAttribute(description="Deprecated. Use 'collapsedNotifyTopics' instead.")
|
||||
public void setTreeCollapsedTopics(String collapsedNotifyTopic) {
|
||||
this.collapsedNotifyTopics = collapsedNotifyTopic;
|
||||
}
|
||||
|
||||
public String getRootNode() {
|
||||
@@ -463,5 +451,23 @@ public class Tree extends ClosingUIBean {
|
||||
public void setName(String name) {
|
||||
super.setName(name);
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Comma separated lis of topics to be published when a node" +
|
||||
" is collapsed. An object with a 'node' property will be passed as parameter to the topics.")
|
||||
public void setCollapsedNotifyTopics(String collapsedNotifyTopics) {
|
||||
this.collapsedNotifyTopics = collapsedNotifyTopics;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Comma separated lis of topics to be published when a node" +
|
||||
" is expanded. An object with a 'node' property will be passed as parameter to the topics.")
|
||||
public void setExpandedNotifyTopics(String expandedNotifyTopics) {
|
||||
this.expandedNotifyTopics= expandedNotifyTopics;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Comma separated lis of topics to be published when a node" +
|
||||
" is selected. An object with a 'node' property will be passed as parameter to the topics.")
|
||||
public void setSelectedNotifyTopics(String selectedNotifyTopics) {
|
||||
this.selectedNotifyTopics = selectedNotifyTopics;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ public class TreeTag extends AbstractClosingTag {
|
||||
private static final long serialVersionUID = 2735218501058548013L;
|
||||
|
||||
private String toggle;
|
||||
private String treeSelectedTopic;
|
||||
private String treeExpandedTopic;
|
||||
private String treeCollapsedTopic;
|
||||
private String selectedNotifyTopics;
|
||||
private String expandedNotifyTopics;
|
||||
private String collapsedNotifyTopics;
|
||||
private String rootNode;
|
||||
private String childCollectionProperty;
|
||||
private String nodeTitleProperty;
|
||||
@@ -80,12 +80,12 @@ public class TreeTag extends AbstractClosingTag {
|
||||
tree.setRootNode(rootNode);
|
||||
if (toggle != null)
|
||||
tree.setToggle(toggle);
|
||||
if (treeCollapsedTopic != null)
|
||||
tree.setTreeCollapsedTopic(treeCollapsedTopic);
|
||||
if (treeExpandedTopic != null)
|
||||
tree.setTreeExpandedTopic(treeExpandedTopic);
|
||||
if (treeSelectedTopic != null)
|
||||
tree.setTreeSelectedTopic(treeSelectedTopic);
|
||||
if (selectedNotifyTopics != null)
|
||||
tree.setSelectedNotifyTopics(selectedNotifyTopics);
|
||||
if (expandedNotifyTopics != null)
|
||||
tree.setExpandedNotifyTopics(expandedNotifyTopics);
|
||||
if (collapsedNotifyTopics != null)
|
||||
tree.setCollapsedNotifyTopics(collapsedNotifyTopics);
|
||||
if (showRootGrid != null)
|
||||
tree.setShowRootGrid(showRootGrid);
|
||||
|
||||
@@ -127,28 +127,19 @@ public class TreeTag extends AbstractClosingTag {
|
||||
this.toggle = toggle;
|
||||
}
|
||||
|
||||
public String getTreeSelectedTopic() {
|
||||
return treeSelectedTopic;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTreeSelectedTopic(String treeSelectedTopic) {
|
||||
this.treeSelectedTopic = treeSelectedTopic;
|
||||
}
|
||||
|
||||
public String getTreeExpandedTopic() {
|
||||
return treeExpandedTopic;
|
||||
this.selectedNotifyTopics = treeSelectedTopic;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTreeExpandedTopic(String treeExpandedTopic) {
|
||||
this.treeExpandedTopic = treeExpandedTopic;
|
||||
}
|
||||
|
||||
public String getTreeCollapsedTopic() {
|
||||
return treeCollapsedTopic;
|
||||
this.expandedNotifyTopics = treeExpandedTopic;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTreeCollapsedTopic(String treeCollapsedTopic) {
|
||||
this.treeCollapsedTopic = treeCollapsedTopic;
|
||||
this.collapsedNotifyTopics = treeCollapsedTopic;
|
||||
}
|
||||
|
||||
public String getRootNode() {
|
||||
@@ -302,5 +293,17 @@ public class TreeTag extends AbstractClosingTag {
|
||||
public void setShowGrid(String showGrid) {
|
||||
this.showGrid = showGrid;
|
||||
}
|
||||
|
||||
public void setCollapsedNotifyTopics(String collapsedNotifyTopics) {
|
||||
this.collapsedNotifyTopics = collapsedNotifyTopics;
|
||||
}
|
||||
|
||||
public void setExpandedNotifyTopics(String expandedNotifyTopics) {
|
||||
this.expandedNotifyTopics = expandedNotifyTopics;
|
||||
}
|
||||
|
||||
public void setSelectedNotifyTopics(String selectedNotifyTopics) {
|
||||
this.selectedNotifyTopics = selectedNotifyTopics;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+62
-4
@@ -6,7 +6,15 @@ dojo.widget.defineWidget(
|
||||
"struts.widget.StrutsTreeSelector",
|
||||
dojo.widget.TreeSelector, {
|
||||
widgetType : "StrutsTreeSelector",
|
||||
|
||||
|
||||
selectedNotifyTopics : "",
|
||||
collapsedNotifyTopics : "",
|
||||
expandedNotifyTopics : "",
|
||||
|
||||
selectedNotifyTopicsArray : null,
|
||||
collapsedNotifyTopicsArray : null,
|
||||
expandedNotifyTopicsArray : null,
|
||||
|
||||
eventNamesDefault: {
|
||||
select : "select",
|
||||
destroy : "destroy",
|
||||
@@ -16,10 +24,26 @@ dojo.widget.defineWidget(
|
||||
collapse: "collapse"
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
struts.widget.StrutsTreeSelector.superclass.initialize.apply(this);
|
||||
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)) {
|
||||
this.selectedNotifyTopicsArray = this.selectedNotifyTopics.split(",");
|
||||
}
|
||||
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)) {
|
||||
this.collapsedNotifyTopicsArray = this.collapsedNotifyTopics.split(",");
|
||||
}
|
||||
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)) {
|
||||
this.expandedNotifyTopicsArray = this.expandedNotifyTopics.split(",");
|
||||
}
|
||||
},
|
||||
|
||||
listenTree: function(tree) {
|
||||
dojo.event.topic.subscribe(tree.eventNames.collapse, this, "collapse");
|
||||
dojo.event.topic.subscribe(tree.eventNames.expand, this, "expand");
|
||||
struts.widget.StrutsTreeSelector.superclass.unlistenTree.apply(this, [tree]);
|
||||
struts.widget.StrutsTreeSelector.superclass.listenTree.apply(this, [tree]);
|
||||
},
|
||||
|
||||
unlistenTree: function(tree) {
|
||||
@@ -28,14 +52,48 @@ dojo.widget.defineWidget(
|
||||
struts.widget.StrutsTreeSelector.superclass.unlistenTree.apply(this, [tree]);
|
||||
},
|
||||
|
||||
publishTopics : function(topics, node) {
|
||||
if(topics != null) {
|
||||
for(var i = 0; i < topics.length; i++) {
|
||||
var topic = topics[i];
|
||||
if(!dojo.string.isBlank(topic)) {
|
||||
try {
|
||||
dojo.event.topic.publish(topic, node);
|
||||
} catch(ex) {
|
||||
dojo.debug(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
select:function (message) {
|
||||
var node = message.source;
|
||||
var e = message.event;
|
||||
if (this.selectedNode === node) {
|
||||
if (e.ctrlKey || e.shiftKey || e.metaKey) {
|
||||
this.deselect();
|
||||
return;
|
||||
}
|
||||
dojo.event.topic.publish(this.eventNames.dblselect, {node:node});
|
||||
return;
|
||||
}
|
||||
if (this.selectedNode) {
|
||||
this.deselect();
|
||||
}
|
||||
this.doSelect(node);
|
||||
|
||||
this.publishTopics(this.selectedNotifyTopicsArray, {node: node});
|
||||
},
|
||||
|
||||
expand: function(message) {
|
||||
var node = message.source;
|
||||
dojo.event.topic.publish(this.eventNames.expand, {node: node} );
|
||||
this.publishTopics(this.expandedNotifyTopicsArray, {node: node});
|
||||
},
|
||||
|
||||
collapse: function(message) {
|
||||
var node = message.source;
|
||||
dojo.event.topic.publish(this.eventNames.collapse, {node: node} );
|
||||
this.publishTopics(this.collapsedNotifyTopicsArray, {node: node});
|
||||
},
|
||||
|
||||
});
|
||||
@@ -17151,6 +17151,151 @@ self.reloadContents();
|
||||
}
|
||||
}
|
||||
}});
|
||||
dojo.kwCompoundRequire({common:["struts.widget.Bind","struts.widget.BindDiv","struts.widget.BindAnchor","struts.widget.ComboBox","struts.widget.StrutsTimePicker","struts.widget.StrutsDatePicker","struts.widget.BindEvent"]});
|
||||
dojo.provide("dojo.widget.TreeSelector");
|
||||
dojo.widget.defineWidget("dojo.widget.TreeSelector",dojo.widget.HtmlWidget,function(){
|
||||
this.eventNames={};
|
||||
this.listenedTrees=[];
|
||||
},{widgetType:"TreeSelector",selectedNode:null,dieWithTree:false,eventNamesDefault:{select:"select",destroy:"destroy",deselect:"deselect",dblselect:"dblselect"},initialize:function(){
|
||||
for(name in this.eventNamesDefault){
|
||||
if(dojo.lang.isUndefined(this.eventNames[name])){
|
||||
this.eventNames[name]=this.widgetId+"/"+this.eventNamesDefault[name];
|
||||
}
|
||||
}
|
||||
},destroy:function(){
|
||||
dojo.event.topic.publish(this.eventNames.destroy,{source:this});
|
||||
return dojo.widget.HtmlWidget.prototype.destroy.apply(this,arguments);
|
||||
},listenTree:function(tree){
|
||||
dojo.event.topic.subscribe(tree.eventNames.titleClick,this,"select");
|
||||
dojo.event.topic.subscribe(tree.eventNames.iconClick,this,"select");
|
||||
dojo.event.topic.subscribe(tree.eventNames.collapse,this,"onCollapse");
|
||||
dojo.event.topic.subscribe(tree.eventNames.moveFrom,this,"onMoveFrom");
|
||||
dojo.event.topic.subscribe(tree.eventNames.removeNode,this,"onRemoveNode");
|
||||
dojo.event.topic.subscribe(tree.eventNames.treeDestroy,this,"onTreeDestroy");
|
||||
this.listenedTrees.push(tree);
|
||||
},unlistenTree:function(tree){
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.titleClick,this,"select");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.iconClick,this,"select");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.collapse,this,"onCollapse");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.moveFrom,this,"onMoveFrom");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.removeNode,this,"onRemoveNode");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.treeDestroy,this,"onTreeDestroy");
|
||||
for(var i=0;i<this.listenedTrees.length;i++){
|
||||
if(this.listenedTrees[i]===tree){
|
||||
this.listenedTrees.splice(i,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},onTreeDestroy:function(_e4d){
|
||||
this.unlistenTree(_e4d.source);
|
||||
if(this.dieWithTree){
|
||||
this.destroy();
|
||||
}
|
||||
},onCollapse:function(_e4e){
|
||||
if(!this.selectedNode){
|
||||
return;
|
||||
}
|
||||
var node=_e4e.source;
|
||||
var _e50=this.selectedNode.parent;
|
||||
while(_e50!==node&&_e50.isTreeNode){
|
||||
_e50=_e50.parent;
|
||||
}
|
||||
if(_e50.isTreeNode){
|
||||
this.deselect();
|
||||
}
|
||||
},select:function(_e51){
|
||||
var node=_e51.source;
|
||||
var e=_e51.event;
|
||||
if(this.selectedNode===node){
|
||||
if(e.ctrlKey||e.shiftKey||e.metaKey){
|
||||
this.deselect();
|
||||
return;
|
||||
}
|
||||
dojo.event.topic.publish(this.eventNames.dblselect,{node:node});
|
||||
return;
|
||||
}
|
||||
if(this.selectedNode){
|
||||
this.deselect();
|
||||
}
|
||||
this.doSelect(node);
|
||||
dojo.event.topic.publish(this.eventNames.select,{node:node});
|
||||
},onMoveFrom:function(_e54){
|
||||
if(_e54.child!==this.selectedNode){
|
||||
return;
|
||||
}
|
||||
if(!dojo.lang.inArray(this.listenedTrees,_e54.newTree)){
|
||||
this.deselect();
|
||||
}
|
||||
},onRemoveNode:function(_e55){
|
||||
if(_e55.child!==this.selectedNode){
|
||||
return;
|
||||
}
|
||||
this.deselect();
|
||||
},doSelect:function(node){
|
||||
node.markSelected();
|
||||
this.selectedNode=node;
|
||||
},deselect:function(){
|
||||
var node=this.selectedNode;
|
||||
this.selectedNode=null;
|
||||
node.unMarkSelected();
|
||||
dojo.event.topic.publish(this.eventNames.deselect,{node:node});
|
||||
}});
|
||||
dojo.provide("struts.widget.StrutsTreeSelector");
|
||||
dojo.widget.defineWidget("struts.widget.StrutsTreeSelector",dojo.widget.TreeSelector,{widgetType:"StrutsTreeSelector",selectedNotifyTopics:"",collapsedNotifyTopics:"",expandedNotifyTopics:"",selectedNotifyTopicsArray:null,collapsedNotifyTopicsArray:null,expandedNotifyTopicsArray:null,eventNamesDefault:{select:"select",destroy:"destroy",deselect:"deselect",dblselect:"dblselect",expand:"expand",collapse:"collapse"},initialize:function(){
|
||||
struts.widget.StrutsTreeSelector.superclass.initialize.apply(this);
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)){
|
||||
this.selectedNotifyTopicsArray=this.selectedNotifyTopics.split(",");
|
||||
}
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)){
|
||||
this.collapsedNotifyTopicsArray=this.collapsedNotifyTopics.split(",");
|
||||
}
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)){
|
||||
this.expandedNotifyTopicsArray=this.expandedNotifyTopics.split(",");
|
||||
}
|
||||
},listenTree:function(tree){
|
||||
dojo.event.topic.subscribe(tree.eventNames.collapse,this,"collapse");
|
||||
dojo.event.topic.subscribe(tree.eventNames.expand,this,"expand");
|
||||
struts.widget.StrutsTreeSelector.superclass.listenTree.apply(this,[tree]);
|
||||
},unlistenTree:function(tree){
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.collapse,this,"collapse");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.expand,this,"expand");
|
||||
struts.widget.StrutsTreeSelector.superclass.unlistenTree.apply(this,[tree]);
|
||||
},publishTopics:function(_e5a,node){
|
||||
if(_e5a!=null){
|
||||
for(var i=0;i<_e5a.length;i++){
|
||||
var _e5d=_e5a[i];
|
||||
if(!dojo.string.isBlank(_e5d)){
|
||||
try{
|
||||
dojo.event.topic.publish(_e5d,node);
|
||||
}
|
||||
catch(ex){
|
||||
dojo.debug(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},select:function(_e5e){
|
||||
var node=_e5e.source;
|
||||
var e=_e5e.event;
|
||||
if(this.selectedNode===node){
|
||||
if(e.ctrlKey||e.shiftKey||e.metaKey){
|
||||
this.deselect();
|
||||
return;
|
||||
}
|
||||
dojo.event.topic.publish(this.eventNames.dblselect,{node:node});
|
||||
return;
|
||||
}
|
||||
if(this.selectedNode){
|
||||
this.deselect();
|
||||
}
|
||||
this.doSelect(node);
|
||||
this.publishTopics(this.selectedNotifyTopicsArray,{node:node});
|
||||
},expand:function(_e61){
|
||||
var node=_e61.source;
|
||||
this.publishTopics(this.expandedNotifyTopicsArray,{node:node});
|
||||
},collapse:function(_e63){
|
||||
var node=_e63.source;
|
||||
this.publishTopics(this.collapsedNotifyTopicsArray,{node:node});
|
||||
},});
|
||||
dojo.kwCompoundRequire({common:["struts.widget.Bind","struts.widget.BindDiv","struts.widget.BindAnchor","struts.widget.ComboBox","struts.widget.StrutsTimePicker","struts.widget.StrutsDatePicker","struts.widget.BindEvent","struts.widget.StrutsTreeSelector"]});
|
||||
dojo.provide("struts.widget.*");
|
||||
|
||||
|
||||
+272
-1
@@ -27711,6 +27711,276 @@ dojo.widget.defineWidget(
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
dojo.provide("dojo.widget.TreeSelector");
|
||||
|
||||
|
||||
|
||||
|
||||
dojo.widget.defineWidget("dojo.widget.TreeSelector", dojo.widget.HtmlWidget, function() {
|
||||
this.eventNames = {};
|
||||
|
||||
this.listenedTrees = [];
|
||||
|
||||
},
|
||||
{
|
||||
widgetType: "TreeSelector",
|
||||
selectedNode: null,
|
||||
|
||||
dieWithTree: false,
|
||||
|
||||
eventNamesDefault: {
|
||||
select : "select",
|
||||
destroy : "destroy",
|
||||
deselect : "deselect",
|
||||
dblselect: "dblselect" // select already selected node.. Edit or whatever
|
||||
},
|
||||
|
||||
initialize: function() {
|
||||
|
||||
for(name in this.eventNamesDefault) {
|
||||
if (dojo.lang.isUndefined(this.eventNames[name])) {
|
||||
this.eventNames[name] = this.widgetId+"/"+this.eventNamesDefault[name];
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
destroy: function() {
|
||||
dojo.event.topic.publish(this.eventNames.destroy, { source: this } );
|
||||
|
||||
return dojo.widget.HtmlWidget.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
|
||||
listenTree: function(tree) {
|
||||
dojo.event.topic.subscribe(tree.eventNames.titleClick, this, "select");
|
||||
dojo.event.topic.subscribe(tree.eventNames.iconClick, this, "select");
|
||||
dojo.event.topic.subscribe(tree.eventNames.collapse, this, "onCollapse");
|
||||
dojo.event.topic.subscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
|
||||
dojo.event.topic.subscribe(tree.eventNames.removeNode, this, "onRemoveNode");
|
||||
dojo.event.topic.subscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
|
||||
|
||||
/* remember all my trees to deselect when element is movedFrom them */
|
||||
this.listenedTrees.push(tree);
|
||||
},
|
||||
|
||||
|
||||
unlistenTree: function(tree) {
|
||||
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.titleClick, this, "select");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.iconClick, this, "select");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.collapse, this, "onCollapse");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.moveFrom, this, "onMoveFrom");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.removeNode, this, "onRemoveNode");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.treeDestroy, this, "onTreeDestroy");
|
||||
|
||||
|
||||
for(var i=0; i<this.listenedTrees.length; i++){
|
||||
if(this.listenedTrees[i] === tree){
|
||||
this.listenedTrees.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
onTreeDestroy: function(message) {
|
||||
|
||||
this.unlistenTree(message.source);
|
||||
|
||||
if (this.dieWithTree) {
|
||||
//dojo.debug("Killing myself "+this.widgetId);
|
||||
this.destroy();
|
||||
//dojo.debug("done");
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// deselect node if parent is collapsed
|
||||
onCollapse: function(message) {
|
||||
if (!this.selectedNode) return;
|
||||
|
||||
var node = message.source;
|
||||
var parent = this.selectedNode.parent;
|
||||
while (parent !== node && parent.isTreeNode) {
|
||||
parent = parent.parent;
|
||||
}
|
||||
if (parent.isTreeNode) {
|
||||
this.deselect();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
select: function(message) {
|
||||
var node = message.source;
|
||||
var e = message.event;
|
||||
|
||||
if (this.selectedNode === node) {
|
||||
if(e.ctrlKey || e.shiftKey || e.metaKey){
|
||||
// If the node is currently selected, and they select it again while holding
|
||||
// down a meta key, it deselects it
|
||||
this.deselect();
|
||||
return;
|
||||
}
|
||||
dojo.event.topic.publish(this.eventNames.dblselect, { node: node });
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.selectedNode) {
|
||||
this.deselect();
|
||||
}
|
||||
|
||||
this.doSelect(node);
|
||||
|
||||
dojo.event.topic.publish(this.eventNames.select, {node: node} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Deselect node if target tree is out of our concern
|
||||
*/
|
||||
onMoveFrom: function(message) {
|
||||
if (message.child !== this.selectedNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dojo.lang.inArray(this.listenedTrees, message.newTree)) {
|
||||
this.deselect();
|
||||
}
|
||||
},
|
||||
|
||||
onRemoveNode: function(message) {
|
||||
if (message.child !== this.selectedNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.deselect();
|
||||
},
|
||||
|
||||
doSelect: function(node){
|
||||
|
||||
node.markSelected();
|
||||
|
||||
this.selectedNode = node;
|
||||
},
|
||||
|
||||
deselect: function(){
|
||||
|
||||
var node = this.selectedNode;
|
||||
|
||||
this.selectedNode = null;
|
||||
node.unMarkSelected();
|
||||
dojo.event.topic.publish(this.eventNames.deselect, {node: node} );
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
dojo.provide("struts.widget.StrutsTreeSelector");
|
||||
|
||||
|
||||
|
||||
dojo.widget.defineWidget(
|
||||
"struts.widget.StrutsTreeSelector",
|
||||
dojo.widget.TreeSelector, {
|
||||
widgetType : "StrutsTreeSelector",
|
||||
|
||||
selectedNotifyTopics : "",
|
||||
collapsedNotifyTopics : "",
|
||||
expandedNotifyTopics : "",
|
||||
|
||||
selectedNotifyTopicsArray : null,
|
||||
collapsedNotifyTopicsArray : null,
|
||||
expandedNotifyTopicsArray : null,
|
||||
|
||||
eventNamesDefault: {
|
||||
select : "select",
|
||||
destroy : "destroy",
|
||||
deselect : "deselect",
|
||||
dblselect: "dblselect", // select already selected node.. Edit or whatever
|
||||
expand: "expand",
|
||||
collapse: "collapse"
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
struts.widget.StrutsTreeSelector.superclass.initialize.apply(this);
|
||||
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)) {
|
||||
this.selectedNotifyTopicsArray = this.selectedNotifyTopics.split(",");
|
||||
}
|
||||
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)) {
|
||||
this.collapsedNotifyTopicsArray = this.collapsedNotifyTopics.split(",");
|
||||
}
|
||||
|
||||
if(!dojo.string.isBlank(this.selectedNotifyTopics)) {
|
||||
this.expandedNotifyTopicsArray = this.expandedNotifyTopics.split(",");
|
||||
}
|
||||
},
|
||||
|
||||
listenTree: function(tree) {
|
||||
dojo.event.topic.subscribe(tree.eventNames.collapse, this, "collapse");
|
||||
dojo.event.topic.subscribe(tree.eventNames.expand, this, "expand");
|
||||
struts.widget.StrutsTreeSelector.superclass.listenTree.apply(this, [tree]);
|
||||
},
|
||||
|
||||
unlistenTree: function(tree) {
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.collapse, this, "collapse");
|
||||
dojo.event.topic.unsubscribe(tree.eventNames.expand, this, "expand");
|
||||
struts.widget.StrutsTreeSelector.superclass.unlistenTree.apply(this, [tree]);
|
||||
},
|
||||
|
||||
publishTopics : function(topics, node) {
|
||||
if(topics != null) {
|
||||
for(var i = 0; i < topics.length; i++) {
|
||||
var topic = topics[i];
|
||||
if(!dojo.string.isBlank(topic)) {
|
||||
try {
|
||||
dojo.event.topic.publish(topic, node);
|
||||
} catch(ex) {
|
||||
dojo.debug(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
select:function (message) {
|
||||
var node = message.source;
|
||||
var e = message.event;
|
||||
if (this.selectedNode === node) {
|
||||
if (e.ctrlKey || e.shiftKey || e.metaKey) {
|
||||
this.deselect();
|
||||
return;
|
||||
}
|
||||
dojo.event.topic.publish(this.eventNames.dblselect, {node:node});
|
||||
return;
|
||||
}
|
||||
if (this.selectedNode) {
|
||||
this.deselect();
|
||||
}
|
||||
this.doSelect(node);
|
||||
|
||||
this.publishTopics(this.selectedNotifyTopicsArray, {node: node});
|
||||
},
|
||||
|
||||
expand: function(message) {
|
||||
var node = message.source;
|
||||
this.publishTopics(this.expandedNotifyTopicsArray, {node: node});
|
||||
},
|
||||
|
||||
collapse: function(message) {
|
||||
var node = message.source;
|
||||
this.publishTopics(this.collapsedNotifyTopicsArray, {node: node});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
dojo.kwCompoundRequire({
|
||||
common: ["struts.widget.Bind",
|
||||
"struts.widget.BindDiv",
|
||||
@@ -27718,7 +27988,8 @@ dojo.kwCompoundRequire({
|
||||
"struts.widget.ComboBox",
|
||||
"struts.widget.StrutsTimePicker",
|
||||
"struts.widget.StrutsDatePicker",
|
||||
"struts.widget.BindEvent"]
|
||||
"struts.widget.BindEvent",
|
||||
"struts.widget.StrutsTreeSelector"]
|
||||
});
|
||||
dojo.provide("struts.widget.*");
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
// dojo.hostenv.writeIncludes();
|
||||
-->
|
||||
</script>
|
||||
<#if parameters.treeSelectedTopic?exists || parameters.treeExpandedTopic?exists
|
||||
|| parameters.treeCollapsedTopic?exists>
|
||||
<#assign eventNames = "" >
|
||||
<#if parameters.treeSelectedTopic?exists>
|
||||
<#assign eventNames = "select:" + parameters.treeSelectedTopic?html + ";">
|
||||
</#if>
|
||||
<#if parameters.treeExpandedTopic?exists>
|
||||
<#assign eventNames = eventNames + "expand:" + parameters.treeExpandedTopic?html + ";">
|
||||
<#if parameters.selectedNotifyTopics?exists || parameters.expandedNotifyTopics?exists
|
||||
|| parameters.collapsedNotifyTopics?exists>
|
||||
<struts:StrutsTreeSelector widgetId="treeSelector_${parameters.id?default("")}"
|
||||
<#if parameters.selectedNotifyTopics?exists>
|
||||
selectedNotifyTopics="${parameters.selectedNotifyTopics?html}"
|
||||
</#if>
|
||||
<#if parameters.treeCollapsedTopic?exists>
|
||||
<#assign eventNames = eventNames + "collapse:" + parameters.treeCollapsedTopic?html>
|
||||
<#if parameters.expandedNotifyTopics?exists>
|
||||
expandedNotifyTopics="${parameters.expandedNotifyTopics?html}"
|
||||
</#if>
|
||||
<struts:StrutsTreeSelector widgetId="treeSelector_${parameters.id?default("")}" eventNames="${eventNames}">
|
||||
<#if parameters.collapsedNotifyTopics?exists>
|
||||
collapsedNotifyTopics="${parameters.collapsedNotifyTopics?html}"
|
||||
</#if>
|
||||
>
|
||||
</struts:StrutsTreeSelector>
|
||||
</#if>
|
||||
<div dojoType="Tree"
|
||||
@@ -73,7 +73,8 @@
|
||||
<#if parameters.id?exists>
|
||||
id="${parameters.id?html}"
|
||||
</#if>
|
||||
<#if parameters.treeSelectedTopic?exists>
|
||||
<#if parameters.selectedNotifyTopics?exists || parameters.expandedNotifyTopics?exists
|
||||
|| parameters.collapsedNotifyTopics?exists>
|
||||
selector="treeSelector_${parameters.id?default("")}"
|
||||
</#if>
|
||||
<#if parameters.treeCollapsedTopic?exists>
|
||||
|
||||
Reference in New Issue
Block a user