mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Add data context to notification event
This commit is contained in:
@@ -229,11 +229,18 @@ public class Notification {
|
||||
}
|
||||
|
||||
public static void fire(@NotNull final Notification notification, @NotNull AnAction action) {
|
||||
fire(notification, action, null);
|
||||
}
|
||||
|
||||
public static void fire(@NotNull final Notification notification, @NotNull AnAction action, @Nullable DataContext context) {
|
||||
AnActionEvent event = AnActionEvent.createFromAnAction(action, null, ActionPlaces.UNKNOWN, new DataContext() {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData(@NonNls String dataId) {
|
||||
return KEY.getName().equals(dataId) ? notification : null;
|
||||
if (KEY.is(dataId)) {
|
||||
return notification;
|
||||
}
|
||||
return context == null ? null : context.getData(dataId);
|
||||
}
|
||||
});
|
||||
if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
package com.intellij.notification;
|
||||
|
||||
import com.intellij.execution.filters.HyperlinkInfo;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.notification.impl.NotificationsConfigurationImpl;
|
||||
import com.intellij.notification.impl.NotificationsManagerImpl;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -52,7 +54,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -169,7 +173,9 @@ public class EventLog {
|
||||
Notification n = new Notification("", "", ".", NotificationType.INFORMATION, new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification n, @NotNull HyperlinkEvent event) {
|
||||
Notification.fire(notification, notification.getActions().get(Integer.parseInt(event.getDescription())));
|
||||
Object source = event.getSource();
|
||||
DataContext context = source instanceof Component ? DataManager.getInstance().getDataContext((Component)source) : null;
|
||||
Notification.fire(notification, notification.getActions().get(Integer.parseInt(event.getDescription())), context);
|
||||
}
|
||||
});
|
||||
if (title.length() > 0 || content.length() > 0) {
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ package com.intellij.notification.impl;
|
||||
|
||||
import com.intellij.codeInsight.hint.TooltipController;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.FrameStateManager;
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonPainter;
|
||||
import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI;
|
||||
@@ -803,7 +804,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
new LinkLabel<>(presentation.getText(), presentation.getIcon(), new LinkListener<AnAction>() {
|
||||
@Override
|
||||
public void linkSelected(LinkLabel aSource, AnAction action) {
|
||||
Notification.fire(notification, action);
|
||||
Notification.fire(notification, action, DataManager.getInstance().getDataContext(aSource));
|
||||
}
|
||||
}, action));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user