private Button btnRestorePackage;
private Button btnDeletePackage;
public ArchivedAssetManager() {
PrettyFormLayout pf = new PrettyFormLayout();
VerticalPanel header = new VerticalPanel();
header.add( new HTML( constants.ArchivedItems() ) );
pf.addHeader( images.backupLarge(),
header );
final TabOpener tabOpener = TabOpener.getInstance();
OpenItemCommand openSelectedCommand = new OpenItemCommand() {
public void open(String key) {
tabOpener.openAsset( key );
}
public void open(MultiViewRow[] rows) {
tabOpener.openAssetsToMultiView( rows );
}
};
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,
openSelectedCommand );
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 );
}