Search in sources :

Example 6 with PageController

use of com.cas.sim.tis.view.controller.PageController 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 7 with PageController

use of com.cas.sim.tis.view.controller.PageController in project TeachingInSimulation by ScOrPiOzzy.

the class ResourceMenu method initMenu.

@Override
protected void initMenu() {
    int role = Session.get(Session.KEY_LOGIN_ROLE);
    int userId = Session.get(Session.KEY_LOGIN_ID);
    if (RoleConst.ADMIN == role) {
        addMenuItem(MsgUtil.getMessage("resource.menu.sys"), "iconfont.svg.resource", e -> {
            PageController controller = SpringUtil.getBean(PageController.class);
            controller.loadContent(new ResourceList(ResourceMenuType.ADMIN_SYS, 1), PageLevel.Level1);
        });
    } else if (RoleConst.TEACHER == role) {
        addMenuItem(MsgUtil.getMessage("resource.menu.sys"), "iconfont.svg.resource", e -> {
            PageController controller = SpringUtil.getBean(PageController.class);
            controller.loadContent(new ResourceList(ResourceMenuType.TEACHER_SYS, 1), PageLevel.Level1);
        });
        addMenuItem(MsgUtil.getMessage("resource.menu.mine"), "iconfont.svg.resource", e -> {
            PageController controller = SpringUtil.getBean(PageController.class);
            controller.loadContent(new ResourceList(ResourceMenuType.TEACHER_MINE, userId), PageLevel.Level1);
        });
    } else if (RoleConst.STUDENT == role) {
        addMenuItem(MsgUtil.getMessage("resource.menu.mine"), "iconfont.svg.resource", e -> {
            PageController controller = SpringUtil.getBean(PageController.class);
            controller.loadContent(new ResourceList(ResourceMenuType.STUDENT_SYS, 1), PageLevel.Level1);
        });
        addMenuItem(MsgUtil.getMessage("resource.menu.teacher"), "iconfont.svg.resource", e -> {
            // 获得教师编号
            Integer tearcherId = SpringUtil.getBean(UserAction.class).getTeacherIdByStudentId(Session.get(Session.KEY_LOGIN_ID));
            PageController controller = SpringUtil.getBean(PageController.class);
            controller.loadContent(new ResourceList(ResourceMenuType.STUDENT_TECH, tearcherId), PageLevel.Level1);
        });
    }
    addMenuItem(MsgUtil.getMessage("resource.menu.browse"), "iconfont.svg.history", e -> {
        PageController controller = SpringUtil.getBean(PageController.class);
        controller.loadContent(new ResourceList(ResourceMenuType.BROWSE, userId), PageLevel.Level1);
    });
    addMenuItem(MsgUtil.getMessage("resource.menu.collection"), "iconfont.svg.favourite", e -> {
        PageController controller = SpringUtil.getBean(PageController.class);
        controller.loadContent(new ResourceList(ResourceMenuType.COLLECTION, userId), PageLevel.Level1);
    });
}
Also used : PageLevel(com.cas.sim.tis.view.controller.PageController.PageLevel) RoleConst(com.cas.sim.tis.consts.RoleConst) ResourceMenuType(com.cas.sim.tis.view.control.imp.resource.ResourceList.ResourceMenuType) PageController(com.cas.sim.tis.view.controller.PageController) SpringUtil(com.cas.sim.tis.util.SpringUtil) LeftMenu(com.cas.sim.tis.view.control.imp.LeftMenu) MsgUtil(com.cas.sim.tis.util.MsgUtil) UserAction(com.cas.sim.tis.action.UserAction) Session(com.cas.sim.tis.consts.Session) UserAction(com.cas.sim.tis.action.UserAction) PageController(com.cas.sim.tis.view.controller.PageController)

Example 8 with PageController

use of com.cas.sim.tis.view.controller.PageController in project TeachingInSimulation by ScOrPiOzzy.

the class InformationMenu method initMenu.

@Override
protected void initMenu() {
    addMenuItem(MsgUtil.getMessage("information.menu.teacher"), "iconfont.svg.teacher", e -> {
        PageController controller = SpringUtil.getBean(PageController.class);
        controller.loadContent(new TeacherList(), PageLevel.Level1);
    });
    addMenuItem(MsgUtil.getMessage("information.menu.class"), "iconfont.svg.class", e -> {
        PageController controller = SpringUtil.getBean(PageController.class);
        controller.loadContent(new ClassList(), PageLevel.Level1);
    });
}
Also used : PageController(com.cas.sim.tis.view.controller.PageController)

Example 9 with PageController

use of com.cas.sim.tis.view.controller.PageController in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method openLibrary.

private void openLibrary(Integer id) {
    PageController controller = SpringUtil.getBean(PageController.class);
    controller.loadContent(new PreviewQuestionPaper(id, false, true), PageLevel.Level2);
}
Also used : PageController(com.cas.sim.tis.view.controller.PageController) PreviewQuestionPaper(com.cas.sim.tis.view.control.imp.question.PreviewQuestionPaper)

Example 10 with PageController

use of com.cas.sim.tis.view.controller.PageController in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method openTypicalCase.

private void openTypicalCase(Integer id) {
    TypicalCase typicalCase = SpringUtil.getBean(TypicalCaseAction.class).findTypicalCaseById(id);
    PageController controller = SpringUtil.getBean(PageController.class);
    TypicalCase3D content = new TypicalCase3D();
    controller.loadContent(content, PageLevel.Level2);
    controller.showLoading();
    controller.setEndHideLoading((v) -> {
        content.setupCase(typicalCase);
    });
}
Also used : PageController(com.cas.sim.tis.view.controller.PageController) TypicalCaseAction(com.cas.sim.tis.action.TypicalCaseAction) TypicalCase(com.cas.sim.tis.entity.TypicalCase) TypicalCase3D(com.cas.sim.tis.view.control.imp.jme.TypicalCase3D)

Aggregations

PageController (com.cas.sim.tis.view.controller.PageController)10 MsgUtil (com.cas.sim.tis.util.MsgUtil)3 SpringUtil (com.cas.sim.tis.util.SpringUtil)3 PageLevel (com.cas.sim.tis.view.controller.PageController.PageLevel)3 ResourceAction (com.cas.sim.tis.action.ResourceAction)2 RoleConst (com.cas.sim.tis.consts.RoleConst)2 Session (com.cas.sim.tis.consts.Session)2 Resource (com.cas.sim.tis.entity.Resource)2 IPublish (com.cas.sim.tis.view.control.IPublish)2 LeftMenu (com.cas.sim.tis.view.control.imp.LeftMenu)2 ResourceViewer (com.cas.sim.tis.view.control.imp.ResourceViewer)2 IOException (java.io.IOException)2 JSONArray (com.alibaba.fastjson.JSONArray)1 CatalogAction (com.cas.sim.tis.action.CatalogAction)1 ClassAction (com.cas.sim.tis.action.ClassAction)1 ElecCompAction (com.cas.sim.tis.action.ElecCompAction)1 LibraryPublishAction (com.cas.sim.tis.action.LibraryPublishAction)1 PreparationResourceAction (com.cas.sim.tis.action.PreparationResourceAction)1 TypicalCaseAction (com.cas.sim.tis.action.TypicalCaseAction)1 UserAction (com.cas.sim.tis.action.UserAction)1