提交 c9685dbd 编写于 作者: N nilspreusker

Tree in activiti-cycle now shows icons for different file types

上级 0b9636b3
......@@ -6,9 +6,39 @@
overflow: auto;
}
#content #left .activiti-component #treeDiv1 .loading {
background:url("/activiti-cycle/res/images/loading.gif") no-repeat scroll center center transparent;
height:8em;
}
\ No newline at end of file
}
/* File type icons for tree nodes */
.icon-doc-blue { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 0px no-repeat; }
.icon-doc { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -16px no-repeat; }
.icon-ppt { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -32px no-repeat; }
.icon-xls { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -48px no-repeat; }
.icon-xls-blue { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -64px no-repeat; }
.icon-office { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -80px no-repeat; }
.icon-pdf { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -96px no-repeat; }
.icon-txt { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -112px no-repeat; }
.icon-blank { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -128px no-repeat; }
.icon-zip { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -144px no-repeat; }
.icon-archive { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -160px no-repeat; }
.icon-www { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -176px no-repeat; }
.icon-camera { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -192px no-repeat; }
.icon-img { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -208px no-repeat; }
.icon-java { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -224px no-repeat; }
.icon-php { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -240px no-repeat; }
.icon-ruby { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -256px no-repeat; }
.icon-sql { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -272px no-repeat; }
.icon-vs { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -288px no-repeat; }
.icon-c { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -304px no-repeat; }
.icon-h { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -320px no-repeat; }
.icon-c-sharp { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -336px no-repeat; }
.icon-c-plus-plus { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -352px no-repeat; }
.icon-action-script { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -368px no-repeat; }
.icon-flash { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -384px no-repeat; }
.icon-free-hand { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -400px no-repeat; }
.icon-code-page-blue { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -416px no-repeat; }
.icon-code-red { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -432px no-repeat; }
.icon-code-blue { display:block; height: 16px; padding-left: 20px; white-space: nowrap; background: transparent url("/activiti-cycle/res/images/doctype-icons.png") 0 -448px no-repeat; }
.htmlnodelabel { margin-left: 20px; }
\ No newline at end of file
......@@ -23,8 +23,8 @@
// Create new service instances and set this component to receive the callbacks
this.services.repositoryService = new Activiti.service.RepositoryService(this);
// Listen for selectTreeLabel event in order to be able to expand the tree up to the selected artifact
this.onEvent(Activiti.event.selectTreeLabel, this.onSelectTreeLabelEvent);
// 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 = {};
......@@ -62,9 +62,14 @@
var treeNodesJson = response.json;
var loadTreeNodes = function (node, fnLoadComplete) {
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
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
......@@ -91,7 +96,28 @@
var treeNodesJson = response.json;
for(var i = 0; i<treeNodesJson.length; i++) {
new YAHOO.widget.TextNode(treeNodesJson[i], obj[0], treeNodesJson[i].expanded);
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/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";
}
}
}
// call the fnLoadComplete function that the treeView component provides to
......@@ -132,15 +158,21 @@
},
onSelectTreeLabelEvent: function Artifact_onSelectTreeLabelEvent(event, args)
onUpdateArtifactView: function Artifact_onUpdateArtifactView(event, args)
{
// Check, whether the tree contains the node that was selected, otherwise we will have to request it from the REST API
// TODO
// this._treeView
// args[1].value.repositoryNodeId
if(!this._treeView._nodes) {
// tree is not initialized yet, we are coming from an external URL
} else {
// Check, whether the tree contains the node that was selected, otherwise we will have to request it from the REST API
var nodeExists = false;
for(var i=0; i<this._treeView._nodes.length; i++) {
if(this._treeView._nodes && this._treeView._nodes[i] && (this._treeView._nodes[i].data.id === args[1].value.repositoryNodeId) ) {
nodeExists = true;
}
}
//alert("Node is there:" + nodeExists);
}
}
});
......
......@@ -68,8 +68,8 @@ public class ArtifactGet extends ActivitiWebScript {
for (DownloadContentAction action : artifact.getArtifactType().getDownloadContentActions()) {
try {
String url = wsReq.getServerPath() + wsReq.getContextPath() + "/service/content?artifactId=" + URLEncoder.encode(artifactId, "UTF-8") + "&content-type="
+ URLEncoder.encode(action.getContentRepresentation().getMimeType(), "UTF-8");
downloads.add(new DownloadActionView(action.getId(), url, action.getContentRepresentation().getMimeType(), action.getContentRepresentation().getId()));
+ URLEncoder.encode(action.getContentRepresentation().getContentType().getName(), "UTF-8");
downloads.add(new DownloadActionView(action.getId(), url, action.getContentRepresentation().getContentType().name(), action.getContentRepresentation().getId()));
} catch (UnsupportedEncodingException e) {
// should never be reached as long as we use UTF-8, which is valid in
// java on all platforms
......
......@@ -48,7 +48,7 @@ public class ContentGet extends ActivitiStreamingWebScript {
Collection<ContentRepresentation> representations = artifact.getArtifactType().getContentRepresentations();
for (ContentRepresentation representation : representations) {
if (representation.getMimeType().equals(contentType)) {
if (representation.getContentType().getName().equals(contentType)) {
// assuming we want to create an attachment for binary data...
boolean attach = contentType.startsWith("application/") ? true : false;
......
......@@ -40,9 +40,9 @@ public class ContentRepresentationGet extends ActivitiWebScript {
try {
for (ContentRepresentation contentRepresentation : artifact.getArtifactType().getContentRepresentations()) {
if (contentRepresentation.getId().equals(representationId)) {
if (contentRepresentation.getMimeType().startsWith("image/")) {
if (contentRepresentation.getContentType().getName().startsWith("image/")) {
String imageUrl = restProxyUri + "/content?artifactId=" + URLEncoder.encode(artifactId, "UTF-8")
+ "&content-type=" + URLEncoder.encode(contentRepresentation.getMimeType(), "UTF-8");
+ "&content-type=" + URLEncoder.encode(contentRepresentation.getContentType().getName(), "UTF-8");
model.put("imageUrl", imageUrl);
} else {
String content = conn.getContent(artifactId, contentRepresentation.getId()).asString();
......
......@@ -17,6 +17,7 @@
"label": "${file.metadata.name}",
"id": "${file.id}",
"expanded": "true",
"file": "true"
"file": "true",
"contentType": "${file.artifactType.contentType.getName()}"
}
</#macro>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册