luaextendsparse.java

来自「JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流」· Java 代码 · 共 68 行

JAVA
68
字号
/**
 * 
 */
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.InputParameter;
import flow.graph.gui.graph.lua.xml.InputParameters;
import flow.graph.gui.graph.lua.xml.Parameter;

/**
 * @author Administrator
 *
 */
public class LuaExtendsParse {
	//private String defineCode = "";
	private String executeCode = "";
	private String discriptionCode = "";
	
	public LuaExtendsParse(DefaultGraphCell cell){
		String cellid = "";
		if(cell != null){
			//设置cell名称到说明部分
			discriptionCode += "-----------------------------------------------------\n";
			discriptionCode += "-- "+cell.toString()+"(id="+FlowGraphConstants.getCellID(cell.getAttributes())+") 嵌入代码\n";
			discriptionCode += "-----------------------------------------------------\n";
			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++){
						InputParameter parameter = (InputParameter)parameters.getParameters().get(i);
						executeCode += 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()+"\"";
						}
						executeCode += "\n";
					}
				}
			}
			if(FlowGraphConstants.getActionTemplate(cell.getAttributes()) != null){
				ActionTemplate action = (ActionTemplate)FlowGraphConstants.getActionTemplate(cell.getAttributes());
				executeCode += action.getAction();
			}
			executeCode += "\n";
		}
	}
	
	public String getExecuteCode(){
		return executeCode;
	}
	
	public String getDiscriptionCode(){
		return discriptionCode;
	}

}

⌨️ 快捷键说明

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