コード例 #1
0
 Link getProductEditorLink(Product product) throws RemoteException {
   Link link = ProductEditorWindow.getEditorLink(product.getID());
   link.setImage(this.iEdit);
   link.addParameter(
       ProductEditorWindow.PRODUCT_CATALOG_OBJECT_INSTANCE_ID, this.getICObjectInstanceID());
   link.setToolTip(
       this.iwrb.getLocalizedString(
           "trade.product_catalog.edit_this_product",
           "Edit this product (" + product.getProductName(this._currentLocaleId) + ")"));
   return link;
 }
コード例 #2
0
 protected String getCacheState(IWContext iwc, String cacheStatePrefix) {
   Product prod = getSelectedProduct(iwc);
   //    System.out.println("[ProductCatalog] gettingCacheState");
   String returnString = cacheStatePrefix + getICObjectInstanceID();
   if (iwc.isParameterSet(CATEGORY_ID)) {
     returnString = returnString + "_" + iwc.getParameter(CATEGORY_ID);
   }
   if (prod != null) {
     returnString = returnString + "_" + prod.getID();
   }
   return returnString;
 }
コード例 #3
0
 public Link getNameLink(Product product, PresentationObject nameText, boolean useAnchor)
     throws RemoteException {
   Link productLink;
   if (this._productIsLink) {
     if (useAnchor) {
       productLink = new AnchorLink(nameText, getAnchorString(product.getID()));
     } else {
       productLink = new Link(nameText);
     }
     productLink.addParameter(ProductBusinessBean.PRODUCT_ID, product.getID());
     if (this._productLinkPage != null) {
       productLink.setPage(this._productLinkPage);
     } else if (this._windowString != null) {
       productLink.setWindowToOpenScript(this._windowString);
     }
     if (this._addCategoryID) {
       try {
         if (this.productCategories != null
             && this.productCategories.size() > 0
             && this._useParameterCategory) {
           List list = this.productCategories;
           if (list != null) {
             Iterator iter = list.iterator();
             while (iter.hasNext()) {
               productLink.addParameter(CATEGORY_ID, ((ICCategory) iter.next()).getID());
             }
           }
         } else {
           List list = getProductBusiness().getProductCategories(product);
           if (list != null) {
             Iterator iter = list.iterator();
             while (iter.hasNext()) {
               productLink.addParameter(CATEGORY_ID, ((ProductCategory) iter.next()).getID());
             }
           }
         }
       } catch (IDORelationshipException e) {
       }
       // productLink.addParameter(CATEGORY_ID,product.g);
     }
     return productLink;
   } else {
     return null;
   }
 }
コード例 #4
0
 PresentationObject getNamePresentationObject(Product product, boolean useCategoryStyle)
     throws RemoteException {
   return getNamePresentationObject(
       product, product.getProductName(this._currentLocaleId), useCategoryStyle);
 }
  public PresentationObject getCatalog(
      ProductCatalog productCatalog, IWContext iwc, List productCategories)
      throws RemoteException, FinderException {
    this.localeID = iwc.getCurrentLocaleId();
    this.locale = iwc.getCurrentLocale();
    this.defaultLocale = iwc.getIWMainApplication().getSettings().getDefaultLocale();
    this.defaultLocaleID = ICLocaleBusiness.getLocaleId(this.defaultLocale);

    Table table = new Table();
    table.setWidth("100%");
    table.setCellspacing(1);
    table.setCellpadding(2);

    Collection products = productCatalog.getProducts(productCategories);
    Iterator iter = products.iterator();
    Iterator catIter = productCategories.iterator();

    int row = 1;
    int column = 1;
    int imageColumn = 1;

    Hashtable metaDataTypes = new Hashtable();

    table.add(
        productCatalog.getHeader(
            productCatalog.iwrb.getLocalizedString("product.product", "Product")),
        column++,
        row);
    List metadataKeys = new Vector();
    String[] metadata = new String[10 + column];

    while (catIter.hasNext()) {
      ICCategory element = (ICCategory) catIter.next();
      metaDataTypes.putAll(
          getCategoryService(iwc).getInheritedMetaDataTypes(element.getMetaDataTypes(), element));
    }

    if (!metaDataTypes.isEmpty()) {
      Set set = metaDataTypes.keySet();
      Iterator setIter = set.iterator();
      while (setIter.hasNext()) {
        String key = setIter.next().toString();
        if (!metadataKeys.contains(key)) {
          metadataKeys.add(key);
          metadata[column] = key;
          table.add(
              productCatalog.getHeader(productCatalog.iwrb.getLocalizedString(METADATA + key, key)),
              column++,
              row);
        }
      }
    }
    imageColumn = column;
    table.add(
        productCatalog.getHeader(
            productCatalog.iwrb.getLocalizedString("product.images", "Images")),
        column++,
        row);
    table.setRowColor(row, productCatalog.getHeaderBackgroundColor());

    Product product;
    String key;
    String meta;
    Locale localeInUse;
    int localeIDinUse;
    while (iter.hasNext()) {
      ++row;
      product = (Product) iter.next();

      if (null == product.getProductName(this.localeID, null)) {
        localeInUse = this.defaultLocale;
        localeIDinUse = this.defaultLocaleID;
      } else {
        localeInUse = this.locale;
        localeIDinUse = this.localeID;
      }

      if (productCatalog.hasEditPermission()) {
        table.add(productCatalog.getProductEditorLink(product), 1, row);
      }
      table.add(
          productCatalog.getNamePresentationObject(
              product, product.getProductName(localeIDinUse), false),
          1,
          row);
      for (int i = 0; i < metadata.length; i++) {
        key = metadata[i];
        if (key != null) {
          meta = product.getMetaData(METADATA + key + "_" + localeInUse.toString());
          if (meta != null) {
            table.add(productCatalog.getText(meta), i, row);
          }
        }
      }

      // Collection coll = getEditorBusiness(iwc).getFiles(product);
      Collection coll;
      try {
        coll = product.getICFile();
        Iterator images = coll.iterator();
        Image image;
        int counter = 0;
        while (images.hasNext()) {
          ++counter;
          try {
            image =
                new Image(
                    new Integer(((ICFile) images.next()).getPrimaryKey().toString()).intValue());
            Window window = new Window(image);

            Link link = new Link(productCatalog.getText(Integer.toString(counter)));

            if (productCatalog._iconPhoto != null) {
              link = new Link(productCatalog._iconPhoto);
            }

            link.setWindow(window);

            table.add(link, imageColumn, row);
            table.add(productCatalog.getText(Text.NON_BREAKING_SPACE), imageColumn, row);
          } catch (Exception e) {
            e.printStackTrace(System.err);
          }
        }
      } catch (IDORelationshipException e1) {
        e1.printStackTrace();
      }

      table.setRowColor(row, productCatalog.getBackgroundColor());
    }

    return table;
  }