Skip to content

Commit

Permalink
Switch (deprecated) ProjectManagerListener#onProjectOpened to Startup…
Browse files Browse the repository at this point in the history
…Activity.

PiperOrigin-RevId: 513811140
  • Loading branch information
plumpy authored and google-java-format Team committed Mar 3, 2023
1 parent 0644d4c commit 32a6c00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.startup.StartupActivity;
import org.jetbrains.annotations.NotNull;

final class InitialConfigurationProjectManagerListener implements ProjectManagerListener {
final class InitialConfigurationStartupActivity implements StartupActivity.Background {

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

@Override
public void projectOpened(@NotNull Project project) {
public void runActivity(@NotNull Project project) {
GoogleJavaFormatSettings settings = GoogleJavaFormatSettings.getInstance(project);

if (settings.isUninitialized()) {
Expand All @@ -47,11 +47,12 @@ private void displayNewUserNotification(Project project, GoogleJavaFormatSetting
NOTIFICATION_TITLE,
"The google-java-format plugin is disabled by default. "
+ "<a href=\"enable\">Enable for this project</a>.",
NotificationType.INFORMATION,
(n, e) -> {
settings.setEnabled(true);
n.expire();
});
NotificationType.INFORMATION);
notification.setListener(
(n, e) -> {
settings.setEnabled(true);
n.expire();
});
notification.notify(project);
}
}
7 changes: 1 addition & 6 deletions idea_plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,10 @@
</dl>
]]></change-notes>

<applicationListeners>
<listener
class="com.google.googlejavaformat.intellij.InitialConfigurationProjectManagerListener"
topic="com.intellij.openapi.project.ProjectManagerListener"/>
</applicationListeners>

<extensions defaultExtensionNs="com.intellij">
<formattingService
implementation="com.google.googlejavaformat.intellij.GoogleJavaFormatFormattingService"/>
<postStartupActivity implementation="com.google.googlejavaformat.intellij.InitialConfigurationStartupActivity"/>
<projectConfigurable
instance="com.google.googlejavaformat.intellij.GoogleJavaFormatConfigurable"
id="google-java-format.settings"
Expand Down

0 comments on commit 32a6c00

Please sign in to comment.