FileDocCategorySizeDatePackage
TableViewImpl.javaAPI DocAzureus 3.0.3.45787Wed Mar 21 11:04:54 GMT 2007com.aelitis.azureus.ui.common.table.impl

TableViewImpl

public abstract class TableViewImpl extends Object implements TableView
author
TuxPaper
created
Feb 6, 2007

Fields Summary
private List
listenersDataSourceChanged
private List
listenersSelection
private List
listenersLifeCycle
private List
listenersRefresh
private List
listenersCountChange
private Object
parentDataSource
Constructors Summary
Methods Summary
public voidaddCountChangeListener(TableCountChangeListener listener)

		listenersCountChange.add(listener);
	
public voidaddLifeCycleListener(TableLifeCycleListener l)

		listenersLifeCycle.add(l);
		if (!isDisposed()) {
			l.tableViewInitialized();
		}
	
public voidaddRefreshListener(TableRefreshListener l, boolean trigger)

		listenersRefresh.add(l);
		if (trigger) {
			l.tableRefresh();
		}
	
public voidaddSelectionListener(TableSelectionListener listener, boolean bFireSelection)


	   
			  
		listenersSelection.add(listener);
		if (bFireSelection) {
			TableRowCore[] rows = getSelectedRows();
			listener.selected(rows);
			listener.focusChanged(getFocusedRow());
		}
	
public voidaddTableDataSourceChangedListener(TableDataSourceChangedListener l, boolean trigger)

		listenersDataSourceChanged.add(l);
		if (trigger) {
			l.tableDataSourceChanged(parentDataSource);
		}
	
public voidremoveTableDataSourceChangedListener(TableDataSourceChangedListener l)

		listenersDataSourceChanged.remove(l);
	
public voidrunForAllRows(TableGroupRowRunner runner)

		// put to array instead of synchronised iterator, so that runner can remove
		TableRowCore[] rows = getRows();
		if (runner.run(rows)) {
			return;
		}

		for (int i = 0; i < rows.length; i++) {
			runner.run(rows[i]);
		}
	
public voidsetParentDataSource(java.lang.Object newDataSource)

		parentDataSource = newDataSource;
		Object[] listeners = listenersDataSourceChanged.toArray();
		for (int i = 0; i < listeners.length; i++) {
			TableDataSourceChangedListener l = (TableDataSourceChangedListener) listeners[i];
			l.tableDataSourceChanged(newDataSource);
		}
	
protected voidtriggerDefaultSelectedListeners(TableRowCore[] selectedRows)

param
selectedRows

		for (Iterator iter = listenersSelection.iterator(); iter.hasNext();) {
			TableSelectionListener l = (TableSelectionListener) iter.next();
			l.defaultSelected(selectedRows);
		}
	
protected voidtriggerDeselectionListeners(TableRowCore[] rows)

		if (rows == null || rows.length == 0) {
			return;
		}
		Object[] listeners = listenersSelection.toArray();
		for (int i = 0; i < listeners.length; i++) {
			TableSelectionListener l = (TableSelectionListener) listeners[i];
			l.deselected(rows);
		}
	
protected voidtriggerFocusChangedListeners(TableRowCore row)

		Object[] listeners = listenersSelection.toArray();
		for (int i = 0; i < listeners.length; i++) {
			TableSelectionListener l = (TableSelectionListener) listeners[i];
			l.focusChanged(row);
		}
	
protected voidtriggerLifeCycleListener(int eventType)

param
eventType

		Object[] listeners = listenersLifeCycle.toArray();
		if (eventType == TableLifeCycleListener.EVENT_INITIALIZED) {
			for (int i = 0; i < listeners.length; i++) {
				TableLifeCycleListener l = (TableLifeCycleListener) listeners[i];
				try {
					l.tableViewInitialized();
				} catch (Exception e) {
					Debug.out(e);
				}
			}
		} else {
			for (int i = 0; i < listeners.length; i++) {
				TableLifeCycleListener l = (TableLifeCycleListener) listeners[i];
				try {
					l.tableViewDestroyed();
				} catch (Exception e) {
					Debug.out(e);
				}
			}
		}
	
protected voidtriggerListenerRowAdded(TableRowCore row)

		for (Iterator iter = listenersCountChange.iterator(); iter.hasNext();) {
			TableCountChangeListener l = (TableCountChangeListener) iter.next();
			l.rowAdded(row);
		}
	
protected voidtriggerListenerRowRemoved(TableRowCore row)

		for (Iterator iter = listenersCountChange.iterator(); iter.hasNext();) {
			TableCountChangeListener l = (TableCountChangeListener) iter.next();
			l.rowRemoved(row);
		}
	
protected voidtriggerSelectionListeners(TableRowCore[] rows)

		if (rows == null || rows.length == 0) {
			return;
		}
		Object[] listeners = listenersSelection.toArray();
		for (int i = 0; i < listeners.length; i++) {
			TableSelectionListener l = (TableSelectionListener) listeners[i];
			l.selected(rows);
		}
	
protected voidtriggerTableRefreshListeners()

		Object[] listeners = listenersRefresh.toArray();
		for (int i = 0; i < listeners.length; i++) {
			TableRefreshListener l = (TableRefreshListener) listeners[i];
			l.tableRefresh();
		}