コード例 #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 boolean canPaste(Object targetObject, Object[] sourceObjects) {
   HashMap<?, ?> currentPackageFragments = null;
   // Only export package objects that represent existing package
   // fragments within the Java project that this plugin.xml is stored
   // can be pasted
   for (Object sourceObject : sourceObjects) {
     // Only export package objects are allowed
     if ((sourceObject instanceof ExportPackageObject) == false) {
       return false;
     }
     // Get the package fragments that are allowed and store them to
     // assist in searching
     if (currentPackageFragments == null) {
       currentPackageFragments = createCurrentExportPackageMap();
     }
     // Only export packages that are in the list of allowed package
     // fragments are allowed
     ExportPackageObject exportPackageObject = (ExportPackageObject) sourceObject;
     if (currentPackageFragments.containsKey(exportPackageObject.getName()) == false) {
       return false;
     }
   }
   return true;
 }
コード例 #3
0
  private boolean shouldEnableProperties(Object[] selected) {
    if (selected.length == 0) return false;
    if (selected.length == 1) return true;

    String version = ((ExportPackageObject) selected[0]).getVersion();
    for (int i = 1; i < selected.length; i++) {
      ExportPackageObject object = (ExportPackageObject) selected[i];
      if (version == null) {
        if (object.getVersion() != null) {
          return false;
        }
      } else if (!version.equals(object.getVersion())) {
        return false;
      }
    }
    return true;
  }
コード例 #4
0
 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);
     }
   }
 }