use of com.liferay.ide.kaleo.core.model.ActionNotification in project liferay-ide by liferay.
the class NotificationsListAddActionHandler method addNotificationDefaults.
public static void addNotificationDefaults(ActionNotification newNotification) {
String defaultTemplateLanguage = KaleoModelUtil.getDefaultValue(newNotification, KaleoCore.DEFAULT_TEMPLATE_LANGUAGE_KEY, TemplateLanguageType.FREEMARKER);
Node[] nodes = new Node[0];
if (newNotification.nearest(Task.class) != null) {
Task task = newNotification.nearest(Task.class);
ElementList<TaskActionNotification> taskNotifications = task.getTaskNotifications();
nodes = taskNotifications.toArray(new Node[0]);
} else {
ActionTimer actionTimer = newNotification.nearest(ActionTimer.class);
ElementList<ActionNotification> actionNotifications = actionTimer.getNotifications();
nodes = actionNotifications.toArray(new Node[0]);
}
String newName = getDefaultName("newNotification1", newNotification, nodes);
newNotification.setName(newName);
newNotification.setTemplateLanguage(defaultTemplateLanguage);
newNotification.setExecutionType(Executable.DEFAULT_EXECUTION_TYPE);
if (newNotification.nearest(Task.class) != null) {
newNotification.setTemplate("/* specify task notification template */");
} else {
newNotification.setTemplate("/* specify notification template */");
}
ElementList<NotificationTransport> notificationTransports = newNotification.getNotificationTransports();
NotificationTransport insertTransport = notificationTransports.insert();
insertTransport.setNotificationTransport("email");
}
use of com.liferay.ide.kaleo.core.model.ActionNotification in project liferay-ide by liferay.
the class NotificationsDiagramNodeEditHandlerFactory method create.
@Override
public List<SapphireActionHandler> create() {
ListFactory<SapphireActionHandler> factory = ListFactory.start();
Element element = getElement();
if (element == null) {
return factory.result();
}
List<ActionNotification> notifications = getNotifications();
if (_listener == null) {
_listener = new FilteredListener<PropertyEvent>() {
@Override
public void handleTypedEvent(PropertyEvent event) {
broadcast(new Event());
}
};
}
element.attach(_listener, getListPropertyName());
for (Notification notification : notifications) {
notification.getName().attach(_listener);
factory.add(new TemplateOpenActionHandler() {
@Override
public void init(SapphireAction sapphireAction, ActionHandlerDef def) {
super.init(sapphireAction, def);
String name = notification.getName().content(true);
setLabel(empty(name) ? "<null>" : name);
addImage(ActionNotification.TYPE.image());
}
@Override
protected Notification notification(Presentation context) {
return notification;
}
});
}
return factory.result();
}
Aggregations