use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class WBrowserListItemRenderer method getCellComponent.
/**
* Generate the cell for the given <code>field</code>.
*
* @param table The table into which the cell will be placed.
* @param field The data field for which the cell is to be created.
* @param rowIndex The row in which the cell is to be placed.
* @param columnIndex The column in which the cell is to be placed.
* @return The list cell component.
*/
private Listcell getCellComponent(WBrowserTable table, Object field, int rowIndex, int columnIndex) {
ListCell listcell = new ListCell();
if (table == null)
return listcell;
BrowserRow browserRows = table.getData();
// BR [ 257 ]
MBrowseField browseField = browserRows.getBrowserField(browserRows.getTableIndex(columnIndex));
if (browseField == null)
return listcell;
//
GridField gridField = table.getGridFieldAt(rowIndex, columnIndex);
boolean isColumnVisible = true;
if (!m_tableColumns.isEmpty())
isColumnVisible = isColumnVisible(getColumn(columnIndex));
// are assigned to Table Columns
if (isColumnVisible && gridField != null) {
// Set Read Only
boolean isCellEditable = table.isCellEditable(rowIndex, columnIndex);
//
if (DisplayType.YesNo == browseField.getAD_Reference_ID()) {
// BR [ 347 ]
boolean selected = false;
if (field != null) {
selected = Boolean.valueOf(field.toString());
}
listcell.setValue(selected);
if (columnIndex == 0)
table.setCheckmark(false);
Checkbox checkbox = new Checkbox();
checkbox.setChecked(selected);
if (isCellEditable) {
checkbox.setEnabled(true);
checkbox.addEventListener(Events.ON_CHECK, this);
} else {
checkbox.setEnabled(false);
}
listcell.appendChild(checkbox);
ZkCssHelper.appendStyle(listcell, "text-align:center");
} else if ((DisplayType.isNumeric(browseField.getAD_Reference_ID())) && !browseField.isKey()) {
DecimalFormat format = field instanceof BigDecimal ? DisplayType.getNumberFormat(DisplayType.Amount, AEnv.getLanguage(Env.getCtx())) : DisplayType.getNumberFormat(DisplayType.Integer, AEnv.getLanguage(Env.getCtx()));
// set cell value to allow sorting
listcell.setValue((field == null ? "0" : field.toString()));
if (isCellEditable) {
NumberBox numberbox = new NumberBox(false);
numberbox.setFormat(format);
numberbox.setValue(field);
numberbox.setWidth("100px");
numberbox.setStyle("text-align:right; " + listcell.getStyle());
numberbox.addEventListener(Events.ON_CHANGE, this);
listcell.appendChild(numberbox);
numberbox.setEnabled(true);
} else {
listcell.setLabel(format.format(((Number) (field == null ? Env.ZERO : field)).doubleValue()));
ZkCssHelper.appendStyle(listcell, "text-align:right");
}
} else if (DisplayType.Date == browseField.getAD_Reference_ID() || DisplayType.DateTime == browseField.getAD_Reference_ID()) {
if (field != null) {
SimpleDateFormat dateFormat = DisplayType.getDateFormat(browseField.getAD_Reference_ID(), AEnv.getLanguage(Env.getCtx()));
// BR [ 270 ]
listcell.setValue(dateFormat.format(field));
if (isCellEditable) {
Datebox datebox = new Datebox();
datebox.setFormat(dateFormat.toPattern());
//
datebox.setValue((Date) field);
datebox.addEventListener(Events.ON_CHANGE, this);
listcell.appendChild(datebox);
} else {
listcell.setLabel(dateFormat.format(field));
}
}
} else // Add support to other String
if (browseField.getAD_Reference_ID() == DisplayType.String || browseField.getAD_Reference_ID() == DisplayType.PrinterName || browseField.getAD_Reference_ID() == DisplayType.Text || browseField.getAD_Reference_ID() == DisplayType.TextLong) {
listcell.setValue((field == null ? "" : field.toString()));
if (isCellEditable) {
Textbox textbox = new Textbox();
textbox.setValue((field == null ? "" : field.toString()));
textbox.addEventListener(Events.ON_CHANGE, this);
listcell.appendChild(textbox);
} else {
listcell.setLabel((field == null ? "" : field.toString()));
}
} else if (field instanceof org.adempiere.webui.component.Combobox) {
listcell.setValue(field);
if (isCellEditable) {
Combobox combobox = (Combobox) field;
combobox.addEventListener(Events.ON_CHANGE, this);
listcell.appendChild(combobox);
} else {
Combobox combobox = (Combobox) field;
if (combobox != null && combobox.getItemCount() > 0) {
if (combobox.getSelectedIndex() >= 0)
listcell.setLabel((String) combobox.getItemAtIndex(combobox.getSelectedIndex()).getLabel());
else
listcell.setLabel("");
}
}
} else if (field instanceof org.adempiere.webui.component.Button) {
listcell.setValue(field);
if (isCellEditable) {
Button button = (Button) field;
button.addEventListener(Events.ON_CLICK, this);
listcell.appendChild(button);
} else {
Button button = (Button) field;
if (button != null) {
listcell.setLabel("");
}
}
} else // if ID column make it invisible
if (field instanceof IDColumn && browseField.isKey()) {
IDColumn id = (IDColumn) field;
if (id != null && id.getRecord_ID() != null) {
listcell.setValue(id.getRecord_ID());
if (!table.isCheckmark()) {
table.setCheckmark(true);
table.removeEventListener(Events.ON_SELECT, this);
table.addEventListener(Events.ON_SELECT, this);
}
}
} else if ((DisplayType.isLookup(browseField.getAD_Reference_ID()) || DisplayType.ID == browseField.getAD_Reference_ID()) && !browseField.isKey()) {
if (isCellEditable) {
WEditor editor = WebEditorFactory.getEditor(gridField, true);
editor.addValueChangeListener(this);
editor.dynamicDisplay();
editor.setReadWrite(true);
editor.fillHorizontal();
gridField.addPropertyChangeListener(editor);
listcell.appendChild(editor.getComponent());
} else {
Component component;
if (gridField.getDisplayType() == DisplayType.YesNo) {
component = createReadonlyCheckbox(field);
} else {
String text = getDisplayText(field, gridField);
Label label = new Label();
setLabelText(text, label);
component = label;
}
listcell.appendChild(component);
}
} else {
listcell.setLabel((field == null ? null : field.toString()));
listcell.setValue((field == null ? null : field.toString()));
}
} else {
listcell.setLabel("");
listcell.setValue("");
}
listcell.setAttribute("zk_component_ID", "ListItem_Cell_" + rowIndex + "_" + columnIndex);
return listcell;
}
use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class WBrowser method getPanelParameters.
@Override
public LinkedHashMap<String, GridField> getPanelParameters() {
LinkedHashMap<String, GridField> m_List = new LinkedHashMap<String, GridField>();
for (Entry<String, Object> entry : searchGrid.getParameters().entrySet()) {
WEditor editor = (WEditor) entry.getValue();
// BR [ 251 ]
if (!editor.isVisible() || editor.getGridField().isInfoOnly())
continue;
//
GridField field = editor.getGridField();
m_List.put(entry.getKey(), field);
}
// Default Return
return m_List;
}
use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class WBrowserSearch method setComponentVisibility.
@Override
public void setComponentVisibility(int index, Boolean visible, Boolean isRange) {
WEditor editor = (WEditor) getEditor(index);
WEditor editorTo = (WEditor) getEditorTo(index);
if (visible) {
if (!editor.isVisible()) {
// Also makes the label visible
editor.setVisible(true);
if (isRange && editorTo != null) {
m_separators.get(index).setVisible(true);
editorTo.setVisible(true);
}
}
} else if (editor.isVisible()) {
// Also hides the label
editor.setVisible(false);
if (isRange && editorTo != null) {
m_separators.get(index).setText("");
editorTo.setVisible(false);
}
}
}
use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class WBrowserListItemRenderer method valueChange.
/**
* Editor Listener
* @param evt Event
*/
public void valueChange(ValueChangeEvent evt) {
if (evt.getSource() instanceof WEditor) {
GridField changedField = ((WEditor) evt.getSource()).getGridField();
if (changedField != null) {
//processDependencies(changedField);
// future processCallout (changedField);
}
}
String columnName = "";
if (evt.getSource() instanceof WEditor) {
WEditor wEditor = (WEditor) evt.getSource();
columnName = wEditor.getGridField().getVO().ColumnNameAlias;
}
//processNewValue(evt.getNewValue(), columnName);
}
use of org.adempiere.webui.editor.WEditor in project adempiere by adempiere.
the class FindWindow method cmd_ok_Simple.
// getTargetMField
/**
* Simple OK Button pressed
**/
private void cmd_ok_Simple() {
// Create Query String
m_query = new MQuery(m_tableName);
if (hasValue && !fieldValue.getText().equals("%") && fieldValue.getText().length() != 0) {
String value = fieldValue.getText().toUpperCase();
if (!value.endsWith("%"))
value += "%";
m_query.addRestriction("UPPER(Value)", MQuery.LIKE, value, lblValue.getValue(), value);
}
//
if (hasDocNo && !fieldDocumentNo.getText().equals("%") && fieldDocumentNo.getText().length() != 0) {
String value = fieldDocumentNo.getText().toUpperCase();
if (!value.endsWith("%"))
value += "%";
m_query.addRestriction("UPPER(DocumentNo)", MQuery.LIKE, value, lblDocumentNo.getValue(), value);
}
//
if ((hasName) && !fieldName.getText().equals("%") && fieldName.getText().length() != 0) {
String value = fieldName.getText().toUpperCase();
if (!value.endsWith("%"))
value += "%";
m_query.addRestriction("UPPER(Name)", MQuery.LIKE, value, lblName.getValue(), value);
}
//
if (hasDescription && !fieldDescription.getText().equals("%") && fieldDescription.getText().length() != 0) {
String value = fieldDescription.getText().toUpperCase();
if (!value.endsWith("%"))
value += "%";
m_query.addRestriction("UPPER(Description)", MQuery.LIKE, value, lblDescription.getValue(), value);
}
// Special Editors
for (int i = 0; i < m_sEditors.size(); i++) {
WEditor wed = (WEditor) m_sEditors.get(i);
Object value = wed.getValue();
Object modifiedvalue = null;
String ColumnSQL = null;
String ColumnName = wed.getColumnName();
GridField field = getTargetMField(ColumnName);
if (value != null && value.toString().length() > 0) {
log.fine(ColumnName + "=" + value);
// globalqss - Carlos Ruiz - 20060711
// fix a bug with virtualColumn + isSelectionColumn not yielding results
field = getTargetMField(ColumnName);
// add encryption here if the field is encrypted.
if (field.isEncryptedColumn()) {
value = SecureEngine.encrypt(value);
}
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
ColumnSQL = field.getColumnSQL(false);
// Be more permissive for String columns
if (isSearchLike(field)) {
String valueStr = value.toString().toUpperCase();
if (!valueStr.endsWith("%"))
valueStr += "%";
//
ColumnSQL = "UPPER(" + ColumnSQL + ")";
modifiedvalue = valueStr;
} else
modifiedvalue = value;
//
if (modifiedvalue.toString().indexOf('%') != -1 && !field.isRangeLookup())
m_query.addRestriction(ColumnSQL, MQuery.LIKE, modifiedvalue, ColumnName, wed.getDisplay());
else if (isProductCategoryField && value instanceof Integer)
m_query.addRestriction(getSubCategoryWhereClause(((Integer) value).intValue()));
else if (//20121115
!field.isRangeLookup())
m_query.addRestriction(ColumnSQL, MQuery.EQUAL, value, ColumnName, wed.getDisplay());
/*
if (value.toString().indexOf('%') != -1)
m_query.addRestriction(ColumnName, MQuery.LIKE, value, ColumnName, ved.getDisplay());
else
m_query.addRestriction(ColumnName, MQuery.EQUAL, value, ColumnName, ved.getDisplay());
*/
// end globalqss patch
}
if (field.isRangeLookup()) {
WEditor toRangeEditor = (WEditor) m_sEditors2.get(i);
Object value2 = null;
Object parsedValue = null;
Object parsedValue2 = null;
String infoDisplay_to = null;
String infoDisplay = null;
if (toRangeEditor != null)
value2 = toRangeEditor.getValue();
if ((value != null && !value.toString().isEmpty()) && (value2 != null && !value2.toString().isEmpty()) && value2.toString().length() > 0) {
ColumnName = toRangeEditor.getColumnName();
log.fine(ColumnName + "=" + value2);
field = getTargetMField(ColumnName);
infoDisplay = value.toString();
parsedValue = parseValue(field, value);
parsedValue2 = parseValue(field, value2);
infoDisplay_to = value2.toString();
if (parsedValue2 == null)
continue;
m_query.addRangeRestriction(ColumnSQL, parsedValue, parsedValue2, ColumnSQL, infoDisplay, infoDisplay_to);
} else // then get all the records after the First value
if (value != null && !value.toString().isEmpty() && (value2 == null || value2.toString().isEmpty())) {
ColumnName = wed.getColumnName();
m_query.addRestriction(ColumnSQL, MQuery.GREATER_EQUAL, value, ColumnName, wed.getDisplay());
} else // then get all the records before the second value
if ((value == null || value.toString().isEmpty()) && value2 != null && !value2.toString().isEmpty()) {
ColumnName = toRangeEditor.getColumnName();
field = getTargetMField(ColumnName);
ColumnSQL = field.getColumnSQL(false);
m_query.addRestriction(ColumnSQL, MQuery.LESS_EQUAL, value2, ColumnName, toRangeEditor.getDisplay());
}
}
}
// editors
// teo_sarca [ 1708717 ]
m_isCancel = false;
// Test for no records
if (getNoOfRecords(m_query, true) != 0)
dispose();
}
Aggregations