⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 luawhileparse.java

📁 JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流控件
💻 JAVA
字号:
/**
 * 
 */
package flow.graph.gui.graph.lua.code;

import org.jgraph.graph.DefaultGraphCell;

import flow.graph.gui.graph.FlowGraphConstants;
import flow.graph.gui.graph.lua.xml.ActionTemplate;
import flow.graph.gui.graph.lua.xml.CaseTemplate;
import flow.graph.gui.graph.lua.xml.InputParameter;
import flow.graph.gui.graph.lua.xml.InputParameters;
import flow.graph.gui.graph.lua.xml.Parameter;
import flow.graph.gui.graph.lua.xml.Parameters;

/**
 * @author Administrator
 *
 */
public class LuaWhileParse {
	private String defineCode = "";
	private String executeCode = "";
	private String discriptionCode = "";
	private String commonCode = "";
	
	public LuaWhileParse(DefaultGraphCell cell){
		String cellid = "";
		if(cell != null){
			//设置cell名称到说明部分
			discriptionCode += "-----------------------------------------------------\n";
			discriptionCode += "-- "+cell.toString()+"\n";
			discriptionCode += "-----------------------------------------------------\n";
			if(FlowGraphConstants.getCellID(cell.getAttributes()) != null){
				//取得节点id
				cellid = FlowGraphConstants.getCellID(cell.getAttributes()).toString();
				defineCode += "function "+cellid+"(";
				
				if(FlowGraphConstants.getOutputTemplate(cell.getAttributes()) != null){
					Parameters parameters = (Parameters)FlowGraphConstants.getOutputTemplate(cell.getAttributes());
					if(parameters != null){
						for(int i=0;i<parameters.getParameters().size();i++){
							if(i!= 0) executeCode += ", ";
							Parameter parameter = (Parameter)parameters.getParameters().get(i);
							executeCode += cellid+"_"+parameter.getName();
						}
						if(parameters.getParameters().size() > 0)
							executeCode += " = ";
					}
				}
				
				executeCode += cellid+"(";
				//取得节点输入参数
				if(FlowGraphConstants.getInputTemplate(cell.getAttributes()) != null){
					InputParameters parameters = (InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes());
					if(parameters != null){
						for(int i=0;i<parameters.getParameters().size();i++){
							if(i!=0){
								defineCode += ", ";
								executeCode += ", ";
							}
							InputParameter parameter = (InputParameter)parameters.getParameters().get(i);
							
							//添加函数定义是的参数
							defineCode += parameter.getName();
							
							//添加函数执行时的参数
							if(parameter.getFlag() == true){
								//数据是前面的函数返回值来源
								executeCode += parameter.getSource();
							}
							else{
								if(parameter.getType().equals(Parameter.INT_TYPE))
									executeCode += parameter.getValue().length()<=0?"0":parameter.getValue();
								else if(parameter.getType().equals(Parameter.STRING_TYPE))
									executeCode += "\""+parameter.getValue()+"\"";
							}
						}
						defineCode += ")\n";
						executeCode += ")";
					}
				}
				if(FlowGraphConstants.getActionTemplate(cell.getAttributes()) != null){
					ActionTemplate action = (ActionTemplate)FlowGraphConstants.getActionTemplate(cell.getAttributes());
					defineCode += action.getAction();
				}
				defineCode += "\n";
				
				if(FlowGraphConstants.getCaseTemplate(cell.getAttributes()) != null){
					CaseTemplate action = (CaseTemplate)FlowGraphConstants.getCaseTemplate(cell.getAttributes());
					defineCode += "  while "+(action.getCondiction().length()<=0?"false":action.getCondiction())+" do\n";
				}
				defineCode += commonCode+"\n";
				
				defineCode += "\n  end\nend\n";
			}
		}
	}
	
	public String getDefineCode(){
		return defineCode;
	}
	
	public String getExecuteCode(){
		return executeCode;
	}
	
	public String getDiscriptionCode(){
		return discriptionCode;
	}
	
	public void insertCode(String s){
		commonCode += s+"\n";
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -