dialogBox.setText("Import site");
dialogBox.setAnimationEnabled(true);
dialogBox.setModal(true);
dialogBox.setGlassEnabled(true);
final AbsolutePanel absolutePanel = new AbsolutePanel();
dialogBox.setWidget(absolutePanel);
absolutePanel.setStyleName("status-panel");
absolutePanel.setSize("400px", "220px");
final Button importButton = new Button("Import");
final Label importModeLabel = new Label("Import Mode:");
final ListBox importModeListBox = new ListBox(false);
importModeListBox.addItem("Conserve", "conserve");
importModeListBox.addItem("Insert", "insert");
importModeListBox.addItem("Merge", "merge");
importModeListBox.addItem("Overwrite", "overwrite");
importModeListBox.setSelectedIndex(2); // set default to 'merge'
final HTML statusImg = new HTML(" ", true);
final Label statusLabel = new Label("status label");
final Label headerLabel = new Label("Select file to import :");
final AbsolutePanel statusPanel = new AbsolutePanel();
headerLabel.setSize("380px", "39px");
headerLabel.setStyleName("header-style");
absolutePanel.add(headerLabel, 10, 10);
final MultiUploader uploader = new GTNMultiUploader();
uploader.setAvoidRepeatFiles(false);
absolutePanel.add(uploader, 10, 46);
uploader.setSize("380px", "32px");
uploader.addOnChangeUploadHandler(new IUploader.OnChangeUploaderHandler() {
@Override
public void onChange(IUploader uploader) {
// Nothing to do
if (uploader.getFileName() != null) {
importButton.setEnabled(true);
}
}
});
// Add a finish handler which will notify user once the upload finishes
uploader.addOnFinishUploadHandler(new IUploader.OnFinishUploaderHandler() {
public void onFinish(IUploader uploader) {
switch (uploader.getStatus()) {
case SUCCESS:
statusLabel.setText("File uploaded with success");
statusLabel.setStyleName("success-style");
statusImg.setStyleName("success-style-icon");
break;
case ERROR:
statusLabel.setText("File upload error");
statusLabel.setStyleName("error-style");
statusImg.setStyleName("error-style-icon");
break;
case CANCELED:
statusLabel.setText("File upload canceled");
statusLabel.setStyleName("warn-style");
statusImg.setStyleName("warn-style-icon");
break;
default:
statusLabel.setText("");
statusLabel.setStyleName("blank-style");
statusImg.setStyleName("blank-style");
break;
}
importModeListBox.setEnabled(true);
importButton.setEnabled(true);
}
});
// Add a start handler which will disable the UI until the upload finishes
uploader.addOnStartUploadHandler(new IUploader.OnStartUploaderHandler() {
boolean isShwon = false;
public void onStart(IUploader uploader) {
if (uploader.getStatus() == IUploadStatus.Status.INPROGRESS) {
statusLabel.setText("Process in progress...");
statusLabel.setStyleName("progress-style");
statusImg.setStyleName("progress-style-icon");
importModeListBox.setEnabled(false);
importButton.setEnabled(false);
if (!isShwon) {
statusPanel.setStyleName("status-panel");
statusPanel.setSize("380px", "0px");
absolutePanel.add(statusPanel, 10, 120);
Timer t = new Timer() {
int dx = 5;
int height = 0;
public void run() {
height += dx;
statusPanel.setHeight(height + "px");
if (height >= 45) {
cancel(); // Stop the timer
}
}
};
// Schedule the timer to run once in 100 milliseconds.
t.scheduleRepeating(100);
isShwon = true;
}
}
}
});
// accept only zip files
uploader.setValidExtensions("zip");
// You can add customized parameters to servlet call
uploader.setServletPath(UPLOAD_ACTION_URL + "?pc=" + getPortalContainerName());
importModeListBox.setTitle("The import mode to use during import.");
importModeListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
String url = UPLOAD_ACTION_URL + "?pc=" + getPortalContainerName() + "&importMode="
+ importModeListBox.getValue(importModeListBox.getSelectedIndex());
uploader.setServletPath(url);
}
});
absolutePanel.add(importModeLabel, 10, 88);
absolutePanel.add(importModeListBox, 95, 84);
Button closeButton = new Button("Close", new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
}
});
absolutePanel.add(closeButton, 343, 188);
statusImg.setStyleName("progress-style-icon");
statusPanel.add(statusImg, 10, 10);
statusImg.setSize("50px", "30px");
statusPanel.add(statusLabel, 60, 15);
statusLabel.setSize("300px", "25px");
importButton.addClickHandler(new ClickHandler() {
@Override