Search in sources :

Example 1 with HtmlColumn

use of org.jmesa.view.html.component.HtmlColumn in project OpenClinica by OpenClinica.

the class AbstractTableFactory method configureColumn.

protected void configureColumn(Column column, String title, CellEditor editor, FilterEditor filterEditor, boolean filterable, boolean sortable) {
    column.setTitle(title);
    if (editor != null) {
        column.getCellRenderer().setCellEditor(editor);
    }
    if (column instanceof HtmlColumn) {
        HtmlColumn htmlColumn = (HtmlColumn) column;
        htmlColumn.setFilterable(filterable);
        htmlColumn.setSortable(sortable);
        if (filterEditor != null) {
            htmlColumn.getFilterRenderer().setFilterEditor(filterEditor);
        }
    }
}
Also used : HtmlColumn(org.jmesa.view.html.component.HtmlColumn)

Example 2 with HtmlColumn

use of org.jmesa.view.html.component.HtmlColumn in project OpenClinica by OpenClinica.

the class ViewCRFServlet method html.

private String html(TableFacade tableFacade) {
    // set the column properties
    tableFacade.setColumnProperties("versionName", "ruleName", "ruleExpression", "executeOnPlaceHolder", "actionTypePlaceHolder", "actionSummaryPlaceHolder", "link");
    HtmlTable table = (HtmlTable) tableFacade.getTable();
    table.setCaption(resword.getString("rule_rules"));
    table.getTableRenderer().setWidth("800px");
    HtmlRow row = table.getRow();
    HtmlColumn versionName = row.getColumn("versionName");
    versionName.setTitle(resword.getString("CRF_version"));
    HtmlColumn ruleName = row.getColumn("ruleName");
    ruleName.setTitle(resword.getString("rule_name"));
    HtmlColumn career = row.getColumn("ruleExpression");
    career.setWidth("100px");
    career.setTitle(resword.getString("rule_expression"));
    HtmlColumn executeOn = row.getColumn("executeOnPlaceHolder");
    executeOn.setSortable(false);
    executeOn.setFilterable(false);
    executeOn.setTitle(resword.getString("rule_execute_on"));
    executeOn.getCellRenderer().setCellEditor(new CellEditor() {

        @SuppressWarnings("unchecked")
        public Object getValue(Object item, String property, int rowcount) {
            String value = "";
            List<RuleActionBean> ruleActions = (List<RuleActionBean>) new BasicCellEditor().getValue(item, "actions", rowcount);
            for (int i = 0; i < ruleActions.size(); i++) {
                value += ruleActions.get(i).getExpressionEvaluatesTo();
                // Do not add horizontal line after last Summary
                if (i != ruleActions.size() - 1) {
                    value += "<hr>";
                }
            }
            return value;
        }
    });
    HtmlColumn actionTypePlaceHolder = row.getColumn("actionTypePlaceHolder");
    actionTypePlaceHolder.setSortable(false);
    actionTypePlaceHolder.setFilterable(false);
    actionTypePlaceHolder.setTitle(resword.getString("rule_action_type"));
    actionTypePlaceHolder.getCellRenderer().setCellEditor(new CellEditor() {

        @SuppressWarnings("unchecked")
        public Object getValue(Object item, String property, int rowcount) {
            String value = "";
            List<RuleActionBean> ruleActions = (List<RuleActionBean>) new BasicCellEditor().getValue(item, "actions", rowcount);
            for (int i = 0; i < ruleActions.size(); i++) {
                value += ruleActions.get(i).getActionType().name();
                // Do not add horizontal line after last Summary
                if (i != ruleActions.size() - 1) {
                    value += "<hr>";
                }
            }
            return value;
        }
    });
    HtmlColumn actionSummaryPlaceHolder = row.getColumn("actionSummaryPlaceHolder");
    actionSummaryPlaceHolder.setSortable(false);
    actionSummaryPlaceHolder.setFilterable(false);
    actionSummaryPlaceHolder.setTitle(resword.getString("rule_action_summary"));
    actionSummaryPlaceHolder.getCellRenderer().setCellEditor(new CellEditor() {

        @SuppressWarnings("unchecked")
        public Object getValue(Object item, String property, int rowcount) {
            String value = "";
            List<RuleActionBean> ruleActions = (List<RuleActionBean>) new BasicCellEditor().getValue(item, "actions", rowcount);
            for (int i = 0; i < ruleActions.size(); i++) {
                value += ruleActions.get(i).getSummary();
                // Do not add horizontal line after last Summary
                if (i != ruleActions.size() - 1) {
                    value += "<hr>";
                }
            }
            return value;
        }
    });
    HtmlColumn link = row.getColumn("link");
    link.setSortable(false);
    link.setFilterable(false);
    link.setTitle(resword.getString("action"));
    link.getCellRenderer().setCellEditor(new CellEditor() {

        @SuppressWarnings("unchecked")
        public Object getValue(Object item, String property, int rowcount) {
            String param1 = (String) new BasicCellEditor().getValue(item, "ruleSetRuleId", rowcount);
            String param2 = (String) new BasicCellEditor().getValue(item, "versionId", rowcount);
            HtmlBuilder html = new HtmlBuilder();
            html.a().href().quote().append(request.getContextPath() + "/RunRule?ruleSetRuleId=" + param1 + "&versionId=" + param2 + "&action=dryRun").quote().close();
            html.img().name("bt_View1").src("images/bt_ExexuteRules.gif").border("0").end();
            html.aEnd();
            return html.toString();
        }
    });
    // Return the Html.
    return tableFacade.render();
}
Also used : RuleActionBean(org.akaza.openclinica.domain.rule.action.RuleActionBean) BasicCellEditor(org.jmesa.view.editor.BasicCellEditor) HtmlTable(org.jmesa.view.html.component.HtmlTable) CellEditor(org.jmesa.view.editor.CellEditor) BasicCellEditor(org.jmesa.view.editor.BasicCellEditor) HtmlBuilder(org.jmesa.view.html.HtmlBuilder) HtmlRow(org.jmesa.view.html.component.HtmlRow) ArrayList(java.util.ArrayList) List(java.util.List) HtmlColumn(org.jmesa.view.html.component.HtmlColumn)

Example 3 with HtmlColumn

use of org.jmesa.view.html.component.HtmlColumn in project OpenClinica by OpenClinica.

the class SubjectIdSDVFactory method configureColumns.

@Override
protected void configureColumns(TableFacade tableFacade, Locale locale) {
    tableFacade.setColumnProperties("sdvStatus", "studySubjectId", "siteId", "personId", "studySubjectStatus", "group", "numberCRFComplete", "numberOfCRFsSDV", "totalEventCRF", "actions");
    resword = ResourceBundleProvider.getWordsBundle(locale);
    Row row = tableFacade.getTable().getRow();
    SDVUtil sdvUtil = new SDVUtil();
    String[] allTitles = new String[] { resword.getString("SDV_status"), resword.getString("study_subject_ID"), resword.getString("site_id"), resword.getString("person_ID"), resword.getString("study_subject_status"), resword.getString("group"), resword.getString("num_CRFs_completed"), resword.getString("num_CRFs_SDV"), resword.getString("total_events_CRF"), resword.getString("actions") };
    sdvUtil.setTitles(allTitles, (HtmlTable) tableFacade.getTable());
    sdvUtil.turnOffFilters(tableFacade, new String[] { "personId", "studySubjectStatus", "group", "numberCRFComplete", "numberOfCRFsSDV", "totalEventCRF", "actions" });
    sdvUtil.turnOffSorts(tableFacade, new String[] { "sdvStatus", "studySubjectId", "siteId", "personId", "studySubjectStatus", "group", "numberCRFComplete", "numberOfCRFsSDV", "totalEventCRF" });
    sdvUtil.setHtmlCellEditors(tableFacade, new String[] { "sdvStatus", "actions" }, false);
    HtmlColumn sdvStatus = ((HtmlRow) row).getColumn("sdvStatus");
    sdvStatus.getFilterRenderer().setFilterEditor(new SdvStatusFilter());
    String actionsHeader = resword.getString("rule_actions") + "&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;";
    configureColumn(row.getColumn("actions"), actionsHeader, sdvUtil.getCellEditorNoEscapes(), new DefaultActionsEditor(locale), true, false);
}
Also used : DefaultActionsEditor(org.akaza.openclinica.control.DefaultActionsEditor) HtmlRow(org.jmesa.view.html.component.HtmlRow) Row(org.jmesa.view.component.Row) HtmlRow(org.jmesa.view.html.component.HtmlRow) HtmlColumn(org.jmesa.view.html.component.HtmlColumn)

Example 4 with HtmlColumn

use of org.jmesa.view.html.component.HtmlColumn in project OpenClinica by OpenClinica.

the class SDVUtil method setHtmlCellEditors.

public void setHtmlCellEditors(TableFacade tableFacade, String[] columnNames, boolean preventHtmlEscapes) {
    HtmlRow row = ((HtmlTable) tableFacade.getTable()).getRow();
    HtmlColumn column = null;
    for (String col : columnNames) {
        column = row.getColumn(col);
        column.getCellRenderer().setCellEditor(this.getCellEditorNoEscapes());
    }
}
Also used : HtmlTable(org.jmesa.view.html.component.HtmlTable) HtmlRow(org.jmesa.view.html.component.HtmlRow) HtmlColumn(org.jmesa.view.html.component.HtmlColumn)

Example 5 with HtmlColumn

use of org.jmesa.view.html.component.HtmlColumn in project OpenClinica by OpenClinica.

the class SDVUtil method renderSubjectsTableWithLimit.

public String renderSubjectsTableWithLimit(HttpServletRequest request, int studyId, int studySubjectId) {
    TableFacade tableFacade = createTableFacade("sdv", request);
    tableFacade.setStateAttr("restore");
    /*StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
        StudySubjectBean subjectBean = (StudySubjectBean) studySubjectDAO.findByPK(studySubjectId);*/
    String[] allColumns = new String[] { "studySubjectId", "studyIdentifier", "personId", "secondaryId", "eventName", "eventDate", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "sdvRequirementDefinition", "crfStatus", "lastUpdatedDate", "lastUpdatedBy", "studyEventStatus", "sdvStatusActions" };
    tableFacade.setColumnProperties("studySubjectId", "studyIdentifier", "personId", "secondaryId", "eventName", "eventDate", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "sdvRequirementDefinition", "crfStatus", "lastUpdatedDate", "lastUpdatedBy", "studyEventStatus", "sdvStatusActions");
    tableFacade.addFilterMatcher(new MatcherKey(String.class, "studySubjectStatus"), new SubjectStatusMatcher());
    tableFacade.addFilterMatcher(new MatcherKey(String.class, "crfStatus"), new CrfStatusMatcher());
    tableFacade.addFilterMatcher(new MatcherKey(String.class, "sdvStatusActions"), new SdvStatusMatcher());
    tableFacade.addFilterMatcher(new MatcherKey(String.class, "sdvRequirementDefinition"), new SDVRequirementMatcher());
    int totalRowCount = 0;
    totalRowCount = setDataAndLimitVariablesSubjects(tableFacade, studyId, studySubjectId, request);
    //tableFacade.setItems(items);
    HtmlRow row = (HtmlRow) tableFacade.getTable().getRow();
    HtmlColumn studySubjectStatus = row.getColumn("studySubjectStatus");
    studySubjectStatus.getFilterRenderer().setFilterEditor(new SubjectStatusFilter());
    HtmlColumn crfStatus = row.getColumn("crfStatus");
    crfStatus.getFilterRenderer().setFilterEditor(new CrfStatusFilter());
    HtmlColumn sdvStatus = row.getColumn("sdvStatusActions");
    sdvStatus.getFilterRenderer().setFilterEditor(new SdvStatusFilter());
    HtmlColumn sdvRequirementDefinition = row.getColumn("sdvRequirementDefinition");
    sdvRequirementDefinition.getFilterRenderer().setFilterEditor(new SDVRequirementFilter());
    //fix HTML in columns
    setHtmlCellEditors(tableFacade, allColumns, true);
    //temporarily disable some of the filters for now
    turnOffFilters(tableFacade, new String[] { "personId", "secondaryId", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "lastUpdatedDate", "lastUpdatedBy" });
    //Create the custom toolbar
    SDVToolbar sDVToolbar = new SDVToolbar(true);
    // if(totalRowCount > 0){
    sDVToolbar.setMaxRowsIncrements(new int[] { 15, 50, totalRowCount });
    tableFacade.setToolbar(sDVToolbar);
    //Fix column titles
    HtmlTable table = (HtmlTable) tableFacade.getTable();
    //i18n caption; TODO: convert to Spring messages
    ResourceBundle resword = ResourceBundle.getBundle("org.akaza.openclinica.i18n.words", LocaleResolver.getLocale(request));
    String[] allTitles = { resword.getString("study_subject_ID"), resword.getString("site_id"), resword.getString("person_ID"), resword.getString("secondary_ID"), resword.getString("event_name"), resword.getString("event_date"), resword.getString("enrollment_date"), resword.getString("subject_status"), resword.getString("CRF_name") + " / " + resword.getString("version"), resword.getString("SDV_requirement"), resword.getString("CRF_status"), resword.getString("last_updated_date"), resword.getString("last_updated_by"), resword.getString("study_event_status"), resword.getString("SDV_status") + " / " + resword.getString("actions") };
    setTitles(allTitles, table);
    //format column dates
    formatColumns(table, new String[] { "eventDate", "enrollmentDate", "lastUpdatedDate" }, request);
    table.getTableRenderer().setWidth("800");
    return tableFacade.render();
}
Also used : HtmlTable(org.jmesa.view.html.component.HtmlTable) HtmlRow(org.jmesa.view.html.component.HtmlRow) HtmlColumn(org.jmesa.view.html.component.HtmlColumn) SDVToolbar(org.akaza.openclinica.controller.helper.table.SDVToolbar) TableFacadeFactory.createTableFacade(org.jmesa.facade.TableFacadeFactory.createTableFacade) TableFacade(org.jmesa.facade.TableFacade) ResourceBundle(java.util.ResourceBundle) MatcherKey(org.jmesa.core.filter.MatcherKey)

Aggregations

HtmlColumn (org.jmesa.view.html.component.HtmlColumn)13 HtmlRow (org.jmesa.view.html.component.HtmlRow)12 HtmlTable (org.jmesa.view.html.component.HtmlTable)6 TableFacade (org.jmesa.facade.TableFacade)4 TableFacadeFactory.createTableFacade (org.jmesa.facade.TableFacadeFactory.createTableFacade)4 ResourceBundle (java.util.ResourceBundle)3 DefaultActionsEditor (org.akaza.openclinica.control.DefaultActionsEditor)2 SDVToolbar (org.akaza.openclinica.controller.helper.table.SDVToolbar)2 MatcherKey (org.jmesa.core.filter.MatcherKey)2 DateCellEditor (org.jmesa.view.editor.DateCellEditor)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Locale (java.util.Locale)1 RuleActionBean (org.akaza.openclinica.domain.rule.action.RuleActionBean)1 SDVUtil (org.akaza.openclinica.web.table.sdv.SDVUtil)1 Row (org.jmesa.view.component.Row)1 BasicCellEditor (org.jmesa.view.editor.BasicCellEditor)1 CellEditor (org.jmesa.view.editor.CellEditor)1 HtmlBuilder (org.jmesa.view.html.HtmlBuilder)1