JavaFX-Plus v1.beta
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
package cn.edu.scau.biubiusuisui.entity;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.layout.Pane;
|
||||
import cn.edu.scau.biubiusuisui.utils.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/6/25 5:51
|
||||
*/
|
||||
|
||||
/**
|
||||
* In JavaFX-Plus Framework Controller
|
||||
* We use MVC model
|
||||
* V means view which stand for fxml
|
||||
* C means controller which stand for FXBaseController instance
|
||||
* M means model which is base cn.edu.scau.biubiusuisui.entity in your program
|
||||
* Every BaseController has a name which is used for identifying different <strong>instance</strong>
|
||||
*
|
||||
*/
|
||||
public class FXBaseController extends Pane {
|
||||
|
||||
protected String name = "";
|
||||
|
||||
private boolean isController = false;
|
||||
|
||||
private boolean isWindows = false;
|
||||
|
||||
public FXBaseController(String name){
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public FXBaseController(){
|
||||
FXController fxController = null;
|
||||
Annotation[] annotations = getClass().getAnnotations();
|
||||
// Find FXController cn.edu.scau.biubiusuisui.annotation
|
||||
for (Annotation annotation : annotations) {
|
||||
if (annotation.annotationType().equals(FXController.class)) {
|
||||
fxController = (FXController) annotation;
|
||||
isController = true;
|
||||
}
|
||||
}
|
||||
//load fxml file to show panel in scene builder
|
||||
if(isController) {
|
||||
FXMLLoaderPlus fxmlLoader = new FXMLLoaderPlus(getClass().getClassLoader().getResource(fxController.path()));
|
||||
fxmlLoader.setRoot(this);
|
||||
fxmlLoader.setController(this);
|
||||
try {
|
||||
fxmlLoader.load();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if("".equals(name)){
|
||||
return StringUtils.getBaseClassName(getClass().getSimpleName());
|
||||
}else{
|
||||
return StringUtils.getBaseClassName(getClass().getSimpleName()) +"#"+name;
|
||||
}
|
||||
}
|
||||
public void doInit(){}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isController() {
|
||||
return isController;
|
||||
}
|
||||
|
||||
public void setController(boolean controller) {
|
||||
isController = controller;
|
||||
}
|
||||
|
||||
public boolean isWindows() {
|
||||
return isWindows;
|
||||
}
|
||||
|
||||
public void setWindows(boolean windows) {
|
||||
isWindows = windows;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.edu.scau.biubiusuisui.entity;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
* @Date:2019/6/28 10:03
|
||||
*/
|
||||
public class FXFieldMethodMapping {
|
||||
|
||||
private Method setMethod ;
|
||||
private Method addMethod ;
|
||||
private Method delMethod;
|
||||
|
||||
public Method getSetMethod() {
|
||||
return setMethod;
|
||||
}
|
||||
|
||||
public void setSetMethod(Method setMethod) {
|
||||
this.setMethod = setMethod;
|
||||
}
|
||||
|
||||
public Method getAddMethod() {
|
||||
return addMethod;
|
||||
}
|
||||
|
||||
public void setAddMethod(Method addMethod) {
|
||||
this.addMethod = addMethod;
|
||||
}
|
||||
|
||||
public Method getDelMethod() {
|
||||
return delMethod;
|
||||
}
|
||||
|
||||
public void setDelMethod(Method delMethod) {
|
||||
this.delMethod = delMethod;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.edu.scau.biubiusuisui.entity;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* This class is base cn.edu.scau.biubiusuisui.entity for queue message(or signal)
|
||||
* you mush save the instance and method which means who will run this method
|
||||
* @Author jack
|
||||
* @Date:2019/6/26 15:39
|
||||
*/
|
||||
public class FXMethodEntity {
|
||||
|
||||
private FXBaseController fxBaseController;
|
||||
|
||||
private Method method;
|
||||
|
||||
public FXMethodEntity(FXBaseController fxBaseController, Method method) {
|
||||
this.fxBaseController = fxBaseController;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public FXBaseController getFxBaseController() {
|
||||
return fxBaseController;
|
||||
}
|
||||
|
||||
public void setFxBaseController(FXBaseController fxBaseController) {
|
||||
this.fxBaseController = fxBaseController;
|
||||
}
|
||||
|
||||
public Method getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(Method method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.edu.scau.biubiusuisui.entity;
|
||||
|
||||
import cn.edu.scau.biubiusuisui.proxy.classProxy.FXEntityProxy;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* Context is use for storing Controller
|
||||
* In addition,you can store an instance into Session to use it everywhere
|
||||
*
|
||||
* @Author jack
|
||||
* @Date:2019/6/26 12:28
|
||||
*/
|
||||
public class FXPlusContext {
|
||||
|
||||
private FXPlusContext(){}
|
||||
|
||||
private static Map<String, List<FXBaseController>> controllerContext = new ConcurrentHashMap<>();
|
||||
|
||||
private static Map<Object, FXEntityProxy> beanProxyMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static void addController(FXBaseController fxBaseController){
|
||||
List<FXBaseController> controllers = controllerContext.get(fxBaseController.getName());
|
||||
if(controllers == null){
|
||||
controllers = new LinkedList<>();
|
||||
}
|
||||
controllers.add(fxBaseController);
|
||||
}
|
||||
|
||||
public static List<FXBaseController> getControllers(String key){
|
||||
return controllerContext.get(key);
|
||||
}
|
||||
|
||||
public static FXEntityProxy getProryByBeanObject(Object object){
|
||||
return beanProxyMap.get(object);
|
||||
}
|
||||
|
||||
public static void setProxyByBeanObject(Object object,FXEntityProxy fxEntityProxy){
|
||||
beanProxyMap.put(object,fxEntityProxy);
|
||||
}
|
||||
public static Map<Object, FXEntityProxy> getBeanProxyMap() {
|
||||
return beanProxyMap;
|
||||
}
|
||||
|
||||
public static void setBeanProxyMap(Map<Object, FXEntityProxy> beanProxyMap) {
|
||||
FXPlusContext.beanProxyMap = beanProxyMap;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user