use of com.minecolonies.api.colony.workorders.WorkOrderView in project minecolonies by ldtteam.
the class WindowWorkOrderPage method updatePriority.
/**
* On Button click update the priority.
*
* @param button the clicked button.
*/
private void updatePriority(@NotNull final Button button) {
final int id = Integer.parseInt(button.getParent().findPaneOfTypeByID("hiddenId", Text.class).getTextAsString());
final String buttonLabel = button.getID();
for (int i = 0; i < workOrders.size(); i++) {
final WorkOrderView workOrder = workOrders.get(i);
if (workOrder.getId() == id) {
if (buttonLabel.equals(BUTTON_UP) && i > 0) {
workOrder.setPriority(workOrders.get(i - 1).getPriority() + 1);
Network.getNetwork().sendToServer(new WorkOrderChangeMessage(this.building, id, false, workOrder.getPriority()));
} else if (buttonLabel.equals(BUTTON_DOWN) && i <= workOrders.size()) {
workOrder.setPriority(workOrders.get(i + 1).getPriority() - 1);
Network.getNetwork().sendToServer(new WorkOrderChangeMessage(this.building, id, false, workOrder.getPriority()));
}
sortWorkOrders();
window.findPaneOfTypeByID(LIST_WORKORDER, ScrollingList.class).refreshElementPanes();
return;
}
}
}
Aggregations