use of com.kyj.fx.voeditor.visual.framework.InstanceTypes in project Gargoyle by callakrsos.
the class FxUtil method load.
/********************************
* 작성일 : 2016. 5. 21. 작성자 : KYJ
*
* FXMLController 어노테이션 에 정의된 내용을 기준으로 FXML을 로드한다. </br>
* 아래메소드를 활용하는 경우
*
* PostInitialize 어노테이션을 활용하여 initialize() 수행후 후처리를 지정할 수 있음.
*
* @param controllerClass
* @param option
* @return
* @throws GargoyleException
* @throws NullPointerException
* @throws IOException
********************************/
public static <N, C> N load(Class<C> controllerClass, Object rootInstance, Consumer<N> option, Consumer<C> controllerAction) throws Exception {
if (controllerClass == null)
throw new NullPointerException("controller is null.");
String fullClassName = controllerClass.getCanonicalName();
FXMLController controller = getFxmlController(controllerClass);
if (controller == null) {
throw new GargoyleException("this is not FXMLController. check @FXMLController");
}
//controller.value();
String fxml = getFxml(controller);
if (ValueUtil.isEmpty(fxml))
throw new IllegalArgumentException("value is empty..");
InstanceTypes type = controller.instanceType();
N newInstance = null;
switch(type) {
case Singleton:
Node node = FxMemory.get(fullClassName);
if (node == null) {
newInstance = newInstance(controllerClass, rootInstance, controller.isSelfController(), fxml, option, controllerAction);
FxMemory.put(fullClassName, (Node) newInstance);
} else {
newInstance = (N) node;
}
break;
case RequireNew:
newInstance = newInstance(controllerClass, rootInstance, controller.isSelfController(), fxml, option, controllerAction);
break;
}
return newInstance;
}
Aggregations