//Designer中用于获取脚本路径的方法
/**
* Get path of scripts.
* @param args SFEventArgs
* @return String
*/
public String getScriptsPath(SFEventArgs args){
String stateflowName = args.getStateflowObject().getStateflow().getName().toLowerCase();
//hs.sln.sanbu.path可以根据自己的情况修改
String scriptsPath = System.getProperty( "hs.sln.sanbu.path" ) + "/com/hansky/sln/sanbu/" + stateflowName + "/";
return scriptsPath;
}
/**
* Get path of scripts.
* @param sfo IStateflowObject
* @return String
*/
public String getScriptsPath(IStateflowObject sfo){
String stateflowName = sfo.getStateflow().getName().toLowerCase();
//hs.sln.sanbu.path可以根据自己的情况修改
String scriptsPath = System.getProperty( "hs.sln.sanbu.path" ) + "/com/hansky/sln/sanbu/" + stateflowName + "/";
return scriptsPath;
}
//doc流程create转换的beforeTransit
public void beforeTransit(IButterflyContext ctx, ITransition tr, SFTransitionCancelEventArgs args) {
try {
source( getScriptsPath(args) + "doc_create__before.java" );
doc_create__before(ctx,tr,args);
} catch (EvalError ee) {
System.out.println("=================doc_create__before=================================");
System.out.println("error message: " + ee.getMessage());
System.out.println("error text:" + ee.getErrorText());
System.out.println("line number:" + ee.getErrorLineNumber());
ee.printStackTrace();
System.out.println("==================================================");
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable t) {
t.printStackTrace();
}
}
//doc_create_before.java
package com.hansky.sln.sanbu.doc;
import com.hansky.intf.butterfly.*;
import com.hansky.intf.sat.*;
import com.hansky.intf.stateflow.*;
public static void doc_create__before (IButterflyContext ctx, ITransition tr, SFTransitionCancelEventArgs args) throws IOException {
}
//SR域脚本例子--Designer中
public IFieldValueList configState_SetReferenceList(IButterflyContext ctx, SFFieldEventArgs args) {
try {
source( getScriptsPath(args) + "doc_configState__SetReferenceList.java" );
return doc_configState__SetReferenceList(ctx,args);
} catch (EvalError ee) {
System.out.println("=============================================doc_configState__SetReferenceList.java=====");
System.out.println("error message: " + ee.getMessage());
System.out.println("error text:" + ee.getErrorText());
System.out.println("line number:" + ee.getErrorLineNumber());
ee.printStackTrace();
System.out.println("==================================================");
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable t) {
t.printStackTrace();
}
}
//SR域脚本例子--外部脚本
package com.hansky.sln.sanbu.doc;
import com.hansky.intf.butterfly.*;
import com.hansky.intf.sat.*;
import com.hansky.intf.stateflow.*;
public static IFieldValueList doc_configState__SetReferenceList(IButterflyContext ctx, SFFieldEventArgs args) {
IStateflowObject sfo = args.getStateflowObject();
ISession session = ctx.createSession();
IFieldValueList fvl = ctx.createFieldValueList(1);
return fvl;
}