List<CategoryInfo> categories = DeviceManager.getCategories();
int index = categories.indexOf(element);
int targetIndex = index + delta;
CategoryInfo nextCategory =
targetIndex < categories.size() ? (CategoryInfo) categories.get(targetIndex) : null;
commands_add(new CategoryMoveCommand(category, nextCategory));
} else if (element instanceof DeviceInfo) {
DeviceInfo device = (DeviceInfo) element;
CategoryInfo category = device.getCategory();
List<DeviceInfo> devices = category.getDevices();
int index = devices.indexOf(device);