use of org.compiere.model.GridField in project adempiere by adempiere.
the class Find method initFind.
/**
* Dynamic Init.6
* Set up GridController
*/
private void initFind() {
log.config("");
// Get Info from target Tab
int parameterNo = 0;
for (int i = 0; i < m_findFields.length; i++) {
GridField mField = m_findFields[i];
if (mField.isSelectionColumn())
parameterNo++;
}
if (parameterNo >= 7)
isTwoColumns = true;
// Get Info from target Tab
for (int i = 0; i < m_findFields.length; i++) {
GridField mField = m_findFields[i];
// Make Yes-No searchable as list
if (mField.getVO().displayType == DisplayType.YesNo) {
GridFieldVO vo = mField.getVO();
GridFieldVO ynvo = vo.clone(vo.ctx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly);
ynvo.IsDisplayed = true;
ynvo.displayType = DisplayType.List;
ynvo.AD_Reference_Value_ID = AD_REFERENCE_ID_YESNO;
ynvo.lookupInfo = MLookupFactory.getLookupInfo(ynvo.ctx, ynvo.WindowNo, ynvo.AD_Column_ID, ynvo.displayType, Env.getLanguage(ynvo.ctx), ynvo.ColumnName, ynvo.AD_Reference_Value_ID, ynvo.IsParent, ynvo.ValidationCode);
ynvo.lookupInfo.InfoFactoryClass = ynvo.InfoFactoryClass;
GridField ynfield = new GridField(ynvo);
// replace the original field by the YN List field
m_findFields[i] = ynfield;
mField = ynfield;
}
// Make Buttons searchable
if (mField.getVO().displayType == DisplayType.Button) {
GridFieldVO vo = mField.getVO();
if (vo.AD_Reference_Value_ID > 0) {
GridFieldVO postedvo = vo.clone(vo.ctx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly);
postedvo.IsDisplayed = true;
postedvo.displayType = DisplayType.List;
postedvo.lookupInfo = MLookupFactory.getLookupInfo(postedvo.ctx, postedvo.WindowNo, postedvo.AD_Column_ID, postedvo.displayType, Env.getLanguage(postedvo.ctx), postedvo.ColumnName, postedvo.AD_Reference_Value_ID, postedvo.IsParent, postedvo.ValidationCode);
postedvo.lookupInfo.InfoFactoryClass = postedvo.InfoFactoryClass;
GridField postedfield = new GridField(postedvo);
// replace the original field by the Posted List field
m_findFields[i] = postedfield;
mField = postedfield;
}
}
/** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214
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;
else
/**/
if (mField.isSelectionColumn()) {
addSelectionColumn(mField);
isPair = !isPair;
}
/** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214
else if (columnName.indexOf("Name") != -1)
addSelectionColumn (mField);
/**/
// TargetFields
m_targetFields.put(new Integer(mField.getAD_Column_ID()), mField);
}
// for all target tab fields
// Disable simple query fields
valueLabel.setVisible(hasValue);
valueField.setVisible(hasValue);
if (hasValue)
valueField.addActionListener(this);
docNoLabel.setVisible(hasDocNo);
docNoField.setVisible(hasDocNo);
if (hasDocNo)
docNoField.addActionListener(this);
nameLabel.setVisible(hasName);
nameField.setVisible(hasName);
if (hasName)
nameField.addActionListener(this);
descriptionLabel.setVisible(hasDescription);
descriptionField.setVisible(hasDescription);
if (hasDescription)
descriptionField.addActionListener(this);
// Get Total
m_total = getNoOfRecords(null, false);
setStatusDB(m_total);
statusBar.setStatusLine("");
tabbedPane.addChangeListener(this);
// Better Labels for OK/Cancel
confirmPanelA.getOKButton().setToolTipText(Msg.getMsg(Env.getCtx(), "QueryEnter"));
confirmPanelA.getCancelButton().setToolTipText(Msg.getMsg(Env.getCtx(), "QueryCancel"));
confirmPanelS.getOKButton().setToolTipText(Msg.getMsg(Env.getCtx(), "QueryEnter"));
confirmPanelS.getCancelButton().setToolTipText(Msg.getMsg(Env.getCtx(), "QueryCancel"));
}
use of org.compiere.model.GridField in project adempiere by adempiere.
the class Find method parseUserQuery.
/**
* Parse delimited string into user query
* Old field sequence: column, operator, value, value to
* New field sequence: column, operator, value, value to, and/or, left brackets, right brackets
* @param userQuery
*/
private void parseUserQuery(MUserQuery userQuery) {
String code = userQuery.getCode();
log.fine("Parse user query: " + code);
String[] segments = code.split(Pattern.quote(SEGMENT_SEPARATOR), -1);
advancedTable.stopEditor(true);
DefaultTableModel model = (DefaultTableModel) advancedTable.getModel();
int cnt = model.getRowCount();
for (int i = cnt - 1; i >= 0; i--) model.removeRow(i);
for (int i = 0; i < segments.length; i++) {
String[] fields = segments[i].split(Pattern.quote(FIELD_SEPARATOR));
model.addRow(new Object[] { "", "", null, MQuery.OPERATORS[MQuery.EQUAL_INDEX], null, null, "" });
String columnName = null;
for (int j = 0; j < fields.length; j++) {
// column
if (j == 0) {
for (ValueNamePair vnp : columnValueNamePairs) {
if (vnp.getValue().equals(fields[j])) {
model.setValueAt(vnp, i, INDEX_COLUMNNAME);
columnName = fields[j];
break;
}
}
} else // operator
if (j == 1) {
for (ValueNamePair vnp : MQuery.OPERATORS) {
if (vnp.getValue().equals(fields[j])) {
model.setValueAt(vnp, i, INDEX_OPERATOR);
break;
}
}
} else // value
if (j == 2 && fields[j].length() > 0) {
GridField field = getTargetMField(columnName);
Object value = parseString(field, fields[j]);
model.setValueAt(value, i, INDEX_VALUE);
} else // value 2
if (j == 3 && fields[j].length() > 0) {
GridField field = getTargetMField(columnName);
Object value = parseString(field, fields[j]);
model.setValueAt(value, i, INDEX_VALUE2);
} else // and/or
if (j == 4 && fields[j].length() > 0) {
if (i != 0)
model.setValueAt(fields[j], i, INDEX_ANDOR);
} else if (j == 5 && fields[j].length() > 0) {
model.setValueAt(fields[j], i, INDEX_LEFTBRACKET);
} else if (j == 6 && fields[j].length() > 0) {
model.setValueAt(fields[j], i, INDEX_RIGHTBRACKET);
}
}
}
advancedTable.invalidate();
}
use of org.compiere.model.GridField in project adempiere by adempiere.
the class WWindow method getSR_Form.
// getFieldValue
/**************************************************************************
* Return SingleRow Form details
* @param action action
* @param wsc web session context
* @param ws window status
* @return Form
*/
public MobileDoc getSR_Form(String action, MobileSessionCtx wsc, WWindowStatus ws) {
log.fine("Tab=" + ws.curTab.getTabNo());
form line = new form("WWindow");
line.addAttribute("selected", "true");
line.setClass("panel");
line.setMethod("post");
line.setTitle(ws.curTab.getName());
// line.setTarget("_self");
fs = new fieldset();
line.addElement(fs);
/**********************
* For all Fields
*/
StringBuffer scriptSrc = new StringBuffer();
MRole role = MRole.getDefault(wsc.ctx, false);
//
//Modified by Rob Klein 4/29/07
m_searchField = null;
boolean isTabRO = ws.isReadOnlyView();
if (ws.curTab.isDisplayed()) {
int noFields = ws.curTab.getFieldCount();
for (int i = 0; i < noFields; i++) {
GridField field = ws.curTab.getField(i);
String columnName = field.getColumnName();
/**
* Get Data and convert to String (singleRow)
*/
Object oData = ws.curTab.getValue(field);
//Modified by Rob Klein 4/29/07
/**
* Get Record ID and Table ID for Processes
*/
int recordID = ws.curTab.getRecord_ID();
int tableID = ws.curTab.getAD_Table_ID();
/**
* Display field
*/
if (field.isDisplayed(true) && field.getDisplayType() != DisplayType.Button) {
/* todo chart support
if ( ws.isReadOnlyView() && field.getDisplayType()== 53370 )
{
img chart = getChart(field.getAD_Chart_ID(), sess);
div div = new div();
div.setClass("row");
if ( chart != null )
{
div.addElement(chart);
fs.addElement(div);
}
}
else */
{
//
boolean hasDependents = ws.curTab.hasDependants(columnName);
//Modified by Rob Klein 4/29/07
addField(wsc, line, field, oData, hasDependents, recordID, tableID, isTabRO, i, ws.curTab, role);
// Additional Values
String dispLogic = field.getDisplayLogic();
if (dispLogic != null && dispLogic.length() > 0) {
// replace ' with "
dispLogic = dispLogic.replace('\'', '"');
scriptSrc.append("document.").append(FORM_NAME).append(".").append(columnName).append(".displayLogic='").append(dispLogic).append("';\n");
}
}
}
}
// for all fields
}
// displayed
/*if (scriptSrc.length() > 0)
table.addElement(new script(scriptSrc.toString()));*/
// Status Line
int rowNo = ws.curTab.getCurrentRow();
String statusDB = String.valueOf(rowNo + 1) + " / " + ws.curTab.getRowCount();
// return createLayout (action, new ul(), wsc, ws, ws.curTab.getDescription(), statusDB);
if (ws.isReadOnlyView()) {
for (int i = ws.curTab.getTabNo() + 1; i < ws.mWindow.getTabCount(); i++) {
GridTab tab = ws.mWindow.getTab(i);
if (tab.getTabNo() >= ws.curTab.getTabNo() && tab.getTabLevel() <= ws.curTab.getTabLevel())
// past all children of curTab
break;
if (tab.getTabLevel() != ws.curTab.getTabLevel() + 1)
// not direct child
continue;
if (tab.isSortTab())
continue;
//Modified by Rob Klein 4/29/07
a big = new a("WWindow?tab=" + i, tab.getName());
big.setClass("whiteButton");
big.setTarget("_self");
line.addElement(big);
}
}
if (!ws.isReadOnlyView()) {
a button = new a("#", "Save");
button.addAttribute("type", "submit");
button.setClass("redButton");
// a.setTarget("_self");
line.addElement(button);
}
MobileDoc doc = createPage(ws);
doc.getBody().addElement(line);
div div = new div();
div.setClass("toolbar");
h1 header = new h1();
header.setID("pageTitle");
div.addElement(header);
a anchor = new a();
anchor.setClass("button");
anchor.setHref(MobileEnv.getBaseDirectory("WMenu"));
anchor.setTarget("_self");
anchor.addElement("Menu");
div.addElement(anchor);
anchor = new a("WWindow?action=list", "Back");
anchor.setID("previousButton");
anchor.setClass("button");
anchor.setTarget("_self");
div.addElement(anchor);
doc.getBody().addElement(div);
if (!ws.curTab.isReadOnly() && ws.isReadOnlyView()) {
div = new div();
div.setClass("footer");
a a = new a("WWindow?action=edit", "Edit");
a.setClass("redButton");
a.setTarget("_self");
div.addElement(a);
doc.getBody().addElement(div);
}
return doc;
}
use of org.compiere.model.GridField in project adempiere by adempiere.
the class WLocation method doGet.
/**
* Process the HTTP Get request - initial Start
* Needs to have parameters FormName and ColumnName
*
* @param request request
* @param response response
* @throws ServletException
* @throws IOException
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.fine("");
HttpSession sess = request.getSession();
WWindowStatus ws = WWindowStatus.get(request);
if (ws == null) {
MobileUtil.createTimeoutPage(request, response, this, null);
return;
}
// Get Mandatory Parameters
String columnName = MobileUtil.getParameter(request, "ColumnName");
log.info("ColumnName=" + columnName + " - " + ws.toString());
//
GridField mField = ws.curTab.getField(columnName);
log.config("ColumnName=" + columnName + ", MField=" + mField);
if (mField == null || columnName == null || columnName.equals("")) {
MobileUtil.createErrorPage(request, response, this, Msg.getMsg(ws.ctx, "ParameterMissing"));
return;
}
MLocation location = null;
Object value = mField.getValue();
if (value != null && value instanceof Integer)
location = new MLocation(ws.ctx, ((Integer) value).intValue(), null);
else
location = new MLocation(ws.ctx, 0, null);
//String targetBase = "parent.WWindow." + WWindow.FORM_NAME + "." + columnName;
String targetBase = "opener.WWindow." + WWindow.FORM_NAME + "." + columnName;
String action = request.getRequestURI();
// Create Document
MobileDoc doc = MobileDoc.createPopup(mField.getHeader());
boolean hasDependents = ws.curTab.hasDependants(columnName);
boolean hasCallout = mField.getCallout().length() > 0;
// Reset
button reset = new button();
// translate
reset.addElement("Reset");
String script = targetBase + "D.value='';" + targetBase + "F.value='';closePopup();";
if (hasDependents || hasCallout)
script += "startUpdate(" + targetBase + "F);";
reset.setOnClick(script);
//
div div = new div();
div.setClass("toolbar");
h1 header = new h1();
header.setID("pageTitle");
div.addElement(header);
a anchor = new a();
anchor.setID("backButton");
anchor.setClass("button");
div.addElement(anchor);
doc.getBody().addElement(fillForm(ws, action, location, targetBase, hasDependents || hasCallout)).addElement(reset).addElement(div);
//
// log.trace(log.l6_Database, doc.toString());
MobileUtil.createResponse(request, response, this, null, doc, true);
}
use of org.compiere.model.GridField in project adempiere by adempiere.
the class WAccountDialog method initAccount.
// jbInit
/**
* Dyanmic Init.
* When a row is selected, the editor values are set
* (editors do not change grid)
* @return true if initialized
*/
private boolean initAccount() {
m_AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Client_ID");
// Get AcctSchema Info
if (s_AcctSchema == null || s_AcctSchema.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
s_AcctSchema = new MAcctSchema(Env.getCtx(), m_C_AcctSchema_ID, null);
log.config(s_AcctSchema.toString() + ", #" + s_AcctSchema.getAcctSchemaElements().length);
Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", m_C_AcctSchema_ID);
// Model
// Maintain Account Combinations
int AD_Window_ID = 153;
GridWindowVO wVO = AEnv.getMWindowVO(m_WindowNo, AD_Window_ID, 0);
if (wVO == null)
return false;
m_mWindow = new GridWindow(wVO);
m_mTab = m_mWindow.getTab(0);
// Make sure is the tab is loaded - teo_sarca [ 1659124 ]
if (!m_mTab.isLoadComplete())
m_mWindow.initTab(0);
// ParameterPanel restrictions
m_mTab.getField("Alias").setDisplayLength(15);
m_mTab.getField("Combination").setDisplayLength(15);
// Grid restrictions
m_mTab.getField("AD_Client_ID").setDisplayed(false);
m_mTab.getField("C_AcctSchema_ID").setDisplayed(false);
m_mTab.getField("IsActive").setDisplayed(false);
m_mTab.getField("IsFullyQualified").setDisplayed(false);
// don't show fields not being displayed in this environment
for (int i = 0; i < m_mTab.getFieldCount(); i++) {
GridField field = m_mTab.getField(i);
if (// check context
!field.isDisplayed(true))
field.setDisplayed(false);
}
// GridController
m_adTabPanel.init(null, m_WindowNo, m_mTab, null);
// Prepare Parameter
parameterLayout.makeNoStrip();
parameterLayout.setOddRowSclass("even");
parameterLayout.setParent(parameterPanel);
parameterLayout.setStyle("background-color: transparent;");
m_rows = new Rows();
m_rows.setParent(parameterLayout);
int TabNo = 0;
// Alias
if (s_AcctSchema.isHasAlias()) {
GridField alias = m_mTab.getField("Alias");
f_Alias = WebEditorFactory.getEditor(alias, false);
addLine(alias, f_Alias, false);
}
// Alias
// Combination
GridField combination = m_mTab.getField("Combination");
f_Combination = WebEditorFactory.getEditor(combination, false);
addLine(combination, f_Combination, false);
m_newRow = true;
/**
* Create Fields in Element Order
*/
MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
for (int i = 0; i < elements.length; i++) {
MAcctSchemaElement ase = elements[i];
String type = ase.getElementType();
boolean isMandatory = ase.isMandatory();
//
if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) {
GridField field = m_mTab.getField("AD_Org_ID");
f_AD_Org_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_AD_Org_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) {
GridField field = m_mTab.getField("Account_ID");
f_Account_ID = WebEditorFactory.getEditor(field, false);
// ((VLookup)f_Account_ID).setWidth(400);
addLine(field, f_Account_ID, isMandatory);
f_Account_ID.addValueChangeListener(this);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) {
GridField field = m_mTab.getField("C_SubAcct_ID");
f_SubAcct_ID = WebEditorFactory.getEditor(field, false);
// ((VLookup)f_SubAcct_ID).setWidth(400);
addLine(field, f_SubAcct_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) {
GridField field = m_mTab.getField("M_Product_ID");
f_M_Product_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_M_Product_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) {
GridField field = m_mTab.getField("C_BPartner_ID");
f_C_BPartner_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_C_BPartner_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) {
GridField field = m_mTab.getField("C_Campaign_ID");
f_C_Campaign_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_C_Campaign_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) {
GridField field = m_mTab.getField("C_LocFrom_ID");
f_C_LocFrom_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_C_LocFrom_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) {
GridField field = m_mTab.getField("C_LocTo_ID");
f_C_LocTo_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_C_LocTo_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) {
GridField field = m_mTab.getField("C_Project_ID");
f_C_Project_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_C_Project_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) {
GridField field = m_mTab.getField("C_SalesRegion_ID");
f_C_SalesRegion_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_C_SalesRegion_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) {
GridField field = m_mTab.getField("AD_OrgTrx_ID");
f_AD_OrgTrx_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_AD_OrgTrx_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) {
GridField field = m_mTab.getField("C_Activity_ID");
f_C_Activity_ID = WebEditorFactory.getEditor(field, false);
addLine(field, f_C_Activity_ID, isMandatory);
} else // User1
if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1)) {
GridField field = m_mTab.getField("User1_ID");
f_User1_ID = WebEditorFactory.getEditor(field, false);
// Change the label from the default to the user defined name
//f_User1_ID.setLabel(ase.getName());
addLine(field, f_User1_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2)) {
GridField field = m_mTab.getField("User2_ID");
f_User2_ID = WebEditorFactory.getEditor(field, false);
// Change the label from the default to the user defined name
//f_User2_ID.setLabel(ase.getName());
addLine(field, f_User2_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList3)) {
GridField field = m_mTab.getField("User3_ID");
f_User3_ID = WebEditorFactory.getEditor(field, false);
// Change the label from the default to the user defined name
//f_User3_ID.setLabel(ase.getName());
addLine(field, f_User3_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList4)) {
GridField field = m_mTab.getField("User4_ID");
f_User4_ID = WebEditorFactory.getEditor(field, false);
// Change the label from the default to the user defined name
//f_User4_ID.setLabel(ase.getName());
addLine(field, f_User4_ID, isMandatory);
}
}
// Create Fields in Element Order
// Add description
m_newRow = true;
Row row = new Row();
f_Description.setStyle("font-decoration: italic;");
row.appendChild(f_Description);
row.setSpans("4");
row.setStyle("background-color: transparent;");
m_rows.appendChild(row);
// Finish
m_query = new MQuery();
m_query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
m_query.addRestriction("IsFullyQualified", MQuery.EQUAL, "Y");
if (m_mAccount.C_ValidCombination_ID == 0)
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
else {
MQuery query = new MQuery();
query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
query.addRestriction("C_ValidCombination_ID", MQuery.EQUAL, m_mAccount.C_ValidCombination_ID);
m_mTab.setQuery(query);
}
m_mTab.query(false);
m_adTabPanel.getGridTab().addDataStatusListener(this);
m_adTabPanel.activate(true);
if (!m_adTabPanel.isGridView())
m_adTabPanel.switchRowPresentation();
statusBar.setStatusLine(s_AcctSchema.toString());
statusBar.setStatusDB("?");
// Initial value
if (m_mAccount.C_ValidCombination_ID != 0)
m_mTab.navigate(0);
log.config("fini");
return true;
}
Aggregations