Ejemplo n.º 1
0
  @Override
  public void setPackageProductType(ProductType packageProductType) {
    this.packageProductType = packageProductType;
    this.packageProductTypeItem = null;
    productTypeItemList.clear();
    productTypeGUIList.removeAll();

    if (packageProductType != null) {
      String languageID = NLLocale.getDefault().getLanguage();

      if (packageProductType.getInnerPriceConfig() != null) {
        productTypeItemList.add(new Item(false, true, packageProductType));
        productTypeGUIList.add(
            packageProductType.getName().getText(languageID)
                + Messages.getString(
                    "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.ProductTypeSelectorListImpl.packageProductType_base")); //$NON-NLS-1$
      }

      //			EventInnerProductInfo assemblyInnerProductInfo =
      // assemblyPackageProductInfo.getEventInnerProductInfo();
      //			if (!(assemblyInnerProductInfo.getPriceConfig() instanceof FormulaPriceConfig))
      //				throw new IllegalArgumentException("The PriceConfig of assemblyInnerProductInfo is not
      // an instance of FormulaPriceConfig!");
      //
      //			productTypeItemList.add(assemblyInnerProductInfo);
      //			productTypeGUIList.add(assemblyInnerProductInfo.getPrimaryKey()); // TO DO i18n

      for (NestedProductTypeLocal nestedProductTypeLocal :
          packageProductType.getProductTypeLocal().getNestedProductTypeLocals()) {
        ProductType productType =
            nestedProductTypeLocal.getInnerProductTypeLocal().getProductType();
        //				if (assemblyInnerProductInfo == productInfo)
        //					continue;

        productTypeItemList.add(new Item(false, false, productType));
        productTypeGUIList.add(
            productType.getName().getText(languageID)
                + " ["
                + nestedProductTypeLocal.getQuantity()
                + "]"); //$NON-NLS-1$ //$NON-NLS-2$
      }

      if (packageProductType.getPackagePriceConfig() != null) {
        packageProductTypeItem = new Item(true, false, packageProductType);
        productTypeItemList.add(packageProductTypeItem);
        productTypeGUIList.add(
            packageProductType.getName().getText(languageID)
                + Messages.getString(
                    "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.ProductTypeSelectorListImpl.packageProductType_total")); //$NON-NLS-1$
      }

      productTypeGUIList.select(0);
    } // if (assemblyPackageProductInfo != null) {

    fireSelectionChangedEvent();
  }
Ejemplo n.º 2
0
  protected Composite createNoPriceConfigAssignedComposite(Composite parent) {
    Composite noPriceConfigComp = new XComposite(parent, SWT.NONE);
    Label label = new Label(noPriceConfigComp, SWT.NONE);
    label.setText(
        Messages.getString(
            "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.PriceConfigComposite.noPriceConfigAssignedLabel.text")); //$NON-NLS-1$
    Button assignButton = new Button(noPriceConfigComp, SWT.NONE);
    assignButton.setText(
        Messages.getString(
            "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.PriceConfigComposite.assignButton.text")); //$NON-NLS-1$
    assignButton.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            AbstractChooseGridPriceConfigWizard wizard =
                createChoosePriceConfigWizard(
                    (ProductTypeID)
                        JDOHelper.getObjectId(packageProductType.getExtendedProductType()));
            DynamicPathWizardDialog dialog = new DynamicPathWizardDialog(getShell(), wizard);
            //				dialog.setTitle("Choose Price Configuration");
            int returnCode = dialog.open();
            if (returnCode == Window.OK) {
              assignNewPriceConfig(wizard);

              //					if (dirtyStateManager instanceof SectionPart) {
              //						SectionPart sectionPart = (SectionPart) dirtyStateManager;
              //
              //	sectionPart.getSection().setText(packageProductType.getInnerPriceConfig().getName().getText());
              //					}

              // Kai: 2009-11-13
              // A revision of the above codes: Without explicitly casting dirtyStateManager as a
              // SectionPart.
              // SEE -- The corresponding registered listener in AbstractGridPriceConfigSection.
              // BUT -- Is the triggering of the properChangeListener appropriate here?? Mebbe other
              // more appropriate listeners are avaiable.
              String innerPriceConfigName =
                  packageProductType.getInnerPriceConfig().getName().getText();
              propertyChangeSupport.firePropertyChange(
                  PriceConfigComposite.PROPERTY_CHANGE_KEY_NO_PRICE_CONFIG_COMPOSITE,
                  null,
                  innerPriceConfigName);
            }
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
          }
        });
    return noPriceConfigComp;
  }
Ejemplo n.º 3
0
  public PriceConfigComposite(Composite parent, IDirtyStateManager dirtyStateManager) {
    super(parent, SWT.NONE, LayoutMode.TIGHT_WRAPPER);

    this.dirtyStateManager = dirtyStateManager;

    stackWrapper = new XComposite(this, SWT.NONE);
    stackLayout = new StackLayout();
    stackWrapper.setLayout(stackLayout);
    stackWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));

    //		priceConfigEditComposite = createPriceConfigEditComposite(stackWrapper);
    //		noPriceConfigAssignedComposite = createNoPriceConfigAssignedComposite(stackWrapper);
    //		stackLayout.topControl = priceConfigEditComposite;
    productTypeNotSetComposite = new XComposite(stackWrapper, SWT.NONE);
    new Label(productTypeNotSetComposite, SWT.NONE)
        .setText(
            Messages.getString(
                "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.PriceConfigComposite.label.text")); //$NON-NLS-1$
    stackLayout.topControl = productTypeNotSetComposite;

    // Forces the composites to be created.
    getPriceConfigEditComposite();

    // Incorporates the inactivity-timeout, to check if formula is valid while idle after typing.
    initKeyTimeOutListener();
  }
Ejemplo n.º 4
0
    public PriceConfigInInnerProductTypeNotEditableComposite(Composite parent) {
      super(parent, SWT.NONE);
      getGridLayout().numColumns = 2;

      Label title = new Label(this, SWT.NONE);
      title.setText(
          Messages.getString(
              "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.PriceConfigComposite.label.title")); //$NON-NLS-1$
      priceConfigName = new Text(this, getBorderStyle() | SWT.READ_ONLY);
      priceConfigName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      Label info = new Label(this, SWT.NONE | SWT.WRAP);
      GridData gdInfo = new GridData(GridData.FILL_HORIZONTAL);
      gdInfo.horizontalSpan = 2;
      info.setLayoutData(gdInfo);

      info.setText(
          Messages.getString(
              "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.PriceConfigComposite.label.info.text")); //$NON-NLS-1$
    }
Ejemplo n.º 5
0
  /**
   * @param parent
   * @param style
   */
  public ProductTypeSelectorListImpl(Composite parent, int style) {
    super(parent, style, LayoutMode.TIGHT_WRAPPER);

    productLabel = new Label(this, SWT.NONE);
    productLabel.setText(
        Messages.getString(
            "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.ProductTypeSelectorListImpl.productTypeLabel.text")); //$NON-NLS-1$
    productTypeGUIList = new List(this, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData productListLayoutData = new GridData(GridData.FILL_BOTH);
    productTypeGUIList.setLayoutData(productListLayoutData);
    productTypeGUIList.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            fireSelectionChangedEvent();
          }
        });
  }
Ejemplo n.º 6
0
  public void assignNewPriceConfig(
      IInnerPriceConfig innerPC, final boolean inherited, final ProgressMonitor monitor) {
    monitor.beginTask(
        Messages.getString(
            "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.PriceConfigComposite.job.assignPriceConfig.name"),
        100); //$NON-NLS-1$
    try {
      if (innerPC != null) {
        PriceConfigID innerPCID = (PriceConfigID) JDOHelper.getObjectId(innerPC);
        if (innerPCID != null) innerPC = retrieveInnerPriceConfigForEditing(innerPCID);
      }
      monitor.worked(80);

      final IInnerPriceConfig finalInnerPC = innerPC;

      Display.getDefault()
          .syncExec(
              new Runnable() {
                public void run() {
                  if (isDisposed()) return;

                  packageProductType.setInnerPriceConfig(finalInnerPC);
                  packageProductType
                      .getFieldMetaData(ProductType.FieldName.innerPriceConfig)
                      .setValueInherited(inherited);
                  if (packageProductType.getInnerPriceConfig() != null) {
                    GridPriceConfig packagePriceConfig =
                        (GridPriceConfig) packageProductType.getPackagePriceConfig();
                    if (packagePriceConfig != null)
                      packagePriceConfig.adoptParameters(
                          packageProductType.getInnerPriceConfig(), false);
                  }

                  _setPackageProductType(packageProductType);
                  dirtyStateManager.markDirty();
                  monitor.worked(20);
                }
              });
    } finally {
      monitor.done();
    }
  }