Search in sources :

Example 1 with SchedulingPolicy

use of org.palladiosimulator.pcm.resourcetype.SchedulingPolicy in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddProcessingResourceSpecification method getSchedulingPolicy.

private SchedulingPolicy getSchedulingPolicy(final ProcessingResourceSpecification processingResourceSpecification) {
    final ResourceSet set = (processingResourceSpecification.getResourceContainer_ProcessingResourceSpecification()).eResource().getResourceSet();
    // positive filter
    final ArrayList<Object> filterList = new ArrayList<Object>();
    // Set types to show and their super types
    filterList.add(SchedulingPolicy.class);
    filterList.add(ResourceRepository.class);
    final ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
    // set EReference that should be set (in this case: SchedulingPolicy)
    additionalReferences.add(ResourceenvironmentPackage.eINSTANCE.getProcessingResourceSpecification_SchedulingPolicy());
    final PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), filterList, additionalReferences, set);
    dialog.setProvidedService(SchedulingPolicy.class);
    dialog.open();
    if (dialog.getResult() == null || !(dialog.getResult() instanceof SchedulingPolicy)) {
        return null;
    }
    return (SchedulingPolicy) dialog.getResult();
}
Also used : PalladioSelectEObjectDialog(org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) SchedulingPolicy(org.palladiosimulator.pcm.resourcetype.SchedulingPolicy) EReference(org.eclipse.emf.ecore.EReference)

Example 2 with SchedulingPolicy

use of org.palladiosimulator.pcm.resourcetype.SchedulingPolicy in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddHDDProcessingResourceSpecification method execute.

@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final Object parameter = parameters.get(NEW_HDD_PROCESSING_RESOURCE_SPECIFICATION);
    if (parameter == null || !(parameter instanceof HDDProcessingResourceSpecification)) {
        return;
    }
    final HDDProcessingResourceSpecification hddProcessingResourceSpecification = (HDDProcessingResourceSpecification) parameter;
    // 1. dialog
    final ProcessingResourceType prt = getResourceType(hddProcessingResourceSpecification);
    if (prt != null) {
        hddProcessingResourceSpecification.setActiveResourceType_ActiveResourceSpecification(prt);
    } else {
        return;
    }
    // set processing rate always to 1
    final PCMRandomVariable processingRate = CoreFactory.eINSTANCE.createPCMRandomVariable();
    processingRate.setSpecification("1");
    hddProcessingResourceSpecification.setProcessingRate_ProcessingResourceSpecification(processingRate);
    // 2. dialog
    final PCMRandomVariable readProcessingRate = getReadProcessingRate();
    if (readProcessingRate != null) {
        hddProcessingResourceSpecification.setReadProcessingRate(readProcessingRate);
    } else {
        return;
    }
    // 3. dialog
    final PCMRandomVariable writeProcessingRate = getWriteProcessingRate();
    if (writeProcessingRate != null) {
        hddProcessingResourceSpecification.setWriteProcessingRate(writeProcessingRate);
    } else {
        return;
    }
    // 4. dialog
    final SchedulingPolicy sp = getSchedulingPolicy(hddProcessingResourceSpecification);
    if (sp != null) {
        hddProcessingResourceSpecification.setSchedulingPolicy(sp);
    } else {
        return;
    }
}
Also used : HDDProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.HDDProcessingResourceSpecification) EObject(org.eclipse.emf.ecore.EObject) ProcessingResourceType(org.palladiosimulator.pcm.resourcetype.ProcessingResourceType) SchedulingPolicy(org.palladiosimulator.pcm.resourcetype.SchedulingPolicy) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Example 3 with SchedulingPolicy

use of org.palladiosimulator.pcm.resourcetype.SchedulingPolicy in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddHDDProcessingResourceSpecification method getSchedulingPolicy.

private SchedulingPolicy getSchedulingPolicy(final ProcessingResourceSpecification processingResourceSpecification) {
    final ResourceSet set = (processingResourceSpecification.getResourceContainer_ProcessingResourceSpecification()).eResource().getResourceSet();
    // positive filter
    final ArrayList<Object> filterList = new ArrayList<Object>();
    // Set types to show and their super types
    filterList.add(SchedulingPolicy.class);
    filterList.add(ResourceRepository.class);
    final ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
    // set EReference that should be set (in this case: SchedulingPolicy)
    additionalReferences.add(ResourceenvironmentPackage.eINSTANCE.getProcessingResourceSpecification_SchedulingPolicy());
    final PalladioSelectEObjectDialog dialog = new PalladioSelectEObjectDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), filterList, additionalReferences, set);
    dialog.setProvidedService(SchedulingPolicy.class);
    dialog.open();
    if (dialog.getResult() == null || !(dialog.getResult() instanceof SchedulingPolicy)) {
        return null;
    }
    return (SchedulingPolicy) dialog.getResult();
}
Also used : PalladioSelectEObjectDialog(org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog) ArrayList(java.util.ArrayList) EObject(org.eclipse.emf.ecore.EObject) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) SchedulingPolicy(org.palladiosimulator.pcm.resourcetype.SchedulingPolicy) EReference(org.eclipse.emf.ecore.EReference)

Example 4 with SchedulingPolicy

use of org.palladiosimulator.pcm.resourcetype.SchedulingPolicy in project Palladio-Editors-Sirius by PalladioSimulator.

the class AddProcessingResourceSpecification method execute.

@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
    final Object parameter = parameters.get(NEW_PROCESSING_RESOURCE_SPECIFICATION);
    if (parameter == null || !(parameter instanceof ProcessingResourceSpecification)) {
        return;
    }
    final ProcessingResourceSpecification processingResourceSpecification = (ProcessingResourceSpecification) parameter;
    // 1. dialog
    final ProcessingResourceType prt = getResourceType(processingResourceSpecification);
    if (prt != null)
        processingResourceSpecification.setActiveResourceType_ActiveResourceSpecification(prt);
    else
        return;
    // 2. dialog
    final PCMRandomVariable pcmrv = getProcessingRate();
    if (pcmrv != null)
        processingResourceSpecification.setProcessingRate_ProcessingResourceSpecification(pcmrv);
    else
        return;
    // 3. dialog
    final SchedulingPolicy sp = getSchedulingPolicy(processingResourceSpecification);
    if (sp != null)
        processingResourceSpecification.setSchedulingPolicy(sp);
    else
        return;
}
Also used : ProcessingResourceSpecification(org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification) EObject(org.eclipse.emf.ecore.EObject) ProcessingResourceType(org.palladiosimulator.pcm.resourcetype.ProcessingResourceType) SchedulingPolicy(org.palladiosimulator.pcm.resourcetype.SchedulingPolicy) PCMRandomVariable(org.palladiosimulator.pcm.core.PCMRandomVariable)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)4 SchedulingPolicy (org.palladiosimulator.pcm.resourcetype.SchedulingPolicy)4 ArrayList (java.util.ArrayList)2 EReference (org.eclipse.emf.ecore.EReference)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 PalladioSelectEObjectDialog (org.palladiosimulator.editors.commons.dialogs.selection.PalladioSelectEObjectDialog)2 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)2 ProcessingResourceType (org.palladiosimulator.pcm.resourcetype.ProcessingResourceType)2 HDDProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.HDDProcessingResourceSpecification)1 ProcessingResourceSpecification (org.palladiosimulator.pcm.resourceenvironment.ProcessingResourceSpecification)1