}
}
protected void updateSelection()
{
final DocumentContextSelectionModel selectionModel = getSelectionModel();
if (selectionModel == null)
{
setEnabled(false);
return;
}
if (selectionModel.getSelectionCount() == 0)
{
// there's nothing selected, we can safely add a new group
// at the report level (AbstractReportDefinition)
setEnabled(true);
return;
}
if (isSingleElementSelection() == false)
{
// there's more than 1 element selected, disable because
// we can't know where to insert in this case
setEnabled(false);
return;
}
final Object selectedElement = selectionModel.getSelectedElement(0);
if (selectedElement == getActiveContext().getReportDefinition() || selectedElement instanceof RelationalGroup)
{
// if the selectedElement is the report-definition or a relational group
// then we can safely insert to those
setEnabled(true);