private Button btnRestorePackage;
private Button btnDeletePackage;
public ArchivedAssetManager(ClientFactory clientFactory) {
PrettyFormLayout pf = new PrettyFormLayout();
VerticalPanel header = new VerticalPanel();
header.add(new HTML(constants.ArchivedItems()));
pf.addHeader(images.backupLarge(),
header);
loadPackages();
Command restoreSelectedAssetCommand = new Command() {
public void execute() {
if (table.getSelectedRowUUIDs() == null) {
Window.alert(constants.PleaseSelectAnItemToRestore());
return;
}
RepositoryServiceFactory.getAssetService().archiveAssets(table.getSelectedRowUUIDs(),
false,
new GenericCallback<java.lang.Void>() {
public void onSuccess(Void arg0) {
Window.alert(constants.ItemRestored());
table.refresh();
}
});
}
};
Command deleteSelectedAssetCommand = new Command() {
public void execute() {
if (table.getSelectedRowUUIDs() == null) {
Window.alert(constants.PleaseSelectAnItemToPermanentlyDelete());
return;
}
if (!Window.confirm(constants.AreYouSureDeletingAsset())) {
return;
}
RepositoryServiceFactory.getAssetService().removeAssets(table.getSelectedRowUUIDs(),
new GenericCallback<java.lang.Void>() {
public void onSuccess(Void arg0) {
Window.alert(constants.ItemDeleted());
table.refresh();
}
});
}
};
table = new AdminArchivedPagedTable(
restoreSelectedAssetCommand,
deleteSelectedAssetCommand,
clientFactory);
HorizontalPanel packagesToolbar = new HorizontalPanel();
btnRestorePackage = new Button(constants.RestoreSelectedPackage());
btnRestorePackage.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (packages.getSelectedIndex() == -1) {
Window.alert(constants.PleaseSelectAnItemToRestore());
return;
}
restorePackage(packages.getValue(packages.getSelectedIndex()));
}
});
packagesToolbar.add(btnRestorePackage);
btnDeletePackage = new Button(constants.PermanentlyDeletePackage());
btnDeletePackage.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (packages.getSelectedIndex() == -1) {
Window.alert(constants.PleaseSelectAnItemToPermanentlyDelete());
return;
}
if (Window.confirm(constants.AreYouSurePackageDelete())) {
deletePackage(packages.getValue(packages.getSelectedIndex()));
}
}
});
packagesToolbar.add(btnDeletePackage);
pf.startSection(constants.ArchivedPackagesList());
pf.addRow(packagesToolbar);
pf.addRow(packages);
pf.endSection();
pf.startSection(constants.ArchivedAssets());
pf.addRow(table);
pf.endSection();
initWidget(pf);
}