public ControlPanel(final MainFrame mainFrame) {
        shoppingList = new ShoppingList();
        this.mainFrame = mainFrame;
        planner = this.mainFrame.planner;
        setSize(WIDTH, HEIGHT);
        setLayout(new FlowLayout(FlowLayout.LEFT));

        shopsJButton = new JButton();
        shopsJButton.setText("Загрузить список магазинов из файла");
        shopsJButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                shopsJFileChooser = new JFileChooser();
                shopsJFileChooser.setCurrentDirectory(new File("."));
                shopsJFileChooser.setFileFilter(new FileNameExtensionFilter("*.xml", "xml"));
                int result = shopsJFileChooser.showDialog(shopsJFileChooser.getParent(), "Выбрать");
                if (result == JFileChooser.APPROVE_OPTION) {
                    try {
                        planner.clear();
                        XmlHelper.readShops(shopsJFileChooser.getSelectedFile(), planner);
                        productCodesJList.setListData(planner.getObjectStorage().orderedProductCodesByAlphabet().toArray());
                        mainFrame.chartPanel.changeInitialCoordinates();
                        mainFrame.chartPanel.showChart();
                    } catch (FileNotFoundException e1) {

                    } catch (XMLStreamException e1) {
                        JOptionPane.showMessageDialog(null, XML_FORMAT_MESSAGE);
                    }
                }
            }
        });
        add(shopsJButton);

        productCodesJList = new JList();
        productCodesJList.setMinimumSize(new Dimension(200, 200));
        add(new JScrollPane(productCodesJList));

        JLabel coordinatesJLabel = new JLabel();
        coordinatesJLabel.setText("Начальная точка");
        add(coordinatesJLabel);

        JPanel coordinatesJPanel = new JPanel(new GridLayout(2, 2));
        coordinatesJPanel.add(new JLabel("x: "));
        xJTextField = new JTextField(0);
        xJTextField.setColumns(4);
        xJTextField.setText("0");
        xJTextField.addFocusListener(new FocusAdapter() {
            private int prevX;

            @Override
            public void focusLost(FocusEvent e) {
                Integer x = convertToInteger(xJTextField.getText());
                if (x != null && prevX != x) {
                    Integer y = convertToInteger(yJTextField.getText());
                    if (y != null) {
                        Coordinates coordinates = new Coordinates(x, y);
                        shoppingList.setCoordinates(coordinates);
                        planner.getObjectStorage().setInitialCoordinates(coordinates);
                        planner.getPlannerContext().setShoppingList(shoppingList);
                        mainFrame.chartPanel.changeInitialCoordinates();
                        prevX = x;
                    }
                }
            }
        });
        coordinatesJPanel.add(xJTextField);
        coordinatesJPanel.add(new JLabel("y: "));
        yJTextField = new JTextField();
        yJTextField.setColumns(4);
        yJTextField.setText("0");
        yJTextField.addFocusListener(new FocusAdapter() {
            private int prevY;

            @Override
            public void focusLost(FocusEvent e) {
                Integer y = convertToInteger(yJTextField.getText());
                if (y != null && prevY != y) {
                    Integer x = convertToInteger(xJTextField.getText());
                    if (x != null) {
                        Coordinates coordinates = new Coordinates(x, y);
                        shoppingList.setCoordinates(coordinates);
                        planner.getObjectStorage().setInitialCoordinates(coordinates);
                        planner.getPlannerContext().setShoppingList(shoppingList);
                        mainFrame.chartPanel.changeInitialCoordinates();
                        prevY = y;
                    }
                }
            }
        });
        coordinatesJPanel.add(yJTextField);
        add(coordinatesJPanel);

        buttonGroupJPanel = new JPanel(new GridLayout(2, 1));
        purposeButtonGroup = new ButtonGroup();
        minCostJRadioButton = new JRadioButton(MIN_COST);
        purposeButtonGroup.add(minCostJRadioButton);
        buttonGroupJPanel.add(minCostJRadioButton);
        minCostJRadioButton.setSelected(true);
        minDistanceJRadioButton = new JRadioButton(MIN_DISTANCE);
        purposeButtonGroup.add(minDistanceJRadioButton);
        buttonGroupJPanel.add(minDistanceJRadioButton);
        add(buttonGroupJPanel);

        buildShoppingPlanJButton = new JButton();
        buildShoppingPlanJButton.setText("Построить маршрут");
        buildShoppingPlanJButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                buildShoppingList();
                planner.buildShoppingPlan();
                mainFrame.chartPanel.showPath();
                ShoppingPlan shoppingPlan = planner.getPlannerContext().getShoppingPlan();
                costJLabel.setText(String.valueOf(shoppingPlan.getCost()));
                distanceJLabel.setText(String.valueOf(shoppingPlan.getDistance()));
            }
        });
        add(buildShoppingPlanJButton);

        JPanel resultPanel = new JPanel(new GridLayout(2, 2));
        resultPanel.add(new JLabel("Стоимость:"));
        costJLabel = new JLabel();
        resultPanel.add(costJLabel);
        resultPanel.add(new JLabel("Пройденный путь:"));
        distanceJLabel = new JLabel();
        resultPanel.add(distanceJLabel);
        add(resultPanel);

        JPanel shopInfoJPanel = new JPanel(new GridLayout(2, 1));
        shopInfoJlabel = new JLabel("Информация о магазине (Кликнете по магазину) ");
        shopInfoJPanel.add(shopInfoJlabel);
        productsJList = new JList();
        shopInfoJPanel.add(new JScrollPane(productsJList));
        add(shopInfoJPanel);
    }