Esempio n. 1
0
 /**
  * Import from another configuration (e.g. imported file). Returns the number of imported items.
  *
  * @param cfg configuration to import from
  * @return added injections count
  */
 public int importFrom(final Configuration cfg) {
   final ArrayList<BaseInjection> originalInjections = new ArrayList<BaseInjection>();
   final ArrayList<BaseInjection> newInjections = new ArrayList<BaseInjection>();
   for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
     importInjections(
         getInjections(supportId),
         cfg.getInjections(supportId),
         originalInjections,
         newInjections);
   }
   if (!newInjections.isEmpty()) configurationModified();
   replaceInjections(newInjections, originalInjections);
   return newInjections.size();
 }
Esempio n. 2
0
 public void replaceInjections(
     final List<? extends BaseInjection> newInjections,
     final List<? extends BaseInjection> originalInjections) {
   for (BaseInjection injection : originalInjections) {
     myInjections.get(injection.getSupportId()).remove(injection);
   }
   for (BaseInjection injection : newInjections) {
     injection.initializePlaces(true);
     myInjections.get(injection.getSupportId()).add(injection);
   }
   configurationModified();
   for (Project project : ProjectManager.getInstance().getOpenProjects()) {
     FileContentUtil.reparseFiles(project, Collections.<VirtualFile>emptyList(), true);
   }
 }
 public boolean replaceInjections(
     List<? extends BaseInjection> newInjections,
     List<? extends BaseInjection> originalInjections,
     boolean forceLevel) {
   boolean changed = false;
   for (BaseInjection injection : originalInjections) {
     changed |= myInjections.get(injection.getSupportId()).remove(injection);
   }
   for (BaseInjection injection : newInjections) {
     changed |= myInjections.get(injection.getSupportId()).add(injection);
   }
   if (changed) {
     configurationModified();
   }
   return changed;
 }
 private int importPlaces(final List<BaseInjection> injections) {
   final Map<String, Set<BaseInjection>> map =
       ContainerUtil.classify(
           injections.iterator(),
           new Convertor<BaseInjection, String>() {
             @Override
             public String convert(final BaseInjection o) {
               return o.getSupportId();
             }
           });
   final ArrayList<BaseInjection> originalInjections = new ArrayList<BaseInjection>();
   final ArrayList<BaseInjection> newInjections = new ArrayList<BaseInjection>();
   for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
     final Set<BaseInjection> importingInjections = map.get(supportId);
     if (importingInjections == null) continue;
     importInjections(
         getInjections(supportId), importingInjections, originalInjections, newInjections);
   }
   if (!newInjections.isEmpty()) configurationModified();
   replaceInjections(newInjections, originalInjections, true);
   return newInjections.size();
 }