Dépôt officiel du code source de l'ERP OpenConcerto
/trunk/OpenConcerto/src/org/openconcerto/ui/light/LightUITable.java |
---|
18,10 → 18,6 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionListener; |
import java.io.Externalizable; |
import java.io.IOException; |
import java.io.ObjectInput; |
import java.io.ObjectOutput; |
import java.util.ArrayList; |
import java.util.List; |
33,7 → 29,7 |
import net.minidev.json.JSONArray; |
import net.minidev.json.JSONObject; |
public class LightUITable extends LightUserControlContainer implements Externalizable { |
public class LightUITable extends LightUserControlContainer { |
public static final int DEFAULT_LINE_HEIGHT = 40; |
49,7 → 45,7 |
private Boolean autoSelectFirstLine = true; |
private TableSpec tableSpec = null; |
private transient List<ActionListener> selectionListeners = new ArrayList<ActionListener>(); |
private transient List<ActionListener> selectionListeners = new ArrayList<>(); |
// Nombre de ligne à afficher par Row |
private int linePerRow = 1; |
81,10 → 77,8 |
final RowSelectionSpec selection = new RowSelectionSpec(this.getId()); |
final ColumnsSpec columnsSpec = new ColumnsSpec(this.getId(), new ArrayList<ColumnSpec>(), new ArrayList<String>(), new ArrayList<String>()); |
final TableSpec tableSpec = new TableSpec(this.getId(), selection, columnsSpec); |
tableSpec.setContent(new TableContent(this.getId())); |
this.setTableSpec(tableSpec); |
this.tableSpec = new TableSpec(this.getId(), selection, columnsSpec); |
this.tableSpec.setContent(new TableContent(this.getId())); |
} |
@Override |
243,7 → 237,7 |
} |
public final List<Row> getSelectedRows() { |
final List<Row> selectedRows = new ArrayList<Row>(); |
final List<Row> selectedRows = new ArrayList<>(); |
if (this.getTableSpec().getSelection() != null) { |
final List<Number> selectedIds = this.getSelectedIds(); |
374,7 → 368,7 |
} |
public <T extends LightUIElement> List<T> findChildren(final Class<T> expectedClass, final boolean recursively) { |
final List<T> result = new ArrayList<T>(); |
final List<T> result = new ArrayList<>(); |
if (this.hasRow()) { |
final int size = this.getRowsCount(); |
382,6 → 376,7 |
final Row row = this.getRow(i); |
final List<Object> rowValues = row.getValues(); |
for (final Object value : rowValues) { |
if (value != null) { |
if (recursively) { |
if (value instanceof LightUIContainer) { |
result.addAll(((LightUIContainer) value).findChildren(expectedClass, recursively)); |
394,6 → 389,7 |
} |
} |
} |
} |
} else { |
System.out.println("LightUITable.getElementById() - No rows for table: " + this.getId()); |
} |
427,7 → 423,7 |
final Document xmlConf = new Document(); |
final int columnSpecCount = columnsSpec.getColumnCount(); |
final List<String> visibleIds = new ArrayList<String>(); |
final List<String> visibleIds = new ArrayList<>(); |
for (int i = 0; i < columnSpecCount; i++) { |
final ColumnSpec columnSpec = columnsSpec.getColumn(i); |
final Element xmlColumn = this.createXmlColumn(columnSpec.getId(), columnSpec.getMaxWidth(), columnSpec.getMinWidth(), columnSpec.getWidth()); |
494,7 → 490,7 |
final Row row = this.getRow(i); |
final List<Object> values = row.getValues(); |
for (final Object value : values) { |
if (value != null && value instanceof LightUIElement) { |
if (value instanceof LightUIElement) { |
((LightUIElement) value).setReadOnly(readOnly); |
} |
} |
526,9 → 522,9 |
for (int i = 0; i < size; i++) { |
final Row row = this.getRow(i); |
final JSONObject jsonLineContext = (JSONObject) JSONConverter.getObjectFromJSON(jsonContext.get(i), JSONObject.class); |
final JSONObject jsonLineContext = JSONConverter.getObjectFromJSON(jsonContext.get(i), JSONObject.class); |
final Number rowId = JSONConverter.getParameterFromJSON(jsonLineContext, "row.id", Number.class); |
final String rowExtendId = (String) JSONConverter.getParameterFromJSON(jsonLineContext, "row.extend.id", String.class); |
final String rowExtendId = JSONConverter.getParameterFromJSON(jsonLineContext, "row.extend.id", String.class); |
if (NumberUtils.areNumericallyEqual(rowId, row.getId()) && (row.getExtendId() == null || (row.getExtendId() != null && rowExtendId.equals(row.getExtendId())))) { |
if (row.isFillWidth()) { |
if (!row.getValues().isEmpty() && row.getValues().get(0) instanceof LightUserControl) { |
559,7 → 555,7 |
} |
} |
} else { |
final List<Number> ids = new ArrayList<Number>(size); |
final List<Number> ids = new ArrayList<>(size); |
for (int j = 0; j < size; j++) { |
ids.add(this.getRow(j).getId()); |
} |
611,29 → 607,6 |
} |
@Override |
public void writeExternal(ObjectOutput out) throws IOException { |
super.writeExternal(out); |
out.writeBoolean(dynamicLoad); |
out.writeBoolean(allowSelection); |
out.writeBoolean(allowMultiSelection); |
out.writeBoolean(autoSelectFirstLine); |
tableSpec.writeExternal(out); |
} |
@Override |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { |
super.readExternal(in); |
this.dynamicLoad = in.readBoolean(); |
this.allowSelection = in.readBoolean(); |
this.allowMultiSelection = in.readBoolean(); |
this.autoSelectFirstLine = in.readBoolean(); |
tableSpec = new TableSpec(); |
tableSpec.readExternal(in); |
} |
@Override |
public void destroy() { |
super.destroy(); |
this.selectionListeners.clear(); |