private void updateButtons() {
    Object[] selected = ((IStructuredSelection) fPackageViewer.getSelection()).toArray();

    TablePart tablePart = getTablePart();
    tablePart.setButtonEnabled(ADD_INDEX, canAddExportedPackages());
    tablePart.setButtonEnabled(REMOVE_INDEX, isEditable() && selected.length > 0);
    tablePart.setButtonEnabled(PROPERTIES_INDEX, shouldEnableProperties(selected));
    tablePart.setButtonEnabled(
        CALCULATE_USE_INDEX, isEditable() && fPackageViewer.getTable().getItemCount() > 0);
  }
 private void handleDelete() {
   IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
   if (ssel.size() > 0) {
     Object[] objects = ssel.toArray();
     IProductPlugin[] plugins = new IProductPlugin[objects.length];
     System.arraycopy(objects, 0, plugins, 0, objects.length);
     getProduct().removePlugins(plugins);
     updateRemoveButtons(true, true);
   }
 }
 private void handleProperties() {
   IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
   if (ssel.size() == 1) {
     IProductPlugin plugin = (IProductPlugin) ssel.toArray()[0];
     VersionDialog dialog =
         new VersionDialog(PDEPlugin.getActiveWorkbenchShell(), isEditable(), plugin.getVersion());
     dialog.create();
     SWTUtil.setDialogSize(dialog, 400, 200);
     if (dialog.open() == Window.OK) {
       plugin.setVersion(dialog.getVersion());
     }
   }
 }
 @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 handleOpenProperties() {
   Object[] selected = ((IStructuredSelection) fPackageViewer.getSelection()).toArray();
   ExportPackageObject first = (ExportPackageObject) selected[0];
   DependencyPropertiesDialog dialog = new DependencyPropertiesDialog(isEditable(), first);
   dialog.create();
   PlatformUI.getWorkbench()
       .getHelpSystem()
       .setHelp(dialog.getShell(), IHelpContextIds.EXPORTED_PACKAGE_PROPERTIES);
   SWTUtil.setDialogSize(dialog, 400, -1);
   if (selected.length == 1) dialog.setTitle(((ExportPackageObject) selected[0]).getName());
   else dialog.setTitle(PDEUIMessages.ExportPackageSection_props);
   if (dialog.open() == Window.OK && isEditable()) {
     String newVersion = dialog.getVersion();
     for (Object selectedObject : selected) {
       ExportPackageObject object = (ExportPackageObject) selectedObject;
       if (!newVersion.equals(object.getVersion())) object.setVersion(newVersion);
     }
   }
 }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#fillContextMenu(org.eclipse.jface.action.IMenuManager)
   */
  protected void fillContextMenu(IMenuManager manager) {
    IStructuredSelection ssel = (IStructuredSelection) fPluginTable.getSelection();
    if (ssel == null) return;

    Action openAction =
        new Action(PDEUIMessages.PluginSection_open) {
          public void run() {
            handleDoubleClick((IStructuredSelection) fPluginTable.getSelection());
          }
        };
    openAction.setEnabled(isEditable() && ssel.size() == 1);
    manager.add(openAction);

    manager.add(new Separator());

    Action removeAction =
        new Action(PDEUIMessages.PluginSection_remove) {
          public void run() {
            handleDelete();
          }
        };
    removeAction.setEnabled(isEditable() && ssel.size() > 0);
    manager.add(removeAction);

    Action removeAll =
        new Action(PDEUIMessages.PluginSection_removeAll) {
          public void run() {
            handleRemoveAll();
          }
        };
    removeAll.setEnabled(isEditable());
    manager.add(removeAll);

    manager.add(new Separator());

    getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager);
  }
 private void handleRemove() {
   Object[] removed = ((IStructuredSelection) fPackageViewer.getSelection()).toArray();
   for (Object removedObject : removed) {
     fHeader.removePackage((PackageObject) removedObject);
   }
 }