Пример #1
0
 /**
  * Creates IFeatureImports based on IPluginImports. Ensures no duplicates in preservedImports +
  * newImports
  *
  * @param preservedImports out for valid existing imports
  * @param newImports out for new imports
  * @param plugin
  * @throws CoreException
  */
 private void addPluginImports(List preservedImports, List newImports, IPluginBase plugin)
     throws CoreException {
   IPluginImport[] pluginImports = plugin.getImports();
   for (int i = 0; i < pluginImports.length; i++) {
     IPluginImport pluginImport = pluginImports[i];
     if (pluginImport.isOptional()) {
       continue;
     }
     String id = pluginImport.getId();
     String version = pluginImport.getVersion();
     int match = pluginImport.getMatch();
     addNewDependency(id, version, match, preservedImports, newImports);
   }
 }
Пример #2
0
  private void executeRemove(IModelChangeProvider model, Object[] elements) {
    IPluginBase pluginBase = null;
    IBuild build = null;
    IBundleModel bundleModel = null;
    if (model instanceof IPluginModelBase) {
      pluginBase = ((IPluginModelBase) model).getPluginBase();
    } else if (model instanceof IBuildModel) {
      build = ((IBuildModel) model).getBuild();
    } else if (model instanceof IBundleModel) {
      bundleModel = (IBundleModel) model;
    }

    try {
      for (Object element : elements) {
        if (element instanceof IPluginImport) {
          pluginBase.remove((IPluginImport) element);
        } else if (element instanceof IPluginLibrary) {
          pluginBase.remove((IPluginLibrary) element);
        } else if (element instanceof IPluginExtensionPoint) {
          pluginBase.remove((IPluginExtensionPoint) element);
        } else if (element instanceof IPluginExtension) {
          pluginBase.remove((IPluginExtension) element);
        } else if (element instanceof IPluginElement) {
          IPluginElement e = (IPluginElement) element;
          Object parent = e.getParent();
          if (parent instanceof PluginLibraryNode && e instanceof PluginElementNode) {
            ((PluginLibraryNode) parent).removeContentFilter((PluginElementNode) e);
          } else if (parent instanceof IPluginParent) {
            ((IPluginParent) parent).remove(e);
          }
        } else if (element instanceof IBuildEntry) {
          IBuildEntry e = (IBuildEntry) element;
          build.remove(e);
        } else if (element instanceof BundleObject) {
          if (element instanceof ImportPackageObject) {
            IManifestHeader header =
                bundleModel.getBundle().getManifestHeader(Constants.IMPORT_PACKAGE);
            if (header != null && header instanceof ImportPackageHeader) {
              ((ImportPackageHeader) header).removePackage((PackageObject) element);
            }
          }
          if (element instanceof RequireBundleObject) {
            IBaseModel aggModel = getEditor().getAggregateModel();
            if (aggModel instanceof BundlePluginModel) {
              BundlePluginModel mod = (BundlePluginModel) aggModel;
              pluginBase = mod.getPluginBase();
              IPluginImport[] imports = pluginBase.getImports();
              IPluginImport currentImport = null;
              for (IPluginImport pluginImport : imports) {
                String elementValue = ((RequireBundleObject) element).getValue();
                if (pluginImport.getId().equals(elementValue)) {
                  currentImport = pluginImport;
                  break;
                }
              }
              IPluginImport[] plugins = {currentImport};
              if (pluginBase instanceof BundlePluginBase && currentImport != null)
                ((BundlePluginBase) pluginBase).remove(plugins);
            }
          }
          if (element instanceof ExportPackageObject) {
            IManifestHeader header =
                bundleModel.getBundle().getManifestHeader(Constants.EXPORT_PACKAGE);
            if (header != null && header instanceof ExportPackageHeader) {
              ((ExportPackageHeader) header).removePackage((PackageObject) element);
            }
          }
        }
      }
    } catch (CoreException e) {
      PDEPlugin.logException(e);
    }
  }