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);
}
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());
}
}
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);
}
}
Aggregations