{
}
public static JPopupMenu getMenu(final ReportDesignerContext context, final Object selectedElement)
{
ReportDesignerView view = context.getView();
if (selectedElement == null || selectedElement instanceof MasterReport) // This check assumes that we've click on a report band see JIRA PRD-1076
{
return view.getPopupMenu("popup-ReportDefinition"); // NON-NLS
}
final ReportDesignerDocumentContext activeContext = context.getActiveContext();
if (activeContext instanceof ReportRenderContext)
{
ReportRenderContext doc = (ReportRenderContext) activeContext;
if (selectedElement == doc.getReportDefinition())
{
return view.getPopupMenu("popup-ReportDefinition");// NON-NLS
}
}
if (selectedElement instanceof SubReport)
{
return view.getPopupMenu("popup-SubReport");// NON-NLS
}
if (selectedElement instanceof CompoundDataFactory)
{
return createDataSourcePopup(context);
}
if (selectedElement instanceof DataFactory)
{
return view.getPopupMenu("popup-DataSource");// NON-NLS
}
if (selectedElement instanceof ReportFunctionNode)
{
return view.getPopupMenu("popup-Expressions");// NON-NLS
}
if (selectedElement instanceof ReportQueryNode)
{
final ReportQueryNode rqn = (ReportQueryNode) selectedElement;
if (rqn.isAllowEdit())
{
return view.getPopupMenu("popup-Query");// NON-NLS
}
return view.getPopupMenu("popup-Inherited-Query");// NON-NLS
}
if (selectedElement instanceof Expression)
{
return view.getPopupMenu("popup-Expression");// NON-NLS
}
if (selectedElement instanceof RootLevelBand)
{
return view.getPopupMenu("popup-RootLevelBand");// NON-NLS
}
if (selectedElement instanceof RelationalGroup)
{
return view.getPopupMenu("popup-RelationalGroup");// NON-NLS
}
if (selectedElement instanceof CrosstabGroup)
{
return view.getPopupMenu("popup-CrosstabGroup");// NON-NLS
}
if (selectedElement instanceof CrosstabOtherGroup)
{
return view.getPopupMenu("popup-CrosstabOtherGroup");// NON-NLS
}
if (selectedElement instanceof CrosstabRowGroup)
{
return view.getPopupMenu("popup-CrosstabRowGroup");// NON-NLS
}
if (selectedElement instanceof CrosstabColumnGroup)
{
return view.getPopupMenu("popup-CrosstabColumnGroup");// NON-NLS
}
if (selectedElement instanceof CrosstabCellBody)
{
return view.getPopupMenu("popup-CrosstabCellBody");// NON-NLS
}
if (selectedElement instanceof Group)
{
return view.getPopupMenu("popup-Group");// NON-NLS
}
if (selectedElement instanceof Band)
{
return view.getPopupMenu("popup-Band");// NON-NLS
}
if (selectedElement instanceof Element)
{
final Element element = (Element) selectedElement;
final JPopupMenu popup = view.getPopupMenu("popup-" + element.getElementTypeName());// NON-NLS
if (popup != null)
{
return popup;
}
return view.getPopupMenu("popup-Element");// NON-NLS
}
if (selectedElement instanceof ReportParameterDefinition)
{
return view.getPopupMenu("popup-Parameters");// NON-NLS
}
if (selectedElement instanceof ParameterDefinitionEntry)
{
return view.getPopupMenu("popup-Parameter");// NON-NLS
}
if (selectedElement instanceof ReportParametersNode)
{
return view.getPopupMenu("popup-Parameters");// NON-NLS
}
if (selectedElement instanceof SubReportParametersNode)
{
return view.getPopupMenu("popup-SubReportParameters");// NON-NLS
}
return null;
}