* @param productId
*/
public TraceableProductBrowser(String componentId, final String fmUrlStr,
final String productId, final boolean enableNotCat, final List<String> excludes) {
super(componentId, fmUrlStr, productId);
final FileManagerConn fm = new FileManagerConn(fmUrlStr);
final Product product = fm.safeGetProductById(productId);
final OpsuiApp app = (OpsuiApp)getApplication();
Form traceForm = new Form("trace_form");
traceForm.add(new Button("trace_button") {
/*
* (non-Javadoc)
*
* @see org.apache.wicket.markup.html.form.Button#onSubmit()
*/
@Override
public void onSubmit() {
Trace tracer = new Trace("pedigree", fmUrlStr, enableNotCat, excludes,
product);
tracer.setVisible(true);
getParent().getParent().replace(tracer);
setVisible(false);
}
});
add(traceForm);
add(new WebMarkupContainer("pedigree").setVisible(false));
List<Reference> refs = fm.getProductReferences(product);
if (refs != null && refs.size() > 0) {
replace(new Label("no_prod_ref_display") {
/*
* (non-Javadoc)
*
* @see org.apache.wicket.Component#isVisible()
*/
@Override
public boolean isVisible() {
return false;
}
});
replace(new ListView<Reference>("ref_list", new ListModel<Reference>(refs)) {
/*
* (non-Javadoc)
*
* @see
* org.apache.wicket.markup.html.list.ListView#populateItem(org.apache
* .wicket.markup.html.list.ListItem)
*/
@Override
protected void populateItem(ListItem<Reference> refItem) {
Reference r = refItem.getModelObject();
String filePath = null;
try {
filePath = new File(new URI(r.getDataStoreReference()))
.getAbsolutePath();
} catch (Exception ignore) {
}
ExternalLink refLink = new ExternalLink("ref_file_path_link",
"/" + app.getRootContext() + "/data?productID="+productId);
refLink.add(new Label("ref_file_path", filePath));
refItem.add(refLink);
refItem.add(new Label("ref_file_size",
String.valueOf(r.getFileSize())));
try {
refItem.add(new Label("ref_pct_transferred", NumberFormat
.getPercentInstance()
.format(fm.getFm().getRefPctTransferred(r))));
} catch (DataTransferException e) {
LOG.log(
Level.WARNING,
"Unable to determine product reference size: Reason: "
+ e.getMessage());