/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jbpm.webapp.tag;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.XPath;
import org.dom4j.xpath.DefaultXPath;
import org.jbpm.JbpmContext;
import org.jbpm.file.def.FileDefinition;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
public class ProcessImageTag extends TagSupport {
private static final long serialVersionUID = 1L;
private long taskInstanceId = -1;
private long tokenInstanceId = -1;
private byte[] gpdBytes = null;
private byte[] imageBytes = null;
private Token currentToken = null;
private ProcessDefinition processDefinition = null;
static String currentTokenColor = "red";
static String childTokenColor = "blue";
static String tokenNameColor = "blue";
public void release() {
taskInstanceId = -1;
gpdBytes = null;
imageBytes = null;
currentToken = null;
}
public int doEndTag() throws JspException {
try {
initialize();
retrieveByteArrays();
if (gpdBytes != null && imageBytes != null) {
writeTable();
}
} catch (IOException e) {
e.printStackTrace();
throw new JspException("table couldn't be displayed", e);
} catch (DocumentException e) {
e.printStackTrace();
throw new JspException("table couldn't be displayed", e);
}
release();
return EVAL_PAGE;
}
private void retrieveByteArrays() {
try {
FileDefinition fileDefinition = processDefinition.getFileDefinition();
gpdBytes = fileDefinition.getBytes("gpd.xml");
imageBytes = fileDefinition.getBytes("processimage.jpg");
} catch (Exception e) {
e.printStackTrace();
}
}
private void writeTable() throws IOException, DocumentException {
int borderWidth = 4;
Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes)).getRootElement();
int[] boxConstraint;
int[] imageDimension = extractImageDimension(rootDiagramElement);
String imageLink = "processimage?definitionId=" + processDefinition.getId();
JspWriter jspOut = pageContext.getOut();
if (tokenInstanceId > 0) {
List allTokens = new ArrayList();
walkTokens(currentToken, allTokens);
jspOut.println("<div style='position:relative; background-image:url(" + imageLink + "); width: " + imageDimension[0] + "px; height: " + imageDimension[1] + "px;'>");
for (int i = 0; i < allTokens.size(); i++)
{
Token token = (Token) allTokens.get(i);
//check how many tokens are on teh same level (= having the same parent)
int offset = i;
if(i > 0) {
while(offset > 0 && ((Token) allTokens.get(offset - 1)).getParent().equals(token.getParent())) {
offset--;
}
}
boxConstraint = extractBoxConstraint(rootDiagramElement, token);
//Adjust for borders
//boxConstraint[2]-=borderWidth*2;
//boxConstraint[3]-=borderWidth*2;
jspOut.println("<div style='position:absolute; left: "+ boxConstraint[0] +"px; top: "+ boxConstraint[1] +"px; ");
if (i == (allTokens.size() - 1)) {
jspOut.println("border: " + currentTokenColor);
}
else {
jspOut.println("border: " + childTokenColor);
}
jspOut.println(" " + borderWidth + "px groove; "+
"width: "+ boxConstraint[2] +"px; height: "+ boxConstraint[3] +"px;'>");
if(token.getName()!=null)
{
jspOut.println("<span style='color:" + tokenNameColor + ";font-style:italic;position:absolute;left:"+ (boxConstraint[2] + 10) +"px;top:" +((i - offset) * 20) +";'> " + token.getName() +"</span>");
}
jspOut.println("</div>");
}
jspOut.println("</div>");
}
else
{
boxConstraint = extractBoxConstraint(rootDiagramElement);
jspOut.println("<table border=0 cellspacing=0 cellpadding=0 width=" + imageDimension[0] + " height=" + imageDimension[1] + ">");
jspOut.println(" <tr>");
jspOut.println(" <td width=" + imageDimension[0] + " height=" + imageDimension[1] + " style=\"background-image:url(" + imageLink + ")\" valign=top>");
jspOut.println(" <table border=0 cellspacing=0 cellpadding=0>");
jspOut.println(" <tr>");
jspOut.println(" <td width=" + (boxConstraint[0] - borderWidth) + " height=" + (boxConstraint[1] - borderWidth)
+ " style=\"background-color:transparent;\"></td>");
jspOut.println(" </tr>");
jspOut.println(" <tr>");
jspOut.println(" <td style=\"background-color:transparent;\"></td>");
jspOut.println(" <td style=\"border-color:" + currentTokenColor + "; border-width:" + borderWidth + "px; border-style:groove; background-color:transparent;\" width="
+ boxConstraint[2] + " height=" + (boxConstraint[3] + (2 * borderWidth)) + "> </td>");
jspOut.println(" </tr>");
jspOut.println(" </table>");
jspOut.println(" </td>");
jspOut.println(" </tr>");
jspOut.println("</table>");
}
}
private int[] extractBoxConstraint(Element root) {
int[] result = new int[4];
String nodeName = currentToken.getNode().getName();
XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
Element node = (Element) xPath.selectSingleNode(root);
result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
result[3] = Integer.valueOf(node.attribute("height").getValue()).intValue();
return result;
}
private int[] extractBoxConstraint(Element root, Token token) {
int[] result = new int[4];
String nodeName = token.getNode().getName();
XPath xPath = new DefaultXPath("//node[@name='" + nodeName + "']");
Element node = (Element) xPath.selectSingleNode(root);
result[0] = Integer.valueOf(node.attribute("x").getValue()).intValue();
result[1] = Integer.valueOf(node.attribute("y").getValue()).intValue();
result[2] = Integer.valueOf(node.attribute("width").getValue()).intValue();
result[3] = Integer.valueOf(node.attribute("height").getValue()
没有合适的资源?快使用搜索试试~ 我知道了~
开源工作流JBPM(完整工程)
共172个文件
jar:94个
jsp:15个
xml:15个
需积分: 10 59 下载量 117 浏览量
2008-12-23
18:07:12
上传
评论 1
收藏 23.39MB RAR 举报
温馨提示
一、环境要求如下: 1.tomcat5.0.28 2.mysql4.1.22 3.hibernate3.1 4.jdk1.5.0_08 5.myeclipse5.5 5.jbpm-starters-kit-3.1.4 二、数据库SQL文件在工程mysql4122目录下
资源推荐
资源详情
资源评论
收起资源包目录
开源工作流JBPM(完整工程) (172个子文件)
ProcessImageTag.class 9KB
UploadServlet.class 4KB
HellowordProcessTest.class 3KB
DeployServlet.class 3KB
SimpleProcessTest.class 2KB
ProcessImageServlet.class 2KB
TaskEndCountersign.class 2KB
CreateTaskInstanceCountersign.class 2KB
RequestAction.class 1KB
DeployProcessTest.class 1KB
MessageActionHandler.class 935B
CosingerAssiHandler.class 908B
ConfirmAction.class 888B
.classpath 411B
jbpm.css 2KB
Thumbs.db 5KB
Thumbs.db 4KB
Thumbs.db 4KB
logo_red.gif 3KB
logo_green.gif 3KB
logo_yellow.gif 3KB
swoosh_green.gif 556B
hdr_green_side.gif 270B
side_nav_green_btm.gif 226B
spacer.gif 43B
deploy.html 352B
hibernate3.jar 1.84MB
hibernate3.jar 1.84MB
hibernate3.jar 1.84MB
xercesImpl.jar 1.15MB
xercesImpl.jar 1.15MB
xercesImpl.jar 1.15MB
tomahawk.jar 877KB
tomahawk.jar 877KB
tomahawk.jar 877KB
jbpm-3.1.4.jar 589KB
jbpm-3.1.4.jar 589KB
jbpm-3.1.4.jar 589KB
myfaces-impl.jar 452KB
myfaces-impl.jar 452KB
myfaces-impl.jar 452KB
antlr-2.7.5H3.jar 426KB
antlr-2.7.5H3.jar 426KB
antlr-2.7.5H3.jar 426KB
mysql-connector-java-3.1.7-bin.jar 388KB
mysql-connector-java-3.1.7-bin.jar 388KB
mysql-connector-java-3.1.7-bin.jar 388KB
standard-1.1.2.jar 384KB
standard-1.1.2.jar 384KB
standard-1.1.2.jar 384KB
log4j.jar 345KB
log4j.jar 345KB
log4j.jar 345KB
dom4j-1.6.1.jar 307KB
dom4j-1.6.1.jar 307KB
dom4j-1.6.1.jar 307KB
cglib-2.1_2jboss.jar 280KB
cglib-2.1_2jboss.jar 280KB
cglib-2.1_2jboss.jar 280KB
bsh-1.3.0.jar 237KB
bsh-1.3.0.jar 237KB
bsh-1.3.0.jar 237KB
jaxen-1.1-beta-4.jar 233KB
jaxen-1.1-beta-4.jar 233KB
jaxen-1.1-beta-4.jar 233KB
myfaces-api.jar 230KB
myfaces-api.jar 230KB
myfaces-api.jar 230KB
xml-apis.jar 195KB
xml-apis.jar 195KB
xml-apis.jar 195KB
commons-collections.jar 161KB
commons-collections.jar 161KB
commons-collections.jar 161KB
junit-3.8.1.jar 118KB
junit-3.8.1.jar 118KB
junit-3.8.1.jar 118KB
commons-beanutils-1.6.1.jar 116KB
commons-beanutils-1.6.1.jar 116KB
commons-beanutils-1.6.1.jar 116KB
commons-digester-1.5.jar 107KB
commons-digester-1.5.jar 107KB
commons-digester-1.5.jar 107KB
javax.servlet.jar 96KB
javax.servlet.jar 96KB
javax.servlet.jsp.jar 50KB
javax.servlet.jsp.jar 50KB
jbpm-identity-3.1.4.jar 40KB
jbpm-identity-3.1.4.jar 40KB
jbpm-identity-3.1.4.jar 40KB
jbpm-webapp-3.1.4.jar 38KB
jbpm-webapp-3.1.4.jar 38KB
jbpm-webapp-3.1.4.jar 38KB
commons-logging.jar 32KB
commons-logging.jar 32KB
commons-logging.jar 32KB
asm.jar 26KB
asm.jar 26KB
asm.jar 26KB
commons-fileupload-1.0.jar 22KB
共 172 条
- 1
- 2
资源评论
tony_6846
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功