2025年4月1日17:57:02
parent
36b85cb41d
commit
783a60ec05
|
|
@ -8,6 +8,7 @@ import com.zhangmeng.online.exam.ui.api.model.*;
|
||||||
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
import com.zhangmeng.online.exam.ui.components.callBack.DynamicTableComponentCallBack;
|
import com.zhangmeng.online.exam.ui.components.callBack.DynamicTableComponentCallBack;
|
||||||
import com.zhangmeng.online.exam.ui.layouts.SideMenu;
|
import com.zhangmeng.online.exam.ui.layouts.SideMenu;
|
||||||
|
import com.zhangmeng.online.exam.ui.utils.FxUtils;
|
||||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||||
import javafx.beans.property.SimpleMapProperty;
|
import javafx.beans.property.SimpleMapProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.zhangmeng.online.exam.ui.api.form;
|
package com.zhangmeng.online.exam.ui.api.form;
|
||||||
|
|
||||||
import com.zhangmeng.online.exam.ui.api.form.base.Form;
|
import com.zhangmeng.online.exam.ui.api.form.base.Form;
|
||||||
|
import com.zhangmeng.online.exam.ui.controller.QuestionEditController;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -12,11 +13,17 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class QuestionForm extends Form {
|
public class QuestionForm extends Form {
|
||||||
|
|
||||||
|
private final QuestionEditController controller;
|
||||||
|
|
||||||
|
public QuestionEditController getController() {
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
public QuestionForm() {
|
public QuestionForm() {
|
||||||
try {
|
try {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/question-edit.fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/question-edit.fxml"));
|
||||||
this.getChildren().add(fxmlLoader.load());
|
this.getChildren().add(fxmlLoader.load());
|
||||||
|
controller = fxmlLoader.getController();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,25 @@ import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
import com.zhangmeng.online.exam.ui.api.DataLoad;
|
||||||
|
import com.zhangmeng.online.exam.ui.api.form.QuestionForm;
|
||||||
|
import com.zhangmeng.online.exam.ui.api.form.UserForm;
|
||||||
|
import com.zhangmeng.online.exam.ui.controller.QuestionEditController;
|
||||||
|
import com.zhangmeng.online.exam.ui.module.QuestionType;
|
||||||
|
import com.zhangmeng.online.exam.ui.module.SubjectType;
|
||||||
|
import com.zhangmeng.online.exam.ui.service.QuestionService;
|
||||||
|
import com.zhangmeng.online.exam.ui.service.SubjectService;
|
||||||
import com.zhangmeng.online.exam.ui.utils.AlertUtils;
|
import com.zhangmeng.online.exam.ui.utils.AlertUtils;
|
||||||
|
import com.zhangmeng.online.exam.ui.utils.FxUtils;
|
||||||
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
import com.zhangmeng.online.exam.ui.utils.HttpUtils;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static com.zhangmeng.online.exam.ui.api.ApiUtils.API_URL;
|
import static com.zhangmeng.online.exam.ui.api.ApiUtils.API_URL;
|
||||||
|
|
@ -30,7 +42,7 @@ public class QuestionDataLoad implements DataLoad {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("pageNum", pageNum.toString());
|
params.put("pageNum", pageNum.toString());
|
||||||
params.put("pageSize", pageSize.toString());
|
params.put("pageSize", pageSize.toString());
|
||||||
String userListData = HttpUtils.GET(API_URL + "/question/list",params);
|
String userListData = HttpUtils.GET(API_URL + "/question/list", params);
|
||||||
JSONObject jsonObject = JSON.parseObject(userListData);
|
JSONObject jsonObject = JSON.parseObject(userListData);
|
||||||
JSONArray data = jsonObject.getJSONArray("data");
|
JSONArray data = jsonObject.getJSONArray("data");
|
||||||
Integer total = jsonObject.getInteger("total");
|
Integer total = jsonObject.getInteger("total");
|
||||||
|
|
@ -74,8 +86,47 @@ public class QuestionDataLoad implements DataLoad {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void editData(String s, Stage stage) {
|
public void editData(String id, Stage stage) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("id", id);
|
||||||
|
String result = HttpUtils.GET(ApiUtils.API_URL + "/question/getQuestionById", map);
|
||||||
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
|
JSONObject data = jsonObject.getJSONObject("data");
|
||||||
|
String question_id = data.getString("id");
|
||||||
|
String name = data.getString("name");
|
||||||
|
String type = data.getString("type");
|
||||||
|
String subject = data.getString("subject");
|
||||||
|
String score = data.getString("score");
|
||||||
|
String explanation = data.getString("explanation");
|
||||||
|
QuestionForm questionForm = new QuestionForm();
|
||||||
|
QuestionEditController controller = questionForm.getController();
|
||||||
|
SubjectType st = null;
|
||||||
|
for (SubjectType subjectType : SubjectService.getALLSubjectType()){
|
||||||
|
if(subjectType.getName().equals(subject)){
|
||||||
|
st = subjectType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QuestionType qt = null;
|
||||||
|
for (QuestionType questionType : QuestionService.getALLQuestionType()) {
|
||||||
|
if (questionType.getDesc().equals(type)) {
|
||||||
|
qt = questionType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.subjectComboBox.setValue(st);
|
||||||
|
controller.typeComboBox.setValue(qt);
|
||||||
|
Map<String, Object> questionMap = new HashMap<>();
|
||||||
|
questionMap.put("id", question_id);
|
||||||
|
questionMap.put("question", name);
|
||||||
|
questionMap.put("type", type);
|
||||||
|
questionMap.put("subject", subject);
|
||||||
|
questionMap.put("score", score);
|
||||||
|
questionMap.put("explanation", explanation);
|
||||||
|
controller.setQuestion(questionMap);
|
||||||
|
|
||||||
|
FxUtils.alert("编辑用户信息", questionForm, stage,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -87,9 +138,9 @@ public class QuestionDataLoad implements DataLoad {
|
||||||
map.put("newValue", newValue);
|
map.put("newValue", newValue);
|
||||||
String result = HttpUtils.POST(ApiUtils.API_URL + "/question/update", map);
|
String result = HttpUtils.POST(ApiUtils.API_URL + "/question/update", map);
|
||||||
JSONObject jsonObject = JSON.parseObject(result);
|
JSONObject jsonObject = JSON.parseObject(result);
|
||||||
if (jsonObject.getIntValue("code") == 200){
|
if (jsonObject.getIntValue("code") == 200) {
|
||||||
AlertUtils.alert_msg("更新成功!");
|
AlertUtils.alert_msg("更新成功!");
|
||||||
}else {
|
} else {
|
||||||
AlertUtils.alert_warning("更新失败!");
|
AlertUtils.alert_warning("更新失败!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -193,4 +193,8 @@ public class DynamicTableComponent extends VBox {
|
||||||
this.getChildren().add(paginationPicker);
|
this.getChildren().add(paginationPicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void flushData() {
|
||||||
|
data.clear();
|
||||||
|
data.addAll(callBack.flushData(ApiUtils.PAGE_NUM, ApiUtils.PAGE_SIZE).getDataList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,7 @@ public class LoginController {
|
||||||
Parent main = FXMLLoader.load(this.getClass().getResource("/fxml/main.fxml"));
|
Parent main = FXMLLoader.load(this.getClass().getResource("/fxml/main.fxml"));
|
||||||
scene = new Scene(main, FxUtils.DEFAULT_WIDTH, FxUtils.DEFAULT_HEIGHT);
|
scene = new Scene(main, FxUtils.DEFAULT_WIDTH, FxUtils.DEFAULT_HEIGHT);
|
||||||
window.setScene(scene);
|
window.setScene(scene);
|
||||||
|
window.setResizable(true);
|
||||||
window.centerOnScreen();
|
window.centerOnScreen();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
||||||
|
|
@ -129,14 +129,14 @@ public class MainController {
|
||||||
|
|
||||||
// 根据标题加载不同的内容
|
// 根据标题加载不同的内容
|
||||||
Node content = switch (menuData.getUrl()) {
|
Node content = switch (menuData.getUrl()) {
|
||||||
case "/user/list" -> init_table( ApiUtils.getUserList());
|
case "/user/list" -> init_table( ApiUtils.getUserList(),FxUtils.User_DynamicTableComponent);
|
||||||
case "/paper/list" -> init_table(ApiUtils.getExamPaper());
|
case "/paper/list" -> init_table(ApiUtils.getExamPaper(),FxUtils.Paper_DynamicTableComponent);
|
||||||
case "/role/list" -> init_table(ApiUtils.getRoleList());
|
case "/role/list" -> init_table(ApiUtils.getRoleList(),FxUtils.Role_DynamicTableComponent);
|
||||||
case "/question/list" -> init_table(ApiUtils.getQuestionList());
|
case "/question/list" -> init_table(ApiUtils.getQuestionList(),FxUtils.Question_DynamicTableComponent);
|
||||||
case "/subject/list" -> init_table(ApiUtils.getSubjectList());
|
case "/subject/list" -> init_table(ApiUtils.getSubjectList(),FxUtils.Subject_DynamicTableComponent);
|
||||||
case "/questionOption/list" -> init_table(ApiUtils.getQuestionOptionList());
|
case "/questionOption/list" -> init_table(ApiUtils.getQuestionOptionList(),FxUtils.QuestionOption_DynamicTableComponent);
|
||||||
case "/permission/list" -> init_table(ApiUtils.getPermissionList());
|
case "/permission/list" -> init_table(ApiUtils.getPermissionList(),FxUtils.Permission_DynamicTableComponent);
|
||||||
case "/profession/list" -> init_table(ApiUtils.getProfessionList());
|
case "/profession/list" -> init_table(ApiUtils.getProfessionList(),FxUtils.Profession_DynamicTableComponent);
|
||||||
case "发布公告" -> FXMLLoader.load(getClass().getResource("/fxml/notice-edit.fxml"));
|
case "发布公告" -> FXMLLoader.load(getClass().getResource("/fxml/notice-edit.fxml"));
|
||||||
case "在线用户" -> FXMLLoader.load(getClass().getResource("/fxml/monitor-online.fxml"));
|
case "在线用户" -> FXMLLoader.load(getClass().getResource("/fxml/monitor-online.fxml"));
|
||||||
case "系统日志" -> FXMLLoader.load(getClass().getResource("/fxml/monitor-log.fxml"));
|
case "系统日志" -> FXMLLoader.load(getClass().getResource("/fxml/monitor-log.fxml"));
|
||||||
|
|
@ -158,7 +158,7 @@ public class MainController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DynamicTableComponent init_table(ApiUtils.DataView dataView) {
|
private DynamicTableComponent init_table(ApiUtils.DataView dataView,String type) {
|
||||||
dataView.setPageNum(dataView.getPageNum());
|
dataView.setPageNum(dataView.getPageNum());
|
||||||
dataView.setPageSize(dataView.getPageSize());
|
dataView.setPageSize(dataView.getPageSize());
|
||||||
dataView.setTotal(dataView.getTotal());
|
dataView.setTotal(dataView.getTotal());
|
||||||
|
|
@ -166,6 +166,9 @@ public class MainController {
|
||||||
dynamicTableComponent.setCallBack(new DynamicTableComponentCallBackImpl(dataView.getDataLoad(),dataView.getDataLoad().getForm()));
|
dynamicTableComponent.setCallBack(new DynamicTableComponentCallBackImpl(dataView.getDataLoad(),dataView.getDataLoad().getForm()));
|
||||||
dynamicTableComponent.setPadding(new Insets(15));
|
dynamicTableComponent.setPadding(new Insets(15));
|
||||||
dynamicTableComponent.prefHeightProperty().bind(contentTabPane.heightProperty().subtract(15));
|
dynamicTableComponent.prefHeightProperty().bind(contentTabPane.heightProperty().subtract(15));
|
||||||
|
|
||||||
|
FxUtils.FX_BEANS.put(type,dynamicTableComponent);
|
||||||
|
|
||||||
return dynamicTableComponent;
|
return dynamicTableComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,28 @@
|
||||||
package com.zhangmeng.online.exam.ui.controller;
|
package com.zhangmeng.online.exam.ui.controller;
|
||||||
|
|
||||||
|
import com.zhangmeng.online.exam.ui.api.ApiUtils;
|
||||||
|
import com.zhangmeng.online.exam.ui.api.model.QuestionDataLoad;
|
||||||
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
import com.zhangmeng.online.exam.ui.module.QuestionType;
|
import com.zhangmeng.online.exam.ui.module.QuestionType;
|
||||||
import com.zhangmeng.online.exam.ui.module.SubjectType;
|
import com.zhangmeng.online.exam.ui.module.SubjectType;
|
||||||
import com.zhangmeng.online.exam.ui.service.QuestionService;
|
import com.zhangmeng.online.exam.ui.service.QuestionService;
|
||||||
import com.zhangmeng.online.exam.ui.service.SubjectService;
|
import com.zhangmeng.online.exam.ui.service.SubjectService;
|
||||||
|
import com.zhangmeng.online.exam.ui.utils.AlertUtils;
|
||||||
|
import com.zhangmeng.online.exam.ui.utils.FxUtils;
|
||||||
|
import javafx.beans.property.SimpleLongProperty;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.Window;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.zhangmeng.online.exam.ui.utils.FxUtils.FX_BEANS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zm
|
* @author zm
|
||||||
|
|
@ -32,7 +43,19 @@ public class QuestionEditController {
|
||||||
public ComboBox<SubjectType> subjectComboBox;
|
public ComboBox<SubjectType> subjectComboBox;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TextField questionField;
|
public TextField questionField;
|
||||||
|
|
||||||
|
private Map<String, Object> question = null;
|
||||||
|
|
||||||
|
private SimpleLongProperty id_property = new SimpleLongProperty(0);
|
||||||
|
|
||||||
|
public void setQuestion(Map<String, Object> map){
|
||||||
|
this.question = map;
|
||||||
|
this.questionField.setText(map.get("question").toString());
|
||||||
|
this.scoreField.setText(map.get("score").toString());
|
||||||
|
this.explanationField.setText(map.get("explanation").toString());
|
||||||
|
id_property.set(Long.parseLong(map.get("id").toString()));
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
@ -72,13 +95,41 @@ public class QuestionEditController {
|
||||||
String question = questionField.getText();
|
String question = questionField.getText();
|
||||||
String score = scoreField.getText();
|
String score = scoreField.getText();
|
||||||
String explanation = explanationField.getText();
|
String explanation = explanationField.getText();
|
||||||
QuestionService.saveQuestion(questionType.getType(), subjectType.getId(), question, score, explanation);
|
|
||||||
|
|
||||||
|
if (question.isEmpty()){
|
||||||
|
AlertUtils.alert_warning("题目不能为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (score.isEmpty()){
|
||||||
|
AlertUtils.alert_warning("分值不能为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (explanation.isEmpty()){
|
||||||
|
AlertUtils.alert_warning("解析不能为空!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (questionType == null){
|
||||||
|
AlertUtils.alert_warning("请选择题型!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subjectType == null){
|
||||||
|
AlertUtils.alert_warning("请选择科目!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestionService.saveQuestion(questionType.getType(), subjectType.getId(), question, score, explanation,id_property.get());
|
||||||
|
handleCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleCancel(ActionEvent actionEvent) {
|
public void handleCancel() {
|
||||||
|
Stage window = (Stage) typeComboBox.getScene().getWindow();
|
||||||
|
window.close();
|
||||||
|
//刷新数据
|
||||||
|
DynamicTableComponent dynamicTableComponent = FX_BEANS.get(FxUtils.Question_DynamicTableComponent);
|
||||||
|
dynamicTableComponent.flushData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,12 @@ public class QuestionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void saveQuestion(String type, Long id, String question, String score, String explanation) {
|
public static void saveQuestion(String type, Long subject_id, String question, String score, String explanation, Long id) {
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("token", UserService.getCurrentUser().getToken());
|
params.put("token", UserService.getCurrentUser().getToken());
|
||||||
params.put("type", type);
|
params.put("type", type);
|
||||||
params.put("id", id);
|
params.put("id", id);
|
||||||
|
params.put("subject_id", subject_id);
|
||||||
params.put("question", question);
|
params.put("question", question);
|
||||||
params.put("score", score);
|
params.put("score", score);
|
||||||
params.put("explanation", explanation);
|
params.put("explanation", explanation);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.zhangmeng.online.exam.ui.api.form.QuestionForm;
|
||||||
import com.zhangmeng.online.exam.ui.api.form.RoleForm;
|
import com.zhangmeng.online.exam.ui.api.form.RoleForm;
|
||||||
import com.zhangmeng.online.exam.ui.api.form.UserForm;
|
import com.zhangmeng.online.exam.ui.api.form.UserForm;
|
||||||
import com.zhangmeng.online.exam.ui.api.form.base.Form;
|
import com.zhangmeng.online.exam.ui.api.form.base.Form;
|
||||||
|
import com.zhangmeng.online.exam.ui.components.DynamicTableComponent;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
|
@ -11,6 +12,8 @@ import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zm
|
* @author zm
|
||||||
|
|
@ -22,6 +25,18 @@ public class FxUtils {
|
||||||
public final static double DEFAULT_WIDTH = 1280;
|
public final static double DEFAULT_WIDTH = 1280;
|
||||||
public final static double DEFAULT_HEIGHT = 720;
|
public final static double DEFAULT_HEIGHT = 720;
|
||||||
|
|
||||||
|
public static final Map<String, DynamicTableComponent> FX_BEANS = new HashMap<>();
|
||||||
|
|
||||||
|
public static String Question_DynamicTableComponent;
|
||||||
|
public static String Role_DynamicTableComponent;
|
||||||
|
public static String User_DynamicTableComponent;
|
||||||
|
public static String Paper_DynamicTableComponent;
|
||||||
|
public static String Subject_DynamicTableComponent;
|
||||||
|
public static String QuestionOption_DynamicTableComponent;
|
||||||
|
public static String Permission_DynamicTableComponent;
|
||||||
|
public static String Profession_DynamicTableComponent;
|
||||||
|
|
||||||
|
|
||||||
public static void alert(String title, Parent node, Stage primaryStage) {
|
public static void alert(String title, Parent node, Stage primaryStage) {
|
||||||
|
|
||||||
Form form = (Form) node;
|
Form form = (Form) node;
|
||||||
|
|
@ -32,7 +47,7 @@ public class FxUtils {
|
||||||
form = new RoleForm();
|
form = new RoleForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form instanceof QuestionForm){
|
if (form instanceof QuestionForm) {
|
||||||
form = new QuestionForm();
|
form = new QuestionForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,4 +61,35 @@ public class FxUtils {
|
||||||
dialogStage.showAndWait();
|
dialogStage.showAndWait();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void alert(String title, Parent node, Stage primaryStage, boolean isEdit) {
|
||||||
|
|
||||||
|
Form form = (Form) node;
|
||||||
|
if (form instanceof UserForm) {
|
||||||
|
form = new UserForm(true);
|
||||||
|
}
|
||||||
|
if (form instanceof RoleForm) {
|
||||||
|
form = new RoleForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form instanceof QuestionForm) {
|
||||||
|
form = new QuestionForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
Scene scene = null;
|
||||||
|
if (!isEdit) {
|
||||||
|
scene = new Scene(form);
|
||||||
|
}else {
|
||||||
|
scene = new Scene(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
Stage dialogStage = new Stage();
|
||||||
|
dialogStage.setTitle(title);
|
||||||
|
dialogStage.setResizable(false);
|
||||||
|
dialogStage.initModality(Modality.WINDOW_MODAL);
|
||||||
|
dialogStage.initOwner(primaryStage);
|
||||||
|
dialogStage.setScene(scene);
|
||||||
|
dialogStage.showAndWait();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue