parameterize - HENGSIN PLEASE REVIEW
This commit is contained in:
parent
b3b2ba9284
commit
591e2f7bfb
|
|
@ -1,4 +1,5 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution
|
||||||
* Copyright (C) 2008 Low Heng Sin All Rights Reserved. *
|
* Copyright (C) 2008 Low Heng Sin All Rights Reserved. *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* 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 *
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
|
@ -31,18 +32,18 @@ import org.zkoss.zul.event.ListDataEvent;
|
||||||
*/
|
*/
|
||||||
public class SimpleListModel extends AbstractListModel implements ListitemRenderer, ListitemRendererExt {
|
public class SimpleListModel extends AbstractListModel implements ListitemRenderer, ListitemRendererExt {
|
||||||
|
|
||||||
protected List list;
|
protected List<Object> list;
|
||||||
|
|
||||||
private int[] maxLength;
|
private int[] maxLength;
|
||||||
|
|
||||||
public SimpleListModel() {
|
public SimpleListModel() {
|
||||||
this(new ArrayList());
|
this(new ArrayList<Object>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleListModel(List list) {
|
public SimpleListModel(List<Object> list) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getElementAt(int index) {
|
public Object getElementAt(int index) {
|
||||||
if (index >= 0 && index < list.size())
|
if (index >= 0 && index < list.size())
|
||||||
return list.get(index);
|
return list.get(index);
|
||||||
|
|
@ -59,9 +60,9 @@ public class SimpleListModel extends AbstractListModel implements ListitemRender
|
||||||
while (j > 0 && Character.isWhitespace(src.charAt(j - 1)))
|
while (j > 0 && Character.isWhitespace(src.charAt(j - 1)))
|
||||||
--j;
|
--j;
|
||||||
return new StringBuffer(j + 3)
|
return new StringBuffer(j + 3)
|
||||||
.append(src.substring(0, j)).append("...");
|
.append(src.substring(0, j)).append("...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(Listitem item, Object data) throws Exception {
|
public void render(Listitem item, Object data) throws Exception {
|
||||||
if (data instanceof Object[]) {
|
if (data instanceof Object[]) {
|
||||||
renderArray(item, (Object[])data);
|
renderArray(item, (Object[])data);
|
||||||
|
|
@ -72,7 +73,7 @@ public class SimpleListModel extends AbstractListModel implements ListitemRender
|
||||||
renderCell(0, item, value);
|
renderCell(0, item, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderCell(int col, Listitem item, String value) {
|
protected void renderCell(int col, Listitem item, String value) {
|
||||||
String tooltip = null;
|
String tooltip = null;
|
||||||
if (maxLength != null && maxLength.length > col && maxLength[col] > 0 && value.length() > maxLength[col]) {
|
if (maxLength != null && maxLength.length > col && maxLength[col] > 0 && value.length() > maxLength[col]) {
|
||||||
|
|
@ -85,7 +86,7 @@ public class SimpleListModel extends AbstractListModel implements ListitemRender
|
||||||
listCell.setTooltiptext(tooltip);
|
listCell.setTooltiptext(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderCollection(Listitem item, Collection data) {
|
private void renderCollection(Listitem item, Collection<Object> data) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Object col : data) {
|
for (Object col : data) {
|
||||||
String value = (col != null ? col.toString() : "");
|
String value = (col != null ? col.toString() : "");
|
||||||
|
|
@ -116,17 +117,17 @@ public class SimpleListModel extends AbstractListModel implements ListitemRender
|
||||||
item.applyProperties();
|
item.applyProperties();
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxLength(int[] maxLength) {
|
public void setMaxLength(int[] maxLength) {
|
||||||
this.maxLength = maxLength;
|
this.maxLength = maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addElement(Object obj) {
|
public void addElement(Object obj) {
|
||||||
list.add(obj);
|
list.add(obj);
|
||||||
int index = list.size() - 1;
|
int index = list.size() - 1;
|
||||||
fireEvent(ListDataEvent.INTERVAL_ADDED, index, index);
|
fireEvent(ListDataEvent.INTERVAL_ADDED, index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(int index, Object obj) {
|
public void add(int index, Object obj) {
|
||||||
list.add(index, obj);
|
list.add(index, obj);
|
||||||
fireEvent(ListDataEvent.INTERVAL_ADDED, index, index);
|
fireEvent(ListDataEvent.INTERVAL_ADDED, index, index);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue