package pl.polgrabia.demos.intellij_plugin_demo1.actions;

import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;

import java.util.Optional;

public class HelloAction extends AnAction {

    @Override
    public void actionPerformed(AnActionEvent e) {
        var name = Optional.of(e)
                .map(AnActionEvent::getProject)
                .map(Project::getName)
                .orElse("Hello");

        var msg = "You invoked hello action on project: %s".formatted(name);
        /**
        Messages.showMessageDialog(
                e.getProject(),
                msg,
                "Title",
                Messages.getInformationIcon());

         **/
        NotificationGroupManager.getInstance()
                .getNotificationGroup("Custom Notification Group")
                .createNotification(msg, NotificationType.INFORMATION)
                .notify(e.getProject());
    }
}
