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;
}
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());
}
}
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());
}
}
}
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;
}
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();
}
Aggregations