- Kleine Optimierung RelatedLinkTable

- Neue RelatedLinks erhalten jetzt wieder eine richtige Order-Angabe


git-svn-id: https://svn.libreccm.org/ccm/trunk@898 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-05-06 16:13:37 +00:00
parent 9c810f3e97
commit d4ad0bb5d8
7 changed files with 339 additions and 304 deletions

View File

@ -42,17 +42,15 @@ import org.apache.log4j.Logger;
public class RelatedLink extends Link { public class RelatedLink extends Link {
private static final Logger s_log = Logger.getLogger(RelatedLink.class); private static final Logger s_log = Logger.getLogger(RelatedLink.class);
/** PDL properties */ /** PDL properties */
public static final String LINK_LIST_NAME = "linkListName"; public static final String LINK_LIST_NAME = "linkListName";
public static final String RESOURCE_SIZE = "resourceSize"; public static final String RESOURCE_SIZE = "resourceSize";
public static final String RESOURCE_TYPE = "resourceType"; public static final String RESOURCE_TYPE = "resourceType";
public static final String LINK_OWNER = "linkOwner"; public static final String LINK_OWNER = "linkOwner";
public static final String RELATED_LINKS = "links"; public static final String RELATED_LINKS = "links";
/** Data object type for this domain object */ /** Data object type for this domain object */
public static final String BASE_DATA_OBJECT_TYPE public static final String BASE_DATA_OBJECT_TYPE =
= "com.arsdigita.cms.contentassets.RelatedLink"; "com.arsdigita.cms.contentassets.RelatedLink";
/** /**
* Default constructor. This creates a new RelatedLink. * Default constructor. This creates a new RelatedLink.
@ -185,12 +183,20 @@ public class RelatedLink extends Link {
* @return * @return
*/ */
public static DataCollection getRelatedLinks(ContentItem item, String name) { public static DataCollection getRelatedLinks(ContentItem item, String name) {
s_log.debug("Getting related links for a content item"); s_log.debug(String.format("Getting related links for content item %s",
item.getID()));
long now = System.currentTimeMillis();
s_log.debug(String.format("Started at %d", now));
Session session = SessionManager.getSession(); Session session = SessionManager.getSession();
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE); DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
links.addEqualsFilter(LINK_OWNER + ".id", item.getID()); links.addEqualsFilter(LINK_OWNER + ".id", item.getID());
links.addEqualsFilter(LINK_LIST_NAME, name); links.addEqualsFilter(LINK_LIST_NAME, name);
links.addOrder(ORDER); links.addOrder(ORDER);
s_log.debug(String.format(
"Got all related links for content item %s in %d ms. (time finished: %d)",
item.getID().toString(),
System.currentTimeMillis() - now,
System.currentTimeMillis()));
return links; return links;
} }
@ -205,20 +211,22 @@ public class RelatedLink extends Link {
public static DataCollection getReferringRelatedLinks(ContentItem item) { public static DataCollection getReferringRelatedLinks(ContentItem item) {
Session session = SessionManager.getSession(); Session session = SessionManager.getSession();
DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE); DataCollection links = session.retrieve(BASE_DATA_OBJECT_TYPE);
Filter filter = links.addInSubqueryFilter("id", "com.arsdigita.cms.contentassets.getReferringRelatedLinks"); Filter filter =
links.addInSubqueryFilter("id",
"com.arsdigita.cms.contentassets.getReferringRelatedLinks");
filter.set("itemID", item.getID()); filter.set("itemID", item.getID());
return links; return links;
} }
/** /**
* Swaps this <code>RelatedLink</code> with the next one, * Swaps this <code>RelatedLink</code> with the next one,
* according to the linkOrder * according to the linkOrder
*/ */
@Override @Override
public void swapWithNext() { public void swapWithNext() {
swapWithNext("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem", swapWithNext(
"com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem",
"com.arsdigita.cms.contentassets.swapRelatedLinkWithNextInGroup", "com.arsdigita.cms.contentassets.swapRelatedLinkWithNextInGroup",
this.getLinkListName()); this.getLinkListName());
} }
@ -229,7 +237,8 @@ public class RelatedLink extends Link {
*/ */
@Override @Override
public void swapWithPrevious() { public void swapWithPrevious() {
swapWithPrevious("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem", swapWithPrevious(
"com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem",
"com.arsdigita.cms.contentassets.swapRelatedLinkWithNextInGroup", "com.arsdigita.cms.contentassets.swapRelatedLinkWithNextInGroup",
this.getLinkListName()); this.getLinkListName());
} }
@ -268,8 +277,6 @@ public class RelatedLink extends Link {
return operation; return operation;
} }
/** /**
* This method is only used for setting initial sort keys for * This method is only used for setting initial sort keys for
* links which exist without them. This is called by swapKeys * links which exist without them. This is called by swapKeys
@ -306,8 +313,8 @@ public class RelatedLink extends Link {
return 0; return 0;
} }
int returnOrder = 0; int returnOrder = 0;
DataQuery query = SessionManager.getSession().retrieveQuery DataQuery query = SessionManager.getSession().retrieveQuery(
("com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem"); "com.arsdigita.cms.contentassets.allRelatedLinkOrderForItem");
query.setParameter("ownerID", getLinkOwner().getID()); query.setParameter("ownerID", getLinkOwner().getID());
query.setParameter("linkListName", getLinkListName()); query.setParameter("linkListName", getLinkListName());
query.addOrder("linkOrder DESC"); query.addOrder("linkOrder DESC");

View File

@ -35,6 +35,7 @@ import com.arsdigita.cms.contentassets.RelatedLink;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.mimetypes.MimeType; import com.arsdigita.mimetypes.MimeType;
import com.arsdigita.mimetypes.MimeTypeCollection; import com.arsdigita.mimetypes.MimeTypeCollection;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -190,6 +191,10 @@ public class RelatedLinkPropertyForm extends LinkPropertyForm {
rl.setResourceType(mType); rl.setResourceType(mType);
} }
rl.setLinkListName((String) data.get(RelatedLink.LINK_LIST_NAME)); rl.setLinkListName((String) data.get(RelatedLink.LINK_LIST_NAME));
DataCollection links = RelatedLink.getRelatedLinks(getContentItem(fse.getPageState()), m_linkListName);
rl.setOrder((int) links.size() + 1);
super.setLinkProperties(link, fse); super.setLinkProperties(link, fse);
} }
} }

View File

@ -165,7 +165,8 @@ public class Link extends ACSObject {
* Link.INTERNAL_LINK * Link.INTERNAL_LINK
*/ */
public void setTargetType(String type) { public void setTargetType(String type) {
Assert.isTrue(type != null && (type.equals(EXTERNAL_LINK) || type.equals( Assert.isTrue(type != null && (type.equals(EXTERNAL_LINK)
|| type.equals(
INTERNAL_LINK))); INTERNAL_LINK)));
set(TARGET_TYPE, type); set(TARGET_TYPE, type);
} }
@ -207,7 +208,8 @@ public class Link extends ACSObject {
// If acsObject is instance of ContentBundle // If acsObject is instance of ContentBundle
if (acsObject instanceof ContentBundle) { if (acsObject instanceof ContentBundle) {
// get the negotiated language version of this ContentBundle // get the negotiated language version of this ContentBundle
ci = ((ContentBundle) acsObject).negotiate(DispatcherHelper.getRequest().getLocales()); ci = ((ContentBundle) acsObject).negotiate(DispatcherHelper.
getRequest().getLocales());
} else { } else {
// else there are no language versions so just use the acsObject // else there are no language versions so just use the acsObject
ci = (ContentItem) acsObject; ci = (ContentItem) acsObject;
@ -299,6 +301,7 @@ public class Link extends ACSObject {
* @return the Link URI * @return the Link URI
*/ */
public String getInternalOrExternalURI(PageState state) { public String getInternalOrExternalURI(PageState state) {
if (EXTERNAL_LINK.equals(getTargetType())) { if (EXTERNAL_LINK.equals(getTargetType())) {
return getTargetURI(); return getTargetURI();
} else { } else {
@ -400,7 +403,8 @@ public class Link extends ACSObject {
swapKeys(true, queryName, operationName, ""); swapKeys(true, queryName, operationName, "");
} }
public void swapWithNext(String queryName, String operationName, String linkListName) { public void swapWithNext(String queryName, String operationName,
String linkListName) {
swapKeys(true, queryName, operationName, linkListName); swapKeys(true, queryName, operationName, linkListName);
} }
@ -417,7 +421,8 @@ public class Link extends ACSObject {
swapKeys(false, queryName, operationName, ""); swapKeys(false, queryName, operationName, "");
} }
public void swapWithPrevious(String queryName, String operationName, String linkListName) { public void swapWithPrevious(String queryName, String operationName,
String linkListName) {
swapKeys(false, queryName, operationName, linkListName); swapKeys(false, queryName, operationName, linkListName);
} }
@ -493,6 +498,8 @@ public class Link extends ACSObject {
int otherKey = key; int otherKey = key;
if (swapNext) { if (swapNext) {
otherKey = key + 1; otherKey = key + 1;
query.addOrder("linkOrder ASC"); query.addOrder("linkOrder ASC");

View File

@ -50,7 +50,6 @@ import com.arsdigita.cms.dispatcher.Utilities;
* @version $Revision: #6 $ $Date: 2004/08/17 $ * @version $Revision: #6 $ $Date: 2004/08/17 $
* @author Nobuko Asakai (nasakai@redhat.com) * @author Nobuko Asakai (nasakai@redhat.com)
*/ */
public class LinkTable extends Table { public class LinkTable extends Table {
private static final Logger s_log = Logger.getLogger(LinkTable.class); private static final Logger s_log = Logger.getLogger(LinkTable.class);
@ -62,11 +61,8 @@ public class LinkTable extends Table {
private TableColumn m_moveDownCol; private TableColumn m_moveDownCol;
private TableColumn m_editCol; private TableColumn m_editCol;
private TableColumn m_delCol; private TableColumn m_delCol;
private RequestLocal m_size; private RequestLocal m_size;
private RequestLocal m_editor; private RequestLocal m_editor;
protected static final String EDIT_EVENT = "Edit"; protected static final String EDIT_EVENT = "Edit";
protected static final String DELETE_EVENT = "Delete"; protected static final String DELETE_EVENT = "Delete";
protected static final String UP_EVENT = "up"; protected static final String UP_EVENT = "up";
@ -90,15 +86,15 @@ public class LinkTable extends Table {
m_size = new RequestLocal(); m_size = new RequestLocal();
m_editor = new RequestLocal() { m_editor = new RequestLocal() {
public Object initialValue(PageState state) { public Object initialValue(PageState state) {
SecurityManager sm = Utilities.getSecurityManager(state); SecurityManager sm = Utilities.getSecurityManager(state);
ContentItem item = (ContentItem)m_itemModel ContentItem item = (ContentItem) m_itemModel.getSelectedObject(
.getSelectedObject(state); state);
Boolean val = new Boolean(sm.canAccess( Boolean val = new Boolean(sm.canAccess(
state.getRequest(), state.getRequest(),
SecurityManager.EDIT_ITEM, SecurityManager.EDIT_ITEM,
item item));
));
return val; return val;
} }
}; };
@ -135,6 +131,7 @@ public class LinkTable extends Table {
* TableCellRenderer class for LinkTable * TableCellRenderer class for LinkTable
*/ */
private class LinkTableRenderer implements TableCellRenderer { private class LinkTableRenderer implements TableCellRenderer {
public Component getComponent(Table table, public Component getComponent(Table table,
PageState state, PageState state,
Object value, Object value,
@ -146,13 +143,14 @@ public class LinkTable extends Table {
boolean isFirst = (row == 0); boolean isFirst = (row == 0);
if (m_size.get(state) == null) { if (m_size.get(state) == null) {
m_size.set(state, m_size.set(state,
new Long(((LinkTableModelBuilder.LinkTableModel) new Long(((LinkTableModelBuilder.LinkTableModel) table.
table.getTableModel(state)).size())); getTableModel(state)).size()));
} }
boolean isLast = (row == ((Long) m_size.get(state)).intValue() - 1); boolean isLast = (row == ((Long) m_size.get(state)).intValue() - 1);
String url = link.getInternalOrExternalURI(state);
if (column == m_titleCol.getModelIndex()) { if (column == m_titleCol.getModelIndex()) {
String url = link.getInternalOrExternalURI(state);
ExternalLink extLink = new ExternalLink(link.getTitle(), url); ExternalLink extLink = new ExternalLink(link.getTitle(), url);
extLink.setTargetFrame("_blank"); extLink.setTargetFrame("_blank");
return extLink; return extLink;
@ -204,6 +202,7 @@ public class LinkTable extends Table {
* TableActionListener class for LinkTable * TableActionListener class for LinkTable
*/ */
private class LinkTableActionListener implements TableActionListener { private class LinkTableActionListener implements TableActionListener {
private Link getLink(TableActionEvent e) { private Link getLink(TableActionEvent e) {
Object o = e.getRowKey(); Object o = e.getRowKey();
BigDecimal id; BigDecimal id;
@ -217,7 +216,8 @@ public class LinkTable extends Table {
Assert.exists(id); Assert.exists(id);
Link link; Link link;
try { try {
link = (Link)DomainObjectFactory.newInstance(new OID(Link.BASE_DATA_OBJECT_TYPE,id)); link = (Link) DomainObjectFactory.newInstance(new OID(
Link.BASE_DATA_OBJECT_TYPE, id));
} catch (DataObjectNotFoundException de) { } catch (DataObjectNotFoundException de) {
throw new UncheckedWrapperException(de); throw new UncheckedWrapperException(de);
} }
@ -259,6 +259,7 @@ public class LinkTable extends Table {
} }
} }
public void headSelected(TableActionEvent e) {} public void headSelected(TableActionEvent e) {
}
} }
} }

View File

@ -36,13 +36,12 @@ import org.apache.log4j.Logger;
* @version $Revision: #4 $ $Date: 2004/08/17 $ * @version $Revision: #4 $ $Date: 2004/08/17 $
* @author Nobuko Asakai (nasakai@redhat.com) * @author Nobuko Asakai (nasakai@redhat.com)
*/ */
public abstract class LinkTableModelBuilder public abstract class LinkTableModelBuilder
extends LockableImpl implements TableModelBuilder { extends LockableImpl implements TableModelBuilder {
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger(LinkTableModelBuilder.class); Logger.getLogger(LinkTableModelBuilder.class);
/** /**
* Creates the LinKTableModel based on the current table and pagestate * Creates the LinKTableModel based on the current table and pagestate
* *
@ -78,15 +77,22 @@ public abstract class LinkTableModelBuilder
Link m_link; Link m_link;
DataCollection m_links; DataCollection m_links;
public LinkTableModel(DataCollection links) { public LinkTableModel(DataCollection links) {
m_links = links; m_links = links;
m_link = null; m_link = null;
} }
public boolean nextRow() { public boolean nextRow() {
s_log.debug(String.format("m_links.size() = %d", m_links.size()));
if (m_links.next()) { if (m_links.next()) {
s_log.debug("Getting domain object for link...");
long now = System.currentTimeMillis();
DataObject object = m_links.getDataObject(); DataObject object = m_links.getDataObject();
m_link = (Link) DomainObjectFactory.newInstance(object); m_link = (Link) DomainObjectFactory.newInstance(object);
s_log.debug(String.format("Got domain object in %d ms", System.
currentTimeMillis() - now));
return true; return true;
} else { } else {
return false; return false;
@ -105,6 +111,7 @@ public abstract class LinkTableModelBuilder
public Object getKeyAt(int columnIndex) { public Object getKeyAt(int columnIndex) {
return m_link.getID(); return m_link.getID();
} }
public long size() { public long size() {
return m_links.size(); return m_links.size();
} }

View File

@ -38,6 +38,7 @@ import com.arsdigita.util.Assert;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.util.Iterator; import java.util.Iterator;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import org.apache.log4j.Logger;
/** /**
* Displays statically or * Displays statically or
@ -92,45 +93,33 @@ import javax.servlet.ServletException;
*/ */
public class Table extends BlockStylable implements BebopConstants { public class Table extends BlockStylable implements BebopConstants {
private static final Logger logger = Logger.getLogger(Table.class);
// Names for HTML Attributes // Names for HTML Attributes
private static final String WIDTH = "width"; private static final String WIDTH = "width";
private static final String CELL_SPACING = "cellspacing"; private static final String CELL_SPACING = "cellspacing";
private static final String CELL_PADDING = "cellpadding"; private static final String CELL_PADDING = "cellpadding";
private static final String BORDER = "border"; private static final String BORDER = "border";
private static final String SELECTED_ROW = "row"; private static final String SELECTED_ROW = "row";
/** /**
* The control event when the user selects one table cell. * The control event when the user selects one table cell.
* This control event will only be used when * This control event will only be used when
*/ */
protected static final String CELL_EVENT = "cell"; protected static final String CELL_EVENT = "cell";
protected static final char SEP = ' '; protected static final char SEP = ' ';
private TableModelBuilder m_modelBuilder; private TableModelBuilder m_modelBuilder;
private TableColumnModel m_columnModel; private TableColumnModel m_columnModel;
private TableHeader m_header; private TableHeader m_header;
private RequestLocal m_tableModel; private RequestLocal m_tableModel;
private SingleSelectionModel m_rowSelectionModel; private SingleSelectionModel m_rowSelectionModel;
/** /**
* A listener to forward headSelected events originating from the * A listener to forward headSelected events originating from the
* TableHeader. This will be null until somebody actually registers a * TableHeader. This will be null until somebody actually registers a
* TableActionListener from the outside. * TableActionListener from the outside.
*/ */
private TableActionListener m_headerForward; private TableActionListener m_headerForward;
private EventListenerList m_listeners; private EventListenerList m_listeners;
private TableCellRenderer m_defaultCellRenderer; private TableCellRenderer m_defaultCellRenderer;
private Component m_emptyView; private Component m_emptyView;
private boolean m_striped = false; private boolean m_striped = false;
/** /**
@ -191,7 +180,6 @@ public class Table extends BlockStylable implements BebopConstants {
} }
// Events and listeners // Events and listeners
/** /**
* Adds a {@link TableActionListener} to the table. The listener is * Adds a {@link TableActionListener} to the table. The listener is
* fired whenever a table cell is clicked. * fired whenever a table cell is clicked.
@ -209,7 +197,6 @@ public class Table extends BlockStylable implements BebopConstants {
m_listeners.add(TableActionListener.class, l); m_listeners.add(TableActionListener.class, l);
} }
/** /**
* Removes a {@link TableActionListener} from the table. * Removes a {@link TableActionListener} from the table.
* *
@ -230,8 +217,7 @@ public class Table extends BlockStylable implements BebopConstants {
*/ */
protected void fireCellSelected(PageState state, protected void fireCellSelected(PageState state,
Object rowKey, Integer column) { Object rowKey, Integer column) {
Iterator Iterator i = m_listeners.getListenerIterator(TableActionListener.class);
i=m_listeners.getListenerIterator(TableActionListener.class);
TableActionEvent e = null; TableActionEvent e = null;
while (i.hasNext()) { while (i.hasNext()) {
@ -252,8 +238,7 @@ public class Table extends BlockStylable implements BebopConstants {
*/ */
protected void fireHeadSelected(PageState state, protected void fireHeadSelected(PageState state,
Object rowKey, Integer column) { Object rowKey, Integer column) {
Iterator Iterator i = m_listeners.getListenerIterator(TableActionListener.class);
i=m_listeners.getListenerIterator(TableActionListener.class);
TableActionEvent e = null; TableActionEvent e = null;
while (i.hasNext()) { while (i.hasNext()) {
@ -264,7 +249,6 @@ public class Table extends BlockStylable implements BebopConstants {
} }
} }
/** /**
* Instantiates a new {@link TableActionListener} for this table. * Instantiates a new {@link TableActionListener} for this table.
* *
@ -274,13 +258,13 @@ public class Table extends BlockStylable implements BebopConstants {
*/ */
protected TableActionListener createTableActionListener() { protected TableActionListener createTableActionListener() {
return new TableActionAdapter() { return new TableActionAdapter() {
public void headSelected(TableActionEvent e) { public void headSelected(TableActionEvent e) {
fireHeadSelected(e.getPageState(), e.getRowKey(), e.getColumn()); fireHeadSelected(e.getPageState(), e.getRowKey(), e.getColumn());
} }
}; };
} }
/** /**
* @return the {@link TableColumnModel} for this table. * @return the {@link TableColumnModel} for this table.
*/ */
@ -389,8 +373,8 @@ public class Table extends BlockStylable implements BebopConstants {
* for selecting the current column. * for selecting the current column.
*/ */
public SingleSelectionModel getColumnSelectionModel() { public SingleSelectionModel getColumnSelectionModel() {
return ( getColumnModel() == null ) ? null : return (getColumnModel() == null) ? null : getColumnModel().
getColumnModel().getSelectionModel(); getSelectionModel();
} }
/** /**
@ -443,7 +427,6 @@ public class Table extends BlockStylable implements BebopConstants {
return m_emptyView; return m_emptyView;
} }
/** /**
* Sets the empty view. The empty view is the component that * Sets the empty view. The empty view is the component that
* is shown if the table is empty. Usually, the component * is shown if the table is empty. Usually, the component
@ -456,7 +439,6 @@ public class Table extends BlockStylable implements BebopConstants {
} }
// Set HTML table attributes // Set HTML table attributes
/** /**
* *
* @return the HTML width of the table. * @return the HTML width of the table.
@ -489,7 +471,6 @@ public class Table extends BlockStylable implements BebopConstants {
setAttribute(BORDER, v); setAttribute(BORDER, v);
} }
public String getCellSpacing() { public String getCellSpacing() {
return getAttribute(CELL_SPACING); return getAttribute(CELL_SPACING);
} }
@ -552,11 +533,13 @@ public class Table extends BlockStylable implements BebopConstants {
* @param p the page that contains this table * @param p the page that contains this table
*/ */
public void register(Page p) { public void register(Page p) {
ParameterModel m = getRowSelectionModel() == null ? null : getRowSelectionModel().getStateParameter(); ParameterModel m = getRowSelectionModel() == null ? null
: getRowSelectionModel().getStateParameter();
if (m != null) { if (m != null) {
p.addComponentStateParam(this, m); p.addComponentStateParam(this, m);
} }
m = getColumnSelectionModel() == null ? null : getColumnSelectionModel().getStateParameter(); m = getColumnSelectionModel() == null ? null : getColumnSelectionModel().
getStateParameter();
if (m != null) { if (m != null) {
p.addComponentStateParam(this, m); p.addComponentStateParam(this, m);
} }
@ -571,6 +554,7 @@ public class Table extends BlockStylable implements BebopConstants {
*/ */
public Iterator children() { public Iterator children() {
return new Iterator() { return new Iterator() {
int pos = (getHeader() == null) ? -1 : -2; int pos = (getHeader() == null) ? -1 : -2;
public boolean hasNext() { public boolean hasNext() {
@ -644,7 +628,6 @@ public class Table extends BlockStylable implements BebopConstants {
return isSelectedRow(s, rowKey) && isSelectedColumn(s, column); return isSelectedRow(s, rowKey) && isSelectedColumn(s, column);
} }
public void setStriped(boolean striped) { public void setStriped(boolean striped) {
m_striped = striped; m_striped = striped;
} }
@ -711,8 +694,13 @@ public class Table extends BlockStylable implements BebopConstants {
final int modelSize = getColumnModel().size(); final int modelSize = getColumnModel().size();
int row = 0; int row = 0;
logger.debug("Creating table rows...");
long start = System.currentTimeMillis();
do { do {
Element trow = tbody.newChildElement(BEBOP_TABLEROW, BEBOP_XML_NS); long rowStart = System.currentTimeMillis();
Element trow = tbody.newChildElement(BEBOP_TABLEROW,
BEBOP_XML_NS);
for (int i = 0; i < modelSize; i++) { for (int i = 0; i < modelSize; i++) {
@ -725,22 +713,43 @@ public class Table extends BlockStylable implements BebopConstants {
final int modelIndex = tc.getModelIndex(); final int modelIndex = tc.getModelIndex();
Object key = model.getKeyAt(modelIndex); Object key = model.getKeyAt(modelIndex);
Object value = model.getElementAt(modelIndex); Object value = model.getElementAt(modelIndex);
boolean selected = isSelectedCell(s, key, new Integer(i)); boolean selected =
isSelectedCell(s, key, new Integer(i));
if (tableIsRegisteredWithPage) { if (tableIsRegisteredWithPage) {
StringBuffer coords = new StringBuffer(40); /*StringBuffer coords = new StringBuffer(40);
coords.append(model.getKeyAt(modelIndex)) coords.append(model.getKeyAt(modelIndex)).append(SEP).
.append(SEP).append(i); append(i);
s.setControlEvent(getControler(), CELL_EVENT, s.setControlEvent(getControler(), CELL_EVENT,
coords.toString()); coords.toString());*/
s.setControlEvent(getControler(),
CELL_EVENT,
String.format("%s%s%d",
model.getKeyAt(
modelIndex),
SEP,
i));
} }
Element cell = trow.newChildElement(BEBOP_CELL, BEBOP_XML_NS);
Element cell = trow.newChildElement(BEBOP_CELL,
BEBOP_XML_NS);
tc.exportCellAttributes(cell); tc.exportCellAttributes(cell);
r.getComponent(this, s, value, selected, key, row, i) long begin = System.currentTimeMillis();
.generateXML(s, cell); r.getComponent(this, s, value, selected, key, row, i).
generateXML(s, cell);
logger.debug(String.format("until here i needed %d ms",
System.currentTimeMillis()
- begin));
} }
} }
row += 1; row += 1;
logger.debug(
String.format("Created row in %d ms",
System.currentTimeMillis() - rowStart));
} while (model.nextRow()); } while (model.nextRow());
logger.debug(String.format("Build table rows in %d ms",
System.currentTimeMillis() - start));
} else if (m_emptyView != null) { } else if (m_emptyView != null) {
m_emptyView.generateXML(s, p); m_emptyView.generateXML(s, p);
} }
@ -771,6 +780,7 @@ public class Table extends BlockStylable implements BebopConstants {
*/ */
private void initTableModel() { private void initTableModel() {
m_tableModel = new RequestLocal() { m_tableModel = new RequestLocal() {
protected Object initialValue(PageState s) { protected Object initialValue(PageState s) {
return m_modelBuilder.makeModel(Table.this, s); return m_modelBuilder.makeModel(Table.this, s);
} }
@ -809,6 +819,7 @@ public class Table extends BlockStylable implements BebopConstants {
public TableModel makeModel(Table t, PageState s) { public TableModel makeModel(Table t, PageState s) {
return new TableModel() { return new TableModel() {
private int row = -1; private int row = -1;
public int getColumnCount() { public int getColumnCount() {
@ -829,8 +840,6 @@ public class Table extends BlockStylable implements BebopConstants {
}; };
} }
} }
/** /**
* A {@link TableModel} that has no rows. * A {@link TableModel} that has no rows.
*/ */
@ -852,5 +861,4 @@ public class Table extends BlockStylable implements BebopConstants {
throw new IllegalStateException("TableModel is empty"); throw new IllegalStateException("TableModel is empty");
} }
}; };
} }