Search in sources :

Example 1 with NotificationDisplayType

use of com.intellij.notification.NotificationDisplayType in project intellij-community by JetBrains.

the class NotificationSettings method save.

@NotNull
public Element save() {
    final Element result = new Element("notification");
    result.setAttribute("groupId", getGroupId());
    final NotificationDisplayType displayType = getDisplayType();
    if (displayType != NotificationDisplayType.BALLOON) {
        result.setAttribute("displayType", displayType.toString());
    }
    if (!myShouldLog) {
        result.setAttribute("shouldLog", "false");
    }
    if (myShouldReadAloud) {
        result.setAttribute("shouldReadAloud", "true");
    }
    return result;
}
Also used : Element(org.jdom.Element) NotificationDisplayType(com.intellij.notification.NotificationDisplayType) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with NotificationDisplayType

use of com.intellij.notification.NotificationDisplayType in project intellij-community by JetBrains.

the class NotificationSettings method load.

@Nullable
public static NotificationSettings load(@NotNull final Element element) {
    final String displayTypeString = element.getAttributeValue("displayType");
    NotificationDisplayType displayType = NotificationDisplayType.BALLOON;
    boolean shouldLog = !"false".equals(element.getAttributeValue("shouldLog"));
    boolean shouldReadAloud = "true".equals(element.getAttributeValue("shouldReadAloud"));
    if ("BALLOON_ONLY".equals(displayTypeString)) {
        shouldLog = false;
        displayType = NotificationDisplayType.BALLOON;
    } else if (displayTypeString != null) {
        try {
            displayType = NotificationDisplayType.valueOf(displayTypeString.toUpperCase());
        } catch (IllegalArgumentException ignored) {
        }
    }
    final String groupId = element.getAttributeValue("groupId");
    return groupId != null ? new NotificationSettings(groupId, displayType, shouldLog, shouldReadAloud) : null;
}
Also used : NotificationDisplayType(com.intellij.notification.NotificationDisplayType) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

NotificationDisplayType (com.intellij.notification.NotificationDisplayType)2 Element (org.jdom.Element)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1