Search in sources :

Example 1 with TasksGroup

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);
}
Also used : AbstractTask(org.obeonetwork.graal.AbstractTask) Task(org.obeonetwork.graal.Task) TasksGroup(org.obeonetwork.graal.TasksGroup) Test(org.junit.Test)

Example 2 with TasksGroup

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));
}
Also used : AbstractTask(org.obeonetwork.graal.AbstractTask) Task(org.obeonetwork.graal.Task) Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) GraalUsageCrossReferencer(org.obeonetwork.graal.util.GraalUsageCrossReferencer) Resource(org.eclipse.emf.ecore.resource.Resource) ArrayList(java.util.ArrayList) System(org.obeonetwork.graal.System) TasksGroup(org.obeonetwork.graal.TasksGroup) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference)

Example 3 with TasksGroup

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);
}
Also used : TasksGroup(org.obeonetwork.graal.TasksGroup) TasksGroupPropertiesEditionPart(org.obeonetwork.graal.parts.TasksGroupPropertiesEditionPart)

Example 4 with TasksGroup

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;
}
Also used : AbstractTask(org.obeonetwork.graal.AbstractTask) InputDialog(org.eclipse.jface.dialogs.InputDialog) TasksContainer(org.obeonetwork.graal.TasksContainer) TasksGroup(org.obeonetwork.graal.TasksGroup) Date(java.util.Date) System(org.obeonetwork.graal.System)

Example 5 with TasksGroup

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;
}
Also used : AbstractTask(org.obeonetwork.graal.AbstractTask) TasksContainer(org.obeonetwork.graal.TasksContainer) TasksGroup(org.obeonetwork.graal.TasksGroup) UseCase(org.obeonetwork.graal.UseCase)

Aggregations

TasksGroup (org.obeonetwork.graal.TasksGroup)11 AbstractTask (org.obeonetwork.graal.AbstractTask)9 Task (org.obeonetwork.graal.Task)7 ArrayList (java.util.ArrayList)5 System (org.obeonetwork.graal.System)3 EObject (org.eclipse.emf.ecore.EObject)2 EReference (org.eclipse.emf.ecore.EReference)2 Setting (org.eclipse.emf.ecore.EStructuralFeature.Setting)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 TasksContainer (org.obeonetwork.graal.TasksContainer)2 GraalUsageCrossReferencer (org.obeonetwork.graal.util.GraalUsageCrossReferencer)2 Date (java.util.Date)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 Session (org.eclipse.sirius.business.api.session.Session)1 ModelAccessor (org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor)1 Test (org.junit.Test)1 Actor (org.obeonetwork.graal.Actor)1 Loop (org.obeonetwork.graal.Loop)1