Method: RDI::Model::DependencyUserChoice#affectContextModifier

Defined in:
lib/rdi/Model/DependencyUserChoice.rb

#affectContextModifier(iCMName) ⇒ Object

Ask the user to change the context of a given context modifier to resolve this dependency

Parameters:

  • iCMName (String): Name of the ContextModifier we want to use



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/rdi/Model/DependencyUserChoice.rb', line 87

def affectContextModifier(iCMName)
  @Installer.accessPlugin('ContextModifiers', iCMName) do |ioPlugin|
    # Get the name of LocationSelector class to use
    lLocationSelectorName = ioPlugin.LocationSelectorName
    @Installer.accessPlugin("LocationSelectors_#{@ViewName}", lLocationSelectorName) do |iLSPlugin|
      # Get the location from the plugin
      lLocationToTry = iLSPlugin.getNewLocation
      if (lLocationToTry != nil)
        # Try adding this new location if not already there
        if (ioPlugin.isLocationInContext?(lLocationToTry))
          logMsg "Location #{lLocationToTry} is already part of #{iCMName}"
        else
          # Add it
          ioPlugin.addLocationToContext(lLocationToTry)
          # Test Testers that were not already resolved
          lIdxTester = 0
          @DepDesc.Testers.each do |iTesterInfo|
            if (!@ResolvedTesters.has_key?(lIdxTester))
              # Test this one
              iTesterName, iTesterContent = iTesterInfo
              @Installer.accessPlugin('Testers', iTesterName) do |iTesterPlugin|
                # Consider it only if it declares iCMName as an AffectingContextModifier
                if (iTesterPlugin.AffectingContextModifiers.include?(iCMName))
                  if (iTesterPlugin.isContentResolved?(iTesterContent))
                    # Yes, it resolved this one
                    @ResolvedTesters[lIdxTester] = [ iCMName, lLocationToTry ]
                    logMsg "Location #{lLocationToTry} resolves correctly #{iTesterName} - #{iTesterContent}"
                  else
                    logErr "Location #{lLocationToTry} does not resolve #{iTesterName} - #{iTesterContent}"
                  end
                end
              end
            end
            lIdxTester += 1
          end
          # Remove it
          ioPlugin.removeLocationFromContext(lLocationToTry)
        end
      end
    end
  end
end