Search in sources :

Example 1 with Column

use of com.cas.sim.tis.view.control.imp.table.Column in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method createQuizTable.

private void createQuizTable() {
    // 数据库唯一表示
    Column<Integer> id = new Column<>();
    id.setPrimary(true);
    id.setVisible(false);
    id.setKey("id");
    // 资源图标
    Column<Integer> icon = new Column<>();
    icon.setAlignment(Pos.CENTER_RIGHT);
    icon.setKey("icon");
    icon.setText("");
    icon.setMaxWidth(25);
    Function<Integer, SVGGlyph> converter = new Function<Integer, SVGGlyph>() {

        @Override
        public SVGGlyph apply(Integer type) {
            if (type == null) {
                return null;
            }
            ResourceType resourceType = ResourceType.getResourceType(type);
            return new SVGGlyph(resourceType.getIcon(), resourceType.getColor(), 22);
        }
    };
    icon.setCellFactory(SVGIconCell.forTableColumn(converter));
    // 资源名称
    Column<String> name = new Column<>();
    name.setAlignment(Pos.CENTER_LEFT);
    name.setKey("name");
    name.setText(MsgUtil.getMessage("resource.name"));
    name.setMaxWidth(250);
    quizs.getColumns().addAll(id, icon, name);
    // 查看按钮
    Column<String> view = new Column<String>();
    view.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.view"), Priority.ALWAYS, "blue-btn", rid -> {
        PreparationQuiz preparationQuiz = SpringUtil.getBean(PreparationQuizAction.class).findQuizById((Integer) rid);
        int type = preparationQuiz.getType();
        if (PreparationQuizType.LIBRARY.getType() == type) {
            openLibrary(preparationQuiz.getRelationId());
        } else if (PreparationQuizType.BROKEN_CASE.getType() == type) {
            openBrokenCase(preparationQuiz.getRelationId());
        } else if (PreparationQuizType.FREE.getType() == type) {
            openFreeMode();
        }
    }));
    view.setAlignment(Pos.CENTER_RIGHT);
    quizs.getColumns().add(view);
    if (RoleConst.TEACHER == Session.get(Session.KEY_LOGIN_ROLE, -1)) {
        // 删除按钮
        Column<String> delete = new Column<String>();
        delete.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.delete"), "blue-btn", rid -> {
            AlertUtil.showConfirm(MsgUtil.getMessage("alert.confirmation.data.delete"), response -> {
                if (response == ButtonType.YES) {
                    SpringUtil.getBean(PreparationResourceAction.class).detele((Integer) rid);
                    loadResources();
                }
            });
        }));
        delete.setAlignment(Pos.CENTER_RIGHT);
        delete.setMaxWidth(58);
        quizs.getColumns().add(delete);
    }
}
Also used : Pos(javafx.geometry.Pos) Title(com.cas.sim.tis.view.control.imp.Title) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) PreparationInfo(com.cas.sim.tis.vo.PreparationInfo) PreparationResource(com.cas.sim.tis.entity.PreparationResource) TypicalCase(com.cas.sim.tis.entity.TypicalCase) PreviewQuestionPaper(com.cas.sim.tis.view.control.imp.question.PreviewQuestionPaper) VBox(javafx.scene.layout.VBox) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) AlertType(javafx.scene.control.Alert.AlertType) ElecCompAction(com.cas.sim.tis.action.ElecCompAction) ElecComp(com.cas.sim.tis.entity.ElecComp) Map(java.util.Map) HBox(javafx.scene.layout.HBox) RoleConst(com.cas.sim.tis.consts.RoleConst) IContent(com.cas.sim.tis.view.control.IContent) Recongnize3D(com.cas.sim.tis.view.control.imp.jme.Recongnize3D) Table(com.cas.sim.tis.view.control.imp.table.Table) Preparation(com.cas.sim.tis.entity.Preparation) PageController(com.cas.sim.tis.view.controller.PageController) Resource(com.cas.sim.tis.entity.Resource) TypicalCaseAction(com.cas.sim.tis.action.TypicalCaseAction) PreparationQuizType(com.cas.sim.tis.consts.PreparationQuizType) PreparationResourceType(com.cas.sim.tis.consts.PreparationResourceType) Session(com.cas.sim.tis.consts.Session) FXML(javafx.fxml.FXML) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) FlowPane(javafx.scene.layout.FlowPane) CatalogAction(com.cas.sim.tis.action.CatalogAction) ResourceAction(com.cas.sim.tis.action.ResourceAction) PreparationQuiz(com.cas.sim.tis.entity.PreparationQuiz) ButtonType(javafx.scene.control.ButtonType) TypicalCase3D(com.cas.sim.tis.view.control.imp.jme.TypicalCase3D) Function(java.util.function.Function) BrokenCase(com.cas.sim.tis.entity.BrokenCase) SVGIconCell(com.cas.sim.tis.view.control.imp.table.SVGIconCell) JSONArray(com.alibaba.fastjson.JSONArray) PageLevel(com.cas.sim.tis.view.controller.PageController.PageLevel) ResourceBundle(java.util.ResourceBundle) BtnCell(com.cas.sim.tis.view.control.imp.table.BtnCell) Column(com.cas.sim.tis.view.control.imp.table.Column) FXMLLoader(javafx.fxml.FXMLLoader) SpringUtil(com.cas.sim.tis.util.SpringUtil) PreparationAction(com.cas.sim.tis.action.PreparationAction) MsgUtil(com.cas.sim.tis.util.MsgUtil) Logger(org.slf4j.Logger) User(com.cas.sim.tis.entity.User) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) AlertUtil(com.cas.sim.tis.util.AlertUtil) PreparationResourceAction(com.cas.sim.tis.action.PreparationResourceAction) ResourceType(com.cas.sim.tis.consts.ResourceType) Dialog(com.cas.sim.tis.view.control.imp.dialog.Dialog) BrokenCaseAction(com.cas.sim.tis.action.BrokenCaseAction) Catalog(com.cas.sim.tis.entity.Catalog) PreparationQuizAction(com.cas.sim.tis.action.PreparationQuizAction) UserAction(com.cas.sim.tis.action.UserAction) Function(java.util.function.Function) PreparationQuiz(com.cas.sim.tis.entity.PreparationQuiz) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Column(com.cas.sim.tis.view.control.imp.table.Column) PreparationResourceType(com.cas.sim.tis.consts.PreparationResourceType) ResourceType(com.cas.sim.tis.consts.ResourceType)

Example 2 with Column

use of com.cas.sim.tis.view.control.imp.table.Column in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceList method createTable.

private void createTable() {
    // 数据库唯一表示
    Column<Integer> id = new Column<>();
    id.setPrimary(true);
    id.setVisible(false);
    id.setKey("id");
    // 资源图标
    Column<Integer> icon = new Column<>();
    icon.setAlignment(Pos.CENTER_RIGHT);
    icon.setKey("type");
    icon.setText("");
    icon.setMaxWidth(25);
    Function<Integer, SVGGlyph> converter = new Function<Integer, SVGGlyph>() {

        @Override
        public SVGGlyph apply(Integer type) {
            if (type == null) {
                return null;
            }
            ResourceType resourceType = ResourceType.getResourceType(type);
            return new SVGGlyph(resourceType.getIcon(), resourceType.getColor(), 22);
        }
    };
    icon.setCellFactory(SVGIconCell.forTableColumn(converter));
    // 资源名称
    Column<String> name = new Column<>();
    name.setAlignment(Pos.CENTER_LEFT);
    name.setKey("name");
    name.setText(MsgUtil.getMessage("resource.name"));
    name.setMaxWidth(250);
    // 日期
    Column<Date> date = new Column<>();
    date.setAlignment(Pos.CENTER);
    date.setKey("createDate");
    date.setText(type.getDateLabel());
    date.setMaxWidth(160);
    date.setCellFactory(Cell.forTableColumn(new StringConverter<Date>() {

        @Override
        public String toString(Date date) {
            return DateUtil.date2Str(date, DateUtil.DATE_TIME_PAT_SHOW_);
        }

        @Override
        public Date fromString(String string) {
            return null;
        }
    }));
    table.getColumns().addAll(id, icon, name, date);
    // 查看按钮
    Column<String> view = new Column<String>();
    view.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.view"), Priority.ALWAYS, "blue-btn", rid -> {
        SpringUtil.getBean(ResourceAction.class).browsed((Integer) rid);
        ResourceAction action = SpringUtil.getBean(ResourceAction.class);
        Resource resource = action.findResourceByID((Integer) rid);
        // 跳转到查看页面
        PageController controller = SpringUtil.getBean(PageController.class);
        controller.loadContent(new ResourceViewer(resource), PageLevel.Level2);
    }));
    view.setAlignment(Pos.CENTER_RIGHT);
    table.getColumns().add(view);
    if (type.isEditable()) {
        // 删除按钮
        Column<String> delete = new Column<String>();
        delete.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.delete"), "blue-btn", rid -> {
            AlertUtil.showConfirm(MsgUtil.getMessage("alert.confirmation.data.delete"), response -> {
                if (response == ButtonType.YES) {
                    SpringUtil.getBean(ResourceAction.class).detele((Integer) rid);
                    pagination.reload();
                }
            });
        }));
        delete.setAlignment(Pos.CENTER_RIGHT);
        delete.setMaxWidth(58);
        table.getColumns().add(delete);
    }
}
Also used : Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) Title(com.cas.sim.tis.view.control.imp.Title) URL(java.net.URL) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) VBox(javafx.scene.layout.VBox) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) StringUtil(com.cas.util.StringUtil) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) AlertType(javafx.scene.control.Alert.AlertType) PaginationBar(com.cas.sim.tis.view.control.imp.pagination.PaginationBar) Data(javafx.scene.chart.PieChart.Data) HBox(javafx.scene.layout.HBox) ResourceConsts(com.cas.sim.tis.consts.ResourceConsts) TextField(javafx.scene.control.TextField) IContent(com.cas.sim.tis.view.control.IContent) Table(com.cas.sim.tis.view.control.imp.table.Table) PageController(com.cas.sim.tis.view.controller.PageController) Resource(com.cas.sim.tis.entity.Resource) UUID(java.util.UUID) PageInfo(com.github.pagehelper.PageInfo) FXML(javafx.fxml.FXML) PieChart(javafx.scene.chart.PieChart) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) GUIState(de.felixroske.jfxsupport.GUIState) ResourceAction(com.cas.sim.tis.action.ResourceAction) Cell(com.cas.sim.tis.view.control.imp.table.Cell) ObservableList(javafx.collections.ObservableList) SearchBox(com.cas.sim.tis.view.control.imp.SearchBox) ButtonType(javafx.scene.control.ButtonType) FXCollections(javafx.collections.FXCollections) FileUtil(com.cas.util.FileUtil) Function(java.util.function.Function) ArrayList(java.util.ArrayList) SVGIconCell(com.cas.sim.tis.view.control.imp.table.SVGIconCell) JSONArray(com.alibaba.fastjson.JSONArray) PageLevel(com.cas.sim.tis.view.controller.PageController.PageLevel) ResourceBundle(java.util.ResourceBundle) BtnCell(com.cas.sim.tis.view.control.imp.table.BtnCell) Column(com.cas.sim.tis.view.control.imp.table.Column) FXMLLoader(javafx.fxml.FXMLLoader) SpringUtil(com.cas.sim.tis.util.SpringUtil) MsgUtil(com.cas.sim.tis.util.MsgUtil) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) Node(javafx.scene.Node) DecimalFormat(java.text.DecimalFormat) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) StringConverter(javafx.util.StringConverter) File(java.io.File) AlertUtil(com.cas.sim.tis.util.AlertUtil) FileChooser(javafx.stage.FileChooser) ActionEvent(javafx.event.ActionEvent) ToggleGroup(javafx.scene.control.ToggleGroup) DateUtil(com.cas.util.DateUtil) ResourceType(com.cas.sim.tis.consts.ResourceType) FTPUtils(com.cas.sim.tis.util.FTPUtils) Resource(com.cas.sim.tis.entity.Resource) ResourceType(com.cas.sim.tis.consts.ResourceType) StringConverter(javafx.util.StringConverter) Date(java.util.Date) Function(java.util.function.Function) PageController(com.cas.sim.tis.view.controller.PageController) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Column(com.cas.sim.tis.view.control.imp.table.Column) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) ResourceAction(com.cas.sim.tis.action.ResourceAction)

Example 3 with Column

use of com.cas.sim.tis.view.control.imp.table.Column in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method createResourceTable.

private void createResourceTable() {
    // 数据库唯一表示
    Column<Integer> id = new Column<>();
    id.setPrimary(true);
    id.setVisible(false);
    id.setKey("id");
    // 资源图标
    Column<Integer> icon = new Column<>();
    icon.setAlignment(Pos.CENTER_RIGHT);
    icon.setKey("icon");
    icon.setText("");
    icon.setMaxWidth(22);
    Function<Integer, SVGGlyph> converter = new Function<Integer, SVGGlyph>() {

        @Override
        public SVGGlyph apply(Integer type) {
            if (type == null) {
                return null;
            }
            ResourceType resourceType = ResourceType.getResourceType(type);
            return new SVGGlyph(resourceType.getIcon(), resourceType.getColor(), 22);
        }
    };
    icon.setCellFactory(SVGIconCell.forTableColumn(converter));
    // 资源名称
    Column<String> name = new Column<>();
    name.setAlignment(Pos.CENTER_LEFT);
    name.setKey("name");
    name.setText(MsgUtil.getMessage("resource.name"));
    name.setMaxWidth(250);
    resces.getColumns().addAll(id, icon, name);
    // 查看按钮
    Column<String> view = new Column<String>();
    view.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.view"), Priority.ALWAYS, "blue-btn", rid -> {
        PreparationResource preparationResource = SpringUtil.getBean(PreparationResourceAction.class).findResourceById((Integer) rid);
        int type = preparationResource.getType();
        if (PreparationResourceType.RESOURCE.getType() == type) {
            openResource(preparationResource.getRelationId());
        } else if (PreparationResourceType.COGNITION.getType() == type) {
            openCognition(preparationResource.getRelationId());
        } else if (PreparationResourceType.TYPICAL.getType() == type) {
            openTypicalCase(preparationResource.getRelationId());
        }
    }));
    view.setAlignment(Pos.CENTER_RIGHT);
    resces.getColumns().add(view);
    if (RoleConst.TEACHER == Session.get(Session.KEY_LOGIN_ROLE, 0)) {
        // 删除按钮
        Column<String> delete = new Column<String>();
        delete.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.delete"), "blue-btn", rid -> {
            AlertUtil.showConfirm(MsgUtil.getMessage("alert.confirmation.data.delete"), response -> {
                if (response == ButtonType.YES) {
                    SpringUtil.getBean(PreparationResourceAction.class).detele((Integer) rid);
                    loadResources();
                }
            });
        }));
        delete.setAlignment(Pos.CENTER_RIGHT);
        delete.setMaxWidth(58);
        resces.getColumns().add(delete);
    }
}
Also used : Pos(javafx.geometry.Pos) Title(com.cas.sim.tis.view.control.imp.Title) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) PreparationInfo(com.cas.sim.tis.vo.PreparationInfo) PreparationResource(com.cas.sim.tis.entity.PreparationResource) TypicalCase(com.cas.sim.tis.entity.TypicalCase) PreviewQuestionPaper(com.cas.sim.tis.view.control.imp.question.PreviewQuestionPaper) VBox(javafx.scene.layout.VBox) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) AlertType(javafx.scene.control.Alert.AlertType) ElecCompAction(com.cas.sim.tis.action.ElecCompAction) ElecComp(com.cas.sim.tis.entity.ElecComp) Map(java.util.Map) HBox(javafx.scene.layout.HBox) RoleConst(com.cas.sim.tis.consts.RoleConst) IContent(com.cas.sim.tis.view.control.IContent) Recongnize3D(com.cas.sim.tis.view.control.imp.jme.Recongnize3D) Table(com.cas.sim.tis.view.control.imp.table.Table) Preparation(com.cas.sim.tis.entity.Preparation) PageController(com.cas.sim.tis.view.controller.PageController) Resource(com.cas.sim.tis.entity.Resource) TypicalCaseAction(com.cas.sim.tis.action.TypicalCaseAction) PreparationQuizType(com.cas.sim.tis.consts.PreparationQuizType) PreparationResourceType(com.cas.sim.tis.consts.PreparationResourceType) Session(com.cas.sim.tis.consts.Session) FXML(javafx.fxml.FXML) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) FlowPane(javafx.scene.layout.FlowPane) CatalogAction(com.cas.sim.tis.action.CatalogAction) ResourceAction(com.cas.sim.tis.action.ResourceAction) PreparationQuiz(com.cas.sim.tis.entity.PreparationQuiz) ButtonType(javafx.scene.control.ButtonType) TypicalCase3D(com.cas.sim.tis.view.control.imp.jme.TypicalCase3D) Function(java.util.function.Function) BrokenCase(com.cas.sim.tis.entity.BrokenCase) SVGIconCell(com.cas.sim.tis.view.control.imp.table.SVGIconCell) JSONArray(com.alibaba.fastjson.JSONArray) PageLevel(com.cas.sim.tis.view.controller.PageController.PageLevel) ResourceBundle(java.util.ResourceBundle) BtnCell(com.cas.sim.tis.view.control.imp.table.BtnCell) Column(com.cas.sim.tis.view.control.imp.table.Column) FXMLLoader(javafx.fxml.FXMLLoader) SpringUtil(com.cas.sim.tis.util.SpringUtil) PreparationAction(com.cas.sim.tis.action.PreparationAction) MsgUtil(com.cas.sim.tis.util.MsgUtil) Logger(org.slf4j.Logger) User(com.cas.sim.tis.entity.User) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) AlertUtil(com.cas.sim.tis.util.AlertUtil) PreparationResourceAction(com.cas.sim.tis.action.PreparationResourceAction) ResourceType(com.cas.sim.tis.consts.ResourceType) Dialog(com.cas.sim.tis.view.control.imp.dialog.Dialog) BrokenCaseAction(com.cas.sim.tis.action.BrokenCaseAction) Catalog(com.cas.sim.tis.entity.Catalog) PreparationQuizAction(com.cas.sim.tis.action.PreparationQuizAction) UserAction(com.cas.sim.tis.action.UserAction) Function(java.util.function.Function) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Column(com.cas.sim.tis.view.control.imp.table.Column) PreparationResourceType(com.cas.sim.tis.consts.PreparationResourceType) ResourceType(com.cas.sim.tis.consts.ResourceType) PreparationResource(com.cas.sim.tis.entity.PreparationResource)

Aggregations

JSONArray (com.alibaba.fastjson.JSONArray)3 ResourceAction (com.cas.sim.tis.action.ResourceAction)3 ResourceType (com.cas.sim.tis.consts.ResourceType)3 Resource (com.cas.sim.tis.entity.Resource)3 SVGGlyph (com.cas.sim.tis.svg.SVGGlyph)3 AlertUtil (com.cas.sim.tis.util.AlertUtil)3 MsgUtil (com.cas.sim.tis.util.MsgUtil)3 SpringUtil (com.cas.sim.tis.util.SpringUtil)3 IContent (com.cas.sim.tis.view.control.IContent)3 ResourceViewer (com.cas.sim.tis.view.control.imp.ResourceViewer)3 Title (com.cas.sim.tis.view.control.imp.Title)3 BtnCell (com.cas.sim.tis.view.control.imp.table.BtnCell)3 Column (com.cas.sim.tis.view.control.imp.table.Column)3 SVGIconCell (com.cas.sim.tis.view.control.imp.table.SVGIconCell)3 Table (com.cas.sim.tis.view.control.imp.table.Table)3 PageController (com.cas.sim.tis.view.controller.PageController)3 BrokenCaseAction (com.cas.sim.tis.action.BrokenCaseAction)2 CatalogAction (com.cas.sim.tis.action.CatalogAction)2 ElecCompAction (com.cas.sim.tis.action.ElecCompAction)2 PreparationAction (com.cas.sim.tis.action.PreparationAction)2