* minor numberbox layout enhancement
* [2308105] WListbox should always re-render when row is select/deselect. - previous patch break InfoPanel * Editable grid view
This commit is contained in:
parent
02378c140d
commit
23f4b5e5ae
|
@ -27,9 +27,11 @@ import org.adempiere.webui.LayoutUtils;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.GridTable;
|
import org.compiere.model.GridTable;
|
||||||
|
import org.zkoss.zk.au.out.AuEcho;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
import org.zkoss.zk.ui.util.Clients;
|
||||||
import org.zkoss.zkex.zul.Borderlayout;
|
import org.zkoss.zkex.zul.Borderlayout;
|
||||||
import org.zkoss.zkex.zul.Center;
|
import org.zkoss.zkex.zul.Center;
|
||||||
import org.zkoss.zkex.zul.South;
|
import org.zkoss.zkex.zul.South;
|
||||||
|
@ -68,6 +70,8 @@ public class GridPanel extends Borderlayout implements EventListener
|
||||||
private GridTableListModel listModel;
|
private GridTableListModel listModel;
|
||||||
|
|
||||||
private Paging paging;
|
private Paging paging;
|
||||||
|
|
||||||
|
private GridTabListItemRenderer renderer;
|
||||||
|
|
||||||
public GridPanel()
|
public GridPanel()
|
||||||
{
|
{
|
||||||
|
@ -136,11 +140,19 @@ public class GridPanel extends Borderlayout implements EventListener
|
||||||
}
|
}
|
||||||
if (paging.getActivePage() != pgNo)
|
if (paging.getActivePage() != pgNo)
|
||||||
paging.setActivePage(pgNo);
|
paging.setActivePage(pgNo);
|
||||||
if (listbox.getSelectedIndex() != pgIndex)
|
if (listbox.getSelectedIndex() != pgIndex) {
|
||||||
listbox.setSelectedIndex(pgIndex);
|
renderer.stopEditing(false);
|
||||||
|
listModel.updateComponent(listbox.getSelectedIndex());
|
||||||
|
listModel.updateComponent(pgIndex);
|
||||||
|
listbox.setSelectedIndex(pgIndex);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (listbox.getSelectedIndex() != rowIndex)
|
if (listbox.getSelectedIndex() != rowIndex) {
|
||||||
listbox.setSelectedIndex(rowIndex);
|
renderer.stopEditing(false);
|
||||||
|
listModel.updateComponent(listbox.getSelectedIndex());
|
||||||
|
listModel.updateComponent(rowIndex);
|
||||||
|
listbox.setSelectedIndex(rowIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +219,8 @@ public class GridPanel extends Borderlayout implements EventListener
|
||||||
center.appendChild(listbox);
|
center.appendChild(listbox);
|
||||||
this.appendChild(center);
|
this.appendChild(center);
|
||||||
|
|
||||||
if (pageSize > 0) {
|
if (pageSize > 0)
|
||||||
|
{
|
||||||
paging = new Paging();
|
paging = new Paging();
|
||||||
paging.setPageSize(pageSize);
|
paging.setPageSize(pageSize);
|
||||||
paging.setTotalSize(tableModel.getRowCount());
|
paging.setTotalSize(tableModel.getRowCount());
|
||||||
|
@ -216,13 +229,25 @@ public class GridPanel extends Borderlayout implements EventListener
|
||||||
south.appendChild(paging);
|
south.appendChild(paging);
|
||||||
this.appendChild(south);
|
this.appendChild(south);
|
||||||
paging.addEventListener(ZulEvents.ON_PAGING, this);
|
paging.addEventListener(ZulEvents.ON_PAGING, this);
|
||||||
}
|
//workaround for layout problem
|
||||||
|
this.setVisible(false);
|
||||||
|
Clients.response(new AuEcho(this, "postRender", null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postRender()
|
||||||
|
{
|
||||||
|
this.setVisible(true);
|
||||||
|
this.getParent().invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateModel() {
|
private void updateModel() {
|
||||||
listModel = new GridTableListModel((GridTable)tableModel, windowNo);
|
listModel = new GridTableListModel((GridTable)tableModel, windowNo);
|
||||||
listModel.setPageSize(pageSize);
|
listModel.setPageSize(pageSize);
|
||||||
listbox.setItemRenderer(listModel);
|
if (renderer != null)
|
||||||
|
renderer.stopEditing(false);
|
||||||
|
renderer = new GridTabListItemRenderer(gridTab, windowNo);
|
||||||
|
listbox.setItemRenderer(renderer);
|
||||||
listbox.setModel(listModel);
|
listbox.setModel(listModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +264,8 @@ public class GridPanel extends Borderlayout implements EventListener
|
||||||
return;
|
return;
|
||||||
else if (event.getTarget() == listbox)
|
else if (event.getTarget() == listbox)
|
||||||
{
|
{
|
||||||
updateModelIndex();
|
int index = listbox.getSelectedIndex();
|
||||||
|
onSelectedRowChange(index);
|
||||||
}
|
}
|
||||||
else if (event.getTarget() == paging)
|
else if (event.getTarget() == paging)
|
||||||
{
|
{
|
||||||
|
@ -249,20 +275,34 @@ public class GridPanel extends Borderlayout implements EventListener
|
||||||
listbox.clearSelection();
|
listbox.clearSelection();
|
||||||
listModel.setPage(pgNo);
|
listModel.setPage(pgNo);
|
||||||
listbox.setSelectedIndex(0);
|
listbox.setSelectedIndex(0);
|
||||||
updateModelIndex();
|
onSelectedRowChange(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateModelIndex() {
|
private void onSelectedRowChange(int index) {
|
||||||
|
if (updateModelIndex()) {
|
||||||
|
listModel.updateComponent(index);
|
||||||
|
listbox.setSelectedIndex(index);
|
||||||
|
} else if (!renderer.isInitialize()) {
|
||||||
|
listModel.updateComponent(index);
|
||||||
|
listbox.setSelectedIndex(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean updateModelIndex() {
|
||||||
int rowIndex = listbox.getSelectedIndex();
|
int rowIndex = listbox.getSelectedIndex();
|
||||||
if (pageSize > 0) {
|
if (pageSize > 0) {
|
||||||
int start = listModel.getPage() * listModel.getPageSize();
|
int start = listModel.getPage() * listModel.getPageSize();
|
||||||
rowIndex = start + rowIndex;
|
rowIndex = start + rowIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gridTab.getCurrentRow() != rowIndex)
|
if (gridTab.getCurrentRow() != rowIndex) {
|
||||||
|
renderer.stopEditing(true);
|
||||||
gridTab.navigate(rowIndex);
|
gridTab.navigate(rowIndex);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Listbox getListbox() {
|
public Listbox getListbox() {
|
||||||
|
|
|
@ -0,0 +1,258 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2008 Low Heng Sin *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.webui.component;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.adempiere.webui.editor.WEditor;
|
||||||
|
import org.adempiere.webui.editor.WEditorPopupMenu;
|
||||||
|
import org.adempiere.webui.editor.WebEditorFactory;
|
||||||
|
import org.adempiere.webui.event.ContextMenuListener;
|
||||||
|
import org.adempiere.webui.util.GridTabDataBinder;
|
||||||
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.MAccountLookup;
|
||||||
|
import org.compiere.model.MLookup;
|
||||||
|
import org.compiere.model.MLookupFactory;
|
||||||
|
import org.compiere.util.DisplayType;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.NamePair;
|
||||||
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
import org.zkoss.zul.Listbox;
|
||||||
|
import org.zkoss.zul.Listcell;
|
||||||
|
import org.zkoss.zul.Listitem;
|
||||||
|
import org.zkoss.zul.ListitemRenderer;
|
||||||
|
import org.zkoss.zul.ListitemRendererExt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ListItem renderer for GridTab list box.
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GridTabListItemRenderer implements ListitemRenderer, ListitemRendererExt {
|
||||||
|
|
||||||
|
private GridTab gridTab;
|
||||||
|
private int windowNo;
|
||||||
|
private GridTabDataBinder dataBinder;
|
||||||
|
private Map<GridField, WEditor> editors = new HashMap<GridField, WEditor>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param gridTab
|
||||||
|
* @param windowNo
|
||||||
|
*/
|
||||||
|
public GridTabListItemRenderer(GridTab gridTab, int windowNo) {
|
||||||
|
this.gridTab = gridTab;
|
||||||
|
this.windowNo = windowNo;
|
||||||
|
this.dataBinder = new GridTabDataBinder(gridTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param listitem
|
||||||
|
* @param data
|
||||||
|
* @see ListitemRenderer#render(Listitem, Object)
|
||||||
|
*/
|
||||||
|
public void render(Listitem listitem, Object data) throws Exception {
|
||||||
|
Object[] values = (Object[])data;
|
||||||
|
int columnCount = gridTab.getTableModel().getColumnCount();
|
||||||
|
GridField[] gridField = gridTab.getFields();
|
||||||
|
for (int i = 0; i < columnCount; i++) {
|
||||||
|
if (!gridField[i].isDisplayed()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (editors.get(gridField[i]) == null)
|
||||||
|
editors.put(gridField[i], WebEditorFactory.getEditor(gridField[i], true));
|
||||||
|
|
||||||
|
int rowIndex = listitem.getIndex();
|
||||||
|
Listcell cell = null;
|
||||||
|
if (rowIndex == gridTab.getCurrentRow() && gridField[i].isEditable(true)) {
|
||||||
|
cell = getEditorCell(gridField[i], values[i], i);
|
||||||
|
cell.setParent(listitem);
|
||||||
|
} else {
|
||||||
|
if (gridField[i].getDisplayType() == DisplayType.YesNo) {
|
||||||
|
cell = new Listcell("", null);
|
||||||
|
cell.setParent(listitem);
|
||||||
|
cell.setStyle("text-align:center");
|
||||||
|
createReadonlyCheckbox(values[i], cell);
|
||||||
|
} else {
|
||||||
|
cell = new Listcell(getDisplayText(values[i], i), null);
|
||||||
|
cell.setParent(listitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CellListener listener = new CellListener((Listbox) listitem.getParent());
|
||||||
|
cell.addEventListener(Events.ON_DOUBLE_CLICK, listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createReadonlyCheckbox(Object value, Listcell cell) {
|
||||||
|
Checkbox checkBox = new Checkbox();
|
||||||
|
if (value != null && "true".equalsIgnoreCase(value.toString()))
|
||||||
|
checkBox.setChecked(true);
|
||||||
|
else
|
||||||
|
checkBox.setChecked(false);
|
||||||
|
checkBox.setDisabled(true);
|
||||||
|
checkBox.setParent(cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Listcell getEditorCell(GridField gridField, Object object, int i) {
|
||||||
|
Listcell cell = new Listcell("", null);
|
||||||
|
WEditor editor = editors.get(gridField);
|
||||||
|
if (editor != null) {
|
||||||
|
editor.addValueChangeListener(dataBinder);
|
||||||
|
cell.appendChild(editor.getComponent());
|
||||||
|
gridField.addPropertyChangeListener(editor);
|
||||||
|
editor.setValue(gridField.getValue());
|
||||||
|
WEditorPopupMenu popupMenu = editor.getPopupMenu();
|
||||||
|
|
||||||
|
if (popupMenu != null)
|
||||||
|
{
|
||||||
|
popupMenu.addMenuListener((ContextMenuListener)editor);
|
||||||
|
cell.appendChild(popupMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detach all editor and optionally set the current value of the editor as cell label.
|
||||||
|
* @param updateCellLabel
|
||||||
|
*/
|
||||||
|
public void stopEditing(boolean updateCellLabel) {
|
||||||
|
for (Entry<GridField, WEditor> entry : editors.entrySet()) {
|
||||||
|
if (entry.getValue().getComponent().getParent() != null) {
|
||||||
|
if (updateCellLabel) {
|
||||||
|
Listcell cell = (Listcell) entry.getValue().getComponent().getParent();
|
||||||
|
if (entry.getKey().getDisplayType() == DisplayType.YesNo) {
|
||||||
|
cell.setLabel("");
|
||||||
|
createReadonlyCheckbox(entry.getValue().getValue(), cell);
|
||||||
|
} else {
|
||||||
|
cell.setLabel(getDisplayText(entry.getValue().getValue(), getColumnIndex(entry.getKey())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry.getValue().getComponent().detach();
|
||||||
|
entry.getKey().removePropertyChangeListener(entry.getValue());
|
||||||
|
entry.getValue().removeValuechangeListener(dataBinder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getColumnIndex(GridField field) {
|
||||||
|
GridField[] fields = gridTab.getFields();
|
||||||
|
for(int i = 0; i < fields.length; i++) {
|
||||||
|
if (fields[i] == field)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ListitemRendererExt#getControls()
|
||||||
|
*/
|
||||||
|
public int getControls() {
|
||||||
|
return DETACH_ON_RENDER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param item
|
||||||
|
* @see ListitemRendererExt#newListcell(Listitem)
|
||||||
|
*/
|
||||||
|
public Listcell newListcell(Listitem item) {
|
||||||
|
ListCell listCell = new ListCell();
|
||||||
|
listCell.applyProperties();
|
||||||
|
listCell.setParent(item);
|
||||||
|
return listCell;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param listbox
|
||||||
|
* @see ListitemRendererExt#newListitem(Listbox)
|
||||||
|
*/
|
||||||
|
public Listitem newListitem(Listbox listbox) {
|
||||||
|
ListItem item = new ListItem();
|
||||||
|
item.applyProperties();
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDisplayText(Object value, int columnIndex)
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
GridField[] gridField = gridTab.getFields();
|
||||||
|
if (gridTab.getTableModel().getColumnClass(columnIndex).equals(Integer.class))
|
||||||
|
{
|
||||||
|
if (gridField[columnIndex].isLookup())
|
||||||
|
{
|
||||||
|
NamePair namepair = null;
|
||||||
|
if (gridField[columnIndex].getDisplayType() == DisplayType.Account)
|
||||||
|
{
|
||||||
|
MAccountLookup lookup = new MAccountLookup(Env.getCtx(), windowNo);
|
||||||
|
namepair = lookup.get(value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MLookup lookup = MLookupFactory.get(
|
||||||
|
Env.getCtx(), windowNo, 0, gridField[columnIndex].getAD_Column_ID(),
|
||||||
|
gridField[columnIndex].getDisplayType());
|
||||||
|
|
||||||
|
namepair = lookup.get(value);
|
||||||
|
}
|
||||||
|
if (namepair != null)
|
||||||
|
return namepair.getName();
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
else if (gridTab.getTableModel().getColumnClass(columnIndex).equals(Timestamp.class))
|
||||||
|
{
|
||||||
|
SimpleDateFormat dateFormat = DisplayType.getDateFormat(DisplayType.Date);
|
||||||
|
return dateFormat.format((Timestamp)value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
class CellListener implements EventListener {
|
||||||
|
|
||||||
|
private Listbox _listbox;
|
||||||
|
|
||||||
|
public CellListener(Listbox listbox) {
|
||||||
|
_listbox = listbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
if (Events.ON_DOUBLE_CLICK.equals(event.getName())) {
|
||||||
|
Event evt = new Event(Events.ON_DOUBLE_CLICK, _listbox);
|
||||||
|
Events.sendEvent(_listbox, evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is renderer initialize
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean isInitialize() {
|
||||||
|
return !editors.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,33 +12,17 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.adempiere.webui.component;
|
package org.adempiere.webui.component;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
import org.compiere.model.DataStatusEvent;
|
import org.compiere.model.DataStatusEvent;
|
||||||
import org.compiere.model.DataStatusListener;
|
import org.compiere.model.DataStatusListener;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.GridTable;
|
import org.compiere.model.GridTable;
|
||||||
import org.compiere.model.MAccountLookup;
|
|
||||||
import org.compiere.model.MLookup;
|
|
||||||
import org.compiere.model.MLookupFactory;
|
|
||||||
import org.compiere.util.DisplayType;
|
|
||||||
import org.compiere.util.Env;
|
|
||||||
import org.compiere.util.NamePair;
|
|
||||||
import org.zkoss.zk.ui.Executions;
|
import org.zkoss.zk.ui.Executions;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
|
||||||
import org.zkoss.zk.ui.event.Events;
|
|
||||||
import org.zkoss.zul.AbstractListModel;
|
import org.zkoss.zul.AbstractListModel;
|
||||||
import org.zkoss.zul.ListModel;
|
import org.zkoss.zul.ListModel;
|
||||||
import org.zkoss.zul.ListModelExt;
|
import org.zkoss.zul.ListModelExt;
|
||||||
import org.zkoss.zul.Listbox;
|
|
||||||
import org.zkoss.zul.Listcell;
|
|
||||||
import org.zkoss.zul.Listitem;
|
|
||||||
import org.zkoss.zul.ListitemComparator;
|
import org.zkoss.zul.ListitemComparator;
|
||||||
import org.zkoss.zul.ListitemRenderer;
|
|
||||||
import org.zkoss.zul.ListitemRendererExt;
|
|
||||||
import org.zkoss.zul.event.ListDataEvent;
|
import org.zkoss.zul.event.ListDataEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,8 +30,7 @@ import org.zkoss.zul.event.ListDataEvent;
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GridTableListModel extends AbstractListModel implements ListitemRenderer,
|
public class GridTableListModel extends AbstractListModel implements DataStatusListener, ListModelExt {
|
||||||
ListitemRendererExt, DataStatusListener, ListModelExt {
|
|
||||||
|
|
||||||
private GridTable tableModel;
|
private GridTable tableModel;
|
||||||
private GridField[] gridField;
|
private GridField[] gridField;
|
||||||
|
@ -147,125 +130,7 @@ ListitemRendererExt, DataStatusListener, ListModelExt {
|
||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param listitem
|
|
||||||
* @param data
|
|
||||||
* @see ListitemRenderer#render(Listitem, Object)
|
|
||||||
*/
|
|
||||||
public void render(Listitem listitem, Object data) throws Exception {
|
|
||||||
Object[] values = (Object[])data;
|
|
||||||
int columnCount = tableModel.getColumnCount();
|
|
||||||
for (int i = 0; i < columnCount; i++) {
|
|
||||||
if (!gridField[i].isDisplayed()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Listcell cell = null;
|
|
||||||
if (gridField[i].getDisplayType() == DisplayType.YesNo) {
|
|
||||||
cell = new Listcell("", null);
|
|
||||||
cell.setParent(listitem);
|
|
||||||
cell.setStyle("text-align:center");
|
|
||||||
Checkbox checkBox = new Checkbox();
|
|
||||||
if (values[i] != null && "true".equalsIgnoreCase(values[i].toString()))
|
|
||||||
checkBox.setChecked(true);
|
|
||||||
else
|
|
||||||
checkBox.setChecked(false);
|
|
||||||
checkBox.setDisabled(true);
|
|
||||||
checkBox.setParent(cell);
|
|
||||||
} else {
|
|
||||||
cell = new Listcell(getCell(values[i], i), null);
|
|
||||||
cell.setParent(listitem);
|
|
||||||
}
|
|
||||||
CellListener listener = new CellListener((Listbox) listitem.getParent());
|
|
||||||
cell.addEventListener(Events.ON_DOUBLE_CLICK, listener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CellListener implements EventListener {
|
|
||||||
|
|
||||||
private Listbox _listbox;
|
|
||||||
|
|
||||||
public CellListener(Listbox listbox) {
|
|
||||||
_listbox = listbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEvent(Event event) throws Exception {
|
|
||||||
if (Events.ON_DOUBLE_CLICK.equals(event.getName())) {
|
|
||||||
Event evt = new Event(Events.ON_DOUBLE_CLICK, _listbox);
|
|
||||||
Events.sendEvent(_listbox, evt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getCell(Object obj, int columnIndex)
|
|
||||||
{
|
|
||||||
if (obj == null)
|
|
||||||
return "";
|
|
||||||
|
|
||||||
if (tableModel.getColumnClass(columnIndex).equals(Integer.class))
|
|
||||||
{
|
|
||||||
if (gridField[columnIndex].isLookup())
|
|
||||||
{
|
|
||||||
NamePair namepair = null;
|
|
||||||
if (gridField[columnIndex].getDisplayType() == DisplayType.Account)
|
|
||||||
{
|
|
||||||
MAccountLookup lookup = new MAccountLookup(Env.getCtx(), windowNo);
|
|
||||||
namepair = lookup.get(obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MLookup lookup = MLookupFactory.get(
|
|
||||||
Env.getCtx(), windowNo, 0, gridField[columnIndex].getAD_Column_ID(),
|
|
||||||
gridField[columnIndex].getDisplayType());
|
|
||||||
|
|
||||||
namepair = lookup.get(obj);
|
|
||||||
}
|
|
||||||
if (namepair != null)
|
|
||||||
return namepair.getName();
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return obj.toString();
|
|
||||||
}
|
|
||||||
else if (tableModel.getColumnClass(columnIndex).equals(Timestamp.class))
|
|
||||||
{
|
|
||||||
SimpleDateFormat dateFormat = DisplayType.getDateFormat(DisplayType.Date);
|
|
||||||
return dateFormat.format((Timestamp)obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return obj.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ListitemRendererExt#getControls()
|
|
||||||
*/
|
|
||||||
public int getControls() {
|
|
||||||
return DETACH_ON_RENDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param item
|
|
||||||
* @see ListitemRendererExt#newListcell(Listitem)
|
|
||||||
*/
|
|
||||||
public Listcell newListcell(Listitem item) {
|
|
||||||
ListCell listCell = new ListCell();
|
|
||||||
listCell.applyProperties();
|
|
||||||
listCell.setParent(item);
|
|
||||||
return listCell;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param listbox
|
|
||||||
* @see ListitemRendererExt#newListitem(Listbox)
|
|
||||||
*/
|
|
||||||
public Listitem newListitem(Listbox listbox) {
|
|
||||||
ListItem item = new ListItem();
|
|
||||||
item.applyProperties();
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param e
|
* @param e
|
||||||
* @see DataStatusListener#dataStatusChanged(DataStatusEvent)
|
* @see DataStatusListener#dataStatusChanged(DataStatusEvent)
|
||||||
|
@ -276,6 +141,26 @@ ListitemRendererExt, DataStatusListener, ListModelExt {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request components that attached to this model to re-render a row.
|
||||||
|
* @param row
|
||||||
|
*/
|
||||||
|
public void updateComponent(int row) {
|
||||||
|
updateComponent(row, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request components that attached to this model to re-render a range of row.
|
||||||
|
* @param fromRow
|
||||||
|
* @param toRow
|
||||||
|
*/
|
||||||
|
public void updateComponent(int fromRow, int toRow) {
|
||||||
|
//must run from the UI thread
|
||||||
|
if (Executions.getCurrent() != null) {
|
||||||
|
fireEvent(ListDataEvent.CONTENTS_CHANGED, fromRow, toRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param cmpr
|
* @param cmpr
|
||||||
|
|
|
@ -27,8 +27,10 @@ import java.util.Vector;
|
||||||
|
|
||||||
import org.adempiere.webui.event.WTableModelEvent;
|
import org.adempiere.webui.event.WTableModelEvent;
|
||||||
import org.adempiere.webui.event.WTableModelListener;
|
import org.adempiere.webui.event.WTableModelListener;
|
||||||
|
import org.zkoss.zk.ui.Executions;
|
||||||
import org.zkoss.zul.ListModelExt;
|
import org.zkoss.zul.ListModelExt;
|
||||||
import org.zkoss.zul.ListModelList;
|
import org.zkoss.zul.ListModelList;
|
||||||
|
import org.zkoss.zul.event.ListDataEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a ListModel to be used with Listbox.
|
* This is a ListModel to be used with Listbox.
|
||||||
|
@ -362,4 +364,24 @@ public class ListModelTable extends ListModelList implements ListModelExt
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return getSize();
|
return getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request components that attached to this model to re-render a row.
|
||||||
|
* @param row
|
||||||
|
*/
|
||||||
|
public void updateComponent(int row) {
|
||||||
|
updateComponent(row, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request components that attached to this model to re-render a range of row.
|
||||||
|
* @param fromRow
|
||||||
|
* @param toRow
|
||||||
|
*/
|
||||||
|
public void updateComponent(int fromRow, int toRow) {
|
||||||
|
//must run from the UI thread
|
||||||
|
if (Executions.getCurrent() != null) {
|
||||||
|
fireEvent(ListDataEvent.CONTENTS_CHANGED, fromRow, toRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ import java.text.ParseException;
|
||||||
|
|
||||||
import org.adempiere.webui.LayoutUtils;
|
import org.adempiere.webui.LayoutUtils;
|
||||||
import org.adempiere.webui.apps.AEnv;
|
import org.adempiere.webui.apps.AEnv;
|
||||||
|
import org.zkoss.zhtml.Table;
|
||||||
|
import org.zkoss.zhtml.Td;
|
||||||
|
import org.zkoss.zhtml.Tr;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zul.Decimalbox;
|
import org.zkoss.zul.Decimalbox;
|
||||||
|
@ -67,20 +70,40 @@ public class NumberBox extends Div
|
||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
decimalBox = new Decimalbox();
|
Table grid = new Table();
|
||||||
|
appendChild(grid);
|
||||||
|
grid.setStyle("border: none; padding: 0px; margin: 0px;");
|
||||||
|
grid.setDynamicProperty("border", "0");
|
||||||
|
grid.setDynamicProperty("cellpadding", "0");
|
||||||
|
grid.setDynamicProperty("cellspacing", "0");
|
||||||
|
|
||||||
|
Tr tr = new Tr();
|
||||||
|
grid.appendChild(tr);
|
||||||
|
tr.setStyle("border: none; padding: 0px; margin: 0px; white-space:nowrap; ");
|
||||||
|
|
||||||
|
Td td = new Td();
|
||||||
|
tr.appendChild(td);
|
||||||
|
td.setStyle("border: none; padding: 0px; margin: 0px;");
|
||||||
|
decimalBox = new Decimalbox();
|
||||||
if (integral)
|
if (integral)
|
||||||
decimalBox.setScale(0);
|
decimalBox.setScale(0);
|
||||||
decimalBox.setStyle("display: inline;");
|
decimalBox.setStyle("display: inline;");
|
||||||
|
td.appendChild(decimalBox);
|
||||||
btn = new Button();
|
|
||||||
|
Td btnColumn = new Td();
|
||||||
|
tr.appendChild(btnColumn);
|
||||||
|
btnColumn.setStyle("border: none; padding: 0px; margin: 0px;");
|
||||||
|
btnColumn.setSclass("editor-button");
|
||||||
|
btn = new Button();
|
||||||
btn.setImage("/images/Calculator10.png");
|
btn.setImage("/images/Calculator10.png");
|
||||||
|
btn.setTabindex(-1);
|
||||||
|
LayoutUtils.addSclass("editor-button", btn);
|
||||||
|
btnColumn.appendChild(btn);
|
||||||
|
|
||||||
popup = getCalculatorPopup();
|
popup = getCalculatorPopup();
|
||||||
LayoutUtils.addSclass("editor-button", btn);
|
LayoutUtils.addSclass("editor-button", btn);
|
||||||
btn.setPopup(popup);
|
btn.setPopup(popup);
|
||||||
btn.setStyle("text-align: center;");
|
btn.setStyle("text-align: center;");
|
||||||
appendChild(decimalBox);
|
|
||||||
appendChild(btn);
|
|
||||||
appendChild(popup);
|
appendChild(popup);
|
||||||
|
|
||||||
String style = AEnv.isFirefox2() ? "display: inline" : "display: inline-block";
|
String style = AEnv.isFirefox2() ? "display: inline" : "display: inline-block";
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class WListbox extends Listbox implements TableValueChangeListener, WTabl
|
||||||
rowRenderer.addTableValueChangeListener(this);
|
rowRenderer.addTableValueChangeListener(this);
|
||||||
|
|
||||||
setItemRenderer(rowRenderer);
|
setItemRenderer(rowRenderer);
|
||||||
setModel(new ListModelTable());
|
setModel(new ListModelTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -936,18 +936,21 @@ public class WListbox extends Listbox implements TableValueChangeListener, WTabl
|
||||||
|
|
||||||
// if the event was caused by an ID Column and the value is a boolean
|
// if the event was caused by an ID Column and the value is a boolean
|
||||||
// then set the IDColumn's select field
|
// then set the IDColumn's select field
|
||||||
if (this.getValueAt(row, col) instanceof IDColumn
|
if (col >= 0 && row >=0)
|
||||||
&& event.getNewValue() instanceof Boolean)
|
|
||||||
{
|
{
|
||||||
newBoolean = ((Boolean)event.getNewValue()).booleanValue();
|
if (this.getValueAt(row, col) instanceof IDColumn
|
||||||
idColumn = (IDColumn)this.getValueAt(row, col);
|
&& event.getNewValue() instanceof Boolean)
|
||||||
idColumn.setSelected(newBoolean);
|
{
|
||||||
this.setValueAt(idColumn, row, col);
|
newBoolean = ((Boolean)event.getNewValue()).booleanValue();
|
||||||
}
|
idColumn = (IDColumn)this.getValueAt(row, col);
|
||||||
// othewise just set the value in the model to the new value
|
idColumn.setSelected(newBoolean);
|
||||||
else
|
this.setValueAt(idColumn, row, col);
|
||||||
{
|
}
|
||||||
this.setValueAt(event.getNewValue(), row, col);
|
// othewise just set the value in the model to the new value
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.setValueAt(event.getNewValue(), row, col);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -964,7 +967,7 @@ public class WListbox extends Listbox implements TableValueChangeListener, WTabl
|
||||||
|
|
||||||
// this causes re-rendering of the Listbox
|
// this causes re-rendering of the Listbox
|
||||||
this.setModel(this.getModel());
|
this.setModel(this.getModel());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1008,14 +1011,25 @@ public class WListbox extends Listbox implements TableValueChangeListener, WTabl
|
||||||
{
|
{
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
else
|
else if ((event.getType() == WTableModelEvent.CONTENTS_CHANGED)
|
||||||
|
&& event.getFirstRow() != WTableModelEvent.ALL_ROWS
|
||||||
|
&& !m_readWriteColumn.isEmpty())
|
||||||
{
|
{
|
||||||
this.setModel(this.getModel());
|
int[] indices = this.getSelectedIndices();
|
||||||
|
ListModelTable model = this.getModel();
|
||||||
|
if (event.getLastRow() > event.getFirstRow())
|
||||||
|
model.updateComponent(event.getFirstRow(), event.getLastRow());
|
||||||
|
else
|
||||||
|
model.updateComponent(event.getFirstRow());
|
||||||
|
if (indices != null && indices.length > 0)
|
||||||
|
{
|
||||||
|
this.setSelectedIndices(indices);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no op, to ease porting of swing form
|
* no op, to ease porting of swing form
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WAccountEditor extends WEditor
|
public class WAccountEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
|
|
||||||
private MAccountLookup m_mAccount;
|
private MAccountLookup m_mAccount;
|
||||||
|
|
||||||
|
@ -173,6 +173,10 @@ public class WAccountEditor extends WEditor
|
||||||
{
|
{
|
||||||
cmd_button();
|
cmd_button();
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
|
|
|
@ -22,6 +22,8 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
public class WAssignmentEditor extends WEditor {
|
public class WAssignmentEditor extends WEditor {
|
||||||
|
|
||||||
private final static CLogger log = CLogger.getCLogger(WAssignmentEditor.class);
|
private final static CLogger log = CLogger.getCLogger(WAssignmentEditor.class);
|
||||||
|
|
||||||
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_FOCUS};
|
||||||
|
|
||||||
private boolean m_readWrite;
|
private boolean m_readWrite;
|
||||||
private Object m_value;
|
private Object m_value;
|
||||||
|
@ -39,9 +41,14 @@ public class WAssignmentEditor extends WEditor {
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
getComponent().getTextbox().setReadonly(true);
|
getComponent().getTextbox().setReadonly(true);
|
||||||
getComponent().setButtonImage("images/Assignment10.png");
|
getComponent().setButtonImage("images/Assignment10.png");
|
||||||
getComponent().addEventListener(Events.ON_CLICK, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getEvents() {
|
||||||
|
return LISTENER_EVENTS;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditorBox getComponent() {
|
public EditorBox getComponent() {
|
||||||
|
@ -119,30 +126,37 @@ public class WAssignmentEditor extends WEditor {
|
||||||
|
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
//
|
//
|
||||||
Integer oldValue = (Integer)getValue();
|
if (Events.ON_CLICK.equalsIgnoreCase(event.getName()))
|
||||||
int S_ResourceAssignment_ID = oldValue == null ? 0 : oldValue.intValue();
|
|
||||||
MResourceAssignment ma = new MResourceAssignment(Env.getCtx(), S_ResourceAssignment_ID, null);
|
|
||||||
|
|
||||||
// Start VAssignment Dialog
|
|
||||||
if (S_ResourceAssignment_ID != 0)
|
|
||||||
{
|
{
|
||||||
WAssignmentDialog vad = new WAssignmentDialog (ma, true, true);
|
Integer oldValue = (Integer)getValue();
|
||||||
ma = vad.getMResourceAssignment();
|
int S_ResourceAssignment_ID = oldValue == null ? 0 : oldValue.intValue();
|
||||||
}
|
MResourceAssignment ma = new MResourceAssignment(Env.getCtx(), S_ResourceAssignment_ID, null);
|
||||||
// Start InfoSchedule directly
|
|
||||||
else
|
// Start VAssignment Dialog
|
||||||
{
|
if (S_ResourceAssignment_ID != 0)
|
||||||
InfoSchedule is = new InfoSchedule(ma, true);
|
{
|
||||||
ma = is.getMResourceAssignment();
|
WAssignmentDialog vad = new WAssignmentDialog (ma, true, true);
|
||||||
}
|
ma = vad.getMResourceAssignment();
|
||||||
|
}
|
||||||
// Set Value
|
// Start InfoSchedule directly
|
||||||
if (ma != null && ma.getS_ResourceAssignment_ID() != 0)
|
else
|
||||||
{
|
{
|
||||||
setValue(new Integer(ma.getS_ResourceAssignment_ID()));
|
InfoSchedule is = new InfoSchedule(ma, true);
|
||||||
ValueChangeEvent vce = new ValueChangeEvent(this, gridField.getColumnName(), oldValue, getValue());
|
ma = is.getMResourceAssignment();
|
||||||
fireValueChange(vce);
|
}
|
||||||
|
|
||||||
|
// Set Value
|
||||||
|
if (ma != null && ma.getS_ResourceAssignment_ID() != 0)
|
||||||
|
{
|
||||||
|
setValue(new Integer(ma.getS_ResourceAssignment_ID()));
|
||||||
|
ValueChangeEvent vce = new ValueChangeEvent(this, gridField.getColumnName(), oldValue, getValue());
|
||||||
|
fireValueChange(vce);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WBinaryEditor extends WEditor
|
public class WBinaryEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_FOCUS};
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger(WBinaryEditor.class);
|
private static CLogger log = CLogger.getCLogger(WBinaryEditor.class);
|
||||||
|
@ -45,8 +45,6 @@ public class WBinaryEditor extends WEditor
|
||||||
label.setValue(" ");
|
label.setValue(" ");
|
||||||
getComponent().setLabel("-");
|
getComponent().setLabel("-");
|
||||||
getComponent().setTooltiptext(gridField.getDescription());
|
getComponent().setTooltiptext(gridField.getDescription());
|
||||||
getComponent().addEventListener(Events.ON_CLICK, this);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -129,5 +127,9 @@ public class WBinaryEditor extends WEditor
|
||||||
if (!dialog.isCancel() && dialog.isChange())
|
if (!dialog.isCancel() && dialog.isChange())
|
||||||
m_data = dialog.getData();
|
m_data = dialog.getData();
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WButtonEditor extends WEditor
|
public class WButtonEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_FOCUS};
|
||||||
|
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
|
||||||
|
@ -100,7 +100,6 @@ public class WButtonEditor extends WEditor
|
||||||
label.setValue(" ");
|
label.setValue(" ");
|
||||||
getComponent().setLabel(gridField.getHeader());
|
getComponent().setLabel(gridField.getHeader());
|
||||||
getComponent().setTooltiptext(gridField.getDescription());
|
getComponent().setTooltiptext(gridField.getDescription());
|
||||||
getComponent().addEventListener(Events.ON_CLICK, this);
|
|
||||||
|
|
||||||
String columnName = super.getColumnName();
|
String columnName = super.getColumnName();
|
||||||
if (columnName.equals("PaymentRule"))
|
if (columnName.equals("PaymentRule"))
|
||||||
|
@ -275,5 +274,9 @@ public class WButtonEditor extends WEditor
|
||||||
evtListener.actionPerformed(actionEvent);
|
evtListener.actionPerformed(actionEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WDateEditor extends WEditor
|
public class WDateEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -105,17 +105,24 @@ public class WDateEditor extends WEditor
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
Date date = getComponent().getValue();
|
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()))
|
||||||
Timestamp newValue = null;
|
{
|
||||||
|
Date date = getComponent().getValue();
|
||||||
if (date != null)
|
Timestamp newValue = null;
|
||||||
{
|
|
||||||
newValue = new Timestamp(date.getTime());
|
if (date != null)
|
||||||
}
|
{
|
||||||
|
newValue = new Timestamp(date.getTime());
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
}
|
||||||
super.fireValueChange(changeEvent);
|
|
||||||
oldValue = newValue;
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||||
|
super.fireValueChange(changeEvent);
|
||||||
|
oldValue = newValue;
|
||||||
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WDatetimeEditor extends WEditor
|
public class WDatetimeEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -98,17 +98,24 @@ public class WDatetimeEditor extends WEditor
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
Date date = getComponent().getValue();
|
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()))
|
||||||
Timestamp newValue = null;
|
{
|
||||||
|
Date date = getComponent().getValue();
|
||||||
if (date != null)
|
Timestamp newValue = null;
|
||||||
{
|
|
||||||
newValue = new Timestamp(date.getTime());
|
if (date != null)
|
||||||
}
|
{
|
||||||
|
newValue = new Timestamp(date.getTime());
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
}
|
||||||
super.fireValueChange(changeEvent);
|
|
||||||
oldValue = newValue;
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||||
|
super.fireValueChange(changeEvent);
|
||||||
|
oldValue = newValue;
|
||||||
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -292,6 +292,11 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean removeValuechangeListener(ValueChangeListener listener)
|
||||||
|
{
|
||||||
|
return listeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
protected void fireValueChange(ValueChangeEvent event)
|
protected void fireValueChange(ValueChangeEvent event)
|
||||||
{
|
{
|
||||||
for (ValueChangeListener listener : listeners)
|
for (ValueChangeListener listener : listeners)
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.zkoss.zul.Fileupload;
|
||||||
*/
|
*/
|
||||||
public class WFilenameEditor extends WEditor
|
public class WFilenameEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
|
|
||||||
private static final CLogger log = CLogger.getCLogger(WFilenameEditor.class);
|
private static final CLogger log = CLogger.getCLogger(WFilenameEditor.class);
|
||||||
|
|
||||||
|
@ -98,6 +98,10 @@ public class WFilenameEditor extends WEditor
|
||||||
{
|
{
|
||||||
cmd_file();
|
cmd_file();
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WImageEditor extends WEditor
|
public class WImageEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_FOCUS};
|
||||||
|
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
|
||||||
|
@ -66,7 +66,6 @@ public class WImageEditor extends WEditor
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
getComponent().setLabel("-");
|
getComponent().setLabel("-");
|
||||||
getComponent().addEventListener(Events.ON_CLICK, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -151,5 +150,9 @@ public class WImageEditor extends WEditor
|
||||||
ValueChangeEvent vce = new ValueChangeEvent(this, gridField.getColumnName(), oldValue, newValue);
|
ValueChangeEvent vce = new ValueChangeEvent(this, gridField.getColumnName(), oldValue, newValue);
|
||||||
fireValueChange(vce);
|
fireValueChange(vce);
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
**/
|
**/
|
||||||
public class WLocationEditor extends WEditor implements EventListener, PropertyChangeListener
|
public class WLocationEditor extends WEditor implements EventListener, PropertyChangeListener
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_FOCUS};
|
||||||
|
|
||||||
private static CLogger log = CLogger.getCLogger(WLocationEditor.class);
|
private static CLogger log = CLogger.getCLogger(WLocationEditor.class);
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -163,6 +163,10 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC
|
||||||
}
|
}
|
||||||
setValue(ii);
|
setValue(ii);
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
public class WLocatorEditor extends WEditor implements EventListener, PropertyChangeListener
|
public class WLocatorEditor extends WEditor implements EventListener, PropertyChangeListener
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_FOCUS};
|
||||||
|
|
||||||
private String m_columnName;
|
private String m_columnName;
|
||||||
private MLocatorLookup m_mLocator;
|
private MLocatorLookup m_mLocator;
|
||||||
|
@ -178,42 +178,48 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
|
||||||
|
|
||||||
public void onEvent(Event event) throws Exception
|
public void onEvent(Event event) throws Exception
|
||||||
{
|
{
|
||||||
// Warehouse/Product
|
if (Events.ON_CLICK.equalsIgnoreCase(event.getName()))
|
||||||
|
{
|
||||||
int only_Warehouse_ID = getOnly_Warehouse_ID();
|
// Warehouse/Product
|
||||||
int only_Product_ID = getOnly_Product_ID();
|
int only_Warehouse_ID = getOnly_Warehouse_ID();
|
||||||
|
int only_Product_ID = getOnly_Product_ID();
|
||||||
log.config("Only Warehouse_ID=" + only_Warehouse_ID + ", Product_ID=" + only_Product_ID);
|
|
||||||
|
log.config("Only Warehouse_ID=" + only_Warehouse_ID + ", Product_ID=" + only_Product_ID);
|
||||||
// Text Entry ok
|
|
||||||
|
// Text Entry ok
|
||||||
if (event.getTarget() == getComponent() && actionText(only_Warehouse_ID, only_Product_ID))
|
|
||||||
return;
|
if (event.getTarget() == getComponent() && actionText(only_Warehouse_ID, only_Product_ID))
|
||||||
|
return;
|
||||||
// Button - Start Dialog
|
|
||||||
|
// Button - Start Dialog
|
||||||
int M_Locator_ID = 0;
|
|
||||||
|
int M_Locator_ID = 0;
|
||||||
if (m_value instanceof Integer)
|
|
||||||
M_Locator_ID = ((Integer)m_value).intValue();
|
if (m_value instanceof Integer)
|
||||||
|
M_Locator_ID = ((Integer)m_value).intValue();
|
||||||
m_mLocator.setOnly_Warehouse_ID(only_Warehouse_ID);
|
|
||||||
m_mLocator.setOnly_Product_ID(getOnly_Product_ID());
|
m_mLocator.setOnly_Warehouse_ID(only_Warehouse_ID);
|
||||||
|
m_mLocator.setOnly_Product_ID(getOnly_Product_ID());
|
||||||
WLocatorDialog ld = new WLocatorDialog(Msg.translate(Env.getCtx(), m_columnName),
|
|
||||||
m_mLocator, M_Locator_ID, isMandatory(), only_Warehouse_ID, this.m_WindowNo);
|
WLocatorDialog ld = new WLocatorDialog(Msg.translate(Env.getCtx(), m_columnName),
|
||||||
|
m_mLocator, M_Locator_ID, isMandatory(), only_Warehouse_ID, this.m_WindowNo);
|
||||||
// display
|
|
||||||
ld.setVisible(true);
|
// display
|
||||||
AEnv.showWindow(ld);
|
ld.setVisible(true);
|
||||||
|
AEnv.showWindow(ld);
|
||||||
m_mLocator.setOnly_Warehouse_ID(0);
|
|
||||||
|
m_mLocator.setOnly_Warehouse_ID(0);
|
||||||
// redisplay
|
|
||||||
|
// redisplay
|
||||||
if (!ld.isChanged())
|
|
||||||
return;
|
if (!ld.isChanged())
|
||||||
setValue (ld.getValue(), true);
|
return;
|
||||||
|
setValue (ld.getValue(), true);
|
||||||
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WNumberEditor extends WEditor
|
public class WNumberEditor extends WEditor
|
||||||
{
|
{
|
||||||
public static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
public static final String[] LISTENER_EVENTS = {Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
|
|
||||||
public static final int MAX_DISPLAY_LENGTH = 20;
|
public static final int MAX_DISPLAY_LENGTH = 20;
|
||||||
|
|
||||||
|
@ -105,10 +105,17 @@ public class WNumberEditor extends WEditor
|
||||||
*/
|
*/
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
BigDecimal newValue = getComponent().getValue();
|
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()))
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
{
|
||||||
super.fireValueChange(changeEvent);
|
BigDecimal newValue = getComponent().getValue();
|
||||||
oldValue = newValue;
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||||
|
super.fireValueChange(changeEvent);
|
||||||
|
oldValue = newValue;
|
||||||
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WPAttributeEditor extends WEditor implements ContextMenuListener
|
public class WPAttributeEditor extends WEditor implements ContextMenuListener
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
|
|
||||||
private static final CLogger log = CLogger.getCLogger(WPAttributeEditor.class);
|
private static final CLogger log = CLogger.getCLogger(WPAttributeEditor.class);
|
||||||
|
|
||||||
|
@ -130,6 +130,10 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener
|
||||||
{
|
{
|
||||||
cmd_dialog();
|
cmd_dialog();
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,7 +56,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WSearchEditor extends WEditor implements ContextMenuListener, ValueChangeListener, IZoomableEditor
|
public class WSearchEditor extends WEditor implements ContextMenuListener, ValueChangeListener, IZoomableEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_OK};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_OK, Events.ON_FOCUS};
|
||||||
private Lookup lookup;
|
private Lookup lookup;
|
||||||
private String m_tableName = null;
|
private String m_tableName = null;
|
||||||
private String m_keyColumnName = null;
|
private String m_keyColumnName = null;
|
||||||
|
@ -216,8 +216,17 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
}
|
}
|
||||||
else if (Events.ON_CLICK.equals(e.getName()))
|
else if (Events.ON_CLICK.equals(e.getName()))
|
||||||
{
|
{
|
||||||
|
if (infoPanel != null)
|
||||||
|
{
|
||||||
|
infoPanel.detach();
|
||||||
|
infoPanel = null;
|
||||||
|
}
|
||||||
actionButton("");
|
actionButton("");
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(e.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +442,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
{
|
{
|
||||||
if (lookup == null)
|
if (lookup == null)
|
||||||
return; // leave button disabled
|
return; // leave button disabled
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Three return options:
|
* Three return options:
|
||||||
* - Value Selected & OK pressed => store result => result has value
|
* - Value Selected & OK pressed => store result => result has value
|
||||||
|
|
|
@ -44,12 +44,14 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
{
|
{
|
||||||
private static final String EDITOR_EVENT = "EDITOR";
|
private static final String EDITOR_EVENT = "EDITOR";
|
||||||
|
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
|
|
||||||
private String oldText;
|
private String oldText;
|
||||||
|
|
||||||
private WEditorPopupMenu popupMenu;
|
private WEditorPopupMenu popupMenu;
|
||||||
|
|
||||||
|
private boolean tableEditor = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to ease porting of swing form
|
* to ease porting of swing form
|
||||||
*/
|
*/
|
||||||
|
@ -58,10 +60,14 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
this("String", false, false, true, 30, 30, "", null);
|
this("String", false, false, true, 30, 30, "", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WStringEditor(GridField gridField)
|
public WStringEditor(GridField gridField) {
|
||||||
|
this(gridField, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WStringEditor(GridField gridField, boolean tableEditor)
|
||||||
{
|
{
|
||||||
super(new Textbox(), gridField);
|
super(new Textbox(), gridField);
|
||||||
|
this.tableEditor = tableEditor;
|
||||||
init(gridField.getObscureType());
|
init(gridField.getObscureType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,20 +117,23 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
}
|
}
|
||||||
getComponent().setCols(displayLength);
|
getComponent().setCols(displayLength);
|
||||||
|
|
||||||
if (gridField.getDisplayType() == DisplayType.Text)
|
if (!tableEditor)
|
||||||
{
|
{
|
||||||
getComponent().setMultiline(true);
|
if (gridField.getDisplayType() == DisplayType.Text)
|
||||||
getComponent().setRows(3);
|
{
|
||||||
}
|
getComponent().setMultiline(true);
|
||||||
else if (gridField.getDisplayType() == DisplayType.TextLong)
|
getComponent().setRows(3);
|
||||||
{
|
}
|
||||||
getComponent().setMultiline(true);
|
else if (gridField.getDisplayType() == DisplayType.TextLong)
|
||||||
getComponent().setRows(5);
|
{
|
||||||
}
|
getComponent().setMultiline(true);
|
||||||
else if (gridField.getDisplayType() == DisplayType.Memo)
|
getComponent().setRows(5);
|
||||||
{
|
}
|
||||||
getComponent().setMultiline(true);
|
else if (gridField.getDisplayType() == DisplayType.Memo)
|
||||||
getComponent().setRows(8);
|
{
|
||||||
|
getComponent().setMultiline(true);
|
||||||
|
getComponent().setRows(8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getComponent().setObscureType(obscureType);
|
getComponent().setObscureType(obscureType);
|
||||||
|
@ -147,6 +156,10 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldText, newText);
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldText, newText);
|
||||||
super.fireValueChange(changeEvent);
|
super.fireValueChange(changeEvent);
|
||||||
oldText = newText;
|
oldText = newText;
|
||||||
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
public class WTableDirEditor extends WEditor implements ListDataListener,
|
public class WTableDirEditor extends WEditor implements ListDataListener,
|
||||||
ContextMenuListener, IZoomableEditor
|
ContextMenuListener, IZoomableEditor
|
||||||
{
|
{
|
||||||
public final static String[] LISTENER_EVENTS = {Events.ON_SELECT};
|
public final static String[] LISTENER_EVENTS = {Events.ON_SELECT, Events.ON_FOCUS};
|
||||||
|
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
|
||||||
|
@ -259,10 +259,17 @@ ContextMenuListener, IZoomableEditor
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
Object newValue = getValue();
|
if (Events.ON_SELECT.equalsIgnoreCase(event.getName()))
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
{
|
||||||
super.fireValueChange(changeEvent);
|
Object newValue = getValue();
|
||||||
oldValue = newValue;
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||||
|
super.fireValueChange(changeEvent);
|
||||||
|
oldValue = newValue;
|
||||||
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.zkoss.zul.Timebox;
|
||||||
*/
|
*/
|
||||||
public class WTimeEditor extends WEditor
|
public class WTimeEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -90,17 +90,24 @@ public class WTimeEditor extends WEditor
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
Date date = getComponent().getValue();
|
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()))
|
||||||
Timestamp newValue = null;
|
{
|
||||||
|
Date date = getComponent().getValue();
|
||||||
if (date != null)
|
Timestamp newValue = null;
|
||||||
{
|
|
||||||
newValue = new Timestamp(date.getTime());
|
if (date != null)
|
||||||
}
|
{
|
||||||
|
newValue = new Timestamp(date.getTime());
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
}
|
||||||
super.fireValueChange(changeEvent);
|
|
||||||
oldValue = newValue;
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||||
|
super.fireValueChange(changeEvent);
|
||||||
|
oldValue = newValue;
|
||||||
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
public class WUrlEditor extends WEditor
|
public class WUrlEditor extends WEditor
|
||||||
{
|
{
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_FOCUS};
|
||||||
|
|
||||||
public WUrlEditor(GridField gridField)
|
public WUrlEditor(GridField gridField)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +108,10 @@ public class WUrlEditor extends WEditor
|
||||||
FDialog.warn(0, this.getComponent(), "URLnotValid", message);
|
FDialog.warn(0, this.getComponent(), "URLnotValid", message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
*/
|
*/
|
||||||
public class WYesNoEditor extends WEditor
|
public class WYesNoEditor extends WEditor
|
||||||
{
|
{
|
||||||
public static final String[] LISTENER_EVENTS = {Events.ON_CHECK};
|
public static final String[] LISTENER_EVENTS = {Events.ON_CHECK, Events.ON_FOCUS};
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -62,10 +62,17 @@ public class WYesNoEditor extends WEditor
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
Boolean newValue = (Boolean)getValue();
|
if (Events.ON_CHECK.equalsIgnoreCase(event.getName()))
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
{
|
||||||
super.fireValueChange(changeEvent);
|
Boolean newValue = (Boolean)getValue();
|
||||||
oldValue = newValue;
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||||
|
super.fireValueChange(changeEvent);
|
||||||
|
oldValue = newValue;
|
||||||
|
}
|
||||||
|
else if (Events.ON_FOCUS.equalsIgnoreCase(event.getName()) && gridField != null)
|
||||||
|
{
|
||||||
|
this.setReadWrite(gridField.isEditable(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void propertyChange(PropertyChangeEvent evt)
|
public void propertyChange(PropertyChangeEvent evt)
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class WebEditorFactory
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
editor = new WStringEditor(gridField);
|
editor = new WStringEditor(gridField, tableEditor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/** File */
|
/** File */
|
||||||
|
|
|
@ -45,14 +45,12 @@ import org.adempiere.webui.editor.WEditor;
|
||||||
import org.adempiere.webui.editor.WEditorPopupMenu;
|
import org.adempiere.webui.editor.WEditorPopupMenu;
|
||||||
import org.adempiere.webui.editor.WebEditorFactory;
|
import org.adempiere.webui.editor.WebEditorFactory;
|
||||||
import org.adempiere.webui.event.ContextMenuListener;
|
import org.adempiere.webui.event.ContextMenuListener;
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
import org.adempiere.webui.util.GridTabDataBinder;
|
||||||
import org.adempiere.webui.event.ValueChangeListener;
|
|
||||||
import org.adempiere.webui.window.FDialog;
|
import org.adempiere.webui.window.FDialog;
|
||||||
import org.compiere.model.DataStatusEvent;
|
import org.compiere.model.DataStatusEvent;
|
||||||
import org.compiere.model.DataStatusListener;
|
import org.compiere.model.DataStatusListener;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
import org.compiere.model.GridTable;
|
|
||||||
import org.compiere.model.GridWindow;
|
import org.compiere.model.GridWindow;
|
||||||
import org.compiere.model.MLookup;
|
import org.compiere.model.MLookup;
|
||||||
import org.compiere.model.MTree;
|
import org.compiere.model.MTree;
|
||||||
|
@ -94,7 +92,7 @@ import org.zkoss.zul.Treeitem;
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*/
|
*/
|
||||||
public class ADTabpanel extends Div implements Evaluatee, EventListener,
|
public class ADTabpanel extends Div implements Evaluatee, EventListener,
|
||||||
DataStatusListener, ValueChangeListener, IADTabpanel
|
DataStatusListener, IADTabpanel
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
@ -134,6 +132,8 @@ DataStatusListener, ValueChangeListener, IADTabpanel
|
||||||
|
|
||||||
private Tree tree = null;
|
private Tree tree = null;
|
||||||
|
|
||||||
|
private GridTabDataBinder dataBinder;
|
||||||
|
|
||||||
public ADTabpanel()
|
public ADTabpanel()
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
@ -169,6 +169,7 @@ DataStatusListener, ValueChangeListener, IADTabpanel
|
||||||
this.gridTab = gridTab;
|
this.gridTab = gridTab;
|
||||||
this.windowPanel = winPanel;
|
this.windowPanel = winPanel;
|
||||||
gridTab.addDataStatusListener(this);
|
gridTab.addDataStatusListener(this);
|
||||||
|
this.dataBinder = new GridTabDataBinder(gridTab);
|
||||||
|
|
||||||
this.getChildren().clear();
|
this.getChildren().clear();
|
||||||
|
|
||||||
|
@ -373,7 +374,7 @@ DataStatusListener, ValueChangeListener, IADTabpanel
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
editor.addValueChangeListener(this);
|
editor.addValueChangeListener(dataBinder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editor.getComponent() instanceof HtmlBasedComponent) {
|
if (editor.getComponent() instanceof HtmlBasedComponent) {
|
||||||
|
@ -835,57 +836,6 @@ DataStatusListener, ValueChangeListener, IADTabpanel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void valueChange(ValueChangeEvent e)
|
|
||||||
{
|
|
||||||
if (gridTab.isProcessed()) // only active records
|
|
||||||
{
|
|
||||||
Object source = e.getSource();
|
|
||||||
if (source instanceof WEditor)
|
|
||||||
{
|
|
||||||
if (!((WEditor)source).isReadWrite())
|
|
||||||
{
|
|
||||||
logger.config("(" + gridTab.toString() + ") " + e.getPropertyName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.config("(" + gridTab.toString() + ") " + e.getPropertyName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} // processed
|
|
||||||
logger.config("(" + gridTab.toString() + ") "
|
|
||||||
+ e.getPropertyName() + "=" + e.getNewValue() + " (" + e.getOldValue() + ") "
|
|
||||||
+ (e.getOldValue() == null ? "" : e.getOldValue().getClass().getName()));
|
|
||||||
|
|
||||||
|
|
||||||
// Get Row/Col Info
|
|
||||||
GridTable mTable = gridTab.getTableModel();
|
|
||||||
int row = gridTab.getCurrentRow();
|
|
||||||
int col = mTable.findColumn(e.getPropertyName());
|
|
||||||
//
|
|
||||||
if (e.getNewValue() == null && e.getOldValue() != null
|
|
||||||
&& e.getOldValue().toString().length() > 0) // some editors return "" instead of null
|
|
||||||
// this is the original code from GridController, don't know what it does there but it breaks ignore button for web ui
|
|
||||||
// mTable.setChanged (true);
|
|
||||||
mTable.setValueAt (e.getNewValue(), row, col);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// mTable.setValueAt (e.getNewValue(), row, col, true);
|
|
||||||
mTable.setValueAt (e.getNewValue(), row, col); // -> dataStatusChanged -> dynamicDisplay
|
|
||||||
// Force Callout
|
|
||||||
if ( e.getPropertyName().equals("S_ResourceAssignment_ID") )
|
|
||||||
{
|
|
||||||
GridField mField = gridTab.getField(col);
|
|
||||||
if (mField != null && mField.getCallout().length() > 0)
|
|
||||||
{
|
|
||||||
gridTab.processFieldChange(mField); // Dependencies & Callout
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // ValueChange
|
|
||||||
|
|
||||||
public void switchRowPresentation() {
|
public void switchRowPresentation() {
|
||||||
if (formComponent.isVisible()) {
|
if (formComponent.isVisible()) {
|
||||||
formComponent.setVisible(false);
|
formComponent.setVisible(false);
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Copyright (C) 2008 Low Heng Sin *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.webui.util;
|
||||||
|
|
||||||
|
import org.adempiere.webui.editor.WEditor;
|
||||||
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
|
import org.adempiere.webui.event.ValueChangeListener;
|
||||||
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.GridTable;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transfer data from editor to GridTab
|
||||||
|
* @author hengsin
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GridTabDataBinder implements ValueChangeListener {
|
||||||
|
|
||||||
|
private final static CLogger logger = CLogger.getCLogger(GridTabDataBinder.class);
|
||||||
|
|
||||||
|
private GridTab gridTab;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param gridTab
|
||||||
|
*/
|
||||||
|
public GridTabDataBinder(GridTab gridTab) {
|
||||||
|
this.gridTab = gridTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
public void valueChange(ValueChangeEvent e)
|
||||||
|
{
|
||||||
|
if (gridTab.isProcessed()) // only active records
|
||||||
|
{
|
||||||
|
Object source = e.getSource();
|
||||||
|
if (source instanceof WEditor)
|
||||||
|
{
|
||||||
|
if (!((WEditor)source).isReadWrite())
|
||||||
|
{
|
||||||
|
logger.config("(" + gridTab.toString() + ") " + e.getPropertyName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.config("(" + gridTab.toString() + ") " + e.getPropertyName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} // processed
|
||||||
|
logger.config("(" + gridTab.toString() + ") "
|
||||||
|
+ e.getPropertyName() + "=" + e.getNewValue() + " (" + e.getOldValue() + ") "
|
||||||
|
+ (e.getOldValue() == null ? "" : e.getOldValue().getClass().getName()));
|
||||||
|
|
||||||
|
|
||||||
|
// Get Row/Col Info
|
||||||
|
GridTable mTable = gridTab.getTableModel();
|
||||||
|
int row = gridTab.getCurrentRow();
|
||||||
|
int col = mTable.findColumn(e.getPropertyName());
|
||||||
|
//
|
||||||
|
if (e.getNewValue() == null && e.getOldValue() != null
|
||||||
|
&& e.getOldValue().toString().length() > 0) // some editors return "" instead of null
|
||||||
|
// this is the original code from GridController, don't know what it does there but it breaks ignore button for web ui
|
||||||
|
// mTable.setChanged (true);
|
||||||
|
mTable.setValueAt (e.getNewValue(), row, col);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// mTable.setValueAt (e.getNewValue(), row, col, true);
|
||||||
|
mTable.setValueAt (e.getNewValue(), row, col); // -> dataStatusChanged -> dynamicDisplay
|
||||||
|
// Force Callout
|
||||||
|
if ( e.getPropertyName().equals("S_ResourceAssignment_ID") )
|
||||||
|
{
|
||||||
|
GridField mField = gridTab.getField(col);
|
||||||
|
if (mField != null && mField.getCallout().length() > 0)
|
||||||
|
{
|
||||||
|
gridTab.processFieldChange(mField); // Dependencies & Callout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ValueChange
|
||||||
|
}
|
Loading…
Reference in New Issue