Search in sources :

Example 6 with ActionNotification

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");
}
Also used : ActionTimer(com.liferay.ide.kaleo.core.model.ActionTimer) NotificationTransport(com.liferay.ide.kaleo.core.model.NotificationTransport) Task(com.liferay.ide.kaleo.core.model.Task) Node(com.liferay.ide.kaleo.core.model.Node) TaskActionNotification(com.liferay.ide.kaleo.core.model.TaskActionNotification) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification) TaskActionNotification(com.liferay.ide.kaleo.core.model.TaskActionNotification)

Example 7 with ActionNotification

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();
}
Also used : Element(org.eclipse.sapphire.Element) PropertyEvent(org.eclipse.sapphire.PropertyEvent) Presentation(org.eclipse.sapphire.ui.Presentation) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification) Notification(com.liferay.ide.kaleo.core.model.Notification) ActionHandlerDef(org.eclipse.sapphire.ui.def.ActionHandlerDef) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) Event(org.eclipse.sapphire.Event) PropertyEvent(org.eclipse.sapphire.PropertyEvent)

Aggregations

ActionNotification (com.liferay.ide.kaleo.core.model.ActionNotification)7 Task (com.liferay.ide.kaleo.core.model.Task)4 ActionTimer (com.liferay.ide.kaleo.core.model.ActionTimer)3 TaskActionNotification (com.liferay.ide.kaleo.core.model.TaskActionNotification)3 Action (com.liferay.ide.kaleo.core.model.Action)2 Element (org.eclipse.sapphire.Element)2 Presentation (org.eclipse.sapphire.ui.Presentation)2 SapphireAction (org.eclipse.sapphire.ui.SapphireAction)2 SapphireActionHandler (org.eclipse.sapphire.ui.SapphireActionHandler)2 ActionHandlerDef (org.eclipse.sapphire.ui.def.ActionHandlerDef)2 Node (com.liferay.ide.kaleo.core.model.Node)1 Notification (com.liferay.ide.kaleo.core.model.Notification)1 NotificationTransport (com.liferay.ide.kaleo.core.model.NotificationTransport)1 AssignableOp (com.liferay.ide.kaleo.core.op.AssignableOp)1 NewTaskNode (com.liferay.ide.kaleo.core.op.NewTaskNode)1 INewTaskNotification (com.liferay.ide.kaleo.core.op.NewTaskNode.INewTaskNotification)1 ArrayList (java.util.ArrayList)1 Event (org.eclipse.sapphire.Event)1 PropertyEvent (org.eclipse.sapphire.PropertyEvent)1