@Override
public String getTitle() {
Selection sel = canvas.getSelection();
Class<? extends CanvasObject> commonClass = null;
int commonCount = 0;
CanvasObject firstObject = null;
int totalCount = 0;
for (CanvasObject obj : sel.getSelected()) {
if (firstObject == null) {
firstObject = obj;
commonClass = obj.getClass();
commonCount = 1;
} else if (obj.getClass() == commonClass) {
commonCount++;
} else {
commonClass = null;
}
totalCount++;
}
if (firstObject == null) {
return null;
} else if (commonClass == null) {
return getFromLocale("selectionVarious", "" + totalCount);
} else if (commonCount == 1) {
return getFromLocale("selectionOne", firstObject.getDisplayName());
} else {
return getFromLocale("selectionMultiple", firstObject.getDisplayName(),
"" + commonCount);
}
}