EPNG PageableSortable firefox bug

Hi everyone i know it's been a while since echo team stop supporting echo2 but anyway here is my problem, ive created a table using EPNG library (PageableSortableTable, DefaultPageableSortableTableModel for the model and so on...) i added a rowselection action to it, and i have some components within the table, so, when i push a button its like the table listen to the rowselection action instead the button click, this behavior only occurs when i launch my app with FireFox(all versions) if i launch with IE 7.0 everything is fine. does someone has been through this ?

i want to know if there is a patch to fix it? ive attached a photo for you to have a better idea what im trying to explain...

and here is the code:

package com.sigesp.base.componentes.obelisco;

public class TablaDatosSimple extends ContainerEx {

private static final long serialVersionUID = 1L;
private PageableSortableTable tabla;
private AbstractTableAdapter adapter;
private DefaultPageableSortableTableModel modeloTabla;
private PageableTableNavigation tableScroller;
private DefaultListSelectionModel defaultListSelectionModel;
private final Vector listeners = new Vector();
// private int filaSeleccionada = -1;
private Component container;
private Object claseEjecutar;
private String metodoEjecutar;
private final ResourceBundle resource = ResourceBundle
.getBundle("com.sigesp.base.properties.MensajesObelisco");

private Catalogo catalogo;

public TablaDatosSimple() {
super();
initComponents();

}

int click = 0;
Object objetoAnterior = null;
// Se activa cuando alguien selecciona una fila de la Tabla
public ActionListener tablaActionListener = new ActionListener() {

public void actionPerformed(ActionEvent e) {

Object objeto = getFilasSeleccionadas();

System.out.println("Indice: " + getIndice());

if (e.getSource().equals(tabla)) {

if (objeto instanceof List) {
distribuirSeleccion((List) objeto);
} else {
distribuirSeleccion(objeto);
}

if (claseEjecutar != null)
if (objetoAnterior == null || objeto.equals(objetoAnterior)) {
if (click > 0) {
try {
MethodUtils.invokeMethod(claseEjecutar,
metodoEjecutar, null);
} catch (Exception ex) {
System.out.println("Error " + ex);
}
click = 0;
objetoAnterior = null;
} else {
click++;

objetoAnterior = objeto;
}
} else {
objetoAnterior = objeto;
}

}
}

};

private final TableModelListener tableModelListener = new TableModelListener() {

private boolean isSorted = false;

List listaSeleccionados = new ArrayList();

public void tableChanged(TableModelEvent event) {

if (hayFilasSeleccionadas()) {

if (!isSorted) {
isSorted = true;
listaSeleccionados.clear();
for (int i = tabla.getSelectionModel()
.getMinSelectedIndex(); i <= tabla
.getSelectionModel().getMaxSelectedIndex(); i++) {
if (tabla.getSelectionModel().isSelectedIndex(i)) {
Integer indice = new Integer(i);
listaSeleccionados.add(indice);
}
}
}

if (modeloTabla.getCurrentSortColumn() == -1) {
isSorted = false;
}

defaultListSelectionModel.clearSelection();
for (int i = 0; i < listaSeleccionados.size(); i++) {
int indiceInt = ((Integer) listaSeleccionados.get(i))
.intValue();
if (isSorted) {
defaultListSelectionModel.setSelectedIndex(modeloTabla
.toSortedViewRowIndex(indiceInt), true);
} else {
defaultListSelectionModel.setSelectedIndex(indiceInt,
true);
}
}

}
}
};

private final SortableTableHeaderRenderer encabezadoTableCellRenderer = new SortableTableHeaderRenderer() {

private ImageReference upArrowImage = new ResourceImageReference(
"/echopointng/resource/images/ArrowUp.gif");

private ImageReference downArrowImage = new ResourceImageReference(
"/echopointng/resource/images/ArrowDown.gif");

private Insets insets = new Insets(1);

private TableLayoutData layoutData = new TableLayoutData();

@Override
protected Button getSortButton(String label, int column,
SortableTableModel model) {

ImageReference icon = null;
if (model.getCurrentSortColumn() == column) {
int sortDirective = model.getSortDirective(column);
if (sortDirective == SortableTableModel.ASCENDING) {
icon = upArrowImage;
} else if (sortDirective == SortableTableModel.DESCENDING) {
icon = downArrowImage;
} else {
icon = null;
}
}
Button button = new Button(icon);
button.setStyleName("Obelisco.Boton.TablaDatos");
button.setText(label);
button.addActionListener(getSortButtonListener(column, model));
button.setTextPosition(new Alignment(Alignment.LEFT,
Alignment.DEFAULT));

return button;
}

};

private final TableCellRenderer tableCellRenderer = new TableCellRenderer() {

private static final long serialVersionUID = 1L;

public Component getTableCellRendererComponent(Table table,
Object value, int column, int row) {
TableLayoutData layoutData = new TableLayoutData();
layoutData.setInsets(new Insets(new Extent(15, Extent.PX),
new Extent(1, Extent.PX), new Extent(5, Extent.PX),
new Extent(1, Extent.PX)));

Alignment alineacion = new Alignment(Alignment.DEFAULT,
Alignment.DEFAULT);

Object objeto = adapter.getRow(row);

Component componente = distribuirDibujarCelda(objeto, value, row,
column, alineacion);

if (componente == null) {

String nombreEstilo = getRowStyle(row);

Label label;
if (value != null) {
if (value.toString().length() > 80) {
label = new Label(value.toString().substring(0, 79)
+ "...");
label.setFont(new Font(Font.VERDANA, 0, new Extent(10,
Extent.PX)));
label.setToolTipText(value.toString());
if (value.toString().equals(null)
|| value.toString().trim().equalsIgnoreCase("")) {
label = new Label("No Contiene Data");
}
} else
label = new Label(value.toString());
label.setFont(new Font(Font.VERDANA, 0, new Extent(10,
Extent.PX)));
// Hasta aca
} else {
label = new Label("");
}
componente = label;

layoutData.setAlignment(alineacion);
componente.setLayoutData(layoutData);

} else {

layoutData.setAlignment(alineacion);
componente.setLayoutData(layoutData);
}

return componente;
}
};

private void initComponents() {

container = new Column();

tabla = new PageableSortableTable();
tabla.setDefaultHeaderRenderer(encabezadoTableCellRenderer);
tabla.setHeaderBackground(new Color(0xb70c0c));
tabla.addActionListener(tablaActionListener);

defaultListSelectionModel = new DefaultListSelectionModel();
tabla.setSelectionModel(defaultListSelectionModel);

defaultListSelectionModel
.setSelectionMode(ListSelectionModel.MULTIPLE_SELECTION);
// tabla.setBorder(new Border(1, Color.BLACK, Border.STYLE_SOLID));
tabla.setStyleName("Obelisco.TablaDatos");
// tabla.setBorder(new BorderEx());
tabla.setHeight(new ExtentEx("90%"));
tabla.setWidth(new ExtentEx("100%"));
add(container);
}

class GenericTableModel extends AbstractTableAdapter {

private static final long serialVersionUID = 1L;

ListModel listModel;

String[] headers = {};

String[] fields = {};

public GenericTableModel(ListModel listModel, String[] headers,
String[] fields) {
super(listModel, headers);
this.listModel = listModel;
this.headers = headers;
this.fields = fields;
}

public Object getValueAt(int columnIndex, int rowIndex) {
Object objeto = getRow(rowIndex);
try {
String atributo = fields[columnIndex];
// Object valor = PropertyUtils
// .getSimpleProperty(objeto, atributo);

Object valor = PropertyUtils
.getNestedProperty(objeto, atributo);

return valor;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

public void setItems(List items, Map camposMostrar) {

SelectionInList selectionInList = new SelectionInList(items);

String[] headers = new String[camposMostrar.size()];
String[] fields = new String[camposMostrar.size()];
camposMostrar.keySet().toArray(headers);
camposMostrar.values().toArray(fields);

GenericTableModel model = new GenericTableModel(selectionInList,
headers, fields);
setAdapter(model);

}

public AbstractTableAdapter getAdapter() {
return adapter;
}

public void setAdapter(AbstractTableAdapter adapter) {

this.adapter = adapter;
container.removeAll();

if ((adapter != null) && (adapter.getRowCount() != 0)) {
container.add(tabla);

modeloTabla = new DefaultPageableSortableTableModel(adapter);
modeloTabla.addTableModelListener(tableModelListener);
modeloTabla.setRowsPerPage(10);
modeloTabla.setCurrentPage(0);
tabla.setModel(modeloTabla);
tabla.setDefaultRenderer(Object.class, tableCellRenderer);

tableScroller = new PageableTableNavigation(tabla);
Alignment alineacion = new Alignment(Alignment.CENTER,
Alignment.TOP);
tableScroller.setAlignment(alineacion);
container.add(tableScroller);

TableColumnModel modeloColumna = tabla.getColumnModel();
for (int i = 0; i < adapter.getColumnCount(); i++) {
TableColumn columna = modeloColumna.getColumn(i);
columna.setHeaderRenderer(encabezadoTableCellRenderer);
}

} else {

Label lblSinDatos = new Label(resource.getString("nohaydatos"));
lblSinDatos.setFont(new Font(null, 1, new Extent(12)));
lblSinDatos.setForeground(Color.LIGHTGRAY);
ColumnLayoutData layoutData = new ColumnLayoutData();
layoutData.setInsets(new Insets(null,
new Extent(20, Extent.PERCENT), null, null));
Alignment alineacion = new Alignment(Alignment.CENTER,
Alignment.CENTER);
layoutData.setAlignment(alineacion);
lblSinDatos.setLayoutData(layoutData);
container.add(lblSinDatos);

}
}

public void setFilasSeleccionadas(List listaObjetos) {

for (int i = 0; i < listaObjetos.size(); i++) {
boolean isIgual = false;
int posicion = 0;
for (int j = 0; j < adapter.getRowCount(); j++) {
Object objeto = adapter.getRow(j);
if (objeto.equals(listaObjetos.get(i))) {
isIgual = true;
posicion = j;
}
}

if (isIgual) {
defaultListSelectionModel.setSelectedIndex(posicion, true);
}

}

}

public Object getFilasSeleccionadas() {
List seleccionados = new ArrayList();
if (tabla.getSelectionModel().getMinSelectedIndex() >= 0) {
if (!isSeleccionMultiple()) {
int currentRowPageIndex = tabla.getSelectionModel()
.getMinSelectedIndex();
int currentPage = tableScroller.getModel().getCurrentPage();

int currentRowsPerPage = tableScroller.getModel()
.getRowsPerPage();

int efectiveRow = (currentRowsPerPage * currentPage)
+ currentRowPageIndex;

return adapter.getRow(modeloTabla
.toUnsortedModelRowIndex(efectiveRow));

} else {
for (int i = tabla.getSelectionModel().getMinSelectedIndex(); i <= tabla
.getSelectionModel().getMaxSelectedIndex(); i++) {
if (tabla.getSelectionModel().isSelectedIndex(i)) {

int currentRowPageIndex = i;
int currentPage = tableScroller.getModel()
.getCurrentPage();
int currentRowsPerPage = tableScroller.getModel()
.getRowsPerPage();

int efectiveRow = (currentRowsPerPage * currentPage)
+ currentRowPageIndex;
seleccionados.add(adapter.getRow(modeloTabla
.toUnsortedModelRowIndex(efectiveRow)));
}
}
}
return seleccionados;
} else {
return null;
}
}

public void setSelectionEnabled(boolean selectionEnabled) {
tabla.setSelectionEnabled(selectionEnabled);
}

public boolean isSelectionEnabled() {
return tabla.isSelectionEnabled();
}

public void clearSelection() {
tabla.getSelectionModel().clearSelection();
}

public boolean hayFilasSeleccionadas() {
if (tabla.getSelectionModel().getMinSelectedIndex() >= 0) {
return true;
} else {
return false;
}
}

public void addTablaDatosActionListener(
ActionListener tablaDatosActionListener) {
tabla.addActionListener(tablaDatosActionListener);
}

public void setSeleccionMultiple(boolean modo) {
if (modo) {
defaultListSelectionModel
.setSelectionMode(DefaultListSelectionModel.MULTIPLE_SELECTION);
} else {
defaultListSelectionModel
.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
}
}

public boolean isSeleccionMultiple() {
return defaultListSelectionModel.getSelectionMode() == DefaultListSelectionModel.MULTIPLE_SELECTION;
}

public Component getComponente(int fila, int columna) {
Component componente = tabla.getCellComponent(columna, fila);
return componente;
}

private String getRowStyle(int r) {
String nombreEstilo = "";
if (r % 2 == 0) {
nombreEstilo = "Obelisco.TablaDatos.Par";
} else {
nombreEstilo = "Obelisco.TablaDatos.Impar";
}
return nombreEstilo;
}

public void addTablaDatosListener(TablaDatosListener listener) {
listeners.add(listener);
}

public void removeTablaDatosListener(TablaDatosListener listener) {
listeners.remove(listener);
}

public void distribuirSeleccion(Object objeto) {
for (TablaDatosListener l : listeners) {
l.seleccionObjeto(objeto);
}
// TODO EVENTO CLICK
}

public void distribuirSeleccion(List objetos) {
for (TablaDatosListener l : listeners) {
l.seleccionObjeto(objetos);
}
}

public Component distribuirDibujarCelda(Object objeto, Object value,
int fila, int columna, Alignment alineacion) {
Component aDibujar = null;
for (TablaDatosListener l : listeners) {
aDibujar = l.onDibujarCelda(objeto, value, fila, columna,
alineacion);
}
return aDibujar;
}

public int getIndice() {
int currentRowPageIndex = tabla.getSelectionModel()
.getMinSelectedIndex();
int currentPage = tableScroller.getModel().getCurrentPage();

int currentRowsPerPage = tableScroller.getModel().getRowsPerPage();

int efectiveRow = (currentRowsPerPage * currentPage)
+ currentRowPageIndex;

return efectiveRow;
}

public Object getClaseEjecutar() {
return claseEjecutar;
}

public void setClaseEjecutar(Object claseEjecutar) {
this.claseEjecutar = claseEjecutar;
}

public String getMetodoEjecutar() {
return metodoEjecutar;
}

public void setMetodoEjecutar(String metodoEjecutar) {
this.metodoEjecutar = metodoEjecutar;
}

public DefaultPageableSortableTableModel getModeloTabla() {
return modeloTabla;
}

}

best regards

Rafael Cadenas.

rakesh's picture

EPNG is abandonware. The

EPNG is abandonware. The original developers have long since left the project. Those of us who created EchoPoint for Echo3 do not have any plans to support EPNG (sorry). Your best bet is to try and patch the sources yourself.

what about

what about if i port all my components to echo3 and echopoint3 ? if it is posible would be quite better cuz modifying the core echo2 its a hard work to do for my experience!!! :(

rakesh's picture

It depends upon whether the

It depends upon whether the component list is as rich as what you want. The benefit is that authoring custom components is much easier with Echo3 (can be quite trivial depending upon what you want to do). I would suggest that you look at the Echo3, Extras and EchoPoint API docs and make a determination as to whether you can move. We have not ported the EPNG table over, since Tod was planning to write an advanced table component that combined features of live table and table. The stock table (and tree for that matter) is quite limited in capability. People have done closed source solutions by using jQuery table implementations with Echo3. There are some jQuery based components in EchoPoint if you want to take a stab at it. If you do decide to upgrade and plan on developing some core components, please consider contributing to EchoPoint so everyone can benefit from your work.

Good luck...