Search in sources :

Example 6 with AbstractField

use of cn.cerc.jpage.fields.AbstractField in project summer-mis by cn-cerc.

the class AbstractGridLine method addComponent.

@Override
public void addComponent(Component component) {
    super.addComponent(component);
    if (component instanceof AbstractField) {
        AbstractField field = (AbstractField) component;
        field.setVisible(false);
    }
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField)

Example 7 with AbstractField

use of cn.cerc.jpage.fields.AbstractField in project summer-mis by cn-cerc.

the class ColumnEditor method format.

public String format(Record ds) {
    String data = ds.getString(owner.getField());
    if (owner.getBuildText() != null) {
        HtmlWriter html = new HtmlWriter();
        owner.getBuildText().outputText(ds, html);
        data = html.toString();
    } else if (ds.getField(owner.getField()) instanceof Double) {
        DecimalFormat df = new DecimalFormat("0.####");
        data = df.format(ds.getDouble(owner.getField()));
    }
    if (!this.init) {
        dataSet = gridLine.getDataSet();
        columns = new ArrayList<>();
        for (IField field : gridLine.getFields()) {
            if (field instanceof IColumn) {
                if (((AbstractField) field).isReadonly())
                    continue;
                if (field.getWidth() == 0)
                    continue;
                columns.add(field);
            }
        }
        if (gridLine.getOwner() instanceof DataGrid) {
            DataGrid grid = (DataGrid) gridLine.getOwner();
            if (columns.size() > 0 && grid.getPrimaryKey() == null)
                throw new RuntimeException("BaseGrid.primaryKey is null");
        }
        this.init = true;
    }
    HtmlWriter html = new HtmlWriter();
    String inputStyle = "";
    html.print("<input");
    if (gridLine instanceof MasterGridLine)
        html.print(" id='%s'", this.getDataId());
    else {
        if (owner.getId() != null)
            html.print(" id='%s'", owner.getId());
        inputStyle = "width:80%;";
    }
    inputStyle += "border: 1px solid #dcdcdc;";
    html.print(" type='text'");
    html.print(" name='%s'", owner.getField());
    html.print(" value='%s'", data);
    html.print(" autocomplete='off'");
    html.print(" data-%s='[%s]'", owner.getField(), data);
    if (gridLine instanceof MasterGridLine) {
        html.print(" data-focus='[%s]'", this.getDataFocus());
        if (owner.getAlign() != null)
            inputStyle += String.format("text-align:%s;", owner.getAlign());
        if (owner.getOnclick() != null) {
            html.print(" onclick=\"%s\"", owner.getOnclick());
        } else
            html.print(" onclick='this.select()'");
    }
    if (!"".equals(inputStyle))
        html.print(" style='%s'", inputStyle);
    html.print(" onkeydown='return tableDirection(event,this)'");
    if (dataField.size() > 0) {
        for (String field : dataField) {
            html.print(" data-%s='%s'", field, ds.getString(field));
        }
    }
    if (onUpdate != null)
        html.print(" oninput=\"tableOnChanged(this,'%s')\"", onUpdate);
    else
        html.print(" oninput='tableOnChanged(this)'");
    html.println("/>");
    return html.toString();
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField) MasterGridLine(cn.cerc.jpage.grid.lines.MasterGridLine) IColumn(cn.cerc.jpage.core.IColumn) HtmlWriter(cn.cerc.jpage.core.HtmlWriter) DecimalFormat(java.text.DecimalFormat) DataGrid(cn.cerc.jpage.grid.DataGrid) IField(cn.cerc.jpage.core.IField)

Example 8 with AbstractField

use of cn.cerc.jpage.fields.AbstractField in project summer-mis by cn-cerc.

the class ChildGridLine method output.

@Override
public void output(HtmlWriter html, int lineNo) {
    html.print("<tr");
    html.print(" id='%s_%s'", "tr" + dataSource.getDataSet().getRecNo(), lineNo);
    if (!this.isVisible())
        html.print(" style=\"display:none\"");
    html.println(">");
    for (RowCell item : this.getCells()) {
        IField objField = item.getFields().get(0);
        html.print("<td");
        if (item.getColSpan() > 1)
            html.print(" colspan=\"%d\"", item.getColSpan());
        if (item.getStyle() != null)
            html.print(" style=\"%s\"", item.getStyle());
        if (item.getAlign() != null)
            html.print(" align=\"%s\"", item.getAlign());
        else if (objField.getAlign() != null)
            html.print(" align=\"%s\"", objField.getAlign());
        if (item.getRole() != null)
            html.print(" role=\"%s\"", item.getRole());
        else if (item.getFields().get(0).getField() != null)
            html.print(" role=\"%s\"", item.getFields().get(0).getField());
        html.print(">");
        for (IField obj : item.getFields()) {
            if (obj instanceof AbstractField) {
                AbstractField field = (AbstractField) obj;
                if (field instanceof IColumn)
                    html.print(((IColumn) field).format(dataSource.getDataSet().getCurrent()));
                else if (field instanceof AbstractField)
                    outputField(html, field);
                else
                    throw new RuntimeException("暂不支持的数据类型:" + field.getClass().getName());
                if (field.getTitle() != null && !"".equals(field.getTitle()))
                    html.print("<span style='float: left;'>%s:</span> ", field.getTitle());
            }
        }
        html.println("</td>");
    }
    html.println("</tr>");
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField) IColumn(cn.cerc.jpage.core.IColumn) RowCell(cn.cerc.jpage.grid.RowCell) IField(cn.cerc.jpage.core.IField)

Example 9 with AbstractField

use of cn.cerc.jpage.fields.AbstractField in project summer-mis by cn-cerc.

the class UIFormHorizontal method readAll.

public ButtonField readAll() {
    if (readAll) {
        return submit;
    }
    if (buttons == null) {
        return submit;
    }
    submit = null;
    // 取 form submit 按钮
    for (AbstractField field : buttons.getFields()) {
        if (field instanceof ButtonField) {
            ButtonField button = (ButtonField) field;
            String key = button.getField();
            String val = request.getParameter(key);
            if (val != null && val.equals(button.getData())) {
                submit = button;
                break;
            }
        }
    }
    // 将用户值或缓存值存入到dataSet中
    for (AbstractField field : this.fields) field.updateField();
    // 将可折叠字段的值存入到dataSet中
    for (IField field : this.getExpender().getFields()) ((AbstractField) field).updateField();
    readAll = true;
    return submit;
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField) IField(cn.cerc.jpage.core.IField) ButtonField(cn.cerc.jpage.fields.ButtonField)

Example 10 with AbstractField

use of cn.cerc.jpage.fields.AbstractField in project summer-mis by cn-cerc.

the class MasterGridLine method output.

@Override
public void output(HtmlWriter html, int lineNo) {
    DataSet dataSet = dataSource.getDataSet();
    html.print("<tr");
    html.print(" id='%s'", "tr" + dataSet.getRecNo());
    if (this.getPrimaryKey() != null)
        html.print(" data-rowid='%s'", dataSet.getString(this.getPrimaryKey()));
    html.println(">");
    for (RowCell cell : this.getOutputCells()) {
        IField obj = cell.getFields().get(0);
        html.print("<td");
        if (cell.getColSpan() > 1)
            html.print(" colspan=\"%d\"", cell.getColSpan());
        if (cell.getStyle() != null)
            html.print(" style=\"%s\"", cell.getStyle());
        else if (obj.getWidth() == 0)
            html.print(" style=\"%s\"", "display:none");
        if (cell.getAlign() != null)
            html.print(" align=\"%s\"", cell.getAlign());
        else if (obj.getAlign() != null)
            html.print(" align=\"%s\"", obj.getAlign());
        if (cell.getRole() != null)
            html.print(" role=\"%s\"", cell.getRole());
        else if (obj.getField() != null)
            html.print(" role=\"%s\"", obj.getField());
        html.print(">");
        if (obj instanceof AbstractField) {
            AbstractField field = (AbstractField) obj;
            if (field instanceof IColumn)
                html.print(((IColumn) field).format(dataSource.getDataSet().getCurrent()));
            else if (field instanceof AbstractField)
                outputField(html, field);
            else
                throw new RuntimeException("暂不支持的数据类型:" + field.getClass().getName());
        }
        html.println("</td>");
    }
    html.println("</tr>");
}
Also used : AbstractField(cn.cerc.jpage.fields.AbstractField) DataSet(cn.cerc.jdb.core.DataSet) IColumn(cn.cerc.jpage.core.IColumn) RowCell(cn.cerc.jpage.grid.RowCell) IField(cn.cerc.jpage.core.IField)

Aggregations

AbstractField (cn.cerc.jpage.fields.AbstractField)11 IField (cn.cerc.jpage.core.IField)5 IColumn (cn.cerc.jpage.core.IColumn)4 RowCell (cn.cerc.jpage.grid.RowCell)3 DataSet (cn.cerc.jdb.core.DataSet)2 Component (cn.cerc.jpage.core.Component)1 HtmlWriter (cn.cerc.jpage.core.HtmlWriter)1 ButtonField (cn.cerc.jpage.fields.ButtonField)1 ExpendField (cn.cerc.jpage.fields.ExpendField)1 DataGrid (cn.cerc.jpage.grid.DataGrid)1 MasterGridLine (cn.cerc.jpage.grid.lines.MasterGridLine)1 UIText (cn.cerc.jui.vcl.UIText)1 DecimalFormat (java.text.DecimalFormat)1