Skip to content

Commit 32a6c00

Browse files
plumpygoogle-java-format Team
authored and
google-java-format Team
committed
Switch (deprecated) ProjectManagerListener#onProjectOpened to StartupActivity.
PiperOrigin-RevId: 513811140
1 parent 0644d4c commit 32a6c00

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
import com.intellij.notification.NotificationGroupManager;
2222
import com.intellij.notification.NotificationType;
2323
import com.intellij.openapi.project.Project;
24-
import com.intellij.openapi.project.ProjectManagerListener;
24+
import com.intellij.openapi.startup.StartupActivity;
2525
import org.jetbrains.annotations.NotNull;
2626

27-
final class InitialConfigurationProjectManagerListener implements ProjectManagerListener {
27+
final class InitialConfigurationStartupActivity implements StartupActivity.Background {
2828

2929
private static final String NOTIFICATION_TITLE = "Enable google-java-format";
3030
private static final NotificationGroup NOTIFICATION_GROUP =
3131
NotificationGroupManager.getInstance().getNotificationGroup(NOTIFICATION_TITLE);
3232

3333
@Override
34-
public void projectOpened(@NotNull Project project) {
34+
public void runActivity(@NotNull Project project) {
3535
GoogleJavaFormatSettings settings = GoogleJavaFormatSettings.getInstance(project);
3636

3737
if (settings.isUninitialized()) {
@@ -47,11 +47,12 @@ private void displayNewUserNotification(Project project, GoogleJavaFormatSetting
4747
NOTIFICATION_TITLE,
4848
"The google-java-format plugin is disabled by default. "
4949
+ "<a href=\"enable\">Enable for this project</a>.",
50-
NotificationType.INFORMATION,
51-
(n, e) -> {
52-
settings.setEnabled(true);
53-
n.expire();
54-
});
50+
NotificationType.INFORMATION);
51+
notification.setListener(
52+
(n, e) -> {
53+
settings.setEnabled(true);
54+
n.expire();
55+
});
5556
notification.notify(project);
5657
}
5758
}

idea_plugin/src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,10 @@
6565
</dl>
6666
]]></change-notes>
6767

68-
<applicationListeners>
69-
<listener
70-
class="com.google.googlejavaformat.intellij.InitialConfigurationProjectManagerListener"
71-
topic="com.intellij.openapi.project.ProjectManagerListener"/>
72-
</applicationListeners>
73-
7468
<extensions defaultExtensionNs="com.intellij">
7569
<formattingService
7670
implementation="com.google.googlejavaformat.intellij.GoogleJavaFormatFormattingService"/>
71+
<postStartupActivity implementation="com.google.googlejavaformat.intellij.InitialConfigurationStartupActivity"/>
7772
<projectConfigurable
7873
instance="com.google.googlejavaformat.intellij.GoogleJavaFormatConfigurable"
7974
id="google-java-format.settings"

0 commit comments

Comments
 (0)