Search in sources :

Example 1 with PreparationResource

use of com.cas.sim.tis.entity.PreparationResource in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationResourceAction method detele.

public void detele(Integer rid) {
    PreparationResourceService service = getService();
    PreparationResource resource = service.findById(rid);
    resource.setDel(true);
    resource.setUpdater(Session.get(Session.KEY_LOGIN_ID));
    service.update(resource);
}
Also used : PreparationResourceService(com.cas.sim.tis.services.PreparationResourceService) PreparationResource(com.cas.sim.tis.entity.PreparationResource)

Example 2 with PreparationResource

use of com.cas.sim.tis.entity.PreparationResource in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method addResource.

private void addResource(Integer id, int type) {
    PreparationResource resource = new PreparationResource();
    resource.setRelationId(id);
    resource.setPreparationId(preparation.getId());
    resource.setType(type);
    try {
        SpringUtil.getBean(PreparationResourceAction.class).addResource(resource);
        loadResources();
        AlertUtil.showAlert(AlertType.INFORMATION, MsgUtil.getMessage("alert.information.data.add.success"));
    } catch (Exception e) {
        e.printStackTrace();
        AlertUtil.showAlert(AlertType.ERROR, e.getMessage());
    }
}
Also used : PreparationResourceAction(com.cas.sim.tis.action.PreparationResourceAction) PreparationResource(com.cas.sim.tis.entity.PreparationResource) IOException(java.io.IOException)

Example 3 with PreparationResource

use of com.cas.sim.tis.entity.PreparationResource 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

PreparationResource (com.cas.sim.tis.entity.PreparationResource)3 PreparationResourceAction (com.cas.sim.tis.action.PreparationResourceAction)2 JSONArray (com.alibaba.fastjson.JSONArray)1 BrokenCaseAction (com.cas.sim.tis.action.BrokenCaseAction)1 CatalogAction (com.cas.sim.tis.action.CatalogAction)1 ElecCompAction (com.cas.sim.tis.action.ElecCompAction)1 PreparationAction (com.cas.sim.tis.action.PreparationAction)1 PreparationQuizAction (com.cas.sim.tis.action.PreparationQuizAction)1 ResourceAction (com.cas.sim.tis.action.ResourceAction)1 TypicalCaseAction (com.cas.sim.tis.action.TypicalCaseAction)1 UserAction (com.cas.sim.tis.action.UserAction)1 PreparationQuizType (com.cas.sim.tis.consts.PreparationQuizType)1 PreparationResourceType (com.cas.sim.tis.consts.PreparationResourceType)1 ResourceType (com.cas.sim.tis.consts.ResourceType)1 RoleConst (com.cas.sim.tis.consts.RoleConst)1 Session (com.cas.sim.tis.consts.Session)1 BrokenCase (com.cas.sim.tis.entity.BrokenCase)1 Catalog (com.cas.sim.tis.entity.Catalog)1 ElecComp (com.cas.sim.tis.entity.ElecComp)1 Preparation (com.cas.sim.tis.entity.Preparation)1