public static List<String> makeHierarchy ( SummaryGroup group ) { final List<String> result = new LinkedList<> (); while ( group != null ) { result.add ( 0, group.getName () ); group = (SummaryGroup) ( group.eContainer () instanceof SummaryGroup ? group.eContainer () : null ); } return result; }
for ( final SummaryGroup subGroup : group.getSubGroups () ) if ( subGroup.getItems ().size () < threshold && subGroup.getSubGroups ().isEmpty () ) group.getItems ().addAll ( subGroup.getItems () ); removeGroups.add ( subGroup ); group.getSubGroups ().removeAll ( removeGroups );
private SummaryGroup getSummaryGroup ( final SummaryGroup parent, final Collection<SummaryGroup> groups, final LinkedList<String> hierarchy ) { if ( hierarchy.isEmpty () ) { return parent; } final String level = hierarchy.pollFirst (); for ( final SummaryGroup group : groups ) { if ( group.getName ().equals ( level ) ) { return getSummaryGroup ( group, group.getSubGroups (), hierarchy ); } } // finally we need to create final SummaryGroup group = OsgiFactory.eINSTANCE.createSummaryGroup (); group.setName ( level ); groups.add ( group ); return getSummaryGroup ( group, group.getSubGroups (), hierarchy ); } }
protected void processGroup ( final MasterServer app, final SummaryGroup group, final AbstractComponentItemCreator creator ) { final SummaryItem item = OsgiFactory.eINSTANCE.createSummaryItem (); item.setGroup ( group ); item.setInformation ( OsgiFactory.eINSTANCE.createItemInformation () ); item.getInformation ().setDescription ( String.format ( "Summary group information: %s", Names.makeId ( group ) ) ); item.getInformation ().getHierarchy ().addAll ( Names.makeHierarchy ( group ) ); item.getInformation ().setSystem ( "SCADA" ); final CreationRequest<SummaryItem> c = creator.addItem ( item ); c.localTags ( "SUMMARY" ); c.customizationTags ( "summary" ); final SummaryItem sumItem = c.create (); /* * FIXME: next thing is a bit wonky * actually the summary group should be used for generating sub items * but since the customization process can rename the item, the generator * cannot create a name for this later on. So for now all items * that are SummaryItem will be treated as sub-summary items. */ if ( group.eContainer () instanceof SummaryGroup ) { ( (SummaryGroup)group.eContainer () ).getItems ().add ( sumItem ); } }
/** * This returns the label styled text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object getStyledText ( Object object ) { String label = ( (SummaryGroup)object ).getName (); StyledString styledLabel = new StyledString (); if ( label == null || label.length () == 0 ) { styledLabel.append ( getString ( "_UI_SummaryGroup_type" ), StyledString.Style.QUALIFIER_STYLER ); //$NON-NLS-1$ } else { styledLabel.append ( getString ( "_UI_SummaryGroup_type" ), StyledString.Style.QUALIFIER_STYLER ).append ( " " + label ); //$NON-NLS-1$ //$NON-NLS-2$ } return styledLabel; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public SummaryGroup getGroup () { if ( group != null && group.eIsProxy () ) { InternalEObject oldGroup = (InternalEObject)group; group = (SummaryGroup)eResolveProxy ( oldGroup ); if ( group != oldGroup ) { if ( eNotificationRequired () ) eNotify ( new ENotificationImpl ( this, Notification.RESOLVE, OsgiPackage.SUMMARY_ITEM__GROUP, oldGroup, group ) ); } } return group; }
public static List<String> makeHierarchy ( SummaryGroup group ) { final List<String> result = new LinkedList<> (); while ( group != null ) { result.add ( 0, group.getName () ); group = (SummaryGroup) ( group.eContainer () instanceof SummaryGroup ? group.eContainer () : null ); } return result; }
private void processItem ( final MasterServer app, final Item item ) { if ( item.getInformation () == null ) { return; } final EList<String> hier = item.getInformation ().getHierarchy (); if ( hier.isEmpty () ) { return; } final SummaryGroup group = getSummaryGroup ( null, app.getSummaryGroups (), new LinkedList<> ( hier ) ); if ( group == null ) { return; } group.getItems ().add ( item ); }