Search in sources :

Example 1 with ActionTimer

use of com.liferay.ide.kaleo.core.model.ActionTimer in project liferay-ide by liferay.

the class NotificationsDiagramNodeEditHandlerFactory method getNotifications.

protected List<ActionNotification> getNotifications() {
    ElementList<ActionNotification> notifications = null;
    ActionTimer actionTimer = getModelElement().nearest(ActionTimer.class);
    if (actionTimer != null) {
        notifications = actionTimer.getNotifications();
    }
    return notifications;
}
Also used : ActionTimer(com.liferay.ide.kaleo.core.model.ActionTimer) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification)

Example 2 with ActionTimer

use of com.liferay.ide.kaleo.core.model.ActionTimer in project liferay-ide by liferay.

the class WorkflowNodeAddHandlerFactory method create.

@Override
public List<SapphireActionHandler> create() {
    List<SapphireActionHandler> handlers = new ArrayList<>();
    if (getModelElement() instanceof Task) {
        Task task = getModelElement().nearest(Task.class);
        handlers.add(new SapphireActionHandler() {

            @Override
            public void init(SapphireAction action, ActionHandlerDef def) {
                super.init(action, def);
                addImage(Action.TYPE.image());
                setLabel("Task Action");
            }

            @Override
            protected Object run(Presentation context) {
                Action newAction = task.getTaskActions().insert();
                ActionsListAddActionHandler.addActionDefaults(newAction);
                return newAction;
            }
        });
        handlers.add(new SapphireActionHandler() {

            @Override
            public void init(SapphireAction action, ActionHandlerDef def) {
                super.init(action, def);
                addImage(ActionNotification.TYPE.image());
                setLabel("Task Notification");
            }

            @Override
            protected Object run(Presentation context) {
                ActionNotification newTaskNotificaction = task.getTaskNotifications().insert();
                NotificationsListAddActionHandler.addNotificationDefaults(newTaskNotificaction);
                return newTaskNotificaction;
            }
        });
    } else {
        ActionTimer actionTimer = getModelElement().nearest(ActionTimer.class);
        handlers.add(new SapphireActionHandler() {

            @Override
            public void init(SapphireAction action, ActionHandlerDef def) {
                super.init(action, def);
                addImage(Action.TYPE.image());
                setLabel("Action");
            }

            @Override
            protected Object run(Presentation context) {
                Action newAction = actionTimer.getActions().insert();
                ActionsListAddActionHandler.addActionDefaults(newAction);
                return newAction;
            }
        });
        handlers.add(new SapphireActionHandler() {

            @Override
            public void init(SapphireAction action, ActionHandlerDef def) {
                super.init(action, def);
                addImage(Notification.TYPE.image());
                setLabel("Notification");
            }

            @Override
            protected Object run(Presentation context) {
                ActionNotification newNotificaction = actionTimer.getNotifications().insert();
                NotificationsListAddActionHandler.addNotificationDefaults(newNotificaction);
                return newNotificaction;
            }
        });
    }
    return handlers;
}
Also used : ActionHandlerDef(org.eclipse.sapphire.ui.def.ActionHandlerDef) ActionTimer(com.liferay.ide.kaleo.core.model.ActionTimer) Task(com.liferay.ide.kaleo.core.model.Task) Action(com.liferay.ide.kaleo.core.model.Action) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) ArrayList(java.util.ArrayList) Presentation(org.eclipse.sapphire.ui.Presentation) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification)

Example 3 with ActionTimer

use of com.liferay.ide.kaleo.core.model.ActionTimer 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 4 with ActionTimer

use of com.liferay.ide.kaleo.core.model.ActionTimer in project liferay-ide by liferay.

the class ActionsDiagramNodeEditHandlerFactory method getActions.

protected ElementList<Action> getActions() {
    ElementList<Action> actions = null;
    ActionTimer actionTimer = getModelElement().nearest(ActionTimer.class);
    if (actionTimer != null) {
        actions = actionTimer.getActions();
    }
    return actions;
}
Also used : ActionTimer(com.liferay.ide.kaleo.core.model.ActionTimer) Action(com.liferay.ide.kaleo.core.model.Action) SapphireAction(org.eclipse.sapphire.ui.SapphireAction)

Example 5 with ActionTimer

use of com.liferay.ide.kaleo.core.model.ActionTimer in project liferay-ide by liferay.

the class ActionsListAddActionHandler method addActionDefaults.

public static void addActionDefaults(Action newAction) {
    Node[] actions = new Node[0];
    if (newAction.nearest(Task.class) != null) {
        Task task = newAction.nearest(Task.class);
        actions = task.getTaskActions().toArray(new Node[0]);
    } else {
        ActionTimer actionTimer = newAction.nearest(ActionTimer.class);
        actions = actionTimer.getActions().toArray(new Node[0]);
    }
    String newName = getDefaultName("newAction1", newAction, actions);
    String defaultScriptLanguage = KaleoModelUtil.getDefaultValue(newAction, KaleoCore.DEFAULT_SCRIPT_LANGUAGE_KEY, ScriptLanguageType.GROOVY);
    newAction.setName(newName);
    newAction.setScriptLanguage(defaultScriptLanguage);
    newAction.setExecutionType(Executable.DEFAULT_EXECUTION_TYPE);
    if (newAction.nearest(Task.class) != null) {
        newAction.setScript("/* specify task action script */");
    } else {
        newAction.setScript("/* specify action script */");
    }
}
Also used : ActionTimer(com.liferay.ide.kaleo.core.model.ActionTimer) Task(com.liferay.ide.kaleo.core.model.Task) Node(com.liferay.ide.kaleo.core.model.Node)

Aggregations

ActionTimer (com.liferay.ide.kaleo.core.model.ActionTimer)5 ActionNotification (com.liferay.ide.kaleo.core.model.ActionNotification)3 Task (com.liferay.ide.kaleo.core.model.Task)3 Action (com.liferay.ide.kaleo.core.model.Action)2 Node (com.liferay.ide.kaleo.core.model.Node)2 SapphireAction (org.eclipse.sapphire.ui.SapphireAction)2 NotificationTransport (com.liferay.ide.kaleo.core.model.NotificationTransport)1 TaskActionNotification (com.liferay.ide.kaleo.core.model.TaskActionNotification)1 ArrayList (java.util.ArrayList)1 Presentation (org.eclipse.sapphire.ui.Presentation)1 SapphireActionHandler (org.eclipse.sapphire.ui.SapphireActionHandler)1 ActionHandlerDef (org.eclipse.sapphire.ui.def.ActionHandlerDef)1