Search in sources :

Example 1 with UseCase

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

the class AbstractTaskImpl method getUseCase.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public UseCase getUseCase() {
    Collection<Setting> useCaseReferences = new GraalUsageCrossReferencer() {

        @Override
        protected boolean crossReference(EObject eObject, EReference eReference, EObject crossReferencedEObject) {
            return eReference == GraalPackage.Literals.USE_CASE__TASKS;
        }

        @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 UseCase);
        }
    }.findUsage(this);
    UseCase useCase = null;
    for (Setting setting : useCaseReferences) {
        useCase = (UseCase) setting.getEObject();
        break;
    }
    return useCase;
}
Also used : Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) EObject(org.eclipse.emf.ecore.EObject) GraalUsageCrossReferencer(org.obeonetwork.graal.util.GraalUsageCrossReferencer) Resource(org.eclipse.emf.ecore.resource.Resource) UseCase(org.obeonetwork.graal.UseCase) EReference(org.eclipse.emf.ecore.EReference) System(org.obeonetwork.graal.System)

Example 2 with UseCase

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

the class UseCaseUseCasePropertiesEditionComponent 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 UseCase useCase = (UseCase) elt;
        final UseCasePropertiesEditionPart useCasePart = (UseCasePropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(GraalViewsRepository.UseCase.Properties.description))
            useCasePart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, useCase.getDescription()));
        if (isAccessible(GraalViewsRepository.UseCase.Properties.tasks)) {
            tasksSettings = new ReferencesTableSettings(useCase, GraalPackage.eINSTANCE.getUseCase_Tasks());
            useCasePart.initTasks(tasksSettings);
        }
        if (isAccessible(GraalViewsRepository.UseCase.Properties.name))
            useCasePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, useCase.getName()));
        if (isAccessible(GraalViewsRepository.UseCase.Properties.namespaces)) {
            namespacesSettings = new ReferencesTableSettings(useCase, GraalPackage.eINSTANCE.getDomainModelRegistry_Namespaces());
            useCasePart.initNamespaces(namespacesSettings);
        }
        if (isAccessible(GraalViewsRepository.UseCase.Properties.domainClasses)) {
            domainClassesSettings = new ReferencesTableSettings(useCase, GraalPackage.eINSTANCE.getUseCase_DomainClasses());
            useCasePart.initDomainClasses(domainClassesSettings);
        }
        if (isAccessible(GraalViewsRepository.UseCase.Properties.tasks)) {
            useCasePart.addFilterToTasks(new EObjectFilter(GraalPackage.Literals.ABSTRACT_TASK));
        // Start of user code for additional businessfilters for tasks
        // End of user code
        }
        if (isAccessible(GraalViewsRepository.UseCase.Properties.namespaces)) {
            useCasePart.addFilterToNamespaces(new EObjectFilter(EnvironmentPackage.Literals.NAMESPACE));
        // Start of user code for additional businessfilters for namespaces
        // End of user code
        }
        if (isAccessible(GraalViewsRepository.UseCase.Properties.domainClasses)) {
            useCasePart.addFilterToDomainClasses(new EObjectFilter(GraalPackage.Literals.DOMAIN_CLASS));
        // Start of user code for additional businessfilters for domainClasses
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : EObjectFilter(org.eclipse.emf.eef.runtime.impl.filters.EObjectFilter) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) UseCase(org.obeonetwork.graal.UseCase) UseCasePropertiesEditionPart(org.obeonetwork.graal.parts.UseCasePropertiesEditionPart)

Example 3 with UseCase

use of org.obeonetwork.graal.UseCase 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)

Example 4 with UseCase

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

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

UseCase (org.obeonetwork.graal.UseCase)14 System (org.obeonetwork.graal.System)12 Test (org.junit.Test)9 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 AbstractTask (org.obeonetwork.graal.AbstractTask)2 GraalUsageCrossReferencer (org.obeonetwork.graal.util.GraalUsageCrossReferencer)2 Date (java.util.Date)1 EObjectFilter (org.eclipse.emf.eef.runtime.impl.filters.EObjectFilter)1 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 Entity (org.obeonetwork.dsl.entity.Entity)1 TasksContainer (org.obeonetwork.graal.TasksContainer)1 TasksGroup (org.obeonetwork.graal.TasksGroup)1 UseCasePropertiesEditionPart (org.obeonetwork.graal.parts.UseCasePropertiesEditionPart)1