& Merge zkwebui revision 6081 changes from branches/adempiere341

This commit is contained in:
Heng Sin Low 2008-08-11 07:14:54 +00:00
parent 09dfff3a6c
commit 59902e3a1a
5 changed files with 147 additions and 105 deletions

View File

@ -388,7 +388,7 @@ public class RModel implements Serializable
* @return the ArrayList of ArrayLists containing the tables data values
* @author Teo Sarca [ 1734327 ]
*/
protected ArrayList<ArrayList<Object>> getRows() {
public ArrayList<ArrayList<Object>> getRows() {
return m_data.rows;
}

View File

@ -42,7 +42,6 @@ import org.adempiere.webui.part.AbstractUIPart;
import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.window.ADWindow;
import org.adempiere.webui.window.InfoSchedule;
import org.compiere.model.MClient;
import org.compiere.model.MMenu;
import org.compiere.model.MQuery;
import org.compiere.model.MRole;
@ -170,7 +169,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
hbox.appendChild(vbCol1);
vbCol1.setWidth("100%");
Groupbox gbxFav = new Groupbox();
Groupbox gbxFav = new Groupbox();
vbCol1.appendChild(gbxFav);
Caption caption = new Caption("Favourites");
// Elaine 2008/07/24
@ -189,7 +188,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
gbxFav.addEventListener(Events.ON_DROP, this);
//
Groupbox gbxView = new Groupbox();
Groupbox gbxView = new Groupbox();
vbCol1.appendChild(gbxView);
gbxView.appendChild(new Caption("Views"));
gbxView.appendChild(createViewPanel());
@ -238,7 +237,8 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
Center center = new Center();
borderlayout.appendChild(center);
center.appendChild(hbox);
center.setFlex(true);
center.setFlex(false);
center.setAutoscroll(true);
//register as 0
registerWindow(homeTab);
@ -697,29 +697,6 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
return no == 1;
}
/**
* Retrieves the Client website url
* @return website url
*/
private String getClientWebsiteURL()
{
MClient client = MClient.get(Env.getCtx());
String defaultUrl = "http://www.adempiere.com";
String url = (String)client.get_Value("WebSiteURL");
if (url == null)
{
url = defaultUrl;
}
else if (!url.startsWith("http"))
{
logger.log(Level.SEVERE, "Website URL provided for the client is not valid!!!");
url = defaultUrl;
}
return url;
}
/**
* Event listener for menu item selection.
* Identifies the action associated with the selected

View File

@ -18,8 +18,9 @@
package org.adempiere.webui.acct;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import org.adempiere.webui.apps.AEnv;
@ -27,7 +28,6 @@ import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Checkbox;
import org.adempiere.webui.component.Datebox;
import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.ListModelTable;
import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Tab;
@ -36,6 +36,7 @@ import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Tabpanels;
import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.VerticalBox;
import org.adempiere.webui.component.WListItemRenderer;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.panel.InfoPanel;
import org.adempiere.webui.session.SessionManager;
@ -45,7 +46,6 @@ import org.compiere.model.MAcctSchemaElement;
import org.compiere.model.X_C_AcctSchema_Element;
import org.compiere.report.core.RModel;
import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.KeyNamePair;
@ -60,10 +60,10 @@ import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Groupbox;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listhead;
import org.zkoss.zul.Listheader;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Paging;
import org.zkoss.zul.Separator;
/**
@ -71,10 +71,15 @@ import org.zkoss.zul.Separator;
*
* @author Niraj Sohun
* July 27, 2007
*
* @author Elaine Tan
* @author Low Heng Sin
*/
public class WAcctViewer extends Window implements EventListener
{
private static final int PAGE_SIZE = 1000;
private static final long serialVersionUID = 1L;
/** State Info */
@ -137,6 +142,7 @@ public class WAcctViewer extends Window implements EventListener
private Tabbox tabbedPane = new Tabbox();
private Listbox table = new Listbox();
private Paging paging = new Paging();
private VerticalBox displayPanel = new VerticalBox();
private VerticalBox selectionPanel = new VerticalBox();
@ -151,6 +157,12 @@ public class WAcctViewer extends Window implements EventListener
private Hbox southPanel = new Hbox();
private int m_windowNo;
private ArrayList<ArrayList<Object>> m_queryData;
private South pagingPanel;
private Borderlayout resultPanel;
/** Logger */
private static CLogger log = CLogger.getCLogger(WAcctViewer.class);
@ -451,7 +463,7 @@ public class WAcctViewer extends Window implements EventListener
Hbox boxQueryPanel = new Hbox();
boxQueryPanel.setWidth("100%");
boxQueryPanel.setWidth("98%");
boxQueryPanel.setWidths("63%,1%,36%");
boxQueryPanel.appendChild(groupSelection);
@ -489,14 +501,31 @@ public class WAcctViewer extends Window implements EventListener
// Result Tab
resultPanel = new Borderlayout();
resultPanel.setStyle("position: absolute");
resultPanel.setWidth("97%");
resultPanel.setHeight("96%");
result.appendChild(resultPanel);
Center resultCenter = new Center();
resultCenter.setFlex(true);
resultPanel.appendChild(resultCenter);
table.setWidth("99%;");
// table.setMold("paging");
// table.setPageSize(10);
// table.setVflex(true);
table.setVflex(true);
table.setHeight("99%");
table.setStyle("position: absolute;");
resultCenter.appendChild(table);
pagingPanel = new South();
resultPanel.appendChild(pagingPanel);
pagingPanel.appendChild(paging);
result.setWidth("100%");
result.setHeight("100%");
result.appendChild(table);
result.setStyle("position: relative");
paging.addEventListener("onPaging", this);
paging.setAutohide(true);
// Query Tab
@ -506,10 +535,10 @@ public class WAcctViewer extends Window implements EventListener
// Tabbox
tabQuery.addEventListener(Events.ON_SELECT, this);
tabQuery.setLabel(Msg.getMsg(Env.getCtx(), "ViewerQuery"));
tabQuery.setLabel(Msg.getMsg(Env.getCtx(), "ViewerQuery").replaceAll("[&]", ""));
tabResult.addEventListener(Events.ON_SELECT, this);
tabResult.setLabel(Msg.getMsg(Env.getCtx(), "ViewerResult"));
tabResult.setLabel(Msg.getMsg(Env.getCtx(), "ViewerResult").replaceAll("[&]", ""));
tabs.appendChild(tabQuery);
tabs.appendChild(tabResult);
@ -705,6 +734,17 @@ public class WAcctViewer extends Window implements EventListener
// InfoButtons
else if (source instanceof Button)
actionButton((Button)source);
else if (source == paging)
{
int pgno = paging.getActivePage();
int start = pgno * PAGE_SIZE;
int end = start + PAGE_SIZE;
if ( end > paging.getTotalSize())
end = paging.getTotalSize();
List<ArrayList<Object>> list = m_queryData.subList(start, end);
ListModelTable model = new ListModelTable(list);
table.setModel(model);
}
} // onEvent
/**
@ -851,9 +891,11 @@ public class WAcctViewer extends Window implements EventListener
}
else
{
m_data.DateFrom = (Timestamp)selDateFrom.getValue();
m_data.DateFrom = selDateFrom.getValue() != null
? new Timestamp(selDateFrom.getValue().getTime()) : null;
para.append(", DateFrom=").append(m_data.DateFrom);
m_data.DateTo = (Timestamp)selDateTo.getValue();
m_data.DateTo = selDateTo.getValue() != null
? new Timestamp(selDateTo.getValue().getTime()) : null;
para.append(", DateTo=").append(m_data.DateTo);
listitem = selOrg.getSelectedItem();
@ -867,7 +909,7 @@ public class WAcctViewer extends Window implements EventListener
m_data.AD_Org_ID = kp.getKey();
para.append(", AD_Org_ID=").append(m_data.AD_Org_ID);
//
Iterator it = m_data.whereInfo.values().iterator();
Iterator<String> it = m_data.whereInfo.values().iterator();
while (it.hasNext())
para.append(", ").append(it.next());
}
@ -941,7 +983,6 @@ public class WAcctViewer extends Window implements EventListener
statusLine.setValue(" " + Msg.getMsg(Env.getCtx(), "Processing"));
log.config(para.toString());
Thread.yield();
// Switch to Result pane
@ -950,7 +991,24 @@ public class WAcctViewer extends Window implements EventListener
// Set TableModel with Query
RModel rmodel = m_data.query();
ListModelTable listmodeltable = new ListModelTable();
m_queryData = rmodel.getRows();
List<ArrayList<Object>> list = null;
paging.setPageSize(PAGE_SIZE);
if (m_queryData.size() > PAGE_SIZE)
{
list = m_queryData.subList(0, PAGE_SIZE);
paging.setTotalSize(m_queryData.size());
pagingPanel.setVisible(true);
}
else
{
list = m_queryData;
paging.setTotalSize(m_queryData.size());
pagingPanel.setVisible(false);
}
paging.setActivePage(0);
ListModelTable listmodeltable = new ListModelTable(list);
if (table.getListhead() == null)
{
@ -960,6 +1018,7 @@ public class WAcctViewer extends Window implements EventListener
for (int i = 0; i < rmodel.getColumnCount(); i++)
{
Listheader listheader = new Listheader(rmodel.getColumnName(i));
listheader.setTooltiptext(rmodel.getColumnName(i));
listhead.appendChild(listheader);
}
@ -984,36 +1043,10 @@ public class WAcctViewer extends Window implements EventListener
table.getItems().clear();
for (int i = 0; i < rmodel.getRowCount(); i++)
{
ListItem listite = new ListItem();
for (int j = 0; j < rmodel.getColumnCount(); j++)
{
Listcell listcell = new Listcell();
Object obj = rmodel.getValueAt(i, j);
if (obj == null)
{
listcell.appendChild(new Label(""));
listite.appendChild(listcell);
continue;
}
if ((Timestamp.class).equals(obj.getClass()))
{
SimpleDateFormat dateFormat = DisplayType.getDateFormat(DisplayType.Date);
obj = dateFormat.format((Timestamp)obj);
}
listcell.appendChild(new Label(obj.toString()));
listite.appendChild(listcell);
}
table.appendChild(listite);
}
table.setItemRenderer(new WListItemRenderer());
table.setModel(listmodeltable);
resultPanel.invalidate();
bQuery.setEnabled(true);
statusLine.setValue(" " + Msg.getMsg(Env.getCtx(), "ViewerOptions"));

View File

@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import org.adempiere.webui.event.WTableModelEvent;
@ -74,13 +75,13 @@ public class ListModelTable extends ListModelList implements ListModelExt
for (Object row : getInnerList())
{
if (row instanceof Vector)
if (row instanceof List)
{
m_noColumns = Math.max(m_noColumns, ((Vector)row).size());
m_noColumns = Math.max(m_noColumns, ((List)row).size());
}
else
{
throw new IllegalArgumentException("The collection must contain vectors of objects");
throw new IllegalArgumentException("The collection must contain list of objects");
}
}
}
@ -114,14 +115,31 @@ public class ListModelTable extends ListModelList implements ListModelExt
*/
private void ensureRowSize()
{
Iterator<Vector<Object>> rowIterator = this.getInnerList().iterator();
Iterator<List<Object>> rowIterator = this.getInnerList().iterator();
while (rowIterator.hasNext())
{
rowIterator.next().setSize(m_noColumns);
List<Object> list = rowIterator.next();
if (list instanceof Vector)
((Vector<Object>)list).setSize(m_noColumns);
else
{
if (m_noColumns > list.size())
{
for(int i = list.size(); i < m_noColumns; i++)
{
list.add(null);
}
}
else if (m_noColumns < list.size())
{
for (int i = list.size(); i > m_noColumns; i--)
{
list.remove(i - 1);
}
}
}
}
return;
}
/**
@ -153,12 +171,12 @@ public class ListModelTable extends ListModelList implements ListModelExt
*/
public Object getDataAt(int rowIndex, int columnIndex)
{
Vector modelRow;
List modelRow;
Object dataObject;
try
{
modelRow = (Vector)getElementAt(rowIndex);
modelRow = (List)getElementAt(rowIndex);
dataObject = modelRow.get(columnIndex);
}
@ -168,7 +186,7 @@ public class ListModelTable extends ListModelList implements ListModelExt
+ "nonexistent ListModelTable field at "
+ rowIndex + ", " + columnIndex);
}
return dataObject;
}
@ -181,14 +199,14 @@ public class ListModelTable extends ListModelList implements ListModelExt
*/
public void setDataAt(Object aValue, int row, int col)
{
Vector<Object> vector;
List<Object> vector;
WTableModelEvent tcEvent;
try
{
if (getElementAt(row) instanceof Vector)
if (getElementAt(row) instanceof List)
{
vector = (Vector<Object>)getElementAt(row);
vector = (List<Object>)getElementAt(row);
try
{
@ -229,15 +247,25 @@ public class ListModelTable extends ListModelList implements ListModelExt
*/
public void setNoRows(int rowCount)
{
Vector newRow = null;
List<Object> newRow = null;
if (rowCount >= getSize())
{
boolean vector = (getInnerList() instanceof Vector) ? true : false;
while (getSize() < rowCount)
{
newRow = new Vector<Object>(getNoColumns());
newRow.setSize(getNoColumns());
add(newRow);
if (vector)
{
newRow = new Vector<Object>(getNoColumns());
((Vector)newRow).ensureCapacity(getNoColumns());
add(newRow);
}
else
{
newRow = new ArrayList<Object>(getNoColumns());
((ArrayList)newRow).ensureCapacity(getNoColumns());
add(newRow);
}
}
}
else

View File

@ -24,8 +24,8 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import org.adempiere.webui.event.TableValueChangeEvent;
import org.adempiere.webui.event.TableValueChangeListener;
@ -78,7 +78,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
*
* @param columnNames vector of column titles.
*/
public WListItemRenderer(Vector< ? extends String> columnNames)
public WListItemRenderer(List< ? extends String> columnNames)
{
super();
WTableColumn tableColumn;
@ -141,12 +141,12 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
table = (WListbox)item.getListbox();
}
if (!(data instanceof Vector))
if (!(data instanceof List))
{
throw new IllegalArgumentException("A model element was not a vector");
throw new IllegalArgumentException("A model element was not a list");
}
for (Object field : (Vector)data)
for (Object field : (List)data)
{
listcell = getCellComponent(table, field, rowIndex, colIndex);
listcell.setParent(item);
@ -241,7 +241,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
int rowIndex, int columnIndex)
{
ListCell listcell = new ListCell();
boolean isCellEditable = table.isCellEditable(rowIndex, columnIndex);
boolean isCellEditable = table != null ? table.isCellEditable(rowIndex, columnIndex) : false;
/* Color fgColor = getForegroundColour(table, rowIndex);
Color bgColor = getBackgroundColour(table, rowIndex, columnIndex);
@ -257,7 +257,8 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
{
listcell.setValue(Boolean.valueOf(field.toString()));
table.setCheckmark(false);
if (table != null)
table.setCheckmark(false);
Checkbox checkbox = new Checkbox();
checkbox.setChecked(Boolean.valueOf(field.toString()));
@ -310,10 +311,13 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
else if (field instanceof IDColumn)
{
//listcell.setLabel(field.toString());
listcell.setValue(((IDColumn) field).getRecord_ID());
listcell.setValue(((IDColumn) field).getRecord_ID());
//listcell.setVisible(false);
table.setCheckmark(true);
table.addEventListener(Events.ON_SELECT, this);
if (table != null)
{
table.setCheckmark(true);
table.addEventListener(Events.ON_SELECT, this);
}
}
else
{
@ -448,8 +452,8 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
{
public int compare(Object o1, Object o2)
{
Object item1 = ((Vector)o1).get(columnIndex);
Object item2 = ((Vector)o2).get(columnIndex);
Object item1 = ((List)o1).get(columnIndex);
Object item2 = ((List)o2).get(columnIndex);
return sort.compare(item1, item2);
}
};
@ -462,7 +466,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
*
* @param head The ListHead component to render.
* @see #addColumn(String)
* @see #WListItemRenderer(Vector)
* @see #WListItemRenderer(List)
*/
public void renderListHead(ListHead head)
{