Search in sources :

Example 6 with System

use of org.obeonetwork.graal.System 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 7 with System

use of org.obeonetwork.graal.System in project InformationSystem by ObeoNetwork.

the class CreateUseCaseAction method executeCreateUseCaseAction.

/**
 * creates a new use case from selected Task and TasksGroup instances
 * @param context EObject needed so the method can be called by Acceleo
 * @param selections Graphical elements selected by the user before invoking the action
 * @return unmodified "context" parameter
 */
public EObject executeCreateUseCaseAction(EObject context, Collection<? extends EObject> selections) {
    // Filter the selections to retrieve only the Tasks
    List<AbstractTask> tasks = extractTasks(selections);
    String suggestedName = "UC - " + TaskUtils.instance.computeNameFromTasks(tasks);
    InputDialog enterNameDialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Creating an use case", "Enter a name for the Use Case", suggestedName, null);
    enterNameDialog.open();
    int returnCode = enterNameDialog.getReturnCode();
    if (returnCode == InputDialog.OK && tasks.size() > 0) {
        // Get the containing System
        System system = tasks.get(0).getContainingSystem();
        // Create a new Use Case
        UseCase useCase = GraalFactory.eINSTANCE.createUseCase();
        Date createdOn = new Date();
        useCase.setCreatedOn(createdOn);
        useCase.setModifiedOn(createdOn);
        useCase.getTasks().addAll(tasks);
        useCase.setName(enterNameDialog.getValue());
        system.getUseCases().add(useCase);
        return useCase;
    }
    return null;
}
Also used : AbstractTask(org.obeonetwork.graal.AbstractTask) InputDialog(org.eclipse.jface.dialogs.InputDialog) UseCase(org.obeonetwork.graal.UseCase) System(org.obeonetwork.graal.System) Date(java.util.Date)

Example 8 with System

use of org.obeonetwork.graal.System in project InformationSystem by ObeoNetwork.

the class DomainClassServicesTest method testAnnotationWithNoMetadataContainer.

@Test
public void testAnnotationWithNoMetadataContainer() {
    System system = loadRoot("AnnotationWithNoMetadataContainer.graal", System.class);
    DomainClass domainClass = query(() -> {
        return (DomainClass) system.getOwnedNamespaces().get(0).getTypes().get(0);
    });
    assertEquals("", getPhysicalSize(domainClass));
}
Also used : DomainClass(org.obeonetwork.graal.DomainClass) System(org.obeonetwork.graal.System) Test(org.junit.Test)

Example 9 with System

use of org.obeonetwork.graal.System in project InformationSystem by ObeoNetwork.

the class DomainClassServicesTest method testAnnotationNotPresent.

@Test
public void testAnnotationNotPresent() {
    System system = loadRoot("AnnotationNotPresent.graal", System.class);
    DomainClass domainClass = query(() -> {
        return (DomainClass) system.getOwnedNamespaces().get(0).getTypes().get(0);
    });
    assertEquals("", getPhysicalSize(domainClass));
}
Also used : DomainClass(org.obeonetwork.graal.DomainClass) System(org.obeonetwork.graal.System) Test(org.junit.Test)

Example 10 with System

use of org.obeonetwork.graal.System in project InformationSystem by ObeoNetwork.

the class UseCaseServicesTest method testSortIgnoringAccents.

@Test
public void testSortIgnoringAccents() {
    System system = loadRoot("SortIgnoringAccents.graal", System.class);
    UseCase useCase = query(() -> {
        return (UseCase) system.getUseCases().get(0);
    });
    verifyAllDomainClasses(useCase, new String[] { "ns1.BaShouldBe1", "ns1.bbShouldBe2", "ns1.éaShouldBe3", "ns1.EBShouldBe4" });
}
Also used : UseCase(org.obeonetwork.graal.UseCase) System(org.obeonetwork.graal.System) Test(org.junit.Test)

Aggregations

System (org.obeonetwork.graal.System)25 Test (org.junit.Test)14 UseCase (org.obeonetwork.graal.UseCase)12 EObject (org.eclipse.emf.ecore.EObject)6 DomainClass (org.obeonetwork.graal.DomainClass)5 ArrayList (java.util.ArrayList)4 EReference (org.eclipse.emf.ecore.EReference)4 Setting (org.eclipse.emf.ecore.EStructuralFeature.Setting)4 Resource (org.eclipse.emf.ecore.resource.Resource)4 AbstractTask (org.obeonetwork.graal.AbstractTask)4 GraalUsageCrossReferencer (org.obeonetwork.graal.util.GraalUsageCrossReferencer)4 Date (java.util.Date)3 TasksGroup (org.obeonetwork.graal.TasksGroup)3 InputDialog (org.eclipse.jface.dialogs.InputDialog)2 Task (org.obeonetwork.graal.Task)2 Entity (org.obeonetwork.dsl.entity.Entity)1 Loop (org.obeonetwork.graal.Loop)1 TaskReference (org.obeonetwork.graal.TaskReference)1 TasksContainer (org.obeonetwork.graal.TasksContainer)1 UserStory (org.obeonetwork.graal.UserStory)1