Search in sources :

Example 1 with Action

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

the class TaskActionsDiagramNodeEditHandlerFactory method getActions.

@Override
protected ElementList<Action> getActions() {
    ElementList<Action> actions = null;
    Task task = getModelElement().nearest(Task.class);
    if (task != null) {
        actions = task.getTaskActions();
    }
    return actions;
}
Also used : Action(com.liferay.ide.kaleo.core.model.Action) Task(com.liferay.ide.kaleo.core.model.Task)

Example 2 with Action

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

the class TaskNodeAddActionHandler method postDiagramNodePartAdded.

@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
    Task newTask = newNode.nearest(Task.class);
    NewTaskNode newTaskFromWizard = newNodeFromWizard.nearest(NewTaskNode.class);
    KaleoModelUtil.changeTaskAssignments(newTask, op.nearest(AssignableOp.class));
    for (Action taskAction : newTaskFromWizard.getTaskActions()) {
        ElementList<Action> action = newTask.getTaskActions();
        Action insertAction = action.insert();
        insertAction.copy(taskAction);
    }
    for (INewTaskNotification taskNotification : newTaskFromWizard.getNewTaskNotifications()) {
        ActionNotification newTaskNotification = newTask.getTaskNotifications().insert();
        newTaskNotification.setName(taskNotification.getName().content());
        newTaskNotification.setExecutionType(taskNotification.getExecutionType().content());
        newTaskNotification.setTemplateLanguage(taskNotification.getTemplateLanguage().content());
    }
}
Also used : AssignableOp(com.liferay.ide.kaleo.core.op.AssignableOp) Task(com.liferay.ide.kaleo.core.model.Task) Action(com.liferay.ide.kaleo.core.model.Action) INewTaskNotification(com.liferay.ide.kaleo.core.op.NewTaskNode.INewTaskNotification) NewTaskNode(com.liferay.ide.kaleo.core.op.NewTaskNode) ActionNotification(com.liferay.ide.kaleo.core.model.ActionNotification)

Example 3 with Action

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

the class StateNodeAddActionHandler method postDiagramNodePartAdded.

@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
    NewStateNodeOp newStateNodeOp = op.nearest(NewStateNodeOp.class);
    NewStateNode newStateNode = newNodeFromWizard.nearest(NewStateNode.class);
    State state = newNode.nearest(State.class);
    if ((newStateNode != null) && (state != null)) {
        state.setName(newStateNode.getName().content());
        NewStateType newStateType = newStateNodeOp.getType().content();
        if (newStateType.equals(NewStateType.START)) {
            state.setInitial(true);
        } else if (newStateType.equals(NewStateType.END)) {
            state.setEnd(true);
        }
        String workflowStatus = newStateNodeOp.getWorkflowStatus().content(false);
        if (!empty(workflowStatus)) {
            Action newAction = state.getActions().insert();
            newAction.setName(state.getName().content());
            newAction.setScriptLanguage(KaleoModelUtil.getDefaultValue(state, KaleoCore.DEFAULT_SCRIPT_LANGUAGE_KEY, ScriptLanguageType.GROOVY));
            newAction.setExecutionType(Executable.DEFAULT_EXECUTION_TYPE);
            IKaleoEditorHelper editorHelper = KaleoUI.getKaleoEditorHelper(newAction.getScriptLanguage().text());
            if (editorHelper != null) {
                try {
                    File statusUpdatesFolder = new File(FileLocator.toFileURL(Platform.getBundle(editorHelper.getContributorName()).getEntry("palette/Status Updates")).getFile());
                    File statusSnippet = new File(statusUpdatesFolder, workflowStatus + "." + editorHelper.getFileExtension());
                    if (FileUtil.exists(statusSnippet)) {
                        newAction.setScript(FileUtil.readContents(statusSnippet, true));
                    }
                } catch (Exception e) {
                }
            }
        }
        if (!newStateType.equals(NewStateType.END) && (newStateNodeOp.getExitTransitionName().content() != null)) {
            Transition newTransition = state.getTransitions().insert();
            newTransition.setTarget(newStateNodeOp.getExitTransitionName().content());
            newTransition.setName(newStateNodeOp.getExitTransitionName().content());
        }
    }
}
Also used : Action(com.liferay.ide.kaleo.core.model.Action) NewStateNodeOp(com.liferay.ide.kaleo.core.op.NewStateNodeOp) State(com.liferay.ide.kaleo.core.model.State) IKaleoEditorHelper(com.liferay.ide.kaleo.ui.IKaleoEditorHelper) NewStateType(com.liferay.ide.kaleo.core.op.NewStateType) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) NewStateNode(com.liferay.ide.kaleo.core.op.NewStateNode) File(java.io.File)

Example 4 with Action

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

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

the class ActionsDiagramNodeEditHandlerFactory method create.

@Override
public List<SapphireActionHandler> create() {
    ListFactory<SapphireActionHandler> factory = ListFactory.start();
    Element element = getElement();
    if (element == null) {
        return factory.result();
    }
    ElementList<Action> actions = getActions();
    if (_listener == null) {
        _listener = new FilteredListener<PropertyEvent>() {

            @Override
            public void handleTypedEvent(PropertyEvent event) {
                broadcast(new Event());
            }
        };
    }
    element.attach(_listener, getListPropertyName());
    for (Action action : actions) {
        action.getName().attach(_listener);
        factory.add(new ScriptableOpenActionHandler() {

            @Override
            public void init(SapphireAction sapphireAction, ActionHandlerDef def) {
                super.init(sapphireAction, def);
                String name = action.getName().content(true);
                setLabel(empty(name) ? "<null>" : name);
                addImage(Action.TYPE.image());
            }

            @Override
            protected Scriptable scriptable(Presentation context) {
                return action;
            }
        });
    }
    return factory.result();
}
Also used : Action(com.liferay.ide.kaleo.core.model.Action) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) Element(org.eclipse.sapphire.Element) PropertyEvent(org.eclipse.sapphire.PropertyEvent) Presentation(org.eclipse.sapphire.ui.Presentation) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable) SapphireActionHandler(org.eclipse.sapphire.ui.SapphireActionHandler) ActionHandlerDef(org.eclipse.sapphire.ui.def.ActionHandlerDef) SapphireAction(org.eclipse.sapphire.ui.SapphireAction) Event(org.eclipse.sapphire.Event) PropertyEvent(org.eclipse.sapphire.PropertyEvent)

Aggregations

Action (com.liferay.ide.kaleo.core.model.Action)8 Task (com.liferay.ide.kaleo.core.model.Task)4 SapphireAction (org.eclipse.sapphire.ui.SapphireAction)4 ActionNotification (com.liferay.ide.kaleo.core.model.ActionNotification)2 ActionTimer (com.liferay.ide.kaleo.core.model.ActionTimer)2 State (com.liferay.ide.kaleo.core.model.State)2 Transition (com.liferay.ide.kaleo.core.model.Transition)2 Element (org.eclipse.sapphire.Element)2 Presentation (org.eclipse.sapphire.ui.Presentation)2 SapphireActionHandler (org.eclipse.sapphire.ui.SapphireActionHandler)2 ActionHandlerDef (org.eclipse.sapphire.ui.def.ActionHandlerDef)2 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)1 Position (com.liferay.ide.kaleo.core.model.Position)1 ScriptLanguageType (com.liferay.ide.kaleo.core.model.ScriptLanguageType)1 Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)1 TemplateLanguageType (com.liferay.ide.kaleo.core.model.TemplateLanguageType)1 TransitionMetadata (com.liferay.ide.kaleo.core.model.TransitionMetadata)1 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)1 WorkflowNodeMetadata (com.liferay.ide.kaleo.core.model.WorkflowNodeMetadata)1 AssignableOp (com.liferay.ide.kaleo.core.op.AssignableOp)1