/** * Constructs a new <code>CollectionConnectorTableModel</code> instance. * * @param collectionConnector * the collection connector holding the values of this table model. * @param columnConnectorKeys * the list of column connector ids. */ public CollectionConnectorTableModel( ICollectionConnector collectionConnector, List<String> columnConnectorKeys) { super(); this.collectionConnector = collectionConnector; this.columnConnectorKeys = columnConnectorKeys; bindConnector(); }
private void updateCell() { if (cell.getX() < getRowCount()) { fireTableCellUpdated(cell.getX(), cell.getY()); } } }
/** * {@inheritDoc} */ public void connectorValueChange(@SuppressWarnings("unused") ConnectorValueChangeEvent evt) { if (row < getRowCount()) { fireTableRowsUpdated(row, row); } if (collectionConnector.getSelectedIndices() != null) { if (Arrays.binarySearch(collectionConnector.getSelectedIndices(), row) >= 0) { collectionConnector.setSelectedIndices(new int[0]); } } } }
CollectionConnectorTableModel tableModel = new CollectionConnectorTableModel( connector, columnConnectorKeys); tableModel.setExceptionHandler(actionHandler); tableModel.setColumnClassesByIds(columnClassesByIds); viewComponent.setModel(tableModel); listSelectionModelBinder.bindSelectionModel(connector, viewComponent
private void bindChildRowConnector(int row) { ICompositeValueConnector rowConnector = (ICompositeValueConnector) collectionConnector .getChildConnector(row); rowConnector .addValueChangeListener(getChildRowConnectorListener(row)); for (int col = 0; col < columnConnectorKeys.size(); col++) { IValueConnector cellConnector = rowConnector .getChildConnector(columnConnectorKeys.get(col)); if (cellConnector instanceof IRenderableCompositeValueConnector && ((IRenderableCompositeValueConnector) cellConnector) .getRenderingConnector() != null) { ((IRenderableCompositeValueConnector) cellConnector) .getRenderingConnector().addValueChangeListener( getChildCellConnectorListener(row, col)); } else { CellConnectorListener listener = getChildCellConnectorListener(row, col); cellConnector.addValueChangeListener(listener); cellConnector.addPropertyChangeListener(listener); } } }
/** * {@inheritDoc} */ public void valueChange(ValueChangeEvent evt) { Collection<?> oldCollection = null; if (evt.getOldValue() instanceof Collection<?>) { oldCollection = (Collection<?>) evt.getOldValue(); } Collection<?> newCollection = (Collection<?>) evt.getNewValue(); int oldCollectionSize = 0; int newCollectionSize = 0; if (oldCollection != null) { oldCollectionSize = oldCollection.size(); } if (newCollection != null) { newCollectionSize = newCollection.size(); } if (newCollectionSize > oldCollectionSize) { fireTableRowsInserted(oldCollectionSize, newCollectionSize - 1); for (int row = oldCollectionSize; row < newCollectionSize; row++) { bindChildRowConnector(row); } } else if (newCollectionSize < oldCollectionSize) { fireTableRowsDeleted(newCollectionSize, oldCollectionSize - 1); } } }
CollectionConnectorTableModel tableModel = new CollectionConnectorTableModel( connector, columnConnectorKeys, columnClasses); tableModel.setExceptionHandler(actionHandler);
/** * Returns the value of the connector which backs the cell model (2nd level of * nesting). * <p> * {@inheritDoc} */ public Object getValueAt(int rowIndex, int columnIndex) { IValueConnector cellConnector = getConnectorAt(rowIndex, columnIndex); Object connectorValue = cellConnector.getConnectorValue(); if (connectorValue instanceof byte[]) { return null; } return connectorValue; }
private void bindConnector() { collectionConnector .addConnectorValueChangeListener(new TableConnectorListener()); for (int row = 0; row < collectionConnector.getChildConnectorCount(); row++) { bindChildRowConnector(row); } }
private void bindChildRowConnector(int row) { ICompositeValueConnector rowConnector = (ICompositeValueConnector) collectionConnector .getChildConnector(row); rowConnector .addConnectorValueChangeListener(getChildRowConnectorListener(row)); for (int col = 0; col < columnConnectorKeys.size(); col++) { IValueConnector cellConnector = rowConnector .getChildConnector(columnConnectorKeys.get(col)); if (cellConnector instanceof IRenderableCompositeValueConnector && ((IRenderableCompositeValueConnector) cellConnector) .getRenderingConnector() != null) { ((IRenderableCompositeValueConnector) cellConnector) .getRenderingConnector().addConnectorValueChangeListener( getChildCellConnectorListener(row, col)); } else { CellConnectorListener listener = getChildCellConnectorListener(row, col); cellConnector.addConnectorValueChangeListener(listener); cellConnector.addPropertyChangeListener(listener); } } }
fireTableRowsInserted(oldCollectionSize, newCollectionSize - 1); for (int row = oldCollectionSize; row < newCollectionSize; row++) { bindChildRowConnector(row); fireTableRowsDeleted(newCollectionSize, oldCollectionSize - 1);
/** * Returns the value of the connector which backs the cell model (2nd level of * nesting). * <p> * {@inheritDoc} */ public Object getValueAt(int rowIndex, int columnIndex) { IValueConnector cellConnector = getConnectorAt(rowIndex, columnIndex); if (cellConnector instanceof ICompositeValueConnector) { return cellConnector; } Object connectorValue = cellConnector.getConnectorValue(); if (connectorValue instanceof byte[]) { return null; } return connectorValue; }
private void bindConnector() { collectionConnector .addValueChangeListener(new TableConnectorListener()); for (int row = 0; row < collectionConnector.getChildConnectorCount(); row++) { bindChildRowConnector(row); } }
private void updateCell() { if (cell.getX() < getRowCount()) { fireTableCellUpdated(cell.getX(), cell.getY()); } } }
/** * {@inheritDoc} */ public void valueChange( @SuppressWarnings("unused") ValueChangeEvent evt) { if (row < getRowCount()) { fireTableRowsUpdated(row, row); } if (collectionConnector.getSelectedIndices() != null) { if (Arrays.binarySearch(collectionConnector.getSelectedIndices(), row) >= 0) { collectionConnector.setSelectedIndices(new int[0]); } } } }
/** * Returns the value of the connector which backs the cell model (2nd level of * nesting). * <p> * {@inheritDoc} */ @Override public void setValueAt(Object cellValue, int rowIndex, int columnIndex) { try { getConnectorAt(rowIndex, columnIndex).setConnectorValue(cellValue); } catch (RuntimeException ex) { if (exceptionHandler != null) { exceptionHandler.handleException(ex, null); } else { throw ex; } } }
/** * Constructs a new <code>CollectionConnectorTableModel</code> instance. * * @param collectionConnector * the collection connector holding the values of this table model. * @param columnConnectorKeys * the list of column connector ids. * @param columnClasses * the column classes. */ public CollectionConnectorTableModel( ICollectionConnector collectionConnector, List<String> columnConnectorKeys, List<Class<?>> columnClasses) { super(); this.collectionConnector = collectionConnector; this.columnConnectorKeys = columnConnectorKeys; this.columnClasses = columnClasses; bindConnector(); }
/** * Returns the value of the connector which backs the cell model (2nd level of * nesting). * <p> * {@inheritDoc} */ @Override public void setValueAt(Object cellValue, int rowIndex, int columnIndex) { try { getConnectorAt(rowIndex, columnIndex).setConnectorValue(cellValue); } catch (RuntimeException ex) { if (exceptionHandler != null) { exceptionHandler.handleException(ex, null); } else { throw ex; } } }
/** * {@inheritDoc} */ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return collectionConnector.isWritable() && collectionConnector.getChildConnector(rowIndex).isWritable() && getConnectorAt(rowIndex, columnIndex).isWritable(); }
/** * {@inheritDoc} */ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return collectionConnector.isWritable() && collectionConnector.getChildConnector(rowIndex).isWritable() && getConnectorAt(rowIndex, columnIndex).isWritable(); }