private Constants constants = GWT.create(Constants.class);
public ArchivedAssetManager(final ExplorerViewCenterPanel tab) {
PrettyFormLayout pf = new PrettyFormLayout();
VerticalPanel header = new VerticalPanel();
header.add(new HTML(constants.ArchivedItems()));
pf.addHeader("images/backup_large.png", header); //NON-NLS
EditItemEvent edit = new EditItemEvent () {
public void open(String key) {
tab.openAsset(key);
}
public void open(MultiViewRow[] rows) {
for ( MultiViewRow row : rows ) {
tab.openAsset( row.uuid );
}
}
};
grid = new AssetItemGrid(edit, AssetItemGrid.ARCHIVED_RULE_LIST_TABLE_ID, new AssetItemGridDataLoader() {
public void loadData(int startRow, int numberOfRows,
GenericCallback cb) {
RepositoryServiceFactory.getService().loadArchivedAssets(startRow, numberOfRows, cb);
}
});
loadPackages();
Toolbar tb = new Toolbar();
final ToolbarButton restorePackage = new ToolbarButton();
restorePackage.addListener(new ButtonListenerAdapter() {
public void onClick(
com.gwtext.client.widgets.Button button,
EventObject e) {
restorePackage(packages.getValue(packages.getSelectedIndex()));
}
});
restorePackage.setText(constants.RestoreSelectedPackage());
tb.addButton(restorePackage);
final ToolbarButton delPackage = new ToolbarButton();
delPackage.setText(constants.PermanentlyDeletePackage());
delPackage.addListener(new ButtonListenerAdapter() {
public void onClick(
com.gwtext.client.widgets.Button button,
EventObject e) {
if (Window.confirm(constants.AreYouSurePackageDelete())) {
deletePackage(packages.getValue(packages.getSelectedIndex()));
}
}
});
tb.addButton(delPackage);
pf.startSection(constants.ArchivedPackagesList());
pf.addRow(tb);
pf.addRow(packages);
pf.endSection();
tb = new Toolbar();
final ToolbarButton restoreAsset = new ToolbarButton();
restoreAsset.setText(constants.RestoreSelectedAsset());
tb.addButton(restoreAsset);
restoreAsset.addListener(new ButtonListenerAdapter() {
public void onClick(com.gwtext.client.widgets.Button button, EventObject e) {
if (grid.getSelectedRowUUIDs() == null) {
Window.alert(constants.PleaseSelectAnItemToRestore());
return;
}
RepositoryServiceFactory.getService().archiveAssets( grid.getSelectedRowUUIDs(), false, new GenericCallback() {
public void onSuccess(Object arg0) {
Window.alert(constants.ItemRestored());
grid.refreshGrid();
}
});
};
});
final ToolbarButton deleteAsset = new ToolbarButton();
deleteAsset.setText(constants.DeleteSelectedAsset());
tb.addButton(deleteAsset);
deleteAsset.addListener(
new ButtonListenerAdapter() {
public void onClick(
com.gwtext.client.widgets.Button button,
EventObject e) {
if (grid.getSelectedRowUUIDs() == null) {
Window.alert(constants.PleaseSelectAnItemToPermanentlyDelete());
return;
}
if (!Window.confirm(constants.AreYouSureDeletingAsset())) {
return;
}
RepositoryServiceFactory.getService().removeAssets( grid.getSelectedRowUUIDs(), new GenericCallback() {
public void onSuccess(Object arg0) {
Window.alert(constants.ItemDeleted());
grid.refreshGrid();
}
});
}
});
pf.startSection(constants.ArchivedAssets());
pf.addRow(tb);
pf.addRow(grid);
pf.endSection();
initWidget( pf );
}