GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable reason) {
}
public void onSuccess() {
final LinkerSelectionContext lh = linker.getSelectionContext();
if (!lh.getMultipleSelection().isEmpty()) {
// Usages
final List<String> l = new ArrayList<String>();
for (GWTJahiaNode node : lh.getMultipleSelection()) {
l.add(node.getPath());
}
final JahiaContentManagementServiceAsync async = JahiaContentManagementService.App.getInstance();
if (lh.getSingleSelection() != null && lh.getSingleSelection().isReference()) {
async.deletePaths(l, new BaseAsyncCallback<Object>() {
public void onApplicationFailure(Throwable throwable) {
Log.error(throwable.getMessage(), throwable);
MessageBox.alert(Messages.get("label.error", "Error"), throwable.getMessage(), null);
}
public void onSuccess(Object o) {
linker.refresh(EditLinker.REFRESH_ALL);
linker.select(null);
}
});
} else {
async.getUsages(l, new BaseAsyncCallback<List<GWTJahiaNodeUsage>>() {
public void onSuccess(List<GWTJahiaNodeUsage> result) {
String icon = MessageBox.WARNING;
String message;
if (l.size() > 1) {
message = Messages.getWithArgs("message.remove.multiple.confirm",
"Do you really want to remove the {0} selected resources?",
new String[]{String.valueOf(
l.size())});
} else {
if (lh.getMultipleSelection().get(0).getNodeTypes().contains("jnt:page")) {
message = Messages.getWithArgs(
"message.remove.single.page.confirm",
"Do you really want to remove the selected PAGE {0}?",
new String[]{lh.getSingleSelection().getName()});
icon = "ext-mb-delete-page";
} else {
message = Messages.getWithArgs(
"message.remove.single.confirm",
"Do you really want to remove the selected resource {0}?",
new String[]{lh.getSingleSelection().getName()});
}
}
if (l.size() > 1) {
message += "<br/><br/>";
int i = 0;
for (GWTJahiaNode node : lh.getMultipleSelection()) {
if (i > 4) {
message += "<br/>...";
break;
}
message += "<br/>" + node.getName();