Setup the listener for the Table objects of Panel
, and setup
the copy and select all actions.
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();
}
}
});