setWidth("50em");
m_artifactsTable = new ResourceTable();
m_artifactsTable.setCaption("Artifacts in repository");
final IndexedContainer dataSource = (IndexedContainer) m_artifactsTable.getContainerDataSource();
final Table uploadedArtifacts = new ArtifactTable();
uploadedArtifacts.setCaption("Uploaded artifacts");
uploadedArtifacts.setSelectable(false);
final GenericUploadHandler uploadHandler = new GenericUploadHandler(m_sessionDir) {
@Override
protected void artifactUploaded(File uploadedArtifact) {
try {
URL artifact = uploadedArtifact.toURI().toURL();
Item item = uploadedArtifacts.addItem(artifact);
item.getItemProperty(ArtifactTable.PROPERTY_SYMBOLIC_NAME).setValue(uploadedArtifact.getName());
item.getItemProperty(ArtifactTable.PROPERTY_VERSION).setValue("");
m_uploadedArtifacts.add(uploadedArtifact);
}
catch (MalformedURLException e) {
showErrorNotification("Upload artifact processing failed", "<br />Reason: " + e.getMessage());
logError("Processing of " + uploadedArtifact + " failed.", e);
}
}
@Override
protected void uploadFailed(String uploadedArtifact, Throwable throwable) {
showErrorNotification("Upload artifact failed", "File "
+ uploadedArtifact
+ "<br />could not be accepted on the server.<br />"
+ "Reason: " + throwable);
logError("Upload of " + uploadedArtifact + " failed.");
}
};
final Upload uploadArtifact = new Upload("Upload Artifact", uploadHandler);
uploadArtifact.addListener((SucceededListener) uploadHandler);
uploadArtifact.addListener((FailedListener) uploadHandler);
uploadArtifact.setImmediate(true);
final DragAndDropWrapper finalUploadedArtifacts = new DragAndDropWrapper(uploadedArtifacts);
finalUploadedArtifacts.setDropHandler(new ArtifactDropHandler(uploadHandler));
addListener(new Window.CloseListener() {
public void windowClose(CloseEvent e) {
for (File artifact : m_uploadedArtifacts) {
artifact.delete();
}
}
});
HorizontalLayout searchBar = new HorizontalLayout();
searchBar.setMargin(false);
searchBar.setSpacing(true);
final TextField searchField = new TextField();
searchField.setImmediate(true);
searchField.setValue("");
m_searchButton = new Button("Search", new ClickListener() {
public void buttonClick(ClickEvent event) {
String searchValue = (String) searchField.getValue();
dataSource.removeAllContainerFilters();
if (searchValue != null && searchValue.trim().length() > 0) {
dataSource.addContainerFilter(ArtifactTable.PROPERTY_SYMBOLIC_NAME, searchValue,
true /* ignoreCase */, false /* onlyMatchPrefix */);
}
}
});
m_searchButton.setImmediate(true);