Removing unwanted elements from the welcome screen can only take us so far. How can we replace the entire welcome screen with our own implementation?
Welcome frame provider
To override the welcome screen we need to contribute a welcome frame provider to the
com.intellij.welcomeFrameProvider
extension point. The provider is responsible for creating an implementation of
com.intellij.openapi.wm.IdeFrame
, the interface representing a top-level IDE window.
However, writing our own fully custom implementation of IdeFrame
from scratch is fairly tedious. To integrate well
with the rest of the IDE we would need to provide such things as a glass pane, a BalloonLayout to house
notifications, and a listener to close the frame when a project is opened. Instead, our welcome frame provider can
create and return an instance of class com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame
which already
implements the necessary integration.
Here is the code for this provider:
Welcome screen provider
The WelcomeFrame
class uses a welcome screen provider to receive the content it should be showing. This provider is
registered via another extension point, com.intellij.welcomeScreen
. It should return an implementation of
com.intellij.openapi.wm.WelcomeScreen
which is very simple to implement–we have to return the JComponent
to use as
the screen contents, and we can also customize the containing Swing frame.
Here is a proof-of-concept implementation of a welcome screen provider:
Integrating with IDEA
Now that we have the classes written, we need to register them with the appropriate IDEA platform extension points. In
MPS this is (rather curiously) done in the build scripts. The build language will generate Ant code to create a plugin
descriptor for each idea plugin
declared in a build script. Each idea plugin
also lets us add extra XML elements to
the generated plugin.xml
and this is where we will add our extensions:
Since MPS registers a default welcomeFrameProvider
, we need to register ours with order="first"
for it get
precedence over the default one. With the welcome screen provider there is no default implementation registered so
this is not necessary.
Proper packaging
We are almost done. By default, the generated build scripts will package our plugin such that the module JARs are not visible to the IDEA platform1. This will lead to IDEA ignoring our extensions because it will not be able to load the necessary classes.
To make our modules visible to IDEA we need to change the packaging to put them under the lib
folder in the plugin.
Fortunately, the MPS build script lets us do so in the project layout
section at the bottom of the build script:
And now, once we build our RCP, we should see our custom, minimalistic, useless welcome screen in action:
And if you want to play with the code yourself, I have put it on GitHub.
-
The modules will be placed under
languages
subdirectory of the plugin where they will not be seen by IDEA but can be found by MPS classloaders. ↩︎