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