提交 293e330b 编写于 作者: N nilspreusker

small layout fix for treeView component, substituted tabs with spaces in cycle...

small layout fix for treeView component, substituted tabs with spaces in cycle javascript files, added null checks for history event based tree node highlighting
上级 03ed90c7
.yui-skin-sam .yui-navset .yui-nav a, .yui-skin-sam .yui-navset .yui-navset-top .yui-nav a {
border-left: 1px solid !important;
border-right: 1px solid !important;
border-color: #A3A3A3 !important;
border-left: 1px solid !important;
border-right: 1px solid !important;
border-color: #A3A3A3 !important;
}
.yui-skin-sam .yui-navset .yui-nav .selected a, .yui-skin-sam .yui-navset .yui-nav .selected a em {
border-color: #A3A3A3 !important;
border-color: #A3A3A3 !important;
}
.yui-skin-sam .yui-navset .yui-nav .selected a, .yui-skin-sam .yui-navset .yui-nav .selected a:focus, .yui-skin-sam .yui-navset .yui-nav .selected a:hover {
color: #FFFFFF !important;
color: #FFFFFF !important;
}
.yui-skin-sam .yui-navset .yui-content {
background: none repeat scroll 0 0 #F9F9F9;
background: none repeat scroll 0 0 #F9F9F9;
}
.artifact-image, .artifact-html, .artifact-html-reference, .artifact-binary, .artifact-code, .artifact-text-plain {
......@@ -18,7 +18,9 @@
}
.artifact-code, .artifact-text-plain, .artifact-html {
margin: 1.2em;
background-color:#FFFFFF;
margin:0.5em;
padding:1.2em;
}
.artifact-html iframe, .artifact-html-reference iframe {
......@@ -28,19 +30,19 @@
}
#options-div.active {
border-bottom: 1px dotted #EEEEEE;
border-top: 1px dotted #EEEEEE;
padding: 5px;
margin-bottom: 15px;
background-color: #FFFFF9;
border-bottom: 1px dotted #EEEEEE;
border-top: 1px dotted #EEEEEE;
padding: 5px;
margin-bottom: 15px;
background-color: #FFFFF9;
}
#artifact-actions, #artifact-links, #artifact-downloads {
float: left;
margin-right: 15px;
float: left;
margin-right: 15px;
}
#artifact-div .yui-navset div.loading div {
background:url("/activiti-cycle/res/images/loading.gif") no-repeat scroll center center transparent;
height:8em;
background:url("/activiti-cycle/res/images/loading.gif") no-repeat scroll center center transparent;
height:8em;
}
\ No newline at end of file
(function()
{
/**
* Shortcuts
*/
var Dom = YAHOO.util.Dom,
Selector = YAHOO.util.Selector,
Event = YAHOO.util.Event,
Pagination = Activiti.util.Pagination,
$html = Activiti.util.decodeHTML;
/**
* Artifact constructor.
*
* @param {String} htmlId The HTML id of the parent element
* @return {Activiti.component.Artifact} The new component.Artifact instance
* @constructor
*/
Activiti.component.Artifact = function Artifact_constructor(htmlId)
/**
* Shortcuts
*/
var Dom = YAHOO.util.Dom,
Selector = YAHOO.util.Selector,
Event = YAHOO.util.Event,
Pagination = Activiti.util.Pagination,
$html = Activiti.util.decodeHTML;
/**
* Artifact constructor.
*
* @param {String} htmlId The HTML id of the parent element
* @return {Activiti.component.Artifact} The new component.Artifact instance
* @constructor
*/
Activiti.component.Artifact = function Artifact_constructor(htmlId)
{
Activiti.component.Artifact.superclass.constructor.call(this, "Activiti.component.Artifact", htmlId);
// Create new service instances and set this component to receive the callbacks
// Create new service instances and set this component to receive the callbacks
this.services.repositoryService = new Activiti.service.RepositoryService(this);
// Listen for events that interest this component
this.onEvent(Activiti.event.updateArtifactView, this.onUpdateArtifactView);
this.onEvent(Activiti.event.clickFormEventButton, this.onClickFormEventButton);
this._tabView = {};
this._repositoryNodeId = "";
this._isRepositoryArtifact = false;
this._name = "";
this._activeTabIndex = 0;
this._tabView = {};
this._repositoryNodeId = "";
this._isRepositoryArtifact = false;
this._name = "";
this._activeTabIndex = 0;
this._fileChooserDialog = {};
......@@ -38,171 +38,171 @@
YAHOO.extend(Activiti.component.Artifact, Activiti.component.Base,
{
/**
* Fired by YUI when parent element is available for scripting.
* Template initialisation, including instantiation of YUI widgets and event listener binding.
*
* @method onReady
*/
onReady: function Artifact_onReady()
{
/**
* Fired by YUI when parent element is available for scripting.
* Template initialisation, including instantiation of YUI widgets and event listener binding.
*
* @method onReady
*/
onReady: function Artifact_onReady()
{
},
/**
* This method is invoked when a node in the tree is selected or the active tab chages.
* It first checks whether the node is still the same and updates the active tab if
* needed. If a new node was selected in the tree, the current artifact view is removed
* and the loadArtifact method is invoked with the new artifacts id.
*
* @method onUpdateArtifactView
* @param event {String} the name of the event that triggered this method invokation
* @param args {array} an array of object literals
*/
onUpdateArtifactView: function Artifact_onUpdateArtifactView(event, args) {
var eventValue = args[1].value;
this._connectorId = eventValue.connectorId;
this._repositoryNodeId = eventValue.repositoryNodeId;
this._isRepositoryArtifact = eventValue.isRepositoryArtifact;
this._name = eventValue.name;
this._activeTabIndex = eventValue.activeTabIndex;
},
/**
* This method is invoked when a node in the tree is selected or the active tab chages.
* It first checks whether the node is still the same and updates the active tab if
* needed. If a new node was selected in the tree, the current artifact view is removed
* and the loadArtifact method is invoked with the new artifacts id.
*
* @method onUpdateArtifactView
* @param event {String} the name of the event that triggered this method invokation
* @param args {array} an array of object literals
*/
onUpdateArtifactView: function Artifact_onUpdateArtifactView(event, args) {
var eventValue = args[1].value;
this._connectorId = eventValue.connectorId;
this._repositoryNodeId = eventValue.repositoryNodeId;
this._isRepositoryArtifact = eventValue.isRepositoryArtifact;
this._name = eventValue.name;
this._activeTabIndex = eventValue.activeTabIndex;
// get the header el of the content area
var headerEl = Selector.query("h1", this.id, true);
// determine whether the node is still the same
if("header-" + eventValue.repositoryNodeId === headerEl.id) {
// still the same node, if the tab view is instanciated, the tab selection should be updated
if(this._tabView.set) {
// Update active tab selection silently, without firing an event (last parameter 'true')
this._tabView.set("activeTab", this._tabView.getTab(this._activeTabIndex), true);
}
} else {
// a new node has been selected in the tree
var tabViewHtml = YAHOO.util.Selector.query('div', 'artifact-div', true);
// check whether an artifact was selected before. If yes, remove tabViewHtml and actions
if(tabViewHtml) {
var artifactDiv = document.getElementById('artifact-div');
artifactDiv.removeChild(tabViewHtml);
var optionsDiv = document.getElementById('options-div');
optionsDiv.innerHTML = "";
optionsDiv.removeAttribute("class");
}
// Check whether the selected node is a file node. If so, load its data
if(eventValue.isRepositoryArtifact ) {
this.services.repositoryService.loadArtifact(eventValue.connectorId, eventValue.repositoryNodeId);
}
// Update the heading that displays the name of the selected node
headerEl.id = "header-" + eventValue.repositoryNodeId;
headerEl.innerHTML = eventValue.name;
}
},
/**
* This method is invoked when an artifact is loaded successfully. It will draw a
* yui tab view component to display the different content representations of the
* artifact and create an options panel for links, downloads and actions.
*
* @method onLoadArtifactSuccess
* @param response {object} The callback response
* @param obj {object} Helper object
*/
// get the header el of the content area
var headerEl = Selector.query("h1", this.id, true);
// determine whether the node is still the same
if("header-" + eventValue.repositoryNodeId === headerEl.id) {
// still the same node, if the tab view is instanciated, the tab selection should be updated
if(this._tabView.set) {
// Update active tab selection silently, without firing an event (last parameter 'true')
this._tabView.set("activeTab", this._tabView.getTab(this._activeTabIndex), true);
}
} else {
// a new node has been selected in the tree
var tabViewHtml = YAHOO.util.Selector.query('div', 'artifact-div', true);
// check whether an artifact was selected before. If yes, remove tabViewHtml and actions
if(tabViewHtml) {
var artifactDiv = document.getElementById('artifact-div');
artifactDiv.removeChild(tabViewHtml);
var optionsDiv = document.getElementById('options-div');
optionsDiv.innerHTML = "";
optionsDiv.removeAttribute("class");
}
// Check whether the selected node is a file node. If so, load its data
if(eventValue.isRepositoryArtifact ) {
this.services.repositoryService.loadArtifact(eventValue.connectorId, eventValue.repositoryNodeId);
}
// Update the heading that displays the name of the selected node
headerEl.id = "header-" + eventValue.repositoryNodeId;
headerEl.innerHTML = eventValue.name;
}
},
/**
* This method is invoked when an artifact is loaded successfully. It will draw a
* yui tab view component to display the different content representations of the
* artifact and create an options panel for links, downloads and actions.
*
* @method onLoadArtifactSuccess
* @param response {object} The callback response
* @param obj {object} Helper object
*/
onLoadArtifactSuccess: function RepoTree_RepositoryService_onLoadArtifactSuccess(response, obj)
{
var me = this;
this._tabView = new YAHOO.widget.TabView();
// Retrieve rest api response
var artifactJson = response.json;
this._tabView = new YAHOO.widget.TabView();
// Retrieve rest api response
var artifactJson = response.json;
for(var i = 0; i<artifactJson.contentRepresentations.length; i++) {
var tab = new YAHOO.widget.Tab({
label: artifactJson.contentRepresentations[i],
dataSrc: this.loadTabDataURL(artifactJson.connectorId, artifactJson.artifactId, artifactJson.contentRepresentations[i]),
cacheData: true
});
tab.addListener("contentChange", this.onTabDataLoaded);
tab.loadHandler.success = function(response) {
for(var i = 0; i<artifactJson.contentRepresentations.length; i++) {
var tab = new YAHOO.widget.Tab({
label: artifactJson.contentRepresentations[i],
dataSrc: this.loadTabDataURL(artifactJson.connectorId, artifactJson.artifactId, artifactJson.contentRepresentations[i]),
cacheData: true
});
tab.addListener("contentChange", this.onTabDataLoaded);
tab.loadHandler.success = function(response) {
me.onLoadTabSuccess(this /* the tab */, response);
};
this._tabView.addTab(tab);
}
};
this._tabView.addTab(tab);
}
this._tabView.appendTo('artifact-div');
this._tabView.appendTo('artifact-div');
// replace the tabViews onActiveTabCHange evnet handler with our own one
this._tabView.unsubscribe("activeTabChange", this._tabView._onActiveTabChange);
this._tabView.subscribe("activeTabChange", this.onActiveTabChange, null, this);
// replace the tabViews onActiveTabCHange evnet handler with our own one
this._tabView.unsubscribe("activeTabChange", this._tabView._onActiveTabChange);
this._tabView.subscribe("activeTabChange", this.onActiveTabChange, null, this);
// Select the active tab without firing an event (last parameter is 'silent=true')
this._tabView.set("activeTab", this._tabView.getTab(this._activeTabIndex), true);
// Select the active tab without firing an event (last parameter is 'silent=true')
this._tabView.set("activeTab", this._tabView.getTab(this._activeTabIndex), true);
// Create the options panel
var optionsDiv = document.getElementById("options-div");//YAHOO.util.Selector.query('div', 'artifact-div', true);
// Create the options panel
var optionsDiv = document.getElementById("options-div");//YAHOO.util.Selector.query('div', 'artifact-div', true);
// Add a dropdown for the actions
if(artifactJson.actions.length > 0) {
var actionsDiv = document.createElement("div");
actionsDiv.setAttribute('id', "artifact-actions");
actionsDiv.appendChild(document.createTextNode("Actions: "));
var actionsDropdown = document.createElement("select");
actionsDropdown.setAttribute('name', "Actions");
var option = document.createElement("option");
option.appendChild(document.createTextNode("choose an action..."));
actionsDropdown.appendChild(option);
for(i = 0; i<artifactJson.actions.length; i++) {
option = document.createElement("option");
option.setAttribute('value', artifactJson.connectorId + "#TOKEN#" + artifactJson.artifactId + "#TOKEN#" + artifactJson.actions[i].name);
option.appendChild(document.createTextNode(artifactJson.actions[i].label));
actionsDropdown.appendChild(option);
YAHOO.util.Event.addListener(option, "click", this.onExecuteActionClick);
}
actionsDiv.appendChild(actionsDropdown);
optionsDiv.appendChild(actionsDiv);
}
if(artifactJson.links.length > 0) {
var linksDiv = document.createElement("div");
linksDiv.setAttribute('id', "artifact-links");
linksDiv.appendChild(document.createTextNode("Links: "));
for(i=0; i<artifactJson.links.length; i++) {
var link = document.createElement("a");
link.setAttribute('href', artifactJson.links[i].url);
link.setAttribute('title', artifactJson.links[i].label);
link.setAttribute('target', "blank");
link.appendChild(document.createTextNode(artifactJson.links[i].label));
linksDiv.appendChild(link);
if(i < (artifactJson.links.length - 1)) {
linksDiv.appendChild(document.createTextNode(" | "));
}
}
optionsDiv.appendChild(linksDiv);
}
// Add download links if available
if(artifactJson.downloads.length > 0) {
var downloadsDiv = document.createElement("div");
downloadsDiv.setAttribute('id', "artifact-downloads");
downloadsDiv.appendChild(document.createTextNode("Downloads: "));
for(i=0; i<artifactJson.downloads.length; i++) {
var link1 = document.createElement("a");
link1.setAttribute('href', artifactJson.downloads[i].url);
link1.setAttribute('title', artifactJson.downloads[i].name + " (" + artifactJson.downloads[i].type + ")");
link1.setAttribute('target', "blank");
link1.appendChild(document.createTextNode(artifactJson.downloads[i].name));
downloadsDiv.appendChild(link1);
if(i < (artifactJson.downloads.length -1)) {
downloadsDiv.appendChild(document.createTextNode(" | "));
}
}
optionsDiv.appendChild(downloadsDiv);
}
var clearDiv = document.createElement('div');
clearDiv.setAttribute('style', 'clear: both');
optionsDiv.appendChild(clearDiv);
optionsDiv.setAttribute('class', 'active');
// Add a dropdown for the actions
if(artifactJson.actions.length > 0) {
var actionsDiv = document.createElement("div");
actionsDiv.setAttribute('id', "artifact-actions");
actionsDiv.appendChild(document.createTextNode("Actions: "));
var actionsDropdown = document.createElement("select");
actionsDropdown.setAttribute('name', "Actions");
var option = document.createElement("option");
option.appendChild(document.createTextNode("choose an action..."));
actionsDropdown.appendChild(option);
for(i = 0; i<artifactJson.actions.length; i++) {
option = document.createElement("option");
option.setAttribute('value', artifactJson.connectorId + "#TOKEN#" + artifactJson.artifactId + "#TOKEN#" + artifactJson.actions[i].name);
option.appendChild(document.createTextNode(artifactJson.actions[i].label));
actionsDropdown.appendChild(option);
YAHOO.util.Event.addListener(option, "click", this.onExecuteActionClick);
}
actionsDiv.appendChild(actionsDropdown);
optionsDiv.appendChild(actionsDiv);
}
if(artifactJson.links.length > 0) {
var linksDiv = document.createElement("div");
linksDiv.setAttribute('id', "artifact-links");
linksDiv.appendChild(document.createTextNode("Links: "));
for(i=0; i<artifactJson.links.length; i++) {
var link = document.createElement("a");
link.setAttribute('href', artifactJson.links[i].url);
link.setAttribute('title', artifactJson.links[i].label);
link.setAttribute('target', "blank");
link.appendChild(document.createTextNode(artifactJson.links[i].label));
linksDiv.appendChild(link);
if(i < (artifactJson.links.length - 1)) {
linksDiv.appendChild(document.createTextNode(" | "));
}
}
optionsDiv.appendChild(linksDiv);
}
// Add download links if available
if(artifactJson.downloads.length > 0) {
var downloadsDiv = document.createElement("div");
downloadsDiv.setAttribute('id', "artifact-downloads");
downloadsDiv.appendChild(document.createTextNode("Downloads: "));
for(i=0; i<artifactJson.downloads.length; i++) {
var link1 = document.createElement("a");
link1.setAttribute('href', artifactJson.downloads[i].url);
link1.setAttribute('title', artifactJson.downloads[i].name + " (" + artifactJson.downloads[i].type + ")");
link1.setAttribute('target', "blank");
link1.appendChild(document.createTextNode(artifactJson.downloads[i].name));
downloadsDiv.appendChild(link1);
if(i < (artifactJson.downloads.length -1)) {
downloadsDiv.appendChild(document.createTextNode(" | "));
}
}
optionsDiv.appendChild(downloadsDiv);
}
var clearDiv = document.createElement('div');
clearDiv.setAttribute('style', 'clear: both');
optionsDiv.appendChild(clearDiv);
optionsDiv.setAttribute('class', 'active');
},
onLoadTabSuccess: function Artifact_onLoadTabSuccess(tab, response) {
......@@ -234,37 +234,37 @@
}
},
onExecuteActionClick: function Artifact_onExecuteActionClick(e)
{
var connectorId = this.value.split("#TOKEN#")[0];
var artifactId = this.value.split("#TOKEN#")[1];
var actionName = this.value.split("#TOKEN#")[2];
onExecuteActionClick: function Artifact_onExecuteActionClick(e)
{
var connectorId = this.value.split("#TOKEN#")[0];
var artifactId = this.value.split("#TOKEN#")[1];
var actionName = this.value.split("#TOKEN#")[2];
return new Activiti.widget.ExecuteArtifactActionForm(this.id + "-executeArtifactActionForm", connectorId, artifactId, actionName);
},
onTabDataLoaded: function Artifact_onTabDataLoaded()
{
prettyPrint();
},
return new Activiti.widget.ExecuteArtifactActionForm(this.id + "-executeArtifactActionForm", connectorId, artifactId, actionName);
},
onTabDataLoaded: function Artifact_onTabDataLoaded()
{
prettyPrint();
},
loadTabDataURL: function Artifact_loadTabDataURL(connectorId, artifactId, representationId)
loadTabDataURL: function Artifact_loadTabDataURL(connectorId, artifactId, representationId)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "content-representation?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactId) + "&representationId=" + encodeURIComponent(representationId);
},
onActiveTabChange: function Artifact_onActiveTabChange(event)
{
var newActiveTabIndex = this._tabView.getTabIndex(event.newValue);
this.fireEvent(Activiti.event.updateArtifactView, {"connectorId": this._connectorId, "repositoryNodeId": this._repositoryNodeId, "isRepositoryArtifact": this._isRepositoryArtifact, "name": this._name, "activeTabIndex": newActiveTabIndex}, null, true);
YAHOO.util.Event.preventDefault(event);
},
onClickFormEventButton: function Artifact_onClickFormEventButton(event, args)
{
return new Activiti.component.FileChooserDialog(this.id, args[1].value.callback);
}
onActiveTabChange: function Artifact_onActiveTabChange(event)
{
var newActiveTabIndex = this._tabView.getTabIndex(event.newValue);
this.fireEvent(Activiti.event.updateArtifactView, {"connectorId": this._connectorId, "repositoryNodeId": this._repositoryNodeId, "isRepositoryArtifact": this._isRepositoryArtifact, "name": this._name, "activeTabIndex": newActiveTabIndex}, null, true);
YAHOO.util.Event.preventDefault(event);
},
onClickFormEventButton: function Artifact_onClickFormEventButton(event, args)
{
return new Activiti.component.FileChooserDialog(this.id, args[1].value.callback);
}
});
});
})();
#fileChooserTree a:hover {
text-decoration: none;
}
\ No newline at end of file
......@@ -49,6 +49,10 @@
text-decoration: none;
}
#treeDiv1 .ygtvcontent {
line-height:1.2em;
}
/* first or middle sibling, no children */
.ygtvtn { background: url("/activiti-cycle/res/images/folder/tn.gif") 0 0 no-repeat; width:17px; height:22px; }
......
(function()
{
/**
* Shortcuts
*/
var Dom = YAHOO.util.Dom,
Selector = YAHOO.util.Selector,
Event = YAHOO.util.Event,
Pagination = Activiti.util.Pagination,
$html = Activiti.util.decodeHTML;
/**
* RepoTree constructor.
*
* @param {String} htmlId The HTML id of the parent element
* @return {Activiti.component.RepoTree} The new component.RepoTree instance
* @constructor
*/
Activiti.component.RepoTree = function RepoTree_constructor(htmlId)
/**
* Shortcuts
*/
var Dom = YAHOO.util.Dom,
Selector = YAHOO.util.Selector,
Event = YAHOO.util.Event,
Pagination = Activiti.util.Pagination,
$html = Activiti.util.decodeHTML;
/**
* RepoTree constructor.
*
* @param {String} htmlId The HTML id of the parent element
* @return {Activiti.component.RepoTree} The new component.RepoTree instance
* @constructor
*/
Activiti.component.RepoTree = function RepoTree_constructor(htmlId)
{
Activiti.component.RepoTree.superclass.constructor.call(this, "Activiti.component.RepoTree", htmlId);
// Create new service instances and set this component to receive the callbacks
this.services.repositoryService = new Activiti.service.RepositoryService(this);
// Listen for updateArtifactView event in order to be able to expand the tree up to the selected artifact
// Listen for updateArtifactView event in order to be able to expand the tree up to the selected artifact
this.onEvent(Activiti.event.updateArtifactView, this.onUpdateArtifactView);
this._treeView = {};
this._treeView = {};
return this;
};
YAHOO.extend(Activiti.component.RepoTree, Activiti.component.Base,
{
/**
* Fired by YUI when parent element is available for scripting.
* Template initialisation, including instantiation of YUI widgets and event listener binding.
*
* @method onReady
*/
onReady: function RepoTree_onReady()
{
// load the json representation of the tree, onLoadTreeSuccess will be called due to naming convention
this.services.repositoryService.loadTree();
},
/**
/**
* Fired by YUI when parent element is available for scripting.
* Template initialisation, including instantiation of YUI widgets and event listener binding.
*
* @method onReady
*/
onReady: function RepoTree_onReady()
{
// load the json representation of the tree, onLoadTreeSuccess will be called due to naming convention
this.services.repositoryService.loadTree();
},
/**
* Will display the tree
*
* @method onLoadTreeSuccess
......@@ -56,80 +56,80 @@
*/
onLoadTreeSuccess: function RepoTree_RepositoryService_onLoadTreeSuccess(response)
{
var me = this;
var me = this;
// Retrieve rest api response
var treeNodesJson = response.json;
var loadTreeNodes = function (node, fnLoadComplete) {
if(node.data.file) {
// Don't attempt to load child nodes for artifacts
fnLoadComplete();
} else {
me.services.repositoryService.loadNodeData(node, fnLoadComplete);
// TODO: see if there is a way to define a timeout even if the server returns a HTTP 500 status
//timeout: 7000
}
};
// instantiate the TreeView control
me._treeView = new YAHOO.widget.TreeView("treeDiv1", treeNodesJson);
// set the callback function to dynamically load child nodes
// set iconMode to 1 to use the leaf node icon when a node has no children.
me._treeView.setDynamicLoad(loadTreeNodes, 1);
me._treeView.render();
me._treeView.subscribe("clickEvent", this.onLabelClick, null, this);
// me._treeView.subscribe("expand", this.onNodeExpand, null, this);
// me._treeView.subscribe("collapse", this.onNodeCollapse, null, this);
var loadTreeNodes = function (node, fnLoadComplete) {
if(node.data.file) {
// Don't attempt to load child nodes for artifacts
fnLoadComplete();
} else {
me.services.repositoryService.loadNodeData(node, fnLoadComplete);
// TODO: see if there is a way to define a timeout even if the server returns a HTTP 500 status
//timeout: 7000
}
};
// instantiate the TreeView control
me._treeView = new YAHOO.widget.TreeView("treeDiv1", treeNodesJson);
// set the callback function to dynamically load child nodes
// set iconMode to 1 to use the leaf node icon when a node has no children.
me._treeView.setDynamicLoad(loadTreeNodes, 1);
me._treeView.render();
me._treeView.subscribe("clickEvent", this.onLabelClick, null, this);
// me._treeView.subscribe("expand", this.onNodeExpand, null, this);
// me._treeView.subscribe("collapse", this.onNodeCollapse, null, this);
},
/**
/**
*
*
*
*/
onLoadNodeDataSuccess: function RepoTree_RepositoryService_onLoadNodeDataSuccess(response, obj)
onLoadNodeDataSuccess: function RepoTree_RepositoryService_onLoadNodeDataSuccess(response, obj)
{
// Retrieve rest api response
var treeNodesJson = response.json;
if(treeNodesJson) {
for(var i = 0; i<treeNodesJson.length; i++) {
var node = new YAHOO.widget.TextNode(treeNodesJson[i], obj[0], treeNodesJson[i].expanded);
if(treeNodesJson[i].contentType) {
if(treeNodesJson[i].contentType === "image/png" || treeNodesJson[i].contentType === "image/gif" || treeNodesJson[i].contentType === "image/jpeg") {
node.labelStyle = "icon-img";
} else if(treeNodesJson[i].contentType === "application/xml") {
node.labelStyle = "icon-code-red";
} else if(treeNodesJson[i].contentType === "text/html") {
node.labelStyle = "icon-www";
} else if(treeNodesJson[i].contentType === "text/plain") {
node.labelStyle = "icon-txt";
} else if(treeNodesJson[i].contentType === "application/pdf") {
node.labelStyle = "icon-pdf";
} else if(treeNodesJson[i].contentType === "application/json;charset=UTF-8") {
node.labelStyle = "icon-code-blue";
} else if(treeNodesJson[i].contentType === "application/msword") {
node.labelStyle = "icon-doc";
} else if(treeNodesJson[i].contentType === "application/powerpoint") {
node.labelStyle = "icon-ppt";
} else if(treeNodesJson[i].contentType === "application/excel") {
node.labelStyle = "icon-xls";
} else if(treeNodesJson[i].contentType === "application/javascript") {
node.labelStyle = "icon-code-blue";
} else {
// Use white page as default icon for all other content types
node.labelStyle = "icon-blank";
}
}
}
}
// call the fnLoadComplete function that the treeView component provides to
// indicate that the loading of the sub nodes was successfull.
obj[1]();
for(var i = 0; i<treeNodesJson.length; i++) {
var node = new YAHOO.widget.TextNode(treeNodesJson[i], obj[0], treeNodesJson[i].expanded);
if(treeNodesJson[i].contentType) {
if(treeNodesJson[i].contentType === "image/png" || treeNodesJson[i].contentType === "image/gif" || treeNodesJson[i].contentType === "image/jpeg") {
node.labelStyle = "icon-img";
} else if(treeNodesJson[i].contentType === "application/xml") {
node.labelStyle = "icon-code-red";
} else if(treeNodesJson[i].contentType === "text/html") {
node.labelStyle = "icon-www";
} else if(treeNodesJson[i].contentType === "text/plain") {
node.labelStyle = "icon-txt";
} else if(treeNodesJson[i].contentType === "application/pdf") {
node.labelStyle = "icon-pdf";
} else if(treeNodesJson[i].contentType === "application/json;charset=UTF-8") {
node.labelStyle = "icon-code-blue";
} else if(treeNodesJson[i].contentType === "application/msword") {
node.labelStyle = "icon-doc";
} else if(treeNodesJson[i].contentType === "application/powerpoint") {
node.labelStyle = "icon-ppt";
} else if(treeNodesJson[i].contentType === "application/excel") {
node.labelStyle = "icon-xls";
} else if(treeNodesJson[i].contentType === "application/javascript") {
node.labelStyle = "icon-code-blue";
} else {
// Use white page as default icon for all other content types
node.labelStyle = "icon-blank";
}
}
}
}
// call the fnLoadComplete function that the treeView component provides to
// indicate that the loading of the sub nodes was successfull.
obj[1]();
},
// TODO: See how we can handle failures
......@@ -139,7 +139,7 @@
//
// },
/**
/**
* Will fire a Activiti.event.selectTreeLabel event so other components may display the node
*
* @method onLabelClick
......@@ -147,55 +147,54 @@
*/
onLabelClick: function RepoTree_onLabelClick (event)
{
// Map the node properties to the event value object (value object property -> node property):
// - repositoryNodeId -> node.data.id
// - isRepositoryArtifact -> node.data.file
// - name -> node.label
// Map the node properties to the event value object (value object property -> node property):
// - repositoryNodeId -> node.data.id
// - isRepositoryArtifact -> node.data.file
// - name -> node.label
this.fireEvent(Activiti.event.updateArtifactView, {"connectorId": event.node.data.connectorId, "repositoryNodeId": event.node.data.artifactId, "isRepositoryArtifact": event.node.data.file, "name": event.node.label, "activeTabIndex": 0}, null, true);
this.fireEvent(Activiti.event.updateArtifactView, {"connectorId": event.node.data.connectorId, "repositoryNodeId": event.node.data.artifactId, "isRepositoryArtifact": event.node.data.file, "name": event.node.label, "activeTabIndex": 0}, null, true);
},
// onNodeExpand: function RepoTree_onNodeExpand (node)
// {
//
// // TODO
// // do the cookie processing to store the expand/collapse state of the tree
//
// },
//
// onNodeCollapse: function RepoTree_onNodeCollapse (node)
// {
//
// // TODO
// // do the cookie processing to store the expand/collapse state of the tree
//
// },
onUpdateArtifactView: function Artifact_onUpdateArtifactView(event, args)
{
if(!this._treeView._nodes) {
// tree is not yet initialized, we are coming from an external URL
// onNodeExpand: function RepoTree_onNodeExpand (node)
// {
//
// // TODO
// // do the cookie processing to store the expand/collapse state of the tree
//
// },
//
// onNodeCollapse: function RepoTree_onNodeCollapse (node)
// {
//
// // TODO
// // do the cookie processing to store the expand/collapse state of the tree
//
// },
onUpdateArtifactView: function Artifact_onUpdateArtifactView(event, args)
{
if(!this._treeView._nodes) {
// tree is not yet initialized, we are coming from an external URL
// TODO: load the tree up to the currently selected node
} else {
// tree is initialized, this is either a regular click on the tree or an event from the browser history manager
var connectorId = args[1].value.connectorId;
var repositoryNodeId = args[1].value.repositoryNodeId;
var nodes = this._treeView.getNodesBy( function(node) {
if(node.data.connectorId && node.data.artifactId && node.data.connectorId === connectorId && node.data.artifactId === repositoryNodeId) {
return true;
}
return false;
});
var node = nodes[0];
if(node && (node != this._treeView.currentFocus) ) {
// if the node isn't already focused this is a browser history event and we manually set focus to the current node
node.focus();
}
}
}
});
} else {
// tree is initialized, this is either a regular click on the tree or an event from the browser history manager
var connectorId = args[1].value.connectorId;
var repositoryNodeId = args[1].value.repositoryNodeId;
var nodes = this._treeView.getNodesBy( function(node) {
if(node.data.connectorId && node.data.artifactId && node.data.connectorId === connectorId && node.data.artifactId === repositoryNodeId) {
return true;
}
return false;
});
if(nodes && nodes[0] && (nodes[0] != this._treeView.currentFocus) ) {
// if the node isn't already focused this is a browser history event and we manually set focus to the current node
nodes[0].focus();
}
}
}
});
})();
......@@ -10,7 +10,7 @@
*/
(function()
{
var that = this;
var that = this;
/**
* RepositoryService constructor.
......@@ -21,9 +21,9 @@
*/
Activiti.service.RepositoryService = function RepositoryService_constructor(callbackHandler)
{
Activiti.service.RepositoryService.superclass.constructor.call(this, "Activiti.service.RepositoryService", callbackHandler);
Activiti.service.RepositoryService.superclass.constructor.call(this, "Activiti.service.RepositoryService", callbackHandler);
that = this;
return this;
return this;
};
/**
......@@ -60,18 +60,18 @@
return Activiti.service.REST_PROXY_URI_RELATIVE + "child-nodes?connectorId=/&artifactId=''";
},
/**
* TODO: document it.. Also see dynamicLoad in repo-tree.js
*
*/
loadNodeData: function RepositoryService_loadNodeData(node, fnLoadComplete)
{
var obj = [node, fnLoadComplete];
this.jsonGet(this.loadNodeURL(node.data.connectorId, node.data.artifactId), obj, "loadNodeData");
},
/**
* TODO: doc
/**
* TODO: document it.. Also see dynamicLoad in repo-tree.js
*
*/
loadNodeData: function RepositoryService_loadNodeData(node, fnLoadComplete)
{
var obj = [node, fnLoadComplete];
this.jsonGet(this.loadNodeURL(node.data.connectorId, node.data.artifactId), obj, "loadNodeData");
},
/**
* TODO: doc
* Creates the GET url used to load the tree
*
* @method loadTreeURL
......@@ -98,7 +98,7 @@
* Creates the GET url used to load the artifact
*
* @method loadArtifactURL
* @param artifactid {string} The id of the artifact
* @param artifactid {string} The id of the artifact
* @return {string} The url
*/
loadArtifactURL: function RepositoryService_loadArtifactURL(connectorId, artifactid)
......@@ -106,27 +106,27 @@
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactid) + "&restProxyUri=" + encodeURIComponent(Activiti.service.REST_PROXY_URI_RELATIVE);
},
// TODO: doc
// TODO: doc
loadArtifactActionForm: function RepositoryService_loadArtifactActionForm(connectorId, artifactId, artifactActionName, obj)
{
this.jsonGet(this.loadArtifactActionFormURL(connectorId, artifactId, artifactActionName), obj, "loadArtifactActionForm");
this.jsonGet(this.loadArtifactActionFormURL(connectorId, artifactId, artifactActionName), obj, "loadArtifactActionForm");
},
// TODO: doc
// TODO: doc
loadArtifactActionFormURL: function RepositoryService_loadArtifactActionFormURL(connectorId, artifactId, artifactActionName)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-action-form?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactId) + "&actionName=" + encodeURIComponent(artifactActionName);
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-action-form?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactId) + "&actionName=" + encodeURIComponent(artifactActionName);
},
executeArtifactAction: function RepositoryService_executeArtifactAction(connectorId, artifactId, artifactActionName, variables, obj)
{
this.jsonPut(this.executeArtifactFormURL(connectorId, artifactId, artifactActionName), variables, obj, "executeArtifactAction");
},
executeArtifactAction: function RepositoryService_executeArtifactAction(connectorId, artifactId, artifactActionName, variables, obj)
{
this.jsonPut(this.executeArtifactFormURL(connectorId, artifactId, artifactActionName), variables, obj, "executeArtifactAction");
},
executeArtifactFormURL: function RepositoryService_executeArtifactFormURL(connectorId, artifactId, artifactActionName)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-action?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactId) + "&actionName=" + encodeURIComponent(artifactActionName);
}
executeArtifactFormURL: function RepositoryService_executeArtifactFormURL(connectorId, artifactId, artifactActionName)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-action?connectorId=" + encodeURIComponent(connectorId) + "&artifactId=" + encodeURIComponent(artifactId) + "&actionName=" + encodeURIComponent(artifactActionName);
}
});
})();
......@@ -149,7 +149,7 @@
/**
* ExecuteArtifactActionForm constructor.
*
* @param id {string} The components id
* @param id {string} The components id
* @parameter handler {object} The response handler object
* @return {Activiti.widget.ExecuteArtifactActionForm} The new Activiti.widget.ExecuteArtifactActionForm instance
* @constructor
......@@ -159,7 +159,7 @@
Activiti.widget.ExecuteArtifactActionForm.superclass.constructor.call(this, id);
this.connectorId = connectorId;
this.artifactId = artifactId;
this.artifactActionName = artifactActionName;
this.artifactActionName = artifactActionName;
this.service = new Activiti.service.RepositoryService(this);
this.service.setCallback("loadArtifactActionForm", { fn: this.onLoadFormSuccess, scope: this }, {fn: this.onLoadFormFailure, scope: this });
this.service.loadArtifactActionForm(this.connectorId, this.artifactId, this.artifactActionName);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册