package ru.nsu.ccfit.bogush.view;

import ru.nsu.ccfit.bogush.CarFactoryModel;

import javax.swing.*;

public class FactoryView extends JPanel {
	private JPanel mainPanel;
	private ControlPanel controlPanel;
	private InformationPanel infoPanel;
	private ButtonPanel buttonPanel;

	private CarFactoryModel model;

	public FactoryView(CarFactoryModel model) {
		this.model = model;
		JFrame frame = new JFrame("Car Factory");
		frame.setContentPane(mainPanel);
		frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		frame.setResizable(false);
		frame.setLocation(0, 0);
		frame.pack();
		frame.setVisible(true);
	}

	private void createUIComponents() {
		controlPanel = new ControlPanel(model);
		infoPanel = new InformationPanel(model);
		buttonPanel = new ButtonPanel(model);
	}
}

@@ -76,29 +76,146 @@
 el;%0A
-%0Aimport javax.swing.*
+import ru.nsu.ccfit.bogush.factory.Supplier;%0A%0Aimport javax.swing.*;%0Aimport java.awt.event.WindowAdapter;%0Aimport java.awt.event.WindowEvent
 ;%0A%0Ap
@@ -622,12 +622,15 @@
 nts.
-EXIT
+DISPOSE
 _ON_
@@ -637,16 +637,413 @@
 CLOSE);%0A
+%09%09frame.addWindowListener(new WindowAdapter() %7B%0A%09%09%09@Override%0A%09%09%09public void windowClosed(WindowEvent e) %7B%0A%09%09%09%09model.getStore().stop();%0A%09%09%09%09model.getEngineSupplier().getThread().interrupt();%0A%09%09%09%09model.getBodySupplier().getThread().interrupt();%0A%09%09%09%09for (Supplier s : model.getAccessorySuppliers()) %7B%0A%09%09%09%09%09s.getThread().interrupt();%0A%09%09%09%09%7D%0A%09%09%09%09model.getCarFactory().getThreadPool().stop();%0A%09%09%09%7D%0A%09%09%7D);%0A
 %09%09frame.

Change default close operation of main window to "dispose" Add windowClosed listener which interrupts all model threads