コード例 #1
0
 @Override
 protected void doPaste(Object targetObject, Object[] sourceObjects) {
   // Get the model
   IBundleModel model = getBundleModel();
   // Ensure the model is defined
   if (model == null) {
     return;
   }
   // Get the bundle
   IBundle bundle = model.getBundle();
   // Paste all source objects
   for (Object sourceObject : sourceObjects) {
     if (sourceObject instanceof ExportPackageObject) {
       ExportPackageObject exportPackageObject = (ExportPackageObject) sourceObject;
       // Export package object
       // Adjust all the source object transient field values to
       // acceptable values
       exportPackageObject.reconnect(model, fHeader, getVersionAttribute());
       // Add the object to the header
       if (fHeader == null) {
         // Export package header not defined yet
         // Define one
         // Value will get inserted into a new export package object
         // created by a factory
         // Value needs to be empty string so no export package
         // object is created as the initial value
         bundle.setHeader(getExportedPackageHeader(), ""); // $NON-NLS-1$
       }
       // Add the export package to the header
       fHeader.addPackage(exportPackageObject);
     }
   }
 }
コード例 #2
0
  @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();
  }
コード例 #3
0
 private IBundle getBundle() {
   IBundleModel model = getBundleModel();
   return (model != null) ? model.getBundle() : null;
 }
コード例 #4
0
 @Override
 public void dispose() {
   IBundleModel model = getBundleModel();
   if (model != null) model.removeModelChangedListener(this);
   super.dispose();
 }