table.getFlexCellFormatter().setColSpan(row, 0, this.columns.length);
table.getRowFormatter().setStyleName(row, "spacer");
row++;
}
Binding bindingRow = new Binding();
topBinding.getChildren().add(bindingRow);
int count = topBinding.getChildren().size();
final Button handle;
int startColumn = 0;
if ((this.masks & BoundTable.ROW_HANDLE_MASK) > 0) {
handle = new Button((this.getActive() && (rowHandles.size() < 9))
? Integer.toString(this.rowHandles.size() + 1) : " ");
handle.setStyleName("rowHandle");
handle.addFocusListener(new FocusListener() {
public void onFocus(Widget sender) {
if (shiftDown) {
return;
}
setActive(true);
List newSelected = null;
if ((masks & BoundTable.MULTIROWSELECT_MASK) > 0) {
newSelected = new ArrayList(getSelected());
if (newSelected.contains(o)) {
newSelected.remove(o);
} else {
newSelected.add(o);
}
} else {
newSelected = new ArrayList();
newSelected.add(o);
}
setSelected(newSelected);
}
public void onLostFocus(Widget sender) {
}
});
handle.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
setActive(true);
List newSelected = null;
if ((masks & BoundTable.MULTIROWSELECT_MASK) > 0) {
newSelected = new ArrayList(getSelected());
if (newSelected.contains(o)) {
newSelected.remove(o);
} else {
newSelected.add(o);
}
} else {
newSelected = new ArrayList();
newSelected.add(o);
}
if (handle != null) {
handle.setFocus(true);
}
if (handle != null) {
handle.setFocus(true);
}
setSelected(newSelected);
}
});
startColumn++;
this.rowHandles.add(handle);
this.table.setWidget(row, 0, handle);
} else {
handle = null;
}
if (count < 10) {
SuggestedKeyBinding kb = new SuggestedKeyBinding(Integer.toString(
count).charAt(0), false, true, false);
Task task = new Task() {
public void run() {
List newSelected = new ArrayList(getSelected());
if (newSelected.contains(o)) {
newSelected.remove(o);
} else {
newSelected.add(o);
}
setSelected(newSelected);
if (handle != null) {
handle.setFocus(true);
}
}
};
this.keyBindings.put(kb, task);
if (this.getActive()) {
try {
KeyboardController.INSTANCE.register(kb, task);
} catch (KeyBindingException kbe) {
BoundTable.LOG.log(Level.DEBUG, "Unable to register" + kb,
kbe);
}
}
}
for (int col = 0; col < this.columns.length; col++) {
Widget widget = (Widget) createCellWidget(bindingRow, col, o);
try {
table.setWidget(row, col + startColumn, widget);
if (widget instanceof HasFocus) {
addSelectedFocusListener((HasFocus) widget,
topBinding.getChildren().size() - 1, col + startColumn);
}
if (widget instanceof SourcesClickEvents) {
addSelectedClickListener((SourcesClickEvents) widget,
topBinding.getChildren().size() - 1, col + startColumn);
}
if (this.columns[col].getStyleName() != null) {
table.getCellFormatter().setStyleName(row, col + startColumn,
this.columns[col].getStyleName());
}
} catch (RuntimeException e) {
BoundTable.LOG.log(Level.ERROR, widget + "", e);
}
}
boolean odd = (this.calculateRowToObjectOffset(new Integer(row)).intValue() % 2) != 0;
this.table.getRowFormatter().setStyleName(row, odd ? "odd" : "even");
if (this.isAttached()) {
bindingRow.setLeft();
bindingRow.bind();
}
}