Commit 89f79f9a authored by Hernan Ponce de Leon's avatar Hernan Ponce de Leon
Browse files

Merge branch 'master' of https://git.fortiss.org/af3/af3.git

parents 70faa131 47f13cd8
DeploymentParameterEditorBackend.java c05b246a6a7b9044fb064380f30f6616fd2278b0 GREEN
DeploymentParameterEditorBackend.java e69ec2c5337cb7d13c527bf6765ac2e713cc513d GREEN
DeploymentParameterEditorBinding.java cfa88f2dc15b70d52527d490d355f958f84d1900 GREEN
DeploymentParameterLabelProvider.java 606038decf2b2ee5ba36bfa277b0653e0c608c0b GREEN
......@@ -26,6 +26,7 @@ import java.util.List;
import org.conqat.lib.commons.collections.Pair;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ColumnLabelProvider;
......@@ -40,6 +41,7 @@ import org.eclipse.swt.widgets.Composite;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.deployment.model.ComponentAllocation;
import org.fortiss.af3.deployment.model.Deployment;
import org.fortiss.af3.deployment.model.DeploymentParameterKey;
import org.fortiss.af3.deployment.model.DeploymentParameterValue;
import org.fortiss.af3.deployment.ui.AF3DeploymentUIActivator;
import org.fortiss.af3.platform.model.ExecutionUnit;
......@@ -155,6 +157,9 @@ public class DeploymentParameterEditorBackend extends EditorBase<Deployment> {
*/
private void fillParameterCombo() {
DeploymentParameterValue paramValue = getFirstDeplParamVal();
if(paramValue == null) {
return;
}
for(IAnnotatedSpecification spec : getAnnotationsOf(paramValue)) {
@SuppressWarnings("unchecked") Class<IAnnotatedSpecification> specType =
......@@ -196,14 +201,25 @@ public class DeploymentParameterEditorBackend extends EditorBase<Deployment> {
final Deployment deployment = getEditedObject();
for(ComponentAllocation cAlloc : deployment.getComponentAllocations()) {
Component component = cAlloc.getComponent();
if(component == null) {
continue;
}
ExecutionUnit executionUnit = cAlloc.getExecutionUnit();
if(executionUnit == null) {
continue;
}
IAnnotatedSpecification spec =
deployment.getDeploymentParameterSpecification(cAlloc.getComponent(),
cAlloc.getExecutionUnit(), selSpecType);
deployment.getDeploymentParameterSpecification(component, executionUnit,
selSpecType);
paramAnnotationEntries.add(annService.getAnnotationEntry(spec.getSpecificationOf()));
}
// Enable editing deployment specific parameters.
DeploymentParameterValue paramValue = getFirstDeplParamVal();
if(paramValue == null) {
return;
}
EditingSupport editingSupport = null;
try {
editingSupport =
......@@ -278,16 +294,18 @@ public class DeploymentParameterEditorBackend extends EditorBase<Deployment> {
/**
* Returns the first {@link DeploymentParameterValue} of the deployment specific parameter map
* of the underlying {@link Deployment}. If none exists yet the map is instantiated.
* of the underlying {@link Deployment}. If none exists yet, the map is instantiated. In case
* the {@link Deployment} does not contain any entries, {@code null} is returned.
*/
private DeploymentParameterValue getFirstDeplParamVal() {
final Deployment deployment = getEditedObject();
if(deployment.getDeploymentParameterMap().isEmpty()) {
EMap<DeploymentParameterKey, DeploymentParameterValue> pMap =
deployment.getDeploymentParameterMap();
if(pMap.isEmpty()) {
instantiateDeploymentParameterMap(deployment, false);
}
// Return the first entry of the parameter map. It is ensured by the above code to be always
// present.
return deployment.getDeploymentParameterMap().get(0).getValue();
// Return the first entry of the parameter map (if it exists).
return !pMap.isEmpty() ? pMap.get(0).getValue() : null;
}
/**
......
DeploymentParameterKeyStaticImpl.java 9e45a8b171af4c01f34c3f86665f350b94b5baff GREEN
DeploymentParameterValueStaticImpl.java 18fc585cef27ec7acef9b43ea1af9ed9f8b063f8 GREEN
DeploymentStaticImpl.java 521eace35b551755114e85abbf6fbbe27732dfd0 GREEN
DeploymentStaticImpl.java 45e9757a01917e024733e28b2a8dd1d380a6a2ae GREEN
SegmentStaticImpl.java b318f19b71321f44b05bae635c50af4ef7ffeae2 GREEN
TransceiverPortStaticImpl.java 82b7721c45dc9033dec9947b14a7deb5bc46c31e GREEN
......@@ -23,8 +23,11 @@ import static org.fortiss.af3.deployment.utils.DeploymentParameterUtils.getAllDe
import static org.fortiss.af3.deployment.utils.DeploymentParameterUtils.instantiateDeploymentParameterMap;
import static org.fortiss.af3.deployment.utils.DeploymentUtils.getComponentArchitecture;
import static org.fortiss.af3.deployment.utils.DeploymentUtils.getPlatformArchitecture;
import static org.fortiss.af3.project.utils.ProjectUtils.getFileProject;
import static org.fortiss.tooling.base.utils.AnnotationUtils.getAnnotation;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.runAsCommand;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.warning;
import java.util.ArrayList;
import java.util.Collection;
......@@ -43,14 +46,11 @@ import org.fortiss.af3.deployment.model.DeploymentParameterKey;
import org.fortiss.af3.deployment.model.DeploymentParameterValue;
import org.fortiss.af3.platform.model.ExecutionUnit;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.project.utils.ProjectUtils;
import org.fortiss.tooling.base.annotation.AnnotationEntry;
import org.fortiss.tooling.base.annotation.IAnnotationValueService;
import org.fortiss.tooling.base.model.element.IAnnotatedSpecification;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.utils.KernelModelElementUtils;
import org.fortiss.tooling.kernel.utils.LoggingUtils;
/**
* Helper methods for {@link EOperation}s of {@link Deployment}.
......@@ -97,7 +97,7 @@ public class DeploymentStaticImpl {
if(parameterValue == null) {
final DeploymentParameterValue newParameterValue =
createDeploymentParameterValue(component, executionUnit);
KernelModelElementUtils.runAsCommand(deployment, new Runnable() {
runAsCommand(deployment, new Runnable() {
@Override
public void run() {
......@@ -367,6 +367,7 @@ public class DeploymentStaticImpl {
Collection<ExecutionUnit> executionUnits =
getAllDeploymentParameterExecutionUnits(getPlatformArchitecture(deployment));
AF3DeploymentActivator plugin = AF3DeploymentActivator.getDefault();
for(Iterator<Entry<DeploymentParameterKey, DeploymentParameterValue>> iter =
deploymentParameterMap.iterator(); iter.hasNext();) {
......@@ -381,7 +382,7 @@ public class DeploymentStaticImpl {
// component / executionUnit might be null if the deployment parameter map is
// updated when deleting an element
if(component != null && executionUnit != null) {
error(AF3DeploymentActivator.getDefault(), getProjectName(deployment) +
error(plugin, getProjectName(deployment) +
": Deployment parameter map contains an invalid entry (Component ID=" +
component.getId() + ", ExecutionUnit ID=" + executionUnit.getId() +
"). Skipped.");
......@@ -393,7 +394,7 @@ public class DeploymentStaticImpl {
// component / executionUnit might be null if the deployment parameter map is
// updated when deleting an element
if(component != null && executionUnit != null) {
error(AF3DeploymentActivator.getDefault(),
error(plugin,
getProjectName(deployment) +
": Deployment parameter map contains a dupliate entry (Component ID=" +
component.getId() + ", ExecutionUnit ID=" +
......@@ -410,22 +411,22 @@ public class DeploymentStaticImpl {
// Re-add all (key, value) entries to the map. This is required since the map's
// internal data structures would not be aware of the changed hash codes, otherwise. (At
// this stage,the map assumes, that the hash code of all keys is 0).
int oldSize = deploymentParameterMap.size();
deploymentParameterMap.clear();
deploymentParameterMap.addAll(entryList);
// Ensure that deployment parameter map is complete
int oldSize = deploymentParameterMap.size();
instantiateDeploymentParameterMap(deployment, false);
if(oldSize != deploymentParameterMap.size()) {
LoggingUtils.warning(AF3DeploymentActivator.getDefault(), getProjectName(deployment) +
": Deployment parameter map was not complete. Fixed.");
warning(plugin, getProjectName(deployment) +
": Deployment parameter map was out of sync with component-to-execution unit allocation. Fixed.");
}
}
/** Helper to determine project name for {@link Deployment}. */
private static String getProjectName(final Deployment deployment) {
FileProject project = ProjectUtils.getFileProject(deployment);
FileProject project = getFileProject(deployment);
String projectName =
project != null && project.getName() != null ? project.getName()
: "<unnamed project>";
......
DeploymentModelElementFactory.java e316ebfc6039651add30fd7d76268774b245960d GREEN
DeploymentParameterUtils.java 244b4ec491ecd2124187d39ab5865b4dfb32052d GREEN
DeploymentParameterUtils.java 57539ccc0f5ef8d637dd21896ea91a9fb15921eb GREEN
DeploymentUtils.java dbf7fff67da3959f2aa336179fde066e757d4140 GREEN
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.deployment.utils;
import static java.util.Collections.emptyList;
import static org.fortiss.af3.deployment.utils.DeploymentUtils.getComponentArchitecture;
import static org.fortiss.af3.deployment.utils.DeploymentUtils.getDeploymentsOf;
import static org.fortiss.af3.deployment.utils.DeploymentUtils.getPlatformArchitecture;
......@@ -23,7 +24,6 @@ import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.eclipse.emf.common.notify.Notification;
......@@ -251,11 +251,8 @@ public class DeploymentParameterUtils {
/** If needed, installs adapters that synchronize the parameter map with changes to the model. */
public static void setupDeploymentAdapters(final Deployment deployment) {
ComponentArchitecture ca =
(ComponentArchitecture)deployment.getComponentArchitectureReference()
.getReference();
PlatformArchitecture pa =
(PlatformArchitecture)deployment.getPlatformArchitectureReference().getReference();
ComponentArchitecture ca = getComponentArchitecture(deployment);
PlatformArchitecture pa = getPlatformArchitecture(deployment);
if(ca != null &&
pickFirstInstanceOf(
......@@ -300,7 +297,7 @@ public class DeploymentParameterUtils {
public static Collection<Component> getAllDeploymentParameterComponents(
final ComponentArchitecture ca) {
if(ca == null) {
return Collections.emptyList();
return emptyList();
}
// Skip top component
......@@ -314,7 +311,7 @@ public class DeploymentParameterUtils {
public static Collection<ExecutionUnit> getAllDeploymentParameterExecutionUnits(
final PlatformArchitecture pa) {
if(pa == null) {
return Collections.emptyList();
return emptyList();
}
return getChildrenWithType(pa, ExecutionUnit.class);
}
......@@ -337,11 +334,13 @@ public class DeploymentParameterUtils {
}
// Ensure that adapters are installed as soon as given deployment is accessed
DeploymentParameterUtils.setupDeploymentAdapters(deployment);
setupDeploymentAdapters(deployment);
// Instantiate parameters for all (Component, ExecutionUnit) pairs
for(Component currentComponent : getAllDeploymentParameterComponents(getComponentArchitecture(deployment))) {
for(ExecutionUnit currentEcu : getAllDeploymentParameterExecutionUnits(getPlatformArchitecture(deployment))) {
ComponentArchitecture ca = getComponentArchitecture(deployment);
PlatformArchitecture pa = getPlatformArchitecture(deployment);
for(Component currentComponent : getAllDeploymentParameterComponents(ca)) {
for(ExecutionUnit currentEcu : getAllDeploymentParameterExecutionUnits(pa)) {
deployment.instantiateDeploymentParameters(currentComponent, currentEcu);
}
}
......@@ -361,9 +360,10 @@ public class DeploymentParameterUtils {
final Component component) {
// Ensure that adapters are installed as soon as given deployment is accessed
DeploymentParameterUtils.setupDeploymentAdapters(deployment);
setupDeploymentAdapters(deployment);
for(ExecutionUnit currentEcu : getAllDeploymentParameterExecutionUnits(getPlatformArchitecture(deployment))) {
PlatformArchitecture pa = getPlatformArchitecture(deployment);
for(ExecutionUnit currentEcu : getAllDeploymentParameterExecutionUnits(pa)) {
deployment.instantiateDeploymentParameters(component, currentEcu);
}
}
......@@ -382,9 +382,10 @@ public class DeploymentParameterUtils {
final ExecutionUnit executionUnit) {
// Ensure that adapters are installed as soon as given deployment is accessed
DeploymentParameterUtils.setupDeploymentAdapters(deployment);
setupDeploymentAdapters(deployment);
for(Component currentComponent : getAllDeploymentParameterComponents(getComponentArchitecture(deployment))) {
ComponentArchitecture ca = getComponentArchitecture(deployment);
for(Component currentComponent : getAllDeploymentParameterComponents(ca)) {
deployment.instantiateDeploymentParameters(currentComponent, executionUnit);
}
}
......@@ -401,7 +402,8 @@ public class DeploymentParameterUtils {
*/
public static void removeComponentParameters(final Deployment deployment,
final Component component) {
for(ExecutionUnit currentEcu : getAllDeploymentParameterExecutionUnits(getPlatformArchitecture(deployment))) {
PlatformArchitecture pa = getPlatformArchitecture(deployment);
for(ExecutionUnit currentEcu : getAllDeploymentParameterExecutionUnits(pa)) {
deployment.removeDeploymentParameters(component, currentEcu);
}
}
......@@ -419,7 +421,8 @@ public class DeploymentParameterUtils {
public static void removeExecutionUnitParameters(final Deployment deployment,
final ExecutionUnit executionUnit) {
for(Component currentComponent : getAllDeploymentParameterComponents(getComponentArchitecture(deployment))) {
ComponentArchitecture ca = getComponentArchitecture(deployment);
for(Component currentComponent : getAllDeploymentParameterComponents(ca)) {
deployment.removeDeploymentParameters(currentComponent, executionUnit);
}
}
......@@ -439,7 +442,7 @@ public class DeploymentParameterUtils {
public static List<Deployment> getDeploymentsWithParametersOf(
ComponentArchitecture componentArchitecture, PlatformArchitecture platformArchitecture) {
if(componentArchitecture == null || platformArchitecture == null) {
return Collections.emptyList();
return emptyList();
}
Collection<Deployment> matchingDeployments =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment