插件开发过程中,往往会有很多Action, 操作完后界面上可能没有任何反映,如果通过输出日志的方式来感知是否操作成功,操作起来不方便,此时Notification不失为一种更方便的展现形式。
在 plugin.xml 中添加通知组
通过通知组id获取通知对象
public class SequenceOutlineNotifier {
private SequenceOutlineNotifier() {
}
public static void notify(String content) {
if (null == content) {
content = "";
}
// 获取配置的对象,id 必须对应
NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup("SequenceOutlineNotifier");
final Notification notification = notificationGroup.createNotification(content, NotificationType.INFORMATION);
notification.notify(null);
}
public static void notifyError(String content) {
if (null == content) {
content = "";
}
NotificationGroup notificationGroup = NotificationGroupManager.getInstance().getNotificationGroup("SequenceOutlineNotifier");
// 通知的内容及通知的类型
final Notification notification = notificationGroup.createNotification(content, NotificationType.ERROR);
notification.notify(null);
}
}
通知配置位置
1.NONE
No popup 不展示弹窗
2.BALLOON
展示弹窗,时间到自动消失
3.STICKY_BALLOON
展示弹窗,需要点击才会消失
通知展示形式
留言与评论(共有 0 条评论) “” |