From fd8162012168509c45adc4e85ac06c331a493a02 Mon Sep 17 00:00:00 2001 From: Timo Maier Date: Mon, 7 May 2018 09:20:03 +0200 Subject: [PATCH] Minor adaptions for KAMP4aPS4Req --- .../presentation/DeploymentContextEditor.java | 53 +++++++++---------- .../DeploymentContextModelWizard.java | 3 +- .../kamp4aps/core/APSArchitectureVersion.java | 46 ++++++++++++++++ .../derivation/APSDifferenceCalculation.java | 11 ++-- 4 files changed, 79 insertions(+), 34 deletions(-) diff --git a/edu.kit.ipd.sdq.kamp4aps.model.deploymentcontext.editor/src/edu/kit/ipd/sdq/kamp4aps/model/DeploymentContext/presentation/DeploymentContextEditor.java b/edu.kit.ipd.sdq.kamp4aps.model.deploymentcontext.editor/src/edu/kit/ipd/sdq/kamp4aps/model/DeploymentContext/presentation/DeploymentContextEditor.java index 57fb6428..e0dcc1ae 100644 --- a/edu.kit.ipd.sdq.kamp4aps.model.deploymentcontext.editor/src/edu/kit/ipd/sdq/kamp4aps/model/DeploymentContext/presentation/DeploymentContextEditor.java +++ b/edu.kit.ipd.sdq.kamp4aps.model.deploymentcontext.editor/src/edu/kit/ipd/sdq/kamp4aps/model/DeploymentContext/presentation/DeploymentContextEditor.java @@ -424,8 +424,6 @@ public void partOpened(IWorkbenchPart p) { */ protected EContentAdapter problemIndicationAdapter = new EContentAdapter() { - protected boolean dispatching; - @Override public void notifyChanged(Notification notification) { if (notification.getNotifier() instanceof Resource) { @@ -441,7 +439,15 @@ public void notifyChanged(Notification notification) { else { resourceToDiagnosticMap.remove(resource); } - dispatchUpdateProblemIndication(); + + if (updateProblemIndication) { + getSite().getShell().getDisplay().asyncExec + (new Runnable() { + public void run() { + updateProblemIndication(); + } + }); + } break; } } @@ -451,19 +457,6 @@ public void notifyChanged(Notification notification) { } } - protected void dispatchUpdateProblemIndication() { - if (updateProblemIndication && !dispatching) { - dispatching = true; - getSite().getShell().getDisplay().asyncExec - (new Runnable() { - public void run() { - dispatching = false; - updateProblemIndication(); - } - }); - } - } - @Override protected void setTarget(Resource target) { basicSetTarget(target); @@ -473,7 +466,14 @@ protected void setTarget(Resource target) { protected void unsetTarget(Resource target) { basicUnsetTarget(target); resourceToDiagnosticMap.remove(target); - dispatchUpdateProblemIndication(); + if (updateProblemIndication) { + getSite().getShell().getDisplay().asyncExec + (new Runnable() { + public void run() { + updateProblemIndication(); + } + }); + } } }; @@ -671,11 +671,14 @@ else if (diagnostic.getSeverity() != Diagnostic.OK) { } if (markerHelper.hasMarkers(editingDomain.getResourceSet())) { - try { - markerHelper.updateMarkers(diagnostic); - } - catch (CoreException exception) { - DeploymentcontextEditorPlugin.INSTANCE.log(exception); + markerHelper.deleteMarkers(editingDomain.getResourceSet()); + if (diagnostic.getSeverity() != Diagnostic.OK) { + try { + markerHelper.createMarkers(diagnostic); + } + catch (CoreException exception) { + DeploymentcontextEditorPlugin.INSTANCE.log(exception); + } } } } @@ -1066,7 +1069,6 @@ public void requestActivation() { selectionViewer = (TreeViewer)viewerPane.getViewer(); selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); - selectionViewer.setUseHashlookup(true); selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); selectionViewer.setInput(editingDomain.getResourceSet()); @@ -1372,7 +1374,6 @@ public void createControl(Composite parent) { // Set up the tree viewer. // - contentOutlineViewer.setUseHashlookup(true); contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); contentOutlineViewer.setInput(editingDomain.getResourceSet()); @@ -1520,9 +1521,7 @@ public void execute(IProgressMonitor monitor) { // Save the resources to the file system. // boolean first = true; - List resources = editingDomain.getResourceSet().getResources(); - for (int i = 0; i < resources.size(); ++i) { - Resource resource = resources.get(i); + for (Resource resource : editingDomain.getResourceSet().getResources()) { if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { try { long timeStamp = resource.getTimeStamp(); diff --git a/edu.kit.ipd.sdq.kamp4aps.model.deploymentcontext.editor/src/edu/kit/ipd/sdq/kamp4aps/model/DeploymentContext/presentation/DeploymentContextModelWizard.java b/edu.kit.ipd.sdq.kamp4aps.model.deploymentcontext.editor/src/edu/kit/ipd/sdq/kamp4aps/model/DeploymentContext/presentation/DeploymentContextModelWizard.java index 94ec4c69..eae5fdff 100644 --- a/edu.kit.ipd.sdq.kamp4aps.model.deploymentcontext.editor/src/edu/kit/ipd/sdq/kamp4aps/model/DeploymentContext/presentation/DeploymentContextModelWizard.java +++ b/edu.kit.ipd.sdq.kamp4aps.model.deploymentcontext.editor/src/edu/kit/ipd/sdq/kamp4aps/model/DeploymentContext/presentation/DeploymentContextModelWizard.java @@ -395,8 +395,7 @@ public DeploymentContextModelWizardInitialObjectCreationPage(String pageId) { * @generated */ public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - { + Composite composite = new Composite(parent, SWT.NONE); { GridLayout layout = new GridLayout(); layout.numColumns = 1; layout.verticalSpacing = 12; diff --git a/edu.kit.ipd.sdq.kamp4aps/src/edu/kit/ipd/sdq/kamp4aps/core/APSArchitectureVersion.java b/edu.kit.ipd.sdq.kamp4aps/src/edu/kit/ipd/sdq/kamp4aps/core/APSArchitectureVersion.java index 5f045fce..10dee75d 100755 --- a/edu.kit.ipd.sdq.kamp4aps/src/edu/kit/ipd/sdq/kamp4aps/core/APSArchitectureVersion.java +++ b/edu.kit.ipd.sdq.kamp4aps/src/edu/kit/ipd/sdq/kamp4aps/core/APSArchitectureVersion.java @@ -108,6 +108,52 @@ public APSArchitectureVersion(ArchitectureVersionParams params) { _iecFieldOfActivityRepository = params.iecFieldOfActivityRepository; _iecModificationMarkRepository = params.iecModificationMarkRepository; } + + public APSArchitectureVersion(String name, FieldOfActivityAnnotationRepository fieldOfActivityRepository, + AbstractKAMP4aPSModificationRepository modificationMarkRepository, Plant aPSPlant, DeploymentContextRepository deploymentContextRepository, Repository iecRepository, + Configuration configuration, IECFieldOfActivityAnnotationsRepository iecFieldOfActivityRepository, + IECModificationRepository iecModificationMarkRepository) { + super(name, modificationMarkRepository); + // Some of the files describing the architecture might not exist; prevent NullPointer + // in propagation algorithm by setting newly created objects (whose EReferences are + // instantiated with empty collections, so the algorithm can handle them) + + if (fieldOfActivityRepository == null) + fieldOfActivityRepository = KAMP4aPSFieldofactivityannotationsFactory.eINSTANCE. + createFieldOfActivityAnnotationRepository(); + + if(deploymentContextRepository == null) + deploymentContextRepository = DeploymentContextFactory.eINSTANCE.createDeploymentContextRepository(); + _deploymentContextRepository = deploymentContextRepository; + + if (iecRepository == null) { + _IECRepository = IECRepositoryFactory.eINSTANCE. + createRepository(); + } + this._IECRepository = iecRepository; + if (configuration == null) { + _configuration = IECModelFactory.eINSTANCE. + createConfiguration(); + } + this._configuration = configuration; + if (iecFieldOfActivityRepository == null) { + _iecFieldOfActivityRepository = IECFieldOfActivityAnnotationsFactory.eINSTANCE. + createIECFieldOfActivityAnnotationsRepository(); + } + this._iecModificationMarkRepository = iecModificationMarkRepository; + if (iecModificationMarkRepository == null) { + _iecModificationMarkRepository = IECModificationmarksFactory.eINSTANCE. + createIECModificationRepository(); + } + + _fieldOfActivityRepository = fieldOfActivityRepository; + _aPSPlant = aPSPlant; + _deploymentContextRepository = deploymentContextRepository; + _IECRepository = iecRepository; + _configuration = configuration; + _iecFieldOfActivityRepository = iecFieldOfActivityRepository; + _iecModificationMarkRepository = iecModificationMarkRepository; + } public FieldOfActivityAnnotationRepository getFieldOfActivityRepository() { return _fieldOfActivityRepository; diff --git a/edu.kit.ipd.sdq.kamp4aps/src/edu/kit/ipd/sdq/kamp4aps/core/derivation/APSDifferenceCalculation.java b/edu.kit.ipd.sdq.kamp4aps/src/edu/kit/ipd/sdq/kamp4aps/core/derivation/APSDifferenceCalculation.java index 2e8fc0b2..62dc86c6 100755 --- a/edu.kit.ipd.sdq.kamp4aps/src/edu/kit/ipd/sdq/kamp4aps/core/derivation/APSDifferenceCalculation.java +++ b/edu.kit.ipd.sdq.kamp4aps/src/edu/kit/ipd/sdq/kamp4aps/core/derivation/APSDifferenceCalculation.java @@ -39,7 +39,7 @@ public class APSDifferenceCalculation extends AbstractDifferenceCalculation workplan) { + public void checkForDifferencesAndAddToWorkplan(Diff diffElement, List workplan) { for (APSActivityElementType elementType : APSActivityElementType.topLevelAPSActivityElementTypes()) { if (detectionRuleAdded(diffElement, elementType.getElementClass())) { NamedElement architectureElement = (NamedElement) (((ReferenceChange) diffElement).getValue()); @@ -105,12 +105,13 @@ private List removeDuplicates(List plantActivities) { for(Activity activity : plantActivities){ isContained = false; for(Activity tmpActivity : newActivities){ - if(tmpActivity.getElementName() == null || activity.getElementName() == null) - System.out.println("gnah"); - if(tmpActivity.getElementName().equals(activity.getElementName())) + if (tmpActivity == null || activity == null) { + continue; + } + if(tmpActivity.getElementName() != null && activity.getElementName() != null && + tmpActivity.getElementName().equals(activity.getElementName())) isContained = true; } - if(!isContained) newActivities.add(activity); }