Ejemplo n.º 1
0
  public void _setPackageProductType(ProductType packageProductType)
        //	throws ModuleException
      {
    if (productTypeSelector != null) productTypeSelector.setPackageProductType(null);

    if (dimensionValueSelector != null) dimensionValueSelector.setGridPriceConfig(null);

    if (priceConfigInInnerProductTypeNotEditableComposite != null)
      priceConfigInInnerProductTypeNotEditableComposite.setPackageProductType(null);

    priceCalculator = null;
    this.packageProductType = packageProductType;

    if (packageProductType == null) {
      stackLayout.topControl = productTypeNotSetComposite;
    } else {
      if (packageProductType.getInnerPriceConfig() == null) {
        stackLayout.topControl = getNoPriceConfigAssignedComposite();
      } else {
        if (packageProductType.getPackageNature() == ProductType.PACKAGE_NATURE_INNER) {
          stackLayout.topControl = getPriceConfigInInnerProductTypeNotEditableComposite();
          getPriceConfigInInnerProductTypeNotEditableComposite()
              .setPackageProductType(packageProductType);
        } else { // package nature outer
          // show price config comp
          stackLayout.topControl = getPriceConfigEditComposite();

          //					if (packageProductType.getInnerPriceConfig() != null ||
          // packageProductType.getPackagePriceConfig() != null) {
          priceCalculator = createPriceCalculator(packageProductType);
          priceCalculator.preparePriceCalculation();
          try {
            priceCalculator.calculatePrices();
          } catch (PriceCalculationException e) {
            throw new RuntimeException(e);
          }

          // The packagePriceConfig defines all parameters (dimension values) we need to know.
          // When the packagePriceConfig comes from the server (after preparePriceCalculation hase
          // been called)
          // it has the same parameters (except PriceFragmentTypes) as the innerPriceConfig.
          // The PriceFragmentTypes have already been collected from all the packaged PriceConfigs.
          GridPriceConfig gridPriceConfig =
              (GridPriceConfig) packageProductType.getPackagePriceConfig();
          if (gridPriceConfig == null) {
            // if the package priceConfig is null in the prodcut-type we
            // take the one created by the PriceCalculator (this might be a non-persistent temporal
            // one)
            gridPriceConfig = (GridPriceConfig) priceCalculator.getPackagePriceConfig();
          }

          if (gridPriceConfig == null)
            throw new IllegalStateException(
                "packageProductType.getPackagePriceConfig() and priceCalculator.getPackagePriceConfig() both returned null!"); //$NON-NLS-1$
          //						gridPriceConfig = (GridPriceConfig) packageProductType.getInnerPriceConfig();

          dimensionValueSelector.setGridPriceConfig(gridPriceConfig);
          productTypeSelector.setPackageProductType(packageProductType);
          //					}

        } // package nature outer
      } // if (packageProductType.getInnerPriceConfig() != null) {
    } // if (packageProductType != null) {
    stackWrapper.layout(true, true);

    if (priceConfigGrid != null) priceConfigGrid.setPriceCalculator(priceCalculator);
  }