FileDocCategorySizeDatePackage
TableView.javaAPI DocAndroid 1.5 API3253Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.ddms.views

TableView

public abstract class TableView extends SelectionDependentViewPart
Base class for view containing Table that needs to support copy, and select all.

Fields Summary
com.android.ddmuilib.ITableFocusListener.IFocusedTableActivator
mActivator
Activator for the current Table that has the focus
private org.eclipse.swt.dnd.Clipboard
mClipboard
private org.eclipse.jface.action.Action
mCopyAction
private org.eclipse.jface.action.Action
mSelectAllAction
Constructors Summary
Methods Summary
public voiddispose()

        super.dispose();
        mClipboard.dispose();
    
voidsetupTableFocusListener(com.android.ddmuilib.TablePanel panel, org.eclipse.swt.widgets.Composite parent)
Setup the listener for the Table objects of Panel, and setup the copy and select all actions.

param
panel The panel to setup
param
parent The parent composite of the Panel's content.


                                         
         
        panel.setTableFocusListener(new ITableFocusListener() {
            public void focusGained(IFocusedTableActivator activator) {
                mActivator = activator;
                mCopyAction.setEnabled(true);
                mSelectAllAction.setEnabled(true);
            }

            public void focusLost(IFocusedTableActivator activator) {
                if (activator == mActivator) {
                    mActivator = null;
                    mCopyAction.setEnabled(false);
                    mSelectAllAction.setEnabled(false);
                }
            }
        });

        // setup the copy action
        mClipboard = new Clipboard(parent.getDisplay());
        IActionBars actionBars = getViewSite().getActionBars();
        actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),
                mCopyAction = new Action("Copy") {
            @Override
            public void run() {
                if (mActivator != null) {
                    mActivator.copy(mClipboard);
                }
            }
        });

        // setup the select all action
        actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
                mSelectAllAction = new Action("Select All") {
            @Override
            public void run() {
                if (mActivator != null) {
                    mActivator.selectAll();
                }
            }
        });