可携带数据跳转
1. 新增可携带数据跳转的功能 2. 完善README 3. 修改示例
This commit is contained in:
@@ -4,12 +4,16 @@ import cn.edu.scau.biubiusuisui.annotation.FXController;
|
||||
import cn.edu.scau.biubiusuisui.annotation.FXWindow;
|
||||
import cn.edu.scau.biubiusuisui.config.FXMLLoaderPlus;
|
||||
import cn.edu.scau.biubiusuisui.config.FXPlusApplication;
|
||||
import cn.edu.scau.biubiusuisui.exception.NotFXWindowException;
|
||||
import cn.edu.scau.biubiusuisui.utils.StringUtils;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author jack
|
||||
@@ -31,6 +35,14 @@ public class FXBaseController extends Pane {
|
||||
private boolean isController = false;
|
||||
private boolean isWindow = false;
|
||||
|
||||
|
||||
/**
|
||||
* @Author: yangsuiyu
|
||||
* @Descriptions: 用于携带信息数据
|
||||
*/
|
||||
private Map<String, Object> query = new HashMap<>();
|
||||
private Map<String, Object> param = new HashMap<>();
|
||||
|
||||
public FXBaseController(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -40,6 +52,7 @@ public class FXBaseController extends Pane {
|
||||
Annotation[] annotations = getClass().getAnnotations();
|
||||
// Find FXController cn.edu.scau.biubiusuisui.annotation
|
||||
for (Annotation annotation : annotations) {
|
||||
// 是否Controller
|
||||
if (annotation.annotationType().equals(FXController.class)) {
|
||||
fxController = (FXController) annotation;
|
||||
isController = true;
|
||||
@@ -55,7 +68,6 @@ public class FXBaseController extends Pane {
|
||||
fxmlLoader.setRoot(this);
|
||||
fxmlLoader.setController(this);
|
||||
fxmlLoader.setShow(true);
|
||||
// System.out.println("?");
|
||||
try {
|
||||
fxmlLoader.load();
|
||||
} catch (IOException e) {
|
||||
@@ -68,12 +80,21 @@ public class FXBaseController extends Pane {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 在显示Stage之前的操作
|
||||
*/
|
||||
public void beforeShowStage() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 唤起舞台
|
||||
*/
|
||||
public void showStage() {
|
||||
this.beforeShowStage();
|
||||
if (isWindow) {
|
||||
this.stage.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +107,13 @@ public class FXBaseController extends Pane {
|
||||
}
|
||||
}
|
||||
|
||||
public void showAndWait() {
|
||||
this.beforeShowStage();
|
||||
if (isWindow) {
|
||||
this.stage.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if ("".equals(name) || name == null) { // 原本无“name == null”判断条件,会出错
|
||||
return StringUtils.getBaseClassName(getClass().getSimpleName());
|
||||
@@ -122,4 +150,19 @@ public class FXBaseController extends Pane {
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
public Map<String, Object> getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public void setQuery(Map<String, Object> query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
public void setParam(Map<String, Object> param) {
|
||||
this.param = param;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FXPlusContext {
|
||||
private static Map<Object, FXEntityProxy> beanMap = new ConcurrentHashMap<>(); // Object注册为FXEntityObject
|
||||
|
||||
|
||||
public static void addController(FXBaseController fxBaseController) {
|
||||
public static void registerController(FXBaseController fxBaseController) {
|
||||
List<FXBaseController> controllers = controllerContext.get(fxBaseController.getName());
|
||||
if (controllers == null) {
|
||||
controllers = new LinkedList<>();
|
||||
@@ -33,9 +33,6 @@ public class FXPlusContext {
|
||||
controllers.add(fxBaseController);
|
||||
}
|
||||
|
||||
public static List<FXBaseController> getControllers(String key) {
|
||||
return controllerContext.get(key);
|
||||
}
|
||||
|
||||
public static FXEntityProxy getProxyByBeanObject(Object object) {
|
||||
return beanMap.get(object);
|
||||
@@ -45,6 +42,10 @@ public class FXPlusContext {
|
||||
beanMap.put(object, fxEntityProxy);
|
||||
}
|
||||
|
||||
public static List<FXBaseController> getControllers(String key) {
|
||||
return controllerContext.get(key);
|
||||
}
|
||||
|
||||
public static Property getEntityPropertyByName(Object object, String fieldName) {
|
||||
return getProxyByBeanObject(object).getPropertyByFieldName(fieldName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package cn.edu.scau.biubiusuisui.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author suiyu_yang
|
||||
* @description 跳转窗口携带的参数
|
||||
* @date 2020/4/6 18:06
|
||||
* @email suiyu_yang@163.com
|
||||
*/
|
||||
public class FXRedirectParam {
|
||||
private String toController;
|
||||
private Map<String, Object> query = new HashMap<>();
|
||||
private Map<String, Object> params = new HashMap<>();
|
||||
|
||||
public FXRedirectParam(String toController) {
|
||||
this.toController = toController;
|
||||
}
|
||||
|
||||
public String getToController() {
|
||||
return toController;
|
||||
}
|
||||
|
||||
public void setToController(String toController) {
|
||||
this.toController = toController;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public Map<String, Object> getQueryMap() {
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
public void addParam(String key, Object param) {
|
||||
this.params.put(key, param);
|
||||
}
|
||||
|
||||
public Object getParam(String key) {
|
||||
return this.params.get(key);
|
||||
}
|
||||
|
||||
public void addQuery(String key, Object param) {
|
||||
this.query.put(key, param);
|
||||
}
|
||||
|
||||
public Object getOneQuery(String key) {
|
||||
return this.query.get(key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user