private void handleGoToPackage(ISelection selection) {
   IPackageFragment frag = getPackageFragment(selection);
   if (frag != null)
     try {
       IViewPart part = PDEPlugin.getActivePage().showView(JavaUI.ID_PACKAGES);
       ShowInPackageViewAction action = new ShowInPackageViewAction(part.getSite());
       action.run(frag);
     } catch (PartInitException e) {
     }
 }
  @Override
  protected void createClient(Section section, FormToolkit toolkit) {
    section.setText(PDEUIMessages.ExportPackageSection_title);
    if (isFragment()) section.setDescription(PDEUIMessages.ExportPackageSection_descFragment);
    else section.setDescription(PDEUIMessages.ExportPackageSection_desc);

    Composite container = createClientContainer(section, 2, toolkit);
    createViewerPartControl(container, SWT.MULTI, 2, toolkit);
    TablePart tablePart = getTablePart();
    fPackageViewer = tablePart.getTableViewer();
    fPackageViewer.setContentProvider(new ExportPackageContentProvider());
    fPackageViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider());
    fPackageViewer.setComparator(
        new ViewerComparator() {
          @Override
          public int compare(Viewer viewer, Object e1, Object e2) {
            String s1 = e1.toString();
            String s2 = e2.toString();
            if (s1.indexOf(" ") != -1) // $NON-NLS-1$
            s1 = s1.substring(0, s1.indexOf(" ")); // $NON-NLS-1$
            if (s2.indexOf(" ") != -1) // $NON-NLS-1$
            s2 = s2.substring(0, s2.indexOf(" ")); // $NON-NLS-1$
            return super.compare(viewer, s1, s2);
          }
        });
    toolkit.paintBordersFor(container);
    section.setClient(container);
    GridData gd = new GridData(GridData.FILL_BOTH);
    if (((ManifestEditor) getPage().getEditor()).isEquinox()) {
      gd.verticalSpan = 2;
      gd.minimumWidth = 300;
    }
    section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
    section.setLayoutData(gd);
    makeActions();

    IBundleModel model = getBundleModel();
    fPackageViewer.setInput(model);
    model.addModelChangedListener(this);
    updateButtons();
  }
 private void handleAdd() {
   IPluginModelBase model = (IPluginModelBase) getPage().getModel();
   final IProject project = model.getUnderlyingResource().getProject();
   try {
     if (project.hasNature(JavaCore.NATURE_ID)) {
       ILabelProvider labelProvider = new JavaElementLabelProvider();
       final ConditionalListSelectionDialog dialog =
           new ConditionalListSelectionDialog(
               PDEPlugin.getActiveWorkbenchShell(),
               labelProvider,
               PDEUIMessages.ExportPackageSection_dialogButtonLabel);
       final Collection<?> pckgs = fHeader == null ? new Vector<>() : fHeader.getPackageNames();
       final boolean allowJava =
           "true".equals(getBundle().getHeader(ICoreConstants.ECLIPSE_JREBUNDLE)); // $NON-NLS-1$
       Runnable runnable =
           new Runnable() {
             @Override
             public void run() {
               ArrayList<IPackageFragment> elements = new ArrayList<>();
               ArrayList<IPackageFragment> conditional = new ArrayList<>();
               IPackageFragment[] fragments =
                   PDEJavaHelper.getPackageFragments(JavaCore.create(project), pckgs, allowJava);
               for (IPackageFragment fragment : fragments) {
                 try {
                   if (fragment.containsJavaResources()) {
                     elements.add(fragment);
                   } else {
                     conditional.add(fragment);
                   }
                 } catch (JavaModelException e) {
                 }
               }
               dialog.setElements(elements.toArray());
               dialog.setConditionalElements(conditional.toArray());
               dialog.setMultipleSelection(true);
               dialog.setMessage(PDEUIMessages.PackageSelectionDialog_label);
               dialog.setTitle(PDEUIMessages.ExportPackageSection_title);
               dialog.create();
               PlatformUI.getWorkbench()
                   .getHelpSystem()
                   .setHelp(dialog.getShell(), IHelpContextIds.EXPORT_PACKAGES);
               SWTUtil.setDialogSize(dialog, 400, 500);
             }
           };
       BusyIndicator.showWhile(Display.getCurrent(), runnable);
       if (dialog.open() == Window.OK) {
         Object[] selected = dialog.getResult();
         if (fHeader != null) {
           for (Object selectedObject : selected) {
             IPackageFragment candidate = (IPackageFragment) selectedObject;
             fHeader.addPackage(
                 new ExportPackageObject(fHeader, candidate, getVersionAttribute()));
           }
         } else {
           getBundle().setHeader(getExportedPackageHeader(), getValue(selected));
           // the way events get triggered, updateButtons isn't called
           if (selected.length > 0) getTablePart().setButtonEnabled(CALCULATE_USE_INDEX, true);
         }
       }
       labelProvider.dispose();
     }
   } catch (CoreException e) {
   }
 }