public void show(final Pair<Product, String> productPair) { this.product = productPair.getEntity1(); if (null != product.getDescription()) description.setHTML(product.getDescription()); else description.setText(""); tags.setValues(product.getTags()); name.setValue(product.getName()); versionNumber.setValue(product.getVersionNumber()); organization.setValue(product.getOrganizationName()); webpageUrl.setValue(product.getWebsiteUrl()); wikiUrl.setValue(product.getWikiUrl()); downloadUrl.setValue(product.getDownloadUrl()); showcaseUrl.setValue(product.getDemoUrl()); forumUrl.setValue(product.getForumUrl()); issueTrackerUrl.setValue(product.getIssueTrackerUrl()); newsfeedUrl.setValue(product.getNewsUrl()); WidgetUtil.selectValue(license.getComponent(), product.getLicense()); WidgetUtil.selectValue(status.getComponent(), product.getStatus()); WidgetUtil.selectValue(category.getComponent(), product.getCategoryId()); new GetProductCategoriesCommand() { @Override public void onSuccess(ArrayList<Category> result) { WidgetUtil.selectValue(category.getComponent(), product.getCategoryId()); } }.execute(); resetIcon(); uploaderContainer.clear(); if (null != product && null != product.getId()) { uploaderContainer.add(new ProductImageUploadPanel(product, this)); } }
public void onSave() { ArrayList<Message> messages = new ArrayList<Message>(); WidgetUtil.checkNull( new LabeledContainer[] {name, category, status, license, webpageUrl}, messages); if (isNull(description.getText())) { messages.add(Message.error("Please enter the description", description)); } if (messages.size() > 0) { Messages.get().setMessages(null, messages); return; } product.setDescription(description.getHTML()); if (null == product.getId()) product.setName(name.getComponent().getValue()); List<String> _tags = tags.getValues(); if (null != _tags && _tags.size() > 0) { product.setTags(_tags.toArray(new String[_tags.size()])); } else { product.setTags(null); } product.setOrganizationName(organization.getValue()); product.setVersionNumber(versionNumber.getComponent().getValue()); product.setStatus(status.getValue(status.getSelectedIndex())); product.setLicense(license.getValue(license.getSelectedIndex())); product.setCategoryId(WidgetUtil.getSelectedValue(category.getComponent())); product.setWebsiteUrl(webpageUrl.getValue()); product.setDownloadUrl(downloadUrl.getValue()); product.setWikiUrl(wikiUrl.getValue()); product.setDemoUrl(showcaseUrl.getValue()); product.setIssueTrackerUrl(issueTrackerUrl.getValue()); product.setForumUrl(forumUrl.getValue()); product.setNewsUrl(newsfeedUrl.getValue()); new SaveProductCommand(product) { @Override public void onSuccess(Product result) { pages .goTo( result.getAlias(), new PageRequestSessionWithMessage("The product details were saved.")) .execute(); } }.execute(); }