} else if (target instanceof CategoryInfo) {
Assert.isTrue(location == LOCATION_ON);
CategoryInfo targetCategory = (CategoryInfo) target;
for (Object element : m_dragElements) {
DeviceInfo device = (DeviceInfo) element;
commands_add(new DeviceMoveCommand(device, targetCategory, null));
}
} else {
DeviceInfo targetDevice = (DeviceInfo) target;
CategoryInfo targetCategory = targetDevice.getCategory();
// prepare next device
DeviceInfo nextDevice;
{
List<DeviceInfo> entries = targetCategory.getDevices();
int index = entries.indexOf(targetDevice);
if (location == LOCATION_BEFORE) {
nextDevice = entries.get(index);
} else {
nextDevice = GenericsUtils.getNextOrNull(entries, index);
}
}
// add commands
for (Object element : m_dragElements) {
DeviceInfo device = (DeviceInfo) element;
commands_add(new DeviceMoveCommand(device, targetCategory, nextDevice));
}
}
// refresh viewer to show result of applying commands
refreshViewer();
return true;