//
////////////////////////////////////////////////////////////////////////////
@Override
public void execute() {
DeviceInfo device = DeviceManager.getDevice(m_id);
CategoryInfo category = DeviceManager.getCategory(m_categoryId);
if (device == null || category == null) {
return;
}
// don't move before itself, this is no-op
if (m_id.equals(m_nextDeviceId)) {
return;
}
// remove source entry
device.getCategory().removeDevice(device);
// add to new location
DeviceInfo nextDevice = DeviceManager.getDevice(m_nextDeviceId);
if (nextDevice != null) {
int index = category.getDevices().indexOf(nextDevice);
category.addDevice(index, device);
} else {
category.addDevice(device);
}
}