Search in sources :

Example 36 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class WAccount method doGet.

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.config("WAccount.doGet");
    WebSessionCtx wsc = WebSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    if (wsc == null || ws == null) {
        WebUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    String columnName = WebUtil.getParameter(request, "ColumnName");
    GridField mField = ws.curTab.getField(columnName);
    log.config(" ColumnName=" + columnName + ", MField=" + mField.toString());
    if (mField == null || columnName == null || columnName.equals("")) {
        WebUtil.createTimeoutPage(request, response, this, Msg.getMsg(wsc.ctx, "ParameterMissing"));
        return;
    }
    String target = "opener.document.WForm." + columnName;
    WebDoc doc = WebDoc.create(mField.getHeader());
    body body = doc.getBody();
    body.setOnBlur("self.focus();");
    body.addElement(fillTable(ws, mField, target));
    button reset = new button();
    reset.addElement("Reset");
    reset.setOnClick(target + "D.value='';" + target + "F.value='';window.close();");
    button cancel = new button();
    cancel.addElement("Cancel");
    cancel.setOnClick("window.close();");
    body.addElement(new p(AlignType.RIGHT).addElement(reset).addElement("&nbsp").addElement(cancel));
    WebUtil.createResponse(request, response, this, null, doc, true);
}
Also used : org.apache.ecs.xhtml.button(org.apache.ecs.xhtml.button) Lookup(org.compiere.model.Lookup) org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) WebDoc(org.compiere.util.WebDoc) GridField(org.compiere.model.GridField) WebSessionCtx(org.compiere.util.WebSessionCtx) org.apache.ecs.xhtml.body(org.apache.ecs.xhtml.body)

Example 37 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class WFindAdv method createPageFind.

private form createPageFind(HttpServletRequest request, HttpServletResponse response, WWindowStatus ws) throws ServletException, IOException {
    boolean hasValue = false;
    boolean hasName = false;
    boolean hasDocNo = false;
    boolean hasDescription = false;
    //Get Info from target Tab
    int size = ws.curTab.getFieldCount();
    for (int i = 0; i < size; i++) {
        GridField mField = ws.curTab.getField(i);
        String columnName = mField.getColumnName();
        if (mField.isDisplayed()) {
            if (columnName.equals("Value"))
                hasValue = true;
            else if (columnName.equals("Name"))
                hasName = true;
            else if (columnName.equals("DocumentNo"))
                hasDocNo = true;
            else if (columnName.equals("Description"))
                hasDescription = true;
        }
    }
    form myForm = new form("/adempiere/WWindow", form.METHOD_POST, form.ENC_DEFAULT);
    myForm.setName("WForm");
    myForm.setOnSubmit("this.target=window.opener.name");
    myForm.addElement(createTabs("Find"));
    table table = new table();
    //table.setClass("centerTable");
    tr line = null;
    if (hasValue) {
        line = new tr();
        line.addElement(new td().addElement(new label().addElement(Msg.translate(ws.ctx, "Value"))).setAlign("right"));
        line.addElement(new td().addElement(new input("text", "txtValue", "")));
        table.addElement(line);
    }
    if (hasDocNo) {
        line = new tr();
        line.addElement(new td().addElement(new label().addElement(Msg.translate(ws.ctx, "DocumentNo"))).setAlign("right"));
        line.addElement(new td().addElement(new input("text", "txtDocumentNo", "")));
        table.addElement(line);
    }
    if (hasName) {
        line = new tr();
        line.addElement(new td().addElement(new label().addElement(Msg.translate(ws.ctx, "Name"))).setAlign("right"));
        line.addElement(new td().addElement(new input("text", "txtName", "")));
        table.addElement(line);
    }
    if (hasDescription) {
        line = new tr();
        line.addElement(new td().addElement(new label().addElement(Msg.translate(ws.ctx, "Description"))).setAlign("right"));
        line.addElement(new td().addElement(new input("text", "txtDescription", "")));
        table.addElement(line);
    }
    if (!hasDescription && !hasDocNo && !hasName && !hasValue) {
        line = new tr();
        line.addElement(new td().addElement(new h2("N/A!")));
        table.addElement(line);
    }
    myForm.addElement(table);
    myForm.addElement(new input("hidden", "txtSQL", "FIND"));
    myForm.addElement(new br());
    myForm.addElement(new input("hidden", "PCommand", "FindAdv"));
    myForm.addElement("&nbsp;&nbsp;");
    myForm.addElement(new input("Reset", "", "  Reset").setClass("resetbtn"));
    myForm.addElement("&nbsp;");
    input cmd = new input("Submit", "", "  Submit");
    cmd.setClass("submitbtn");
    myForm.addElement(cmd);
    myForm.addElement("&nbsp;");
    cmd = new input("button", "", "  Close");
    cmd.setClass("closebtn");
    cmd.setOnClick("window.close()");
    myForm.addElement(cmd);
    return myForm;
}
Also used : org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.br(org.apache.ecs.xhtml.br) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form) org.apache.ecs.xhtml.h2(org.apache.ecs.xhtml.h2) GridField(org.compiere.model.GridField) org.apache.ecs.xhtml.label(org.apache.ecs.xhtml.label) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr)

Example 38 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class BrowserRow method getValue.

/**
	 * BR[ 268 ]
	 * Get Value from a column name in a row
	 * @param p_Row
	 * @param p_ColumnName
	 * @return
	 */
public Object getValue(int p_Row, String p_ColumnName) {
    Integer columnIndex = columnNamesIndex.get(p_ColumnName);
    //	Valid Index
    if (columnIndex == null)
        return null;
    //	Get current Value
    GridField gridField = getValue(p_Row, columnIndex);
    if (gridField == null)
        return null;
    //	Return value of GridField
    return gridField.getValue();
}
Also used : GridField(org.compiere.model.GridField)

Example 39 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class DeleteSelectionController method getValue.

/**
	 * Get value from index
	 * @param index
	 * @return
	 */
private String getValue(int index) {
    StringBuffer displayValue = new StringBuffer();
    if (keyColumnName.trim().length() == 0) {
        ArrayList<String> parentColumnNames = currentTab.getParentColumnNames();
        for (Iterator<String> iter = parentColumnNames.iterator(); iter.hasNext(); ) {
            String columnName = iter.next();
            GridField field = currentTab.getField(columnName);
            if (field.isLookup()) {
                Lookup lookup = field.getLookup();
                if (lookup != null) {
                    displayValue = displayValue.append(lookup.getDisplay(currentTab.getValue(index, columnName))).append(" | ");
                } else {
                    displayValue = displayValue.append(currentTab.getValue(index, columnName)).append(" | ");
                }
            } else {
                displayValue = displayValue.append(currentTab.getValue(index, columnName)).append(" | ");
            }
        }
    } else {
        final int id = currentTab.getKeyID(index);
        String value = DB.getSQLValueStringEx(null, sql, id);
        if (value != null)
            value = value.replace(" - ", " | ");
        displayValue.append(value);
        // Append ID
        if (displayValue.length() == 0 || CLogMgt.isLevelFine()) {
            if (displayValue.length() > 0)
                displayValue.append(" | ");
            displayValue.append("<").append(id).append(">");
        }
    }
    //	Return
    return displayValue.toString();
}
Also used : Lookup(org.compiere.model.Lookup) GridField(org.compiere.model.GridField)

Example 40 with GridField

use of org.compiere.model.GridField in project adempiere by adempiere.

the class SmallViewController method createEditors.

/**
	 * Create editors for each field/fieldTo.  The function calls the View to create
	 * the appropriate editor for the field.
	 * 
	 * TODO The GridFields are Model level entities and the view should not have to 
	 * deal with the Model. An intermediate factory could be used to create Controller 
	 * level editors common to all interfaces.  The View would then only have to implement
	 * the actual editor.  There is a CEditor interface used but an abstract class would be 
	 * better. 
	 */
private void createEditors() {
    for (int i = 0; i < fields.size(); i++) {
        //    Get Values
        GridField field = (GridField) fields.get(i);
        GridField field_To = (GridField) fieldsTo.get(i);
        createEditors(field, field_To);
    }
}
Also used : GridField(org.compiere.model.GridField)

Aggregations

GridField (org.compiere.model.GridField)114 MQuery (org.compiere.model.MQuery)15 WEditor (org.adempiere.webui.editor.WEditor)11 GridFieldVO (org.compiere.model.GridFieldVO)10 GridTab (org.compiere.model.GridTab)10 Lookup (org.compiere.model.Lookup)9 org.apache.ecs.xhtml.tr (org.apache.ecs.xhtml.tr)8 MLookup (org.compiere.model.MLookup)8 Component (java.awt.Component)7 AdempiereException (org.adempiere.exceptions.AdempiereException)7 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)7 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)7 ValueNamePair (org.compiere.util.ValueNamePair)7 SQLException (java.sql.SQLException)6 MBrowseField (org.adempiere.model.MBrowseField)6 org.apache.ecs.xhtml.td (org.apache.ecs.xhtml.td)6 VEditor (org.compiere.grid.ed.VEditor)6 Point (java.awt.Point)5 org.apache.ecs.xhtml.a (org.apache.ecs.xhtml.a)5 org.apache.ecs.xhtml.div (org.apache.ecs.xhtml.div)5