layout.setSpacing(true);
final TextField search = new TextField("search");
final Table artifacts = new ArtifactTable(main);
final Table uploadedArtifacts = new ArtifactTable(main);
final Upload uploadArtifact = new Upload("Upload Artifact", new Upload.Receiver() {
public OutputStream receiveUpload(String filename, String MIMEType) {
FileOutputStream fos = null;
try {
m_file = new File(m_sessionDir, filename);
if (m_file.exists()) {
throw new IOException("Uploaded file already exists.");
}
fos = new FileOutputStream(m_file);
}
catch (final IOException e) {
getMainWindow().showNotification(
"Upload artifact failed",
"File " + m_file.getName() + "<br />could not be accepted on the server.<br />" +
"Reason: " + e.getMessage(),
Notification.TYPE_ERROR_MESSAGE);
m_log.log(LogService.LOG_ERROR, "Upload of " + m_file.getAbsolutePath() + " failed.", e);
return null;
}
return fos;
}
});
artifacts.setCaption("Artifacts in repository");
uploadedArtifacts.setCaption("Uploaded artifacts");
uploadedArtifacts.setSelectable(false);
search.setValue("");
try {
getBundles(artifacts);
}
catch (Exception e) {
e.printStackTrace();
}
uploadArtifact.setImmediate(true);
uploadArtifact.addListener(new Upload.SucceededListener() {
public void uploadSucceeded(SucceededEvent event) {
try {
URL artifact = m_file.toURI().toURL();
Item item = uploadedArtifacts.addItem(artifact);
item.getItemProperty("symbolic name").setValue(m_file.getName());
item.getItemProperty("version").setValue("");
m_uploadedArtifacts.add(m_file);
}
catch (IOException e) {
getMainWindow().showNotification(
"Upload artifact processing failed",
"<br />Reason: " + e.getMessage(),
Notification.TYPE_ERROR_MESSAGE);
m_log.log(LogService.LOG_ERROR, "Processing of " + m_file.getAbsolutePath() + " failed.", e);
}
}
});
uploadArtifact.addListener(new Upload.FailedListener() {
public void uploadFailed(FailedEvent event) {
getMainWindow().showNotification(
"Upload artifact failed",
"File " + event.getFilename() + "<br />could not be uploaded to the server.<br />" +
"Reason: " + event.getReason().getMessage(),