@Test public void testToggleActivationItem() throws Exception { final MasterReport masterReport = new MasterReport(); final CompoundDataFactory compoundDataFactory = new CompoundDataFactory(); final TableDataFactory tableDataFactory = new TableDataFactory(); tableDataFactory.addTable( "default", new DefaultTableModel() ); compoundDataFactory.add( tableDataFactory ); masterReport.setDataFactory( compoundDataFactory ); final ReportRenderContext doc = new ReportRenderContext( masterReport ); final JMenuItem item = new JMenuItem(); final ReportQueryNode reportQueryNode = new ReportQueryNode( compoundDataFactory, "default", true ); ContextMenuUtility.toggleActivationItem( doc, reportQueryNode, item ); Assert.assertTrue( item.isEnabled() ); final TableDataFactory tableDataFactory2 = new TableDataFactory(); tableDataFactory2.addTable( "default", new DefaultTableModel() ); compoundDataFactory.add( tableDataFactory2 ); ContextMenuUtility.toggleActivationItem( doc, reportQueryNode, item ); Assert.assertFalse( item.isEnabled() ); }
protected static void toggleActivationItem( final ReportRenderContext doc, final ReportQueryNode rqn, final MenuElement activationItem ) { if ( activationItem instanceof JMenuItem && doc != null ) { final DataFactory dataFactory = doc.getContextRoot().getDataFactory(); boolean disabled = false; if ( dataFactory instanceof CompoundDataFactory ) { final CompoundDataFactory compound = (CompoundDataFactory) dataFactory; int count = countQueriesWithName( rqn.getQueryName(), compound ); disabled = count > 1; } if ( disabled ) { ( (JMenuItem) activationItem ).setEnabled( false ); } else { ( (JMenuItem) activationItem ).setEnabled( true ); } } }
ContextMenuUtility { protected static void toggleActivationItem( final ReportRenderContext doc, final ReportQueryNode rqn, final MenuElement activationItem ) { if ( activationItem instanceof JMenuItem && doc != null ) { final DataFactory dataFactory = doc.getContextRoot().getDataFactory(); boolean disabled = false; if ( dataFactory instanceof CompoundDataFactory ) { final CompoundDataFactory compound = (CompoundDataFactory) dataFactory; int count = countQueriesWithName( rqn.getQueryName(), compound ); disabled = count > 1; } if ( disabled ) { ( (JMenuItem) activationItem ).setEnabled( false ); } else { ( (JMenuItem) activationItem ).setEnabled( true ); } } } }
ContextMenuUtility { protected static void toggleActivationItem( final ReportRenderContext doc, final ReportQueryNode rqn, final MenuElement activationItem ) { if ( activationItem instanceof JMenuItem && doc != null ) { final DataFactory dataFactory = doc.getContextRoot().getDataFactory(); boolean disabled = false; if ( dataFactory instanceof CompoundDataFactory ) { final CompoundDataFactory compound = (CompoundDataFactory) dataFactory; int count = countQueriesWithName( rqn.getQueryName(), compound ); disabled = count > 1; } if ( disabled ) { ( (JMenuItem) activationItem ).setEnabled( false ); } else { ( (JMenuItem) activationItem ).setEnabled( true ); } } } private  ContextMenuUtility(); }
ContextMenuUtility { protected static void toggleActivationItem( final ReportRenderContext doc, final ReportQueryNode rqn, final MenuElement activationItem ) { if ( activationItem instanceof JMenuItem && doc != null ) { final DataFactory dataFactory = doc.getContextRoot().getDataFactory(); boolean disabled = false; if ( dataFactory instanceof CompoundDataFactory ) { final CompoundDataFactory compound = (CompoundDataFactory) dataFactory; int count = countQueriesWithName( rqn.getQueryName(), compound ); disabled = count > 1; } if ( disabled ) { ( (JMenuItem) activationItem ).setEnabled( false ); } else { ( (JMenuItem) activationItem ).setEnabled( true ); } } } private  ContextMenuUtility(); static JPopupMenu getMenu( final ReportDesignerContext context, final Object selectedElement ); static JPopupMenu createDataSourcePopup( final ReportDesignerContext designerContext ); static void createDataSourceMenu( final ReportDesignerContext designerContext,
                                           final JComponent insertDataSourcesMenu ); }
ContextMenuUtility { protected static void toggleActivationItem( final ReportRenderContext doc, final ReportQueryNode rqn, final MenuElement activationItem ) { if ( activationItem instanceof JMenuItem && doc != null ) { final DataFactory dataFactory = doc.getContextRoot().getDataFactory(); boolean disabled = false; if ( dataFactory instanceof CompoundDataFactory ) { final CompoundDataFactory compound = (CompoundDataFactory) dataFactory; int count = countQueriesWithName( rqn.getQueryName(), compound ); disabled = count > 1; } if ( disabled ) { ( (JMenuItem) activationItem ).setEnabled( false ); } else { ( (JMenuItem) activationItem ).setEnabled( true ); } } } private  ContextMenuUtility(); static JPopupMenu getMenu( final ReportDesignerContext context, final Object selectedElement ); static JPopupMenu createDataSourcePopup( final ReportDesignerContext designerContext ); static void createDataSourceMenu( final ReportDesignerContext designerContext,
                                           final JComponent insertDataSourcesMenu );  }