Heat a large saute pan or Dutch oven over high heat for 2 minutes. Swirl in 3 tablespoons olive oil, and then add the onions, 1 teaspoon thyme, 1 teaspoon salt and some pepper. Cook 6 minutes, stirring often, and then turn the heat down to medium. Add the butter, and cook 15 minutes, stirring and scraping with a wooden spoon, until the onions start to caramelize. Turn the heat down to low and continue cooking for about 10 minutes, stirring often, until the onions are a deep golden brown. Remove the pan from the heat and set aside.
Use a mandoline to slice the potatoes into 1/8-inch-thick rounds. Toss them with the cream, 1 teaspoon thyme, 1 teaspoon salt and some pepper.
Cut the tomatoes into 1/4-inch-thick slices. Arrange them on a plate and season with 1 teaspoon salt and some pepper.
Place half the caramelized onions in an even layer in a 9-by-9-inch (or equivalent) gratin or baking dish. Arrange one layer of alternating potatoes and tomatoes on top of the onion layer. Layer a couple of slices of cheese and scatter some olives over the cheese. Drizzle with 2 tablespoons of the cream from the potatoes and 1 tablespoon olive oil. Season with 1 teaspoon salt, a healthy pinch of pepper, 1/2 teaspoon thyme and half the basil.
Scatter the rest of the caramelized onions over the potatoes and tomatoes. Arrange another layer of potatoes, tomatoes and cheese on top; make this layer pretty, because it will be the top of your gratin. Pour the remaining cream from the potatoes and the remaining 1 tablespoon olive oil over the potatoes and tomatoes. Season with 1/4 teaspoon salt, a pinch of pepper, and the remaining 1/2 teaspoon thyme, olives and basil. Press the vegetables down with your fingers. The cream and oil will come up through the layers and coat the vegetables evenly.
Cover the baking dish tightly with aluminum foil. Bake until the potatoes are tender when pierced, about 2 hours. Remove the gratin from the oven and uncover it, being careful of the steam.
Turn the oven up to 450 degrees F and return the gratin, uncovered, to the oven. Cook until the juices have thickened and the top is nice and golden brown (as in "gratineed"), another 25 to 30 minutes.