private void updateRemoveButtons(boolean updateRemove, boolean updateRemoveAll) {
   TablePart tablePart = getTablePart();
   Table table = tablePart.getTableViewer().getTable();
   TableItem[] tableSelection = table.getSelection();
   if (updateRemove) {
     ISelection selection = getViewerSelection();
     tablePart.setButtonEnabled(
         3,
         isEditable()
             && !selection.isEmpty()
             && selection instanceof IStructuredSelection
             && ((IStructuredSelection) selection).getFirstElement() instanceof IProductPlugin);
   }
   int count = fPluginTable.getTable().getItemCount();
   if (updateRemoveAll) tablePart.setButtonEnabled(4, isEditable() && count > 0);
   tablePart.setButtonEnabled(2, isEditable() && count > 0);
   tablePart.setButtonEnabled(5, isEditable() && tableSelection.length == 1);
 }
 @Override
 protected void fillContextMenu(IMenuManager manager) {
   ISelection selection = fPackageViewer.getSelection();
   manager.add(fAddAction);
   boolean singleSelection =
       selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1;
   if (singleSelection) manager.add(fGoToAction);
   manager.add(new Separator());
   if (!selection.isEmpty()) manager.add(fRemoveAction);
   getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager);
   if (singleSelection)
     manager.add(
         new Action(PDEUIMessages.ExportPackageSection_findReferences) {
           @Override
           public void run() {
             doSearch(fPackageViewer.getSelection());
           }
         });
   if (shouldEnableProperties(((IStructuredSelection) fPackageViewer.getSelection()).toArray())) {
     manager.add(new Separator());
     manager.add(fPropertiesAction);
   }
 }
 private void updateSelectionBasedEnablement(ISelection theSelection, boolean available) {
   if (available) fAddButton.setEnabled(!theSelection.isEmpty());
   else fRemoveButton.setEnabled(!theSelection.isEmpty());
 }