use of org.obeonetwork.graal.TasksGroup in project InformationSystem by ObeoNetwork.
the class RelatedActorsTests method directActorsOnTask.
@Test
public void directActorsOnTask() {
initSystem();
Task t1 = addTask(s, "T1", a1);
Task t2 = addTask(s, "T2");
assertActors(s, a1);
assertActors(t1, a1);
assertActors(t2);
addUse(t1, t2);
assertActors(s, a1);
assertActors(t1, a1);
assertActors(t2, a1);
addActor(t2, a2);
assertActors(s, a1, a2);
assertActors(t1, a1);
assertActors(t2, a2);
Task t3 = addTask(s, "T3", a3);
addUse(t2, t3);
assertActors(s, a1, a2, a3);
assertActors(t1, a1);
assertActors(t2, a2);
assertActors(t3, a3);
Task t4 = addTask(s, "T4");
assertActors(s, a1, a2, a3);
assertActors(t1, a1);
assertActors(t2, a2);
assertActors(t3, a3);
assertActors(t4);
addUse(t3, t4);
assertActors(s, a1, a2, a3);
assertActors(t1, a1);
assertActors(t2, a2);
assertActors(t3, a3);
assertActors(t4, a3);
addUse(t2, t4);
assertActors(s, a1, a2, a3);
assertActors(t1, a1);
assertActors(t2, a2);
assertActors(t3, a3);
assertActors(t4, a2, a3);
t2.getActors().remove(a2);
assertActors(s, a1, a3);
assertActors(t1, a1);
assertActors(t2, a1);
assertActors(t3, a3);
assertActors(t4, a1, a3);
TasksGroup g1 = addGroup(s, "G1");
g1.getTasks().add(t3);
g1.getTasks().add(t4);
assertActors(s, a1, a3);
assertActors(t1, a1);
assertActors(t2, a1);
assertActors(t3, a3);
assertActors(t4, a1, a3);
assertActors(g1, a1, a3);
addActor(t2, a2);
assertActors(s, a1, a2, a3);
assertActors(t1, a1);
assertActors(t2, a2);
assertActors(t3, a3);
assertActors(t4, a2, a3);
assertActors(g1, a2, a3);
Task t5 = addTask(g1, "T5", a4);
addUse(t3, t5);
assertActors(s, a1, a2, a3, a4);
assertActors(t1, a1);
assertActors(t2, a2);
assertActors(t3, a3);
assertActors(t4, a2, a3);
assertActors(t5, a4);
assertActors(g1, a2, a3, a4);
t1.getActors().remove(a1);
t3.getActors().remove(a3);
assertActors(s, a2, a4);
assertActors(t1);
assertActors(t2, a2);
assertActors(t3, a2);
assertActors(t4, a2);
assertActors(t5, a4);
assertActors(g1, a2, a4);
TasksGroup g2 = addGroup(g1, "G2");
g2.getTasks().add(t3);
g2.getTasks().add(t5);
assertActors(s, a2, a4);
assertActors(t1);
assertActors(t2, a2);
assertActors(t3, a2);
assertActors(t4, a2);
assertActors(t5, a4);
assertActors(g1, a2, a4);
assertActors(g2, a2, a4);
}
use of org.obeonetwork.graal.TasksGroup in project InformationSystem by ObeoNetwork.
the class TaskImpl method getUsedBy.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public EList<Task> getUsedBy() {
Collection<Setting> usingTasksSettings = new GraalUsageCrossReferencer() {
@Override
protected boolean crossReference(EObject eObject, EReference eReference, EObject crossReferencedEObject) {
return eReference == GraalPackage.Literals.TASK__USES;
}
@Override
protected boolean containment(EObject eObject) {
// (We use Resource instead of CDOResource to avoid dependency on CDO)
return (eObject instanceof Resource) || (eObject instanceof System) || (eObject instanceof TasksGroup) || (eObject instanceof Task);
}
}.findUsage(this);
List<Task> foundTasks = new ArrayList<Task>();
for (Setting setting : usingTasksSettings) {
foundTasks.add((Task) setting.getEObject());
}
return ECollections.unmodifiableEList(new BasicEList<Task>(foundTasks));
}
use of org.obeonetwork.graal.TasksGroup in project InformationSystem by ObeoNetwork.
the class TasksGroupTasksGroupPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final TasksGroup tasksGroup = (TasksGroup) elt;
final TasksGroupPropertiesEditionPart tasksGroupPart = (TasksGroupPropertiesEditionPart) editingPart;
// init values
if (isAccessible(GraalViewsRepository.TasksGroup.Properties.description))
tasksGroupPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, tasksGroup.getDescription()));
if (isAccessible(GraalViewsRepository.TasksGroup.Properties.id))
tasksGroupPart.setId(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, tasksGroup.getId()));
if (isAccessible(GraalViewsRepository.TasksGroup.Properties.name))
tasksGroupPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, tasksGroup.getName()));
// init filters
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
use of org.obeonetwork.graal.TasksGroup 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.TasksGroup 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;
}
Aggregations