use of org.obeonetwork.graal.AbstractTask in project InformationSystem by ObeoNetwork.
the class ActorUtils method getVisibleActors.
/**
* Returns the visible actors for a tasks group
* @param group
* @return
*/
public Set<Actor> getVisibleActors(TasksGroup group) {
HashMap<Task, Set<Actor>> cache = new HashMap<Task, Set<Actor>>();
Set<Actor> actors = new LinkedHashSet<Actor>();
List<Actor> actorsLeft = getAllActorsInContext(group);
for (AbstractTask abstractTask : group.getTasks()) {
actors.addAll(internalGetVisibleActors(abstractTask, cache, actorsLeft));
}
return actors;
}
use of org.obeonetwork.graal.AbstractTask in project InformationSystem by ObeoNetwork.
the class GroupAction method executeGroupAction.
/**
* Executes the grouping action
* @param context Object needed so the method can be called by Acceleo. It is returned unchanged
* @param selections Graphical elements selected by the user before launching the action
* @return The first parameter without any change
*/
public EObject executeGroupAction(EObject context, Collection<? extends EObject> selections) {
// Filter the selections to retrieve only the Tasks
List<AbstractTask> tasks = extractTasks(selections);
String suggestedName = TaskUtils.instance.computeNameFromTasks(tasks);
InputDialog enterNameDialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Creating a group", "Enter a name for the group", suggestedName, null);
enterNameDialog.open();
int returnCode = enterNameDialog.getReturnCode();
if (returnCode == InputDialog.OK) {
TasksContainer container = null;
if (tasks.size() > 0) {
// Store the current container
container = (TasksContainer) tasks.get(0).eContainer();
// Create a new group to contain the selected tasks
TasksGroup group = GraalFactory.eINSTANCE.createTasksGroup();
Date createdOn = new Date();
group.setCreatedOn(createdOn);
group.setModifiedOn(createdOn);
// Attach the selected tasks to the new group
group.getTasks().addAll(tasks);
group.setName(enterNameDialog.getValue());
// Get an available ID for the TasksGroup
System system = TaskUtils.instance.getClosestSystem(container);
String id = TaskUtils.instance.getNextAvailableTasksGroupId(system);
group.setId(id);
// Attach the new group to the container
((TasksContainer) container).getTasks().add(group);
}
}
return context;
}
use of org.obeonetwork.graal.AbstractTask in project InformationSystem by ObeoNetwork.
the class UngroupAction method executeUngroupAction.
/**
* Executes the ungrouping action
* @param context Object needed so the method can be called by Acceleo. It is returned unchanged
* @param selections Graphical elements selected by the user before launching the action
* @return The first parameter without any change
*/
public EObject executeUngroupAction(EObject context, Collection<? extends EObject> selections) {
TasksGroup group = extractTasksGroup(selections);
// Keep attachment to use case
UseCase useCase = group.getUseCase();
if (useCase != null) {
for (AbstractTask abstractTask : group.getTasks()) {
useCase.getTasks().add(abstractTask);
}
}
TasksContainer container = (TasksContainer) group.eContainer();
container.getTasks().addAll(group.getTasks());
// Delete without EcoreUtil.delete()
DeleteUtils.delete(group);
return context;
}
use of org.obeonetwork.graal.AbstractTask in project InformationSystem by ObeoNetwork.
the class TaskUtils method tasksUsed.
/**
* Retrieve all tasks used by the context
*
* @param context
* the context on which is applied the service
* @return List of Tasks
*/
public List<Task> tasksUsed(TasksGroup context) {
List<Task> tasks = new ArrayList<Task>();
for (AbstractTask task : context.getTasks()) {
tasks.addAll(tasksUsed(task));
}
// Remove tasks contained in the context
tasks.removeAll(context.getTasks());
Set<Task> tasksUsed = new HashSet<Task>();
// Remove duplicates
tasksUsed.addAll(tasks);
return new ArrayList<Task>(tasksUsed);
}
use of org.obeonetwork.graal.AbstractTask in project InformationSystem by ObeoNetwork.
the class TaskUtils method getMainTasks.
/**
* Gets the main tasks from a list of abstract tasks
*
* @param abstractTasks
* List of abstract tasks to be considered
* @return the main tasks from the list, considering the "use" relationships
* between tasks
*/
private List<Task> getMainTasks(List<AbstractTask> abstractTasks) {
List<Task> mainTasks = new ArrayList<Task>();
// We have to consider every task in groups or not
List<Task> tasks = new ArrayList<Task>();
for (AbstractTask abstractTask : abstractTasks) {
if (abstractTask instanceof Task) {
tasks.add((Task) abstractTask);
} else {
tasks.addAll(getAllEnclosedTasks((TasksGroup) abstractTask));
}
}
// Get all tasks in the group
for (Task task : tasks) {
boolean usedByInnerTask = false;
for (Task usingTask : task.getUsedBy()) {
if (tasks.contains(usingTask)) {
usedByInnerTask = true;
break;
}
}
if (usedByInnerTask == false) {
mainTasks.add(task);
}
}
return mainTasks;
}
Aggregations