class MachineReassignmentPanel extends SolutionPanel<MachineReassignment> {

    public static final String LOGO_PATH = "/org/optaplanner/examples/machinereassignment/swingui/machineReassignmentLogo.png";

    private JPanel machineListPanel;

    private MrMachinePanel unassignedPanel;
    private JLabel tooBigLabel = null;
    private Map<MrMachine, MrMachinePanel> machineToPanelMap;

    public MachineReassignmentPanel() {
        GroupLayout layout = new GroupLayout(this);
        setLayout(layout);
        createMachineListPanel();
        JPanel headerPanel = new JPanel();
        layout.setHorizontalGroup(layout.createParallelGroup()
                .addComponent(headerPanel).addComponent(machineListPanel));
        layout.setVerticalGroup(layout.createSequentialGroup()
                .addComponent(headerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                .addComponent(machineListPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                        GroupLayout.PREFERRED_SIZE));
    }

    private void createMachineListPanel() {
        machineListPanel = new JPanel(new GridLayout(0, 1));
        unassignedPanel = new MrMachinePanel(this, Collections.emptyList(), null);
        machineListPanel.add(unassignedPanel);
        machineToPanelMap = new LinkedHashMap<>();
        machineToPanelMap.put(null, unassignedPanel);
    }

    @Override
    public void resetPanel(MachineReassignment machineReassignment) {
        for (MrMachinePanel machinePanel : machineToPanelMap.values()) {
            if (machinePanel.getMachine() != null) {
                machineListPanel.remove(machinePanel);
            }
        }
        machineToPanelMap.clear();
        machineToPanelMap.put(null, unassignedPanel);
        unassignedPanel.clearProcessAssignments();
        updatePanel(machineReassignment);
    }

    @Override
    public void updatePanel(MachineReassignment machineReassignment) {<FILL_FUNCTION_BODY>}

    public void deleteMachine(final MrMachine machine) {
        logger.info("Scheduling delete of machine ({}).", machine);
        doProblemChange((machineReassignment, problemChangeDirector) -> problemChangeDirector.lookUpWorkingObject(machine)
                .ifPresentOrElse(workingMachine -> {
                    // First remove the problem fact from all planning entities that use it
                    for (MrProcessAssignment processAssignment : machineReassignment.getProcessAssignmentList()) {
                        if (processAssignment.getOriginalMachine() == workingMachine) {
                            problemChangeDirector.changeProblemProperty(processAssignment,
                                    workingProcessAssignment -> workingProcessAssignment.setOriginalMachine(null));
                        }
                        if (processAssignment.getMachine() == workingMachine) {
                            problemChangeDirector.changeVariable(processAssignment, "machine",
                                    workingProcessAssignment -> workingProcessAssignment.setMachine(null));
                        }
                    }
                    // A SolutionCloner does not clone problem fact lists (such as machineList)
                    // Shallow clone the machineList so only workingSolution is affected, not bestSolution or guiSolution
                    ArrayList<MrMachine> machineList = new ArrayList<>(machineReassignment.getMachineList());
                    machineReassignment.setMachineList(machineList);
                    // Remove it the problem fact itself
                    problemChangeDirector.removeProblemFact(workingMachine, machineList::remove);
                }, () -> logger.info("Skipping problem change due to machine ({}) already deleted.", machine)));
    }

}

        List<MrResource> resourceList = machineReassignment.getResourceList();
        unassignedPanel.setResourceList(resourceList);
        if (machineReassignment.getMachineList().size() > 1000) {
            if (tooBigLabel == null) {
                tooBigLabel = new JLabel("The dataset is too big to show.");
                machineListPanel.add(tooBigLabel);
            }
        } else {
            if (tooBigLabel != null) {
                machineListPanel.remove(tooBigLabel);
                tooBigLabel = null;
            }
            Set<MrMachine> deadMachineSet = new LinkedHashSet<>(machineToPanelMap.keySet());
            deadMachineSet.remove(null);
            for (MrMachine machine : machineReassignment.getMachineList()) {
                deadMachineSet.remove(machine);
                MrMachinePanel machinePanel = machineToPanelMap.get(machine);
                if (machinePanel == null) {
                    machinePanel = new MrMachinePanel(this, resourceList, machine);
                    machineListPanel.add(machinePanel);
                    machineToPanelMap.put(machine, machinePanel);
                }
                machinePanel.clearProcessAssignments();
            }
            unassignedPanel.clearProcessAssignments();
            for (MrProcessAssignment processAssignment : machineReassignment.getProcessAssignmentList()) {
                MrMachine machine = processAssignment.getMachine();
                MrMachinePanel machinePanel = machineToPanelMap.get(machine);
                machinePanel.addProcessAssignment(processAssignment);
            }
            for (MrMachine deadMachine : deadMachineSet) {
                MrMachinePanel deadMachinePanel = machineToPanelMap.remove(deadMachine);
                machineListPanel.remove(deadMachinePanel);
            }
            for (MrMachinePanel machinePanel : machineToPanelMap.values()) {
                machinePanel.update();
            }
        }
    
<methods>public non-sealed void <init>() ,public java.awt.Color determinePlanningEntityColor(java.lang.Object, java.lang.Object) ,public java.lang.String determinePlanningEntityTooltip(java.lang.Object) ,public void doProblemChange(ProblemChange<org.optaplanner.examples.machinereassignment.domain.MachineReassignment>) ,public void doProblemChange(ProblemChange<org.optaplanner.examples.machinereassignment.domain.MachineReassignment>, boolean) ,public java.awt.Dimension getPreferredScrollableViewportSize() ,public int getScrollableBlockIncrement(java.awt.Rectangle, int, int) ,public boolean getScrollableTracksViewportHeight() ,public boolean getScrollableTracksViewportWidth() ,public int getScrollableUnitIncrement(java.awt.Rectangle, int, int) ,public org.optaplanner.examples.machinereassignment.domain.MachineReassignment getSolution() ,public SolutionBusiness<org.optaplanner.examples.machinereassignment.domain.MachineReassignment,?> getSolutionBusiness() ,public SolverAndPersistenceFrame<org.optaplanner.examples.machinereassignment.domain.MachineReassignment> getSolverAndPersistenceFrame() ,public java.lang.String getUsageExplanationPath() ,public boolean isIndictmentHeatMapEnabled() ,public boolean isUseIndictmentColor() ,public boolean isWrapInScrollPane() ,public abstract void resetPanel(org.optaplanner.examples.machinereassignment.domain.MachineReassignment) ,public void setSolutionBusiness(SolutionBusiness<org.optaplanner.examples.machinereassignment.domain.MachineReassignment,?>) ,public void setSolverAndPersistenceFrame(SolverAndPersistenceFrame<org.optaplanner.examples.machinereassignment.domain.MachineReassignment>) ,public void setUseIndictmentColor(boolean) ,public void updatePanel(org.optaplanner.examples.machinereassignment.domain.MachineReassignment) <variables>protected static final java.awt.Color[][] INDICTMENT_COLORS,public static final java.awt.Dimension PREFERRED_SCROLLABLE_VIEWPORT_SIZE,protected static final java.lang.String USAGE_EXPLANATION_PATH,protected double[] indictmentMinimumLevelNumbers,protected final transient Logger logger,protected org.optaplanner.swing.impl.TangoColorFactory normalColorFactory,protected SolutionBusiness<org.optaplanner.examples.machinereassignment.domain.MachineReassignment,?> solutionBusiness,protected SolverAndPersistenceFrame<org.optaplanner.examples.machinereassignment.domain.MachineReassignment> solverAndPersistenceFrame,protected boolean useIndictmentColor