public static FigureEditorDialog buildEditFigureDialog(JFrame frame, FigureModel figureModel, FigureTableModel figureTableModel, int indexToEdit) {
        Figure figure = figureModel.getFigure(indexToEdit);
        if (figure instanceof Rectangle) {
            return new RectangleEditorDialog(frame, figureModel, figureTableModel, false, (Rectangle) figure, indexToEdit);
        }
        if (figure instanceof Oval) {
            return new OvalEditorDialog(frame, figureModel, figureTableModel, false, (Oval) figure, indexToEdit);
        }
        throw new IllegalArgumentException();
    }