Search in sources :

Example 11 with SVGGlyph

use of com.cas.sim.tis.svg.SVGGlyph 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)

Example 12 with SVGGlyph

use of com.cas.sim.tis.svg.SVGGlyph in project TeachingInSimulation by ScOrPiOzzy.

the class RotateTransitionApp method createContent.

public Parent createContent() {
    Pane root = new Pane();
    root.setPrefSize(140, 140);
    root.setMinSize(Pane.USE_PREF_SIZE, Pane.USE_PREF_SIZE);
    root.setMaxSize(Pane.USE_PREF_SIZE, Pane.USE_PREF_SIZE);
    // create rectangle
    try {
        SVGHelper.loadGlyphsFont(RotateTransitionApp.class.getResource("/svg/iconfont.svg"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    SVGGlyph glyph = new SVGGlyph("iconfont.svg.clock", Color.RED, 22);
    root.getChildren().add(new Button("TEST", glyph));
    shaking(glyph);
    return root;
}
Also used : SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Button(javafx.scene.control.Button) IOException(java.io.IOException) Pane(javafx.scene.layout.Pane)

Aggregations

SVGGlyph (com.cas.sim.tis.svg.SVGGlyph)12 ResourceAction (com.cas.sim.tis.action.ResourceAction)5 FXML (javafx.fxml.FXML)5 Button (javafx.scene.control.Button)5 VBox (javafx.scene.layout.VBox)5 AlertUtil (com.cas.sim.tis.util.AlertUtil)4 MsgUtil (com.cas.sim.tis.util.MsgUtil)4 SpringUtil (com.cas.sim.tis.util.SpringUtil)4 PageController (com.cas.sim.tis.view.controller.PageController)4 Pos (javafx.geometry.Pos)4 Node (javafx.scene.Node)4 AlertType (javafx.scene.control.Alert.AlertType)4 HBox (javafx.scene.layout.HBox)4 Region (javafx.scene.layout.Region)4 JSONArray (com.alibaba.fastjson.JSONArray)3 ResourceType (com.cas.sim.tis.consts.ResourceType)3 Resource (com.cas.sim.tis.entity.Resource)3 IContent (com.cas.sim.tis.view.control.IContent)3 IOException (java.io.IOException)3 BrokenCaseAction (com.cas.sim.tis.action.BrokenCaseAction)2