Device[] devices = this.deviceDatabase.getDeviceManager().getDevices(configurations, platforms); DeviceTreeItem[] deviceItems = new DeviceTreeItem[ devices.length ]; ArrayList rootItemsList = new ArrayList(); DeviceTreeItem virtualTreeItem = null; Vendor lastVendor = null; DeviceTreeItem lastVendorItem = null; for (int i = 0; i < devices.length; i++) { Device device = devices[i]; DeviceTreeItem item; if (device.isVirtual()) { if(virtualTreeItem == null) { virtualTreeItem = getItem( null, null, null ); rootItemsList.add( virtualTreeItem ); } item = getItem( virtualTreeItem, null, device ); virtualTreeItem.addChild(item); } else { if (device.getVendor() != lastVendor) { lastVendor = device.getVendor(); lastVendorItem = getItem( null, lastVendor, null ); rootItemsList.add( lastVendorItem ); } item = getItem( lastVendorItem, lastVendor, device ); lastVendorItem.addChild( item ); } deviceItems[i] = item; } this.deviceTreeItems = deviceItems;  if (virtualTreeItem != null) { DeviceTreeItem[] rootItems = (DeviceTreeItem[]) rootItemsList.toArray( new DeviceTreeItem[ rootItemsList.size() ]); rootItemsList.clear(); rootItemsList.add( virtualTreeItem ); for (int i = 0; i < rootItems.length; i++) { DeviceTreeItem item = rootItems[i]; if ( item != virtualTreeItem ) { rootItemsList.add( item ); } } } this.rootTreeItems = (DeviceTreeItem[]) rootItemsList.toArray( new DeviceTreeItem[ rootItemsList.size() ]);
rebuild(configurations,platforms,null);
	public void rebuild(Configuration[] configurations, Platform[] platforms) {		Device[] devices = this.deviceDatabase.getDeviceManager().getDevices(configurations, platforms);		DeviceTreeItem[] deviceItems = new DeviceTreeItem[ devices.length ];		ArrayList rootItemsList = new ArrayList();        DeviceTreeItem virtualTreeItem = null;		Vendor lastVendor = null;		DeviceTreeItem lastVendorItem = null;		for (int i = 0; i < devices.length; i++) {			Device device = devices[i];			DeviceTreeItem item;			if (device.isVirtual()) {                if(virtualTreeItem == null) {                    virtualTreeItem = getItem( null, null, null );                    rootItemsList.add( virtualTreeItem );                }				item = getItem( virtualTreeItem, null, device );				virtualTreeItem.addChild(item);			} else {				if (device.getVendor() != lastVendor) {					lastVendor = device.getVendor();					lastVendorItem = getItem( null, lastVendor, null );					rootItemsList.add( lastVendorItem );				}				item = getItem( lastVendorItem, lastVendor, device );				lastVendorItem.addChild( item );			}			deviceItems[i] = item;		}		this.deviceTreeItems = deviceItems;		// now sort the root items with the "virtual" tree item as the first element:		if (virtualTreeItem != null) {			DeviceTreeItem[] rootItems = (DeviceTreeItem[]) rootItemsList.toArray( new DeviceTreeItem[ rootItemsList.size() ]);			rootItemsList.clear();			rootItemsList.add( virtualTreeItem );			for (int i = 0; i < rootItems.length; i++) {				DeviceTreeItem item = rootItems[i];				if ( item != virtualTreeItem ) {					rootItemsList.add( item );				}			}		}		this.rootTreeItems = (DeviceTreeItem[]) rootItemsList.toArray( new DeviceTreeItem[ rootItemsList.size() ]);    }