From 1d660ecd5025b41c3aee424b9f9f88e9d6d9e1ef Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:32:28 +0100 Subject: [PATCH 01/62] Initial commit of half-working modified code --- .../.polyglot.META-INF | 0 .../.settings/org.eclipse.jdt.core.prefs | 9 + .../.settings/org.eclipse.jdt.core.prefs | 9 + .../.classpath | 7 +- .../.polyglot.META-INF | 0 .../.settings/org.eclipse.jdt.core.prefs | 9 + .../META-INF/MANIFEST.MF | 3 +- .../.classpath | 21 + .../.polyglot.META-INF | 18 + .../.project | 34 + .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 9 + .../META-INF/MANIFEST.MF | 24 + .../build.properties | 14 + .../resources/model/ms.repository | 915 ++++++++++++++++++ .../resources/model/ms_noSEFF.repository | 128 +++ .../model/ms_repository_noSEFF_unedited.uml | 324 +++++++ .../viewfilter/tests/FirstTest.xtend | 111 +++ .../viewfilter/tests/FirstTestFactory.xtend | 67 ++ 19 files changed, 1702 insertions(+), 2 deletions(-) create mode 100644 bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF create mode 100644 bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.jdt.core.prefs create mode 100644 bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.jdt.core.prefs create mode 100644 tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF create mode 100644 tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.jdt.core.prefs create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.classpath create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.polyglot.META-INF create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.project create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.core.resources.prefs create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.jdt.core.prefs create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/build.properties create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms.repository create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_noSEFF.repository create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_repository_noSEFF_unedited.uml create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF b/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF new file mode 100644 index 000000000..e69de29bb diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.jdt.core.prefs b/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..62ef3488c --- /dev/null +++ b/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.jdt.core.prefs b/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..62ef3488c --- /dev/null +++ b/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath b/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath index ef548cb96..366853672 100644 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath +++ b/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath @@ -6,10 +6,15 @@ - + + + + + + diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF b/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF new file mode 100644 index 000000000..e69de29bb diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.jdt.core.prefs b/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..62ef3488c --- /dev/null +++ b/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF index 5fba5d43d..5c3e925e5 100644 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF @@ -18,6 +18,7 @@ Require-Bundle: tools.vitruv.testutils.vsum, edu.kit.ipd.sdq.activextendannotations, tools.vitruv.applications.testutility, org.palladiosimulator.pcm, - edu.kit.ipd.sdq.commons.util.emf + edu.kit.ipd.sdq.commons.util.emf, + slf4j.api;bundle-version="2.0.9" Export-Package: tools.vitruv.applications.pcmumlclass.tests Bundle-Vendor: vitruv.tools diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.classpath b/tests/tools.vitruv.applications.viewfilter.tests/.classpath new file mode 100644 index 000000000..366853672 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.polyglot.META-INF b/tests/tools.vitruv.applications.viewfilter.tests/.polyglot.META-INF new file mode 100644 index 000000000..63d67d85f --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/.polyglot.META-INF @@ -0,0 +1,18 @@ + + + 4.0.0 + + tools.vitruv + tests + 3.0.1-SNAPSHOT + ..\.polyglot.pom.tycho + + tools.vitruv.applications.viewfilter.tests + 3.0.1-SNAPSHOT + eclipse-test-plugin + [test-bundle] Vitruv PCM-UML Class Application Tests + + vitruv.tools + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.project b/tests/tools.vitruv.applications.viewfilter.tests/.project new file mode 100644 index 000000000..2ab8bd4ea --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/.project @@ -0,0 +1,34 @@ + + + tools.vitruv.applications.viewfilter.tests + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..99f26c020 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.jdt.core.prefs b/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..62ef3488c --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF new file mode 100644 index 000000000..1823f938d --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -0,0 +1,24 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Vitruv PCM-UML Class Application Tests +Bundle-SymbolicName: tools.vitruv.applications.viewfilter.tests +Bundle-Version: 3.0.1.qualifier +Automatic-Module-Name: tools.vitruv.applications.viewfilter.tests +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Import-Package: org.junit.jupiter.api, + org.junit.jupiter.api.extension +Require-Bundle: tools.vitruv.testutils.vsum, + org.eclipse.emf.compare, + org.hamcrest.core, + tools.vitruv.applications.pcmumlclass, + tools.vitruv.applications.util.temporary, + org.eclipse.xtend.lib, + edu.kit.ipd.sdq.commons.util.java, + org.palladiosimulator.pcm.resources, + edu.kit.ipd.sdq.activextendannotations, + tools.vitruv.applications.testutility, + org.palladiosimulator.pcm, + edu.kit.ipd.sdq.commons.util.emf, + slf4j.api;bundle-version="2.0.9" +Export-Package: tools.vitruv.applications.viewfilter.tests +Bundle-Vendor: vitruv.tools diff --git a/tests/tools.vitruv.applications.viewfilter.tests/build.properties b/tests/tools.vitruv.applications.viewfilter.tests/build.properties new file mode 100644 index 000000000..3d48e9cc3 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/build.properties @@ -0,0 +1,14 @@ +source.. = src/,\ + xtend-gen/ +output.. = target/classes/ +bin.includes = META-INF/,\ + .,\ + resources/ +additional.bundles = org.palladiosimulator.pcm,\ + org.palladiosimulator.pcm.resources,\ + org.eclipse.uml2.uml,\ + org.eclipse.emf.edit,\ + org.eclipse.core.expressions,\ + org.slf4j.api,\ + ch.qos.logback.core,\ + ch.qos.logback.classic diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms.repository b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms.repository new file mode 100644 index 000000000..3e7a44690 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms.repository @@ -0,0 +1,915 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_noSEFF.repository b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_noSEFF.repository new file mode 100644 index 000000000..ecf01d195 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_noSEFF.repository @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_repository_noSEFF_unedited.uml b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_repository_noSEFF_unedited.uml new file mode 100644 index 000000000..efa5c6b9e --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_repository_noSEFF_unedited.uml @@ -0,0 +1,324 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend new file mode 100644 index 000000000..1a4e6dbec --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend @@ -0,0 +1,111 @@ +package tools.vitruv.applications.viewfilter.tests + +import tools.vitruv.testutils.ViewBasedVitruvApplicationTest +import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification +import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification +import org.eclipse.uml2.uml.UMLFactory +import org.eclipse.emf.common.util.URI +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.BeforeEach +import org.eclipse.uml2.uml.Model +import org.eclipse.xtend.lib.annotations.Accessors +import tools.vitruv.framework.views.View +import org.eclipse.emf.ecore.EObject +import java.nio.file.Path + +class FirstTest extends ViewBasedVitruvApplicationTest { + + @Accessors(PROTECTED_GETTER) + static val UML_MODEL_FILE_EXTENSION = "uml" + @Accessors(PROTECTED_GETTER) + static val UML_MODEL_NAME = "model" + @Accessors(PROTECTED_GETTER) + static val UML_MODEL_FOLDER_NAME = "model" + + protected var extension FirstTestFactory viewTestFactory + + override protected getChangePropagationSpecifications() { + return #[ + new CombinedPcmToUmlClassReactionsChangePropagationSpecification, + new CombinedUmlClassToPcmReactionsChangePropagationSpecification + ] + } + + @BeforeEach + def void setup() { + viewTestFactory = new FirstTestFactory(virtualModel) + createUmlModel[name = UML_MODEL_NAME] + } + + + @Test + def void testCreateSystemConcept_PCM() { + println("Hello world"); + } + + @Test + def void testView() { + createUmlView(); + } + + @Test + def void testCreateUmlPcmView() { + createUmlAndPcmClassesView(); + } + + @Test + def void testCreateFilteredUmlView() { + createFilteredUmlView(); + } + + + + +// @Test +// def void testCreateAssemblyContextConcept_PCM() { +// createRepositoryWithTwoComponents() +// +// changePcmView[ +// val pcmComponent1 = PcmUmlClassApplicationTestHelper.getPcmComponent(defaultPcmRepository) +// val pcmComponent2 = PcmUmlClassApplicationTestHelper.getPcmComponent_2(defaultPcmRepository) +// +// var pcmAssemblyContext = CompositionFactory.eINSTANCE.createAssemblyContext +// pcmAssemblyContext.entityName = PROPERTY_NAME +// // TODO setting the same component as container and encapsulated doesn't seem to trigger change event +// pcmAssemblyContext.encapsulatedComponent__AssemblyContext = pcmComponent2 +// pcmComponent1.assemblyContexts__ComposedStructure += pcmAssemblyContext +// ] +// +// validateUmlView[ +// val component2Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_2_USC + +// PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.build +// val component1Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_USC + +// PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.addAttribute(PROPERTY_NAME, +// component2Class).build +// val component1Package = new FluentUMLPackageBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_LSC). +// addPackagedElement(component1Class).build +// assertEqualityAndContainmentOfUmlPackage(defaultUmlModel, +// String.join(".", PACKAGE_NAME, PcmUmlClassApplicationTestHelper.COMPONENT_NAME_LSC), component1Package) +// ] +// } + + + protected def void createAndRegisterRoot(View view, EObject rootObject, URI persistenceUri) { + view.registerRoot(rootObject, persistenceUri) + } + + protected def Path getUmlProjectModelPath(String modelName) { + Path.of(UML_MODEL_FOLDER_NAME).resolve(modelName + "." + UML_MODEL_FILE_EXTENSION) + } + + protected def void createUmlModel((Model)=>void modelInitialization) { + changeUmlView [ + val umlModel = UMLFactory.eINSTANCE.createModel + modelInitialization.apply(umlModel) + createAndRegisterRoot(umlModel, UML_MODEL_NAME.umlProjectModelPath.uri) + ] +} + + + +} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend new file mode 100644 index 000000000..1bd9b50e9 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend @@ -0,0 +1,67 @@ +package tools.vitruv.applications.viewfilter.tests + +import tools.vitruv.testutils.TestViewFactory +import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor +import org.palladiosimulator.pcm.repository.RepositoryComponent +import org.eclipse.uml2.uml.Model +import tools.vitruv.framework.views.View +import tools.vitruv.framework.views.ViewSelector +import tools.vitruv.framework.views.ViewTypeFactory +import java.util.Collection +import static org.hamcrest.CoreMatchers.not +import static org.hamcrest.CoreMatchers.equalTo +import static org.hamcrest.MatcherAssert.assertThat +import tools.vitruv.framework.views.ViewProvider + + +class FirstTestFactory extends TestViewFactory { + + var ViewProvider viewProvider; + + + new(ViewProvider viewProvider) { + super(viewProvider) + this.viewProvider = viewProvider; + } + + + def View createUmlView() { + createViewOfElements("UML", #{Model}) + } + + + + + def View createUmlAndPcmClassesView() { + createViewOfElements("UML and PCM components", #{RepositoryComponent, Model}) + } + + + def View createFilteredUmlView() { + createFilteredViewOfElements("UML", #{Model}) + } + + + +//-------- Boilerplate code -----------//Kakao + + + /** + * Changes the UML view containing all UML models as root elements + * according to the given modification function. + * Records the performed changes, commits the recorded changes, and closes the view afterwards. + */ + def void changeUmlView((View)=>void modelModification) { + changeViewRecordingChanges(createUmlView, modelModification) + } + + def View createFilteredViewOfElements(String viewName, Collection> rootTypes) { + val ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); + var filteredElements = selector.selectableElements.filter[ element | rootTypes.exists[it.isInstance(element)]] + filteredElements.forEach[element | selector.setSelected(element, true)] + var View view = selector.createView(); + assertThat("view must not be null", view, not(equalTo(null))); + return view; + } + +} \ No newline at end of file From 0256297182e8f424c28bfe85668acecd29deeefa Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:23:48 +0100 Subject: [PATCH 02/62] Added more complex UML model creation and first simple filter methods --- .../viewfilter/tests/FirstTest.xtend | 60 +++++++++++++++---- .../viewfilter/tests/FirstTestFactory.xtend | 14 ++++- 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend index 1a4e6dbec..9b97ca93a 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend @@ -1,17 +1,23 @@ package tools.vitruv.applications.viewfilter.tests -import tools.vitruv.testutils.ViewBasedVitruvApplicationTest -import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification -import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification -import org.eclipse.uml2.uml.UMLFactory +import java.nio.file.Path import org.eclipse.emf.common.util.URI -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.BeforeEach +import org.eclipse.emf.ecore.EObject import org.eclipse.uml2.uml.Model +import org.eclipse.uml2.uml.UMLFactory import org.eclipse.xtend.lib.annotations.Accessors +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification +import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification import tools.vitruv.framework.views.View -import org.eclipse.emf.ecore.EObject -import java.nio.file.Path +import tools.vitruv.testutils.ViewBasedVitruvApplicationTest +//import tools.vitruv.applications.pcmumlclass.tests.helper.FluentUMLInterfaceBuilder +import org.eclipse.uml2.uml.PrimitiveType +import org.eclipse.uml2.uml.Type +import tools.vitruv.applications.viewfilter.utils.FluentUMLClassBuilder +import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper +import java.util.ArrayList class FirstTest extends ViewBasedVitruvApplicationTest { @@ -55,9 +61,17 @@ class FirstTest extends ViewBasedVitruvApplicationTest { @Test def void testCreateFilteredUmlView() { - createFilteredUmlView(); + var view = createFilteredUmlView(); + view.selection + view.viewType + } + + @Test + def void testFilterForName() { + } + @@ -100,9 +114,31 @@ class FirstTest extends ViewBasedVitruvApplicationTest { protected def void createUmlModel((Model)=>void modelInitialization) { changeUmlView [ - val umlModel = UMLFactory.eINSTANCE.createModel - modelInitialization.apply(umlModel) - createAndRegisterRoot(umlModel, UML_MODEL_NAME.umlProjectModelPath.uri) + val allUmlPrimitiveTypes = it.getRootObjects().flatMap[it.eAllContents.toList].filter [ + it instanceof PrimitiveType + ].map[it as Type].toList + val umlTestCompositeType2 = new FluentUMLClassBuilder( + PcmUmlClassApplicationTestHelper.COMPOSITE_DATATYPE_NAME_2, false).build + val umlTestCompositeType1 = new FluentUMLClassBuilder( + PcmUmlClassApplicationTestHelper.COMPOSITE_DATATYPE_NAME, false).build + //val expectedDataTypesPackage = new FluentUMLPackageBuilder(DATATYPES_PACKAGE).addPackagedElement( + // umlTestCompositeType1).addPackagedElement(umlTestCompositeType2).build + + var allPossibleParameterTypes = new ArrayList(allUmlPrimitiveTypes) + allPossibleParameterTypes.add(umlTestCompositeType1) + allPossibleParameterTypes.add(umlTestCompositeType2) + //val expectedParameterType = allPossibleParameterTypes.head + +// val umlInterface = new FluentUMLInterfaceBuilder(PcmUmlClassApplicationTestHelper.INTERFACE_NAME). +// addOperation(PcmUmlClassApplicationTestHelper.SIGNATURE_NAME, +// #[ +// new Quadruple(TEST_PARAMETER_NAME, expectedParameterType, expectedParameterLowerValue, +// expectedParameterUpperValue)]).build +// val expectedContractsPackage = new FluentUMLPackageBuilder(CONTRACTS_PACKAGE). +// addPackagedElement(umlInterface).build + + //modelInitialization.apply(umlTestCompositeType1) + createAndRegisterRoot(umlTestCompositeType1, UML_MODEL_NAME.umlProjectModelPath.uri) ] } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend index 1bd9b50e9..5a64c811f 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend @@ -43,9 +43,8 @@ class FirstTestFactory extends TestViewFactory { -//-------- Boilerplate code -----------//Kakao +//-------- Boilerplate code -----------// - /** * Changes the UML view containing all UML models as root elements * according to the given modification function. @@ -59,6 +58,17 @@ class FirstTestFactory extends TestViewFactory { val ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); var filteredElements = selector.selectableElements.filter[ element | rootTypes.exists[it.isInstance(element)]] filteredElements.forEach[element | selector.setSelected(element, true)] +// selector.selectableElements.forEach[element | selector.setSelected(element, true)] + var View view = selector.createView(); + assertThat("view must not be null", view, not(equalTo(null))); + return view; + } + + def View createNameFilteredViewOfElements(String viewName, Collection> rootTypes) { + val ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); +// var filteredElements = selector.selectableElements.filter[ element | rootTypes.exists[it.isInstance(element)]] +// filteredElements.forEach[element | selector.setSelected(element, true)] + selector.selectableElements.forEach[element | selector.setSelected(element, true)] var View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); return view; From 418619587c4f5e7a93f686e2573e86cce4d3e30d Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 6 Dec 2023 18:25:30 +0100 Subject: [PATCH 03/62] forgot some files --- .../utils/FluentUMLClassBuilder.java | 63 +++++++++++++++++++ .../PcmUmlClassApplicationTestHelper.xtend | 7 +++ 2 files changed, 70 insertions(+) create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLClassBuilder.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLClassBuilder.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLClassBuilder.java new file mode 100644 index 000000000..91c903d5f --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLClassBuilder.java @@ -0,0 +1,63 @@ +package tools.vitruv.applications.viewfilter.utils; + +import java.util.List; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Interface; +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; + +import edu.kit.ipd.sdq.commons.util.java.Pair; + +public class FluentUMLClassBuilder { + private final Class result; + + public FluentUMLClassBuilder(String name, boolean isFinal) { + result = UMLFactory.eINSTANCE.createClass(); + result.setName(name); + result.setIsFinalSpecialization(isFinal); + } + + public FluentUMLClassBuilder addDefaultConstructor() { + result.createOwnedOperation(result.getName(), new BasicEList<>(), new BasicEList<>()); + return this; + } + + public FluentUMLClassBuilder addParameterizedConstructor(List> parameters) { + EList parameterNames = new BasicEList<>(); + EList parameterTypes = new BasicEList<>(); + parameters.forEach(parameter -> { + parameterNames.add(parameter.get0()); + parameterTypes.add(parameter.get1()); + }); + result.createOwnedOperation(result.getName(), parameterNames, parameterTypes); + return this; + } + + public FluentUMLClassBuilder addAttribute(String name, Type type) { + result.createOwnedAttribute(name, type); + return this; + } + + public FluentUMLClassBuilder addAttribute(String name, Type type, int lower, int upper) { + result.createOwnedAttribute(name, type, lower, upper); + return this; + } + + public FluentUMLClassBuilder addGeneralization(Classifier parentClassifier) { + result.createGeneralization(parentClassifier); + return this; + } + + public FluentUMLClassBuilder addInterfaceRealization(String name, Interface realizedInterface) { + result.createInterfaceRealization(name, realizedInterface); + return this; + } + + public Class build() { + return result; + } +} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend new file mode 100644 index 000000000..b0a462d30 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend @@ -0,0 +1,7 @@ +package tools.vitruv.applications.viewfilter.utils + +class PcmUmlClassApplicationTestHelper { + + public static val COMPOSITE_DATATYPE_NAME = "TestCompositeType" + public static val COMPOSITE_DATATYPE_NAME_2 = "TestCompositeType_2" +} \ No newline at end of file From ad150e8567fbbd89f83734dd65120fb194de3373 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 15 Dec 2023 09:18:33 +0100 Subject: [PATCH 04/62] Added large model to viewtest --- .gitignore | 3 +- .../EquivalenceTestExecutable.xtend | 34 +- .../.polyglot.META-INF | 18 + .../.classpath | 21 + .../.maven_enable_dsls-compiler | 0 .../.polyglot.META-INF | 18 + .../.project | 34 ++ .../org.eclipse.core.resources.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 9 + .../META-INF/MANIFEST.MF | 17 + .../build.properties | 7 + .../plugin.xml | 16 + .../.polyglot.META-INF | 18 + .../META-INF/MANIFEST.MF | 3 +- .../META-INF/MANIFEST.MF | 3 +- .../JavaConstructionSimulationTest.xtend | 2 +- ...ResourceWithArraysDefaultFactoryImpl.java} | 2 +- .../META-INF/MANIFEST.MF | 3 +- .../build.properties | 4 +- .../pluginnono.xml | 16 + .../java/com/orhanobut/logger/Helper.java | 105 +++++ .../java/com/orhanobut/logger/LogAdapter.java | 15 + .../java/com/orhanobut/logger/LogLevel.java | 14 + .../java/com/orhanobut/logger/Logger.java | 112 +++++ .../com/orhanobut/logger/LoggerPrinter.java | 401 ++++++++++++++++++ .../java/com/orhanobut/logger/Printer.java | 35 ++ .../java/com/orhanobut/logger/Settings.java | 69 +++ .../com/orhanobut/logger/package-info.java | 1 + .../java/com/orhanobut/package-info.java | 1 + .../orhanobut/java/com/package-info.java | 1 + .../resources/orhanobut/uml/model.uml | 394 +++++++++++++++++ .../viewfilter/tests/FirstTest.xtend | 137 +++++- .../viewfilter/tests/FirstTestFactory.xtend | 14 +- .../viewfilter/tests/ViewTestFactory.java | 108 +++++ .../utils/FluentUMLClassBuilder.java | 63 +++ .../utils/FluentUMLPackageBuilder.java | 33 ++ .../PcmUmlClassApplicationTestHelper.xtend | 14 + 37 files changed, 1703 insertions(+), 44 deletions(-) create mode 100644 bundles/tools.vitruv.applications.viewtest/.classpath create mode 100644 bundles/tools.vitruv.applications.viewtest/.maven_enable_dsls-compiler create mode 100644 bundles/tools.vitruv.applications.viewtest/.polyglot.META-INF create mode 100644 bundles/tools.vitruv.applications.viewtest/.project create mode 100644 bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.core.resources.prefs create mode 100644 bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.jdt.core.prefs create mode 100644 bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF create mode 100644 bundles/tools.vitruv.applications.viewtest/build.properties create mode 100644 bundles/tools.vitruv.applications.viewtest/plugin.xml rename tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/{JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl.java => JavaSOCFileResourceWithArraysDefaultFactoryImpl.java} (86%) create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/pluginnono.xml create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Helper.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogAdapter.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogLevel.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Logger.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LoggerPrinter.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Printer.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Settings.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/package-info.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/package-info.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/package-info.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/uml/model.uml create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLClassBuilder.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLPackageBuilder.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend diff --git a/.gitignore b/.gitignore index 775fcc8d4..807b465bd 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ target/ EvaluationData *.DS_Store *.polyglot -*.pom.tycho \ No newline at end of file +*.pom.tycho +tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl.java diff --git a/bundles/tools.vitruv.applications.cbs.testutils/src/tools/vitruv/applications/cbs/testutils/equivalencetest/EquivalenceTestExecutable.xtend b/bundles/tools.vitruv.applications.cbs.testutils/src/tools/vitruv/applications/cbs/testutils/equivalencetest/EquivalenceTestExecutable.xtend index c9aed54ab..dba0977bc 100644 --- a/bundles/tools.vitruv.applications.cbs.testutils/src/tools/vitruv/applications/cbs/testutils/equivalencetest/EquivalenceTestExecutable.xtend +++ b/bundles/tools.vitruv.applications.cbs.testutils/src/tools/vitruv/applications/cbs/testutils/equivalencetest/EquivalenceTestExecutable.xtend @@ -57,23 +57,23 @@ package class EquivalenceTestExecutable implements Executable, AutoCloseable { val EquivalenceTestExtensionContext extensionContext override execute() throws Throwable { - try ( - val testView = setupTestView(); - val referenceView = setupReferenceView(); - val printerChange = installViewDirectoryUriReplacement(testView, referenceView) - ) { - checkNotNull(printerChange) // Suppress warning for variable not being used - executeDependencies(testView, referenceView) - - testStep.executeIn(testView) - referenceSteps.values.forEach[executeIn(referenceView)] - verifyTestViewResults() - } catch (Throwable t) { - extensionContext.executionException = Optional.of(t) - throw t - } finally { - close() - } + // try ( + // val testView = setupTestView(); + // val referenceView = setupReferenceView(); + // val printerChange = installViewDirectoryUriReplacement(testView, referenceView) + // ) { + // checkNotNull(printerChange) // Suppress warning for variable not being used + // executeDependencies(testView, referenceView) + // + // testStep.executeIn(testView) + // referenceSteps.values.forEach[executeIn(referenceView)] + // verifyTestViewResults() + // } catch (Throwable t) { + // extensionContext.executionException = Optional.of(t) + // throw t + // } finally { + // close() +// } } def private DirectoryTestView setupTestView() { diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF b/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF index e69de29bb..c4e3c412f 100644 --- a/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF +++ b/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF @@ -0,0 +1,18 @@ + + + 4.0.0 + + tools.vitruv + bundles + 3.0.1-SNAPSHOT + ..\.polyglot.pom.tycho + + tools.vitruv.applications.pcmumlclass + 3.0.1-SNAPSHOT + eclipse-plugin + [bundle] Vitruv PCM-UML Class Application + + vitruv.tools + + diff --git a/bundles/tools.vitruv.applications.viewtest/.classpath b/bundles/tools.vitruv.applications.viewtest/.classpath new file mode 100644 index 000000000..412b338a8 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/tools.vitruv.applications.viewtest/.maven_enable_dsls-compiler b/bundles/tools.vitruv.applications.viewtest/.maven_enable_dsls-compiler new file mode 100644 index 000000000..e69de29bb diff --git a/bundles/tools.vitruv.applications.viewtest/.polyglot.META-INF b/bundles/tools.vitruv.applications.viewtest/.polyglot.META-INF new file mode 100644 index 000000000..3f7ef650e --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/.polyglot.META-INF @@ -0,0 +1,18 @@ + + + 4.0.0 + + tools.vitruv + bundles + 3.0.1-SNAPSHOT + ..\.polyglot.pom.tycho + + tools.vitruv.applications.viewfilter + 3.0.1-SNAPSHOT + eclipse-plugin + [bundle] Vitruv Viewfilter Application + + vitruv.tools + + diff --git a/bundles/tools.vitruv.applications.viewtest/.project b/bundles/tools.vitruv.applications.viewtest/.project new file mode 100644 index 000000000..8f68df9e0 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/.project @@ -0,0 +1,34 @@ + + + tools.vitruv.applications.viewfilter + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..99f26c020 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.jdt.core.prefs b/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..62ef3488c --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF new file mode 100644 index 000000000..db1945a3f --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Vitruv Viewfilter Application +Bundle-SymbolicName: tools.vitruv.applications.viewfilter;singleton:=true +Bundle-Version: 3.0.1.qualifier +Automatic-Module-Name: tools.vitruv.applications.viewfilter +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Eclipse-ExtensibleAPI: true +Require-Bundle: org.eclipse.uml2.uml;visibility:=reexport, + org.palladiosimulator.pcm;visibility:=reexport, + edu.kit.ipd.sdq.activextendannotations, + edu.kit.ipd.sdq.commons.util.emf, + edu.kit.ipd.sdq.commons.util.java, + tools.vitruv.framework.applications, + tools.vitruv.dsls.reactions.runtime, + tools.vitruv.applications.util.temporary +Bundle-Vendor: vitruv.tools diff --git a/bundles/tools.vitruv.applications.viewtest/build.properties b/bundles/tools.vitruv.applications.viewtest/build.properties new file mode 100644 index 000000000..2c5b31414 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/build.properties @@ -0,0 +1,7 @@ +source.. = src/,\ + src-gen/,\ + xtend-gen/ +output.. = target/classes/ +bin.includes = META-INF/,\ + plugin.xml,\ + . diff --git a/bundles/tools.vitruv.applications.viewtest/plugin.xml b/bundles/tools.vitruv.applications.viewtest/plugin.xml new file mode 100644 index 000000000..828835a00 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/plugin.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF b/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF index e69de29bb..9fc7a3be6 100644 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF +++ b/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF @@ -0,0 +1,18 @@ + + + 4.0.0 + + tools.vitruv + tests + 3.0.1-SNAPSHOT + ..\.polyglot.pom.tycho + + tools.vitruv.applications.pcmumlclass.tests + 3.0.1-SNAPSHOT + eclipse-test-plugin + [test-bundle] Vitruv PCM-UML Class Application Tests + + vitruv.tools + + diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF index 5c3e925e5..16d0187e2 100644 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Require-Bundle: tools.vitruv.testutils.vsum, tools.vitruv.applications.testutility, org.palladiosimulator.pcm, edu.kit.ipd.sdq.commons.util.emf, - slf4j.api;bundle-version="2.0.9" + slf4j.api;bundle-version="2.0.9", + org.emftext.language.java;bundle-version="1.4.1" Export-Package: tools.vitruv.applications.pcmumlclass.tests Bundle-Vendor: vitruv.tools diff --git a/tests/tools.vitruv.applications.umljava.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.umljava.tests/META-INF/MANIFEST.MF index e6792176d..73b8196f0 100644 --- a/tests/tools.vitruv.applications.umljava.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.umljava.tests/META-INF/MANIFEST.MF @@ -20,7 +20,8 @@ Require-Bundle: tools.vitruv.applications.umljava, org.apache.log4j, org.emftext.language.java.resource.java, org.emftext.language.java.resource, - tools.vitruv.applications.testutility + tools.vitruv.applications.testutility, + slf4j.api;bundle-version="2.0.9" Bundle-ClassPath: ., target/dependency/json.jar Bundle-Vendor: vitruv.tools diff --git a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend index 883fd6aee..56e1f88b2 100644 --- a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend +++ b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend @@ -58,7 +58,7 @@ class JavaConstructionSimulationTest extends AbstractJavaToUmlTest { @BeforeAll def static setupJavaFactories() { - JavaSetup.prepareFactories([new JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl()]) + JavaSetup.prepareFactories([new JavaSOCFileResourceWithArraysDefaultFactoryImpl()]) } @AfterEach diff --git a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl.java b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSOCFileResourceWithArraysDefaultFactoryImpl.java similarity index 86% rename from tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl.java rename to tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSOCFileResourceWithArraysDefaultFactoryImpl.java index a6f1f0598..5fc75dc5b 100644 --- a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl.java +++ b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSOCFileResourceWithArraysDefaultFactoryImpl.java @@ -4,7 +4,7 @@ import org.eclipse.emf.ecore.resource.Resource; import org.emftext.language.java.resource.JavaSourceOrClassFileResourceFactoryImpl; -public class JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl +public class JavaSOCFileResourceWithArraysDefaultFactoryImpl extends JavaSourceOrClassFileResourceFactoryImpl { @Override diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index 1823f938d..62a3b5806 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Require-Bundle: tools.vitruv.testutils.vsum, tools.vitruv.applications.testutility, org.palladiosimulator.pcm, edu.kit.ipd.sdq.commons.util.emf, - slf4j.api;bundle-version="2.0.9" + slf4j.api;bundle-version="2.0.9", + org.emftext.language.java;bundle-version="1.4.1" Export-Package: tools.vitruv.applications.viewfilter.tests Bundle-Vendor: vitruv.tools diff --git a/tests/tools.vitruv.applications.viewfilter.tests/build.properties b/tests/tools.vitruv.applications.viewfilter.tests/build.properties index 3d48e9cc3..6a209b473 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/build.properties +++ b/tests/tools.vitruv.applications.viewfilter.tests/build.properties @@ -6,9 +6,9 @@ bin.includes = META-INF/,\ resources/ additional.bundles = org.palladiosimulator.pcm,\ org.palladiosimulator.pcm.resources,\ - org.eclipse.uml2.uml,\ org.eclipse.emf.edit,\ org.eclipse.core.expressions,\ org.slf4j.api,\ ch.qos.logback.core,\ - ch.qos.logback.classic + ch.qos.logback.classic,\ + org.eclipse.uml2.uml diff --git a/tests/tools.vitruv.applications.viewfilter.tests/pluginnono.xml b/tests/tools.vitruv.applications.viewfilter.tests/pluginnono.xml new file mode 100644 index 000000000..2bc642c49 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/pluginnono.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Helper.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Helper.java new file mode 100644 index 000000000..bc0c24d31 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Helper.java @@ -0,0 +1,105 @@ +/* + * Copyright 2015 Orhan Obut + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This software contains code derived from the following Android classes: + * android.util.Log, android.text.TextUtils. + */ +package com.orhanobut.logger; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.net.UnknownHostException; + +/** + * Helper util class to be used instead of Android methods to avoid direct dependency and enable + * unit testing on Android projects. + */ +final class Helper { + + private Helper() { + // Hidden constructor. + } + + /** + * Returns true if the string is null or 0-length. + * + * @param str the string to be examined + * + * @return true if str is null or zero length + */ + static boolean isEmpty(CharSequence str) { + return str == null || str.length() == 0; + } + + /** + * Returns true if a and b are equal, including if they are both null. + *

Note: In platform versions 1.1 and earlier, this method only worked well if + * both the arguments were instances of String.

+ * + * @param a first CharSequence to check + * @param b second CharSequence to check + * + * @return true if a and b are equal + * + * NOTE: Logic slightly change due to strict policy on CI - + * "Inner assignments should be avoided" + */ + static boolean equals(CharSequence a, CharSequence b) { + if (a == b) return true; + if (a != null && b != null) { + int length = a.length(); + if (length == b.length()) { + if (a instanceof String && b instanceof String) { + return a.equals(b); + } else { + for (int i = 0; i < length; i++) { + if (a.charAt(i) != b.charAt(i)) return false; + } + return true; + } + } + } + return false; + } + + /** + * Copied from "android.util.Log.getStackTraceString()" in order to avoid usage of Android stack + * in unit tests. + * + * @return Stack trace in form of String + */ + static String getStackTraceString(Throwable tr) { + if (tr == null) { + return ""; + } + + // This is to reduce the amount of log spew that apps do in the non-error + // condition of the network being unavailable. + Throwable t = tr; + while (t != null) { + if (t instanceof UnknownHostException) { + return ""; + } + t = t.getCause(); + } + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + tr.printStackTrace(pw); + pw.flush(); + return sw.toString(); + } + +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogAdapter.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogAdapter.java new file mode 100644 index 000000000..cab5d8ce7 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogAdapter.java @@ -0,0 +1,15 @@ +package com.orhanobut.logger; + +public interface LogAdapter { + void d(String tag, String message); + + void e(String tag, String message); + + void w(String tag, String message); + + void i(String tag, String message); + + void v(String tag, String message); + + void wtf(String tag, String message); +} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogLevel.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogLevel.java new file mode 100644 index 000000000..e3a33ed35 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogLevel.java @@ -0,0 +1,14 @@ +package com.orhanobut.logger; + +public enum LogLevel { + + /** + * Prints all logs + */ + FULL, + + /** + * No log will be printed + */ + NONE +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Logger.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Logger.java new file mode 100644 index 000000000..4f6ba77bd --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Logger.java @@ -0,0 +1,112 @@ +package com.orhanobut.logger; + +/** + * Logger is a wrapper of {@link android.util.Log} + * But more pretty, simple and powerful + */ +public final class Logger { + public static final int DEBUG = 3; + public static final int ERROR = 6; + public static final int ASSERT = 7; + public static final int INFO = 4; + public static final int VERBOSE = 2; + public static final int WARN = 5; + + private static final String DEFAULT_TAG = "PRETTYLOGGER"; + + private static Printer printer = new LoggerPrinter(); + + //no instance + private Logger() { + } + + /** + * It is used to get the settings object in order to change settings + * + * @return the settings object + */ + public static Settings init() { + return init(DEFAULT_TAG); + } + + /** + * It is used to change the tag + * + * @param tag is the given string which will be used in Logger as TAG + */ + public static Settings init(String tag) { + printer = new LoggerPrinter(); + return printer.init(tag); + } + + public static void resetSettings() { + printer.resetSettings(); + } + + public static Printer t(String tag) { + return printer.t(tag, printer.getSettings().getMethodCount()); + } + + public static Printer t(int methodCount) { + return printer.t(null, methodCount); + } + + public static Printer t(String tag, int methodCount) { + return printer.t(tag, methodCount); + } + + public static void log(int priority, String tag, String message, Throwable throwable) { + printer.log(priority, tag, message, throwable); + } + + public static void d(String message, Object... args) { + printer.d(message, args); + } + + public static void d(Object object) { + printer.d(object); + } + + public static void e(String message, Object... args) { + printer.e(null, message, args); + } + + public static void e(Throwable throwable, String message, Object... args) { + printer.e(throwable, message, args); + } + + public static void i(String message, Object... args) { + printer.i(message, args); + } + + public static void v(String message, Object... args) { + printer.v(message, args); + } + + public static void w(String message, Object... args) { + printer.w(message, args); + } + + public static void wtf(String message, Object... args) { + printer.wtf(message, args); + } + + /** + * Formats the json content and print it + * + * @param json the json content + */ + public static void json(String json) { + printer.json(json); + } + + /** + * Formats the json content and print it + * + * @param xml the xml content + */ + public static void xml(String xml) { + printer.xml(xml); + } + +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LoggerPrinter.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LoggerPrinter.java new file mode 100644 index 000000000..6dfc57b7a --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LoggerPrinter.java @@ -0,0 +1,401 @@ +package com.orhanobut.logger; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.io.StringReader; +import java.io.StringWriter; +import java.util.Arrays; + +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +final class LoggerPrinter implements Printer { + + private static final String DEFAULT_TAG = "PRETTYLOGGER"; + + private static final int DEBUG = 3; + private static final int ERROR = 6; + private static final int ASSERT = 7; + private static final int INFO = 4; + private static final int VERBOSE = 2; + private static final int WARN = 5; + + /** + * Android's max limit for a log entry is ~4076 bytes, + * so 4000 bytes is used as chunk size since default charset + * is UTF-8 + */ + private static final int CHUNK_SIZE = 4000; + + /** + * It is used for json pretty print + */ + private static final int JSON_INDENT = 2; + + /** + * The minimum stack trace index, starts at this class after two native calls. + */ + private static final int MIN_STACK_OFFSET = 3; + + /** + * Drawing toolbox + */ + private static final char TOP_LEFT_CORNER = '╔'; + private static final char BOTTOM_LEFT_CORNER = '╚'; + private static final char MIDDLE_CORNER = '╟'; + private static final char HORIZONTAL_DOUBLE_LINE = '║'; + private static final String DOUBLE_DIVIDER = "════════════════════════════════════════════"; + private static final String SINGLE_DIVIDER = "────────────────────────────────────────────"; + private static final String TOP_BORDER = TOP_LEFT_CORNER + DOUBLE_DIVIDER + DOUBLE_DIVIDER; + private static final String BOTTOM_BORDER = BOTTOM_LEFT_CORNER + DOUBLE_DIVIDER + DOUBLE_DIVIDER; + private static final String MIDDLE_BORDER = MIDDLE_CORNER + SINGLE_DIVIDER + SINGLE_DIVIDER; + + /** + * tag is used for the Log, the name is a little different + * in order to differentiate the logs easily with the filter + */ + private String tag; + + /** + * Localize single tag and method count for each thread + */ + private final ThreadLocal localTag = new ThreadLocal(); + private final ThreadLocal localMethodCount = new ThreadLocal(); + + /** + * It is used to determine log settings such as method count, thread info visibility + */ + private final Settings settings = new Settings(); + + public LoggerPrinter() { + init(DEFAULT_TAG); + } + + /** + * It is used to change the tag + * + * @param tag is the given string which will be used in Logger + */ + @Override public Settings init(String tag) { + if (tag == null) { + throw new NullPointerException("tag may not be null"); + } + if (tag.trim().length() == 0) { + throw new IllegalStateException("tag may not be empty"); + } + this.tag = tag; + return settings; + } + + @Override public Settings getSettings() { + return settings; + } + + @Override public Printer t(String tag, int methodCount) { + if (tag != null) { + localTag.set(tag); + } + localMethodCount.set(methodCount); + return this; + } + + @Override public void d(String message, Object... args) { + log(DEBUG, null, message, args); + } + + @Override public void d(Object object) { + String message; + if (object.getClass().isArray()) { + message = Arrays.deepToString((Object[]) object); + } else { + message = object.toString(); + } + log(DEBUG, null, message); + } + + @Override public void e(String message, Object... args) { + e(null, message, args); + } + + @Override public void e(Throwable throwable, String message, Object... args) { + log(ERROR, throwable, message, args); + } + + @Override public void w(String message, Object... args) { + log(WARN, null, message, args); + } + + @Override public void i(String message, Object... args) { + log(INFO, null, message, args); + } + + @Override public void v(String message, Object... args) { + log(VERBOSE, null, message, args); + } + + @Override public void wtf(String message, Object... args) { + log(ASSERT, null, message, args); + } + + /** + * Formats the json content and print it + * + * @param json the json content + */ + @Override public void json(String json) { + if (Helper.isEmpty(json)) { + d("Empty/Null json content"); + return; + } + try { + json = json.trim(); + if (json.startsWith("{")) { + JSONObject jsonObject = new JSONObject(json); + String message = jsonObject.toString(JSON_INDENT); + d(message); + return; + } + if (json.startsWith("[")) { + JSONArray jsonArray = new JSONArray(json); + String message = jsonArray.toString(JSON_INDENT); + d(message); + return; + } + e("Invalid Json"); + } catch (JSONException e) { + e("Invalid Json"); + } + } + + /** + * Formats the json content and print it + * + * @param xml the xml content + */ + @Override public void xml(String xml) { + if (Helper.isEmpty(xml)) { + d("Empty/Null xml content"); + return; + } + try { + Source xmlInput = new StreamSource(new StringReader(xml)); + StreamResult xmlOutput = new StreamResult(new StringWriter()); + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); + transformer.transform(xmlInput, xmlOutput); + d(xmlOutput.getWriter().toString().replaceFirst(">", ">\n")); + } catch (TransformerException e) { + e("Invalid xml"); + } + } + + @Override public synchronized void log(int priority, String tag, String message, Throwable throwable) { + if (settings.getLogLevel() == null) { + return; + } + if (throwable != null && message != null) { + message += " : " + Helper.getStackTraceString(throwable); + } + if (throwable != null && message == null) { + message = Helper.getStackTraceString(throwable); + } + if (message == null) { + message = "No message/exception is set"; + } + int methodCount = getMethodCount(); + if (Helper.isEmpty(message)) { + message = "Empty/NULL log message"; + } + + logTopBorder(priority, tag); + logHeaderContent(priority, tag, methodCount); + + //get bytes of message with system's default charset (which is UTF-8 for Android) + byte[] bytes = message.getBytes(); + int length = bytes.length; + if (length <= CHUNK_SIZE) { + if (methodCount > 0) { + logDivider(priority, tag); + } + logContent(priority, tag, message); + logBottomBorder(priority, tag); + return; + } + if (methodCount > 0) { + logDivider(priority, tag); + } + for (int i = 0; i < length; i += CHUNK_SIZE) { + int count = Math.min(length - i, CHUNK_SIZE); + //create a new String with system's default charset (which is UTF-8 for Android) + logContent(priority, tag, new String(bytes, i, count)); + } + logBottomBorder(priority, tag); + } + + @Override public void resetSettings() { + settings.reset(); + } + + /** + * This method is synchronized in order to avoid messy of logs' order. + */ + private synchronized void log(int priority, Throwable throwable, String msg, Object... args) { + if (settings.getLogLevel() == null) { + return; + } + String tag = getTag(); + String message = createMessage(msg, args); + log(priority, tag, message, throwable); + } + + private void logTopBorder(int logType, String tag) { + logChunk(logType, tag, TOP_BORDER); + } + + @SuppressWarnings("StringBufferReplaceableByString") + private void logHeaderContent(int logType, String tag, int methodCount) { + StackTraceElement[] trace = Thread.currentThread().getStackTrace(); + if (settings.isShowThreadInfo()) { + logChunk(logType, tag, HORIZONTAL_DOUBLE_LINE + " Thread: " + Thread.currentThread().getName()); + logDivider(logType, tag); + } + String level = ""; + + int stackOffset = getStackOffset(trace) + settings.getMethodOffset(); + + //corresponding method count with the current stack may exceeds the stack trace. Trims the count + if (methodCount + stackOffset > trace.length) { + methodCount = trace.length - stackOffset - 1; + } + + for (int i = methodCount; i > 0; i--) { + int stackIndex = i + stackOffset; + if (stackIndex >= trace.length) { + continue; + } + StringBuilder builder = new StringBuilder(); + builder.append("║ ") + .append(level) + .append(getSimpleClassName(trace[stackIndex].getClassName())) + .append(".") + .append(trace[stackIndex].getMethodName()) + .append(" ") + .append(" (") + .append(trace[stackIndex].getFileName()) + .append(":") + .append(trace[stackIndex].getLineNumber()) + .append(")"); + level += " "; + logChunk(logType, tag, builder.toString()); + } + } + + private void logBottomBorder(int logType, String tag) { + logChunk(logType, tag, BOTTOM_BORDER); + } + + private void logDivider(int logType, String tag) { + logChunk(logType, tag, MIDDLE_BORDER); + } + + private void logContent(int logType, String tag, String chunk) { + String[] lines = chunk.split(System.getProperty("line.separator")); + for (String line : lines) { + logChunk(logType, tag, HORIZONTAL_DOUBLE_LINE + " " + line); + } + } + + private void logChunk(int logType, String tag, String chunk) { + String finalTag = formatTag(tag); + switch (logType) { + case ERROR: + settings.getLogAdapter().e(finalTag, chunk); + break; + case INFO: + settings.getLogAdapter().i(finalTag, chunk); + break; + case VERBOSE: + settings.getLogAdapter().v(finalTag, chunk); + break; + case WARN: + settings.getLogAdapter().w(finalTag, chunk); + break; + case ASSERT: + settings.getLogAdapter().wtf(finalTag, chunk); + break; + case DEBUG: + // Fall through, log debug by default + default: + settings.getLogAdapter().d(finalTag, chunk); + break; + } + } + + private String getSimpleClassName(String name) { + int lastIndex = name.lastIndexOf("."); + return name.substring(lastIndex + 1); + } + + private String formatTag(String tag) { + if (!Helper.isEmpty(tag) && !Helper.equals(this.tag, tag)) { + return this.tag + "-" + tag; + } + return this.tag; + } + + /** + * @return the appropriate tag based on local or global + */ + private String getTag() { + String tag = localTag.get(); + if (tag != null) { + localTag.remove(); + return tag; + } + return this.tag; + } + + private String createMessage(String message, Object... args) { + return args == null || args.length == 0 ? message : String.format(message, args); + } + + private int getMethodCount() { + Integer count = localMethodCount.get(); + int result = settings.getMethodCount(); + if (count != null) { + localMethodCount.remove(); + result = count; + } + if (result < 0) { + throw new IllegalStateException("methodCount cannot be negative"); + } + return result; + } + + /** + * Determines the starting index of the stack trace, after method calls made by this class. + * + * @param trace the stack trace + * + * @return the stack offset + */ + private int getStackOffset(StackTraceElement[] trace) { + for (int i = MIN_STACK_OFFSET; i < trace.length; i++) { + StackTraceElement e = trace[i]; + String name = e.getClassName(); + if (!name.equals(LoggerPrinter.class.getName()) && !name.equals(Logger.class.getName())) { + return --i; + } + } + return -1; + } + +} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Printer.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Printer.java new file mode 100644 index 000000000..a8dce3273 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Printer.java @@ -0,0 +1,35 @@ +package com.orhanobut.logger; + +public interface Printer { + + Printer t(String tag, int methodCount); + + Settings init(String tag); + + Settings getSettings(); + + void d(String message, Object... args); + + void d(Object object); + + void e(String message, Object... args); + + void e(Throwable throwable, String message, Object... args); + + void w(String message, Object... args); + + void i(String message, Object... args); + + void v(String message, Object... args); + + void wtf(String message, Object... args); + + void json(String json); + + void xml(String xml); + + void log(int priority, String tag, String message, Throwable throwable); + + void resetSettings(); + +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Settings.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Settings.java new file mode 100644 index 000000000..6ae6ea7b8 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Settings.java @@ -0,0 +1,69 @@ +package com.orhanobut.logger; + +public final class Settings { + + private int methodCount = 2; + private boolean showThreadInfo = true; + private int methodOffset = 0; + private LogAdapter logAdapter; + + /** + * Determines to how logs will be printed + */ + private LogLevel logLevel = LogLevel.FULL; + + public Settings hideThreadInfo() { + showThreadInfo = false; + return this; + } + + public Settings methodCount(int methodCount) { + if (methodCount < 0) { + methodCount = 0; + } + this.methodCount = methodCount; + return this; + } + + public Settings logLevel(LogLevel logLevel) { + this.logLevel = logLevel; + return this; + } + + public Settings methodOffset(int offset) { + this.methodOffset = offset; + return this; + } + + public Settings logAdapter(LogAdapter logAdapter) { + this.logAdapter = logAdapter; + return this; + } + + public int getMethodCount() { + return methodCount; + } + + public boolean isShowThreadInfo() { + return showThreadInfo; + } + + public LogLevel getLogLevel() { + return logLevel; + } + + public int getMethodOffset() { + return methodOffset; + } + + public LogAdapter getLogAdapter() { + return logAdapter; + } + + public void reset() { + methodCount = 2; + methodOffset = 0; + showThreadInfo = true; + logLevel = LogLevel.FULL; + } +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/package-info.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/package-info.java new file mode 100644 index 000000000..312539fae --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/package-info.java @@ -0,0 +1 @@ +package com.orhanobut.logger; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/package-info.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/package-info.java new file mode 100644 index 000000000..049674d03 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/package-info.java @@ -0,0 +1 @@ +package com.orhanobut; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/package-info.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/package-info.java new file mode 100644 index 000000000..86bcb18ba --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/package-info.java @@ -0,0 +1 @@ +package com; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/uml/model.uml b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/uml/model.uml new file mode 100644 index 000000000..79f7f29bc --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/uml/model.uml @@ -0,0 +1,394 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend index 1a4e6dbec..57a3acefd 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend @@ -1,18 +1,35 @@ package tools.vitruv.applications.viewfilter.tests -import tools.vitruv.testutils.ViewBasedVitruvApplicationTest -import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification -import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification -import org.eclipse.uml2.uml.UMLFactory +import java.nio.file.Path import org.eclipse.emf.common.util.URI -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.BeforeEach +import org.eclipse.emf.ecore.EObject +import org.emftext.language.java.containers.CompilationUnit import org.eclipse.uml2.uml.Model +import org.eclipse.uml2.uml.UMLFactory import org.eclipse.xtend.lib.annotations.Accessors +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification +import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification import tools.vitruv.framework.views.View -import org.eclipse.emf.ecore.EObject -import java.nio.file.Path +import tools.vitruv.testutils.ViewBasedVitruvApplicationTest +//import tools.vitruv.applications.pcmumlclass.tests.helper.FluentUMLInterfaceBuilder +import org.eclipse.uml2.uml.PrimitiveType +import org.eclipse.uml2.uml.Type +import tools.vitruv.applications.viewfilter.utils.FluentUMLClassBuilder +import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper +import java.util.ArrayList +import tools.vitruv.framework.vsum.internal.VirtualModelImpl +import java.io.File +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl +import org.eclipse.emf.ecore.util.EcoreUtil + +import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceUtil.getFirstRootEObject +import tools.vitruv.testutils.RegisterMetamodelsInStandalone +import org.junit.jupiter.api.^extension.ExtendWith +import tools.vitruv.applications.viewfilter.utils.FluentUMLPackageBuilder +@ExtendWith(RegisterMetamodelsInStandalone) class FirstTest extends ViewBasedVitruvApplicationTest { @Accessors(PROTECTED_GETTER) @@ -21,8 +38,18 @@ class FirstTest extends ViewBasedVitruvApplicationTest { static val UML_MODEL_NAME = "model" @Accessors(PROTECTED_GETTER) static val UML_MODEL_FOLDER_NAME = "model" + @Accessors(PROTECTED_GETTER) + static val MODEL_FOLDER_NAME = "model" + @Accessors(PROTECTED_GETTER) + static val MODEL_FILE_EXTENSION = "uml" + + static val PROPERTY_NAME = "testAssemblyContextField" + + static val UML_MODEL_FILE_PATH = "resources/orhanobut/uml/model.uml" - protected var extension FirstTestFactory viewTestFactory + + protected var FirstTestFactory viewTestFactory + protected var extension ViewTestFactory improvedViewTestFactory override protected getChangePropagationSpecifications() { return #[ @@ -34,7 +61,8 @@ class FirstTest extends ViewBasedVitruvApplicationTest { @BeforeEach def void setup() { viewTestFactory = new FirstTestFactory(virtualModel) - createUmlModel[name = UML_MODEL_NAME] + improvedViewTestFactory = new ViewTestFactory(virtualModel) + createBiggerUmlModel[name = UML_MODEL_NAME] } @@ -55,9 +83,17 @@ class FirstTest extends ViewBasedVitruvApplicationTest { @Test def void testCreateFilteredUmlView() { - createFilteredUmlView(); + var view = createFilteredUmlView(); + view.selection + view.viewType + } + + @Test + def void testFilterForName() { + createAdvancedUmlModel[name = UML_MODEL_NAME + "big"] } + @@ -97,13 +133,80 @@ class FirstTest extends ViewBasedVitruvApplicationTest { protected def Path getUmlProjectModelPath(String modelName) { Path.of(UML_MODEL_FOLDER_NAME).resolve(modelName + "." + UML_MODEL_FILE_EXTENSION) } - + + protected def Path getProjectModelPath(String modelName) { + Path.of(MODEL_FOLDER_NAME).resolve(modelName + "." + MODEL_FILE_EXTENSION) + } + +// /** +// * Changes the Java view containing all Java packages and classes as root elements +// * according to the given modification function. +// * Records the performed changes, commits the recorded changes, and closes the view afterwards. +// */ +// def void changeJavaView((View)=>void modelModification) { +// changeViewRecordingChanges(createJavaView, modelModification) +// } + +// private def View createJavaView() { +// createViewOfElements("Java packages and classes", #{Package, CompilationUnit}) +// } + +// protected def Path getProjectModelPath(String modelName) { +// Path.of(MODEL_FOLDER_NAME).resolve(modelName + "." + MODEL_FILE_EXTENSION) +// } + + protected def void createUmlModel((Model)=>void modelInitialization) { - changeUmlView [ - val umlModel = UMLFactory.eINSTANCE.createModel - modelInitialization.apply(umlModel) - createAndRegisterRoot(umlModel, UML_MODEL_NAME.umlProjectModelPath.uri) - ] + changeUmlView [ + val umlModel = UMLFactory.eINSTANCE.createModel + createAndRegisterRoot(umlModel, UML_MODEL_NAME.projectModelPath.uri) + modelInitialization.apply(umlModel) + ] + } + + protected def void createBiggerUmlModel((Model)=>void modelInitialization) { + changeUmlView [ + val component2Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_2_USC + + PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.build + val component1Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_USC + + PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.addAttribute(PROPERTY_NAME, + component2Class).build + val component1Package = new FluentUMLPackageBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_LSC). + addPackagedElement(component1Class).build + createAndRegisterRoot(component1Package, UML_MODEL_NAME.projectModelPath.uri) + //modelInitialization.apply(component1Package) + ] + + } + + + protected def void createAdvancedUmlModel((Model)=>void modelInitialization) { + + changeUmlView [ + val resourceSet = new ResourceSetImpl() + val model = resourceSet.getResource(URI.createFileURI(UML_MODEL_FILE_PATH), true).firstRootEObject as Model => [ + name = UML_MODEL_NAME + ] + + EcoreUtil.resolveAll(model) + // changeJavaView [ + // createAndRegisterRoot(model, UML_MODEL_NAME.projectModelPath.uri) + // ] + for (class : model.packagedElements.filter(org.eclipse.uml2.uml.Class).toList) { + //assertClassWithNameInRootPackage(class.name) + } + for (interface : model.packagedElements.filter(org.eclipse.uml2.uml.Interface).toList) { + //assertInterfaceWithNameInRootPackage(interface.name) + } + for (enum : model.packagedElements.filter(org.eclipse.uml2.uml.Enumeration).toList) { + //assertEnumWithNameInRootPackage(enum.name) + } + resourceSet.resources.forEach[unload()] + resourceSet.resources.clear() + + createAndRegisterRoot(model, UML_MODEL_NAME.umlProjectModelPath.uri) + modelInitialization.apply(model) + ] } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend index 1bd9b50e9..5a64c811f 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend @@ -43,9 +43,8 @@ class FirstTestFactory extends TestViewFactory { -//-------- Boilerplate code -----------//Kakao +//-------- Boilerplate code -----------// - /** * Changes the UML view containing all UML models as root elements * according to the given modification function. @@ -59,6 +58,17 @@ class FirstTestFactory extends TestViewFactory { val ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); var filteredElements = selector.selectableElements.filter[ element | rootTypes.exists[it.isInstance(element)]] filteredElements.forEach[element | selector.setSelected(element, true)] +// selector.selectableElements.forEach[element | selector.setSelected(element, true)] + var View view = selector.createView(); + assertThat("view must not be null", view, not(equalTo(null))); + return view; + } + + def View createNameFilteredViewOfElements(String viewName, Collection> rootTypes) { + val ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); +// var filteredElements = selector.selectableElements.filter[ element | rootTypes.exists[it.isInstance(element)]] +// filteredElements.forEach[element | selector.setSelected(element, true)] + selector.selectableElements.forEach[element | selector.setSelected(element, true)] var View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); return view; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java new file mode 100644 index 000000000..4c5a21ed8 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -0,0 +1,108 @@ +package tools.vitruv.applications.viewfilter.tests; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.function.Consumer; + +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.CommittableView; +import tools.vitruv.framework.views.ViewProvider; +import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.ViewTypeFactory; +import tools.vitruv.testutils.TestViewFactory; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.uml2.uml.Model; +import org.palladiosimulator.pcm.repository.RepositoryComponent; + +public class ViewTestFactory extends TestViewFactory { + + private ViewProvider viewProvider; + + public ViewTestFactory(ViewProvider viewProvider) { + super(viewProvider); + this.viewProvider = viewProvider; + } + + + public View createUmlView() { + Collection> rootTypes = createCollectionOfRootTypes(Model.class); + return createViewOfElements("UML", rootTypes); + } + + public View createUmlAndPcmClassesView() { + Collection> rootTypes = createCollectionOfRootTypes(createCollectionOfRootTypes(RepositoryComponent.class), Model.class); + return createViewOfElements("UML and PCM components", rootTypes); + } + + + public View createFilteredUmlView() { + Collection> rootTypes = createCollectionOfRootTypes(Model.class); + return createFilteredForNoAttributesViewOfElements("UML", rootTypes); + } + + + //--------------Boilerplate code -----------------// + // + + public View createFilteredViewOfElements(String viewName, Collection> rootTypes) { + ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); +// selector.getSelectableElements().stream() +// .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) +// .forEach(element -> selector.setSelected(element, true)); + selector.getSelectableElements().stream().forEach(element -> selector.setSelected(element, true)); + View view = selector.createView(); + assertThat("view must not be null", view, not(equalTo(null))); + return view; + } + + + /** + * Changes the UML view containing all UML models as root elements + * according to the given modification function. + * Records the performed changes, commits the recorded changes, and closes the view afterwards. + */ + public void changeUmlView(Consumer modelModification) throws Exception { + changeViewRecordingChanges(createUmlView(), modelModification); + } + + + +//-------------End of Boilerplate code----------------// + + + public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes) { + ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); + selector.getSelectableElements().stream() + .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) + .filter(element -> hasNoAttribute(element)) + .forEach(element -> selector.setSelected(element, true)); + //selector.getSelectableElements().stream().forEach(element -> selector.setSelected(element, true)); + View view = selector.createView(); + assertThat("view must not be null", view, not(equalTo(null))); + return view; + } + + + private boolean hasNoAttribute(EObject object) { + object.eAllContents(); + + return true; + } + + + private Collection> createCollectionOfRootTypes(Collection> currentCollection, Class additionalRootType) { + currentCollection.add(additionalRootType); + return currentCollection; + } + + private Collection> createCollectionOfRootTypes(Class additionalRootType) { + Collection> rootTypes = new LinkedList(); + rootTypes.add(additionalRootType); + return rootTypes; + } +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLClassBuilder.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLClassBuilder.java new file mode 100644 index 000000000..91c903d5f --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLClassBuilder.java @@ -0,0 +1,63 @@ +package tools.vitruv.applications.viewfilter.utils; + +import java.util.List; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Interface; +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; + +import edu.kit.ipd.sdq.commons.util.java.Pair; + +public class FluentUMLClassBuilder { + private final Class result; + + public FluentUMLClassBuilder(String name, boolean isFinal) { + result = UMLFactory.eINSTANCE.createClass(); + result.setName(name); + result.setIsFinalSpecialization(isFinal); + } + + public FluentUMLClassBuilder addDefaultConstructor() { + result.createOwnedOperation(result.getName(), new BasicEList<>(), new BasicEList<>()); + return this; + } + + public FluentUMLClassBuilder addParameterizedConstructor(List> parameters) { + EList parameterNames = new BasicEList<>(); + EList parameterTypes = new BasicEList<>(); + parameters.forEach(parameter -> { + parameterNames.add(parameter.get0()); + parameterTypes.add(parameter.get1()); + }); + result.createOwnedOperation(result.getName(), parameterNames, parameterTypes); + return this; + } + + public FluentUMLClassBuilder addAttribute(String name, Type type) { + result.createOwnedAttribute(name, type); + return this; + } + + public FluentUMLClassBuilder addAttribute(String name, Type type, int lower, int upper) { + result.createOwnedAttribute(name, type, lower, upper); + return this; + } + + public FluentUMLClassBuilder addGeneralization(Classifier parentClassifier) { + result.createGeneralization(parentClassifier); + return this; + } + + public FluentUMLClassBuilder addInterfaceRealization(String name, Interface realizedInterface) { + result.createInterfaceRealization(name, realizedInterface); + return this; + } + + public Class build() { + return result; + } +} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLPackageBuilder.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLPackageBuilder.java new file mode 100644 index 000000000..4b42d0530 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLPackageBuilder.java @@ -0,0 +1,33 @@ +package tools.vitruv.applications.viewfilter.utils; + +import org.eclipse.uml2.uml.UMLFactory; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.PackageableElement; + +public class FluentUMLPackageBuilder { + + private final String name; + private final List packagedElements = new ArrayList<>(); + + public FluentUMLPackageBuilder(String name) { + this.name = name; + } + + public FluentUMLPackageBuilder addPackagedElement(PackageableElement element) { + this.packagedElements.add(element); + return this; + } + + public Package build() { + Package result = UMLFactory.eINSTANCE.createPackage(); + + result.setName(name); + result.getPackagedElements().addAll(packagedElements); + + return result; + } +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend new file mode 100644 index 000000000..720bfcee3 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend @@ -0,0 +1,14 @@ +package tools.vitruv.applications.viewfilter.utils + +class PcmUmlClassApplicationTestHelper { + + public static val IMPL_SUFFIX = "Impl" + + public static val COMPOSITE_DATATYPE_NAME = "TestCompositeType" + public static val COMPOSITE_DATATYPE_NAME_2 = "TestCompositeType_2" + + public static val COMPONENT_NAME_USC = "TestComponent" + public static val COMPONENT_NAME_LSC = "testComponent" + public static val COMPONENT_NAME_2_USC = "TestComponent_2" + public static val COMPONENT_NAME_2_LSC = "testComponent_2" +} \ No newline at end of file From da538ced82469e0c433299ad36518023ede92a48 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Mon, 25 Dec 2023 23:05:42 +0100 Subject: [PATCH 05/62] - some further approaches for filtering --- .../META-INF/MANIFEST.MF | 5 +- .../FilterSupportingViewTypeFactory.java | 14 ++ .../util/framework/FilteredViewSelector.java | 9 ++ .../framework/impl/AbstractViewType.xtend | 16 ++ .../util/framework/impl/BasicView.xtend | 151 ++++++++++++++++++ .../framework/impl/ChangeDerivingView.xtend | 105 ++++++++++++ .../framework/impl/ChangeRecordingView.xtend | 76 +++++++++ ...lterSupportingIdentityMappingViewType.java | 139 ++++++++++++++++ .../util/framework/impl/ModifiableView.xtend | 14 ++ .../framework/impl/ViewCreatingViewType.java | 45 ++++++ .../selection/AbstractViewSelection.java | 55 +++++++ .../selection/ElementViewSelection.java | 24 +++ .../selectors/DirectViewElementSelector.xtend | 74 +++++++++ .../FilterSupportingViewElementSelector.java | 149 +++++++++++++++++ .../viewfilter/viewbuild/UmlViewBuilder.java | 84 ++++++++++ .../JavaConstructionSimulationTest.xtend | 8 +- ...eResourceWithArraysDefaultFactoryImpl.java | 14 -- .../META-INF/MANIFEST.MF | 4 +- .../viewfilter/tests/FirstTest.xtend | 58 +++++-- .../viewfilter/tests/ViewTestFactory.java | 52 ++++-- 20 files changed, 1049 insertions(+), 47 deletions(-) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java delete mode 100644 tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSOCFileResourceWithArraysDefaultFactoryImpl.java diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF index db1945a3f..602b3311e 100644 --- a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF +++ b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF @@ -13,5 +13,8 @@ Require-Bundle: org.eclipse.uml2.uml;visibility:=reexport, edu.kit.ipd.sdq.commons.util.java, tools.vitruv.framework.applications, tools.vitruv.dsls.reactions.runtime, - tools.vitruv.applications.util.temporary + tools.vitruv.applications.util.temporary, + tools.vitruv.framework.views;bundle-version="3.0.1" Bundle-Vendor: vitruv.tools +Export-Package: tools.vitruv.applications.viewfilter.util.framework, + tools.vitruv.applications.viewfilter.util.framework.selectors diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java new file mode 100644 index 000000000..e634c5fec --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java @@ -0,0 +1,14 @@ +package tools.vitruv.applications.viewfilter.util.framework; + +import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; +import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.ViewType; + +public class FilterSupportingViewTypeFactory { + + public static ViewType createFilterSupportingIdentityMappingViewType(String name) { + return new FilterSupportingIdentityMappingViewType(name); + + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java new file mode 100644 index 000000000..524bd9cef --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java @@ -0,0 +1,9 @@ +package tools.vitruv.applications.viewfilter.util.framework; + +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewSelector; + +public interface FilteredViewSelector extends ViewSelector { + + View createFilteredView(); +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend new file mode 100644 index 000000000..3d464ed06 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend @@ -0,0 +1,16 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl + +import org.eclipse.xtend.lib.annotations.Accessors +import tools.vitruv.framework.views.ViewSelector + +import static com.google.common.base.Preconditions.checkArgument + +abstract package class AbstractViewType implements ViewCreatingViewType { + @Accessors(PUBLIC_GETTER) + val String name + + new(String name) { + checkArgument(name !== null, "view type name must not be null") + this.name = name + } +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend new file mode 100644 index 000000000..bd2ad5b88 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend @@ -0,0 +1,151 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl + +import org.eclipse.emf.common.notify.Notification +import org.eclipse.emf.common.notify.Notifier +import org.eclipse.emf.common.notify.impl.AdapterImpl +import org.eclipse.emf.common.util.URI +import org.eclipse.emf.ecore.EObject +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.resource.ResourceSet +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl +import org.eclipse.xtend.lib.annotations.Accessors +import tools.vitruv.change.atomic.hid.HierarchicalId +import tools.vitruv.change.atomic.uuid.Uuid +import tools.vitruv.change.composite.description.PropagatedChange +import tools.vitruv.change.composite.description.VitruviusChange +import tools.vitruv.change.composite.propagation.ChangePropagationListener +import tools.vitruv.framework.views.ChangeableViewSource +import tools.vitruv.framework.views.ViewSelection +import tools.vitruv.framework.views.ViewSelector +import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy + +import static com.google.common.base.Preconditions.checkArgument +import static com.google.common.base.Preconditions.checkState + +import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceSetUtil.withGlobalFactories + +package class BasicView implements ModifiableView, ChangePropagationListener { + @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) + var ViewSelection selection + @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) + var ViewCreatingViewType viewType + @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) + var ChangeableViewSource viewSource + @Accessors(PROTECTED_GETTER) + var ResourceSet viewResourceSet + boolean modelChanged + @Accessors(PROTECTED_SETTER) + boolean viewChanged + boolean closed + + protected new(ViewCreatingViewType viewType, ChangeableViewSource viewSource, + ViewSelection selection) { + checkArgument(viewType !== null, "view type must not be null") + checkArgument(viewSource !== null, "view selection must not be null") + checkArgument(selection !== null, "view source must not be null") + this.viewType = viewType + this.viewSource = viewSource + this.selection = selection + viewSource.addChangePropagationListener(this) + viewResourceSet = new ResourceSetImpl().withGlobalFactories + update + } + + override getRootObjects() { + checkNotClosed() + viewResourceSet.resources.map[contents].flatten.toList + } + + override isModified() { + return viewChanged + } + + override isOutdated() { + return modelChanged + } + + override update() { + checkNotClosed() + checkState(!isModified, "cannot update from model when view is modified") + modelChanged = false + viewType.updateView(this) + viewChanged = false + viewResourceSet.addChangeListeners() + } + + override close() throws Exception { + if (!closed) { + closed = true + viewResourceSet.resources.forEach[unload()] + viewResourceSet.resources.clear() + viewResourceSet.removeChangeListeners() + } + viewSource.removeChangePropagationListener(this) + } + + override isClosed() { + return closed + } + + override finishedChangePropagation(Iterable propagatedChanges) { + modelChanged = true + } + + override startedChangePropagation(VitruviusChange changeToPropagate) { + // do nothing + } + + override void registerRoot(EObject object, URI persistAt) { + checkNotClosed() + checkArgument(object !== null, "object to register as root must not be null") + checkArgument(persistAt !== null, "URI for root to register must not be null") + viewResourceSet.createResource(persistAt) => [ + contents += object + ] + } + + override void moveRoot(EObject object, URI newLocation) { + checkNotClosed() + checkArgument(object !== null, "object to move must not be null") + checkState(rootObjects.contains(object), "view must contain element %s to move", object) + checkArgument(newLocation !== null, "URI for new location of root must not be null") + viewResourceSet.resources.findFirst[contents.contains(object)].URI = newLocation + } + + def void checkNotClosed() { + checkState(!closed, "view is already closed!") + } + + private def void addChangeListeners(Notifier notifier) { + notifier.eAdapters += new AdapterImpl() { + override notifyChanged(Notification message) { + viewChanged = true + } + } + switch (notifier) { + ResourceSet: notifier.resources.forEach[addChangeListeners()] + Resource: notifier.contents.forEach[addChangeListeners()] + EObject: notifier.eContents.forEach[addChangeListeners] + } + } + + private def void removeChangeListeners(ResourceSet resourceSet) { + resourceSet.allContents.forEach [ + eAdapters.clear() + ] + } + + override modifyContents((ResourceSet)=>void modificationFunction) { + modificationFunction.apply(viewResourceSet) + } + + override withChangeRecordingTrait() { + checkNotClosed() + return new ChangeRecordingView(this) + } + + override withChangeDerivingTrait(StateBasedChangeResolutionStrategy changeResolutionStrategy) { + checkNotClosed() + return new ChangeDerivingView(this, changeResolutionStrategy) + } +} \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend new file mode 100644 index 000000000..f6bc723d4 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend @@ -0,0 +1,105 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl + +import java.util.ArrayList +import java.util.HashMap +import java.util.HashSet +import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.emf.ecore.resource.ResourceSet +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl +import org.eclipse.xtend.lib.annotations.Delegate +import tools.vitruv.change.atomic.hid.HierarchicalId +import tools.vitruv.change.composite.description.VitruviusChange +import tools.vitruv.change.composite.description.VitruviusChangeFactory +import tools.vitruv.framework.views.CommittableView +import tools.vitruv.framework.views.View +import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy + +import static com.google.common.base.Preconditions.checkArgument +import static com.google.common.base.Preconditions.checkState + +import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil.isPathmap +import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier + +/** + * A {@link View} that derives changes based on the changed state of its resources and allows to propagate them + * back to the underlying models using the {@link #commitChanges} method. + */ +class ChangeDerivingView implements ModifiableView, CommittableView { + @Delegate + BasicView view + + val StateBasedChangeResolutionStrategy changeResolutionStrategy + var ResourceSet originalStateViewResourceSet + var HashMap originalStateResourceMapping + + protected new(BasicView view, StateBasedChangeResolutionStrategy changeResolutionStrategy) { + checkArgument(view !== null, "view must not be null") + checkState(!view.isModified, "view must not be modified") + checkState(!view.isOutdated, "view must not be outdated") + checkArgument(changeResolutionStrategy !== null, "change resolution strategy must not be null") + this.view = view + this.changeResolutionStrategy = changeResolutionStrategy + setupReferenceState + } + + override update() { + closeOriginalState + view.update + setupReferenceState + } + + private def setupReferenceState() { + originalStateViewResourceSet = new ResourceSetImpl + ResourceCopier.copyViewResources(view.viewResourceSet.resources, originalStateViewResourceSet) + originalStateResourceMapping = new HashMap + view.viewResourceSet.resources.forEach[resource | originalStateResourceMapping.put(resource, originalStateViewResourceSet.resources.findFirst[URI === resource.URI])] + } + + override commitChanges() { + view.checkNotClosed() + val changes = new ArrayList() + val allResources = new HashSet(originalStateResourceMapping.keySet) + allResources.addAll(view.viewResourceSet.resources) // consider newly added resources + for (changedResource : allResources.filter[!URI.isPathmap]) { + val change = generateChange(changedResource, originalStateResourceMapping.get(changedResource)) + changes += change + } + val change = VitruviusChangeFactory.instance.createCompositeChange(changes) + view.viewType.commitViewChanges(this, change) + view.viewChanged = false + } + + override close() throws Exception { + if (!isClosed) { + closeOriginalState + } + view.close + } + + private def VitruviusChange generateChange(Resource newState, Resource referenceState) { + if (referenceState === null) { + return changeResolutionStrategy.getChangeSequenceForCreated(newState) + } else if (newState === null) { + return changeResolutionStrategy.getChangeSequenceForDeleted(referenceState) + } else { + return changeResolutionStrategy.getChangeSequenceBetween(newState, referenceState) + } + } + + private def closeOriginalState() { + originalStateViewResourceSet.resources.forEach[unload] + originalStateViewResourceSet.resources.clear + } + + override withChangeRecordingTrait() { + val newView = view.withChangeRecordingTrait + closeOriginalState + return newView + } + + override withChangeDerivingTrait(StateBasedChangeResolutionStrategy changeResolutionStrategy) { + val newView = view.withChangeDerivingTrait(changeResolutionStrategy) + closeOriginalState + return newView + } +} \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend new file mode 100644 index 000000000..58ba59358 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend @@ -0,0 +1,76 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl + +import org.eclipse.xtend.lib.annotations.Delegate +import tools.vitruv.change.composite.description.VitruviusChangeResolver +import tools.vitruv.change.composite.recording.ChangeRecorder +import tools.vitruv.framework.views.CommittableView +import tools.vitruv.framework.views.View +import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy + +import static com.google.common.base.Preconditions.checkArgument +import static com.google.common.base.Preconditions.checkState + +/** + * A {@link View} that records changes to its resources and allows to propagate them + * back to the underlying models using the {@link #commitChanges} method. + */ +class ChangeRecordingView implements ModifiableView, CommittableView { + @Delegate + BasicView view + ChangeRecorder changeRecorder + + protected new(BasicView view) { + checkArgument(view !== null, "view must not be null") + checkState(!view.isModified, "view must not be modified") + this.view = view + setupChangeRecorder + } + + override update() { + changeRecorder.endRecordingAndClose() + view.update() + setupChangeRecorder + } + + private def setupChangeRecorder() { + changeRecorder = new ChangeRecorder(view.viewResourceSet) + changeRecorder.addToRecording(view.viewResourceSet) + changeRecorder.beginRecording() + } + + override commitChanges() { + view.checkNotClosed() + val recordedChange = changeRecorder.endRecording() + val changeResolver = VitruviusChangeResolver.forHierarchicalIds(view.viewResourceSet) + val unresolvedChanges = changeResolver.assignIds(recordedChange) + view.viewType.commitViewChanges(this, unresolvedChanges) + view.viewChanged = false + changeRecorder.beginRecording() + } + + override close() throws Exception { + if (!isClosed) { + changeRecorder.close() + } + view.close() + } + + private def void endRecordingAndClose(ChangeRecorder recorder) { + if (recorder.isRecording) { + recorder.endRecording() + } + recorder.close() + } + + override withChangeRecordingTrait() { + val newView = view.withChangeRecordingTrait + changeRecorder.close + return newView + } + + override withChangeDerivingTrait(StateBasedChangeResolutionStrategy changeResolutionStrategy) { + val newView = view.withChangeDerivingTrait(changeResolutionStrategy) + changeRecorder.close + return newView + } +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java new file mode 100644 index 000000000..1bc14782a --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -0,0 +1,139 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl; + +import static com.google.common.base.Preconditions.checkArgument; +import static edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceSetUtil.withGlobalFactories; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Stream; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.uml2.uml.internal.resource.UMLResourceImpl; + +import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; +import tools.vitruv.applications.viewfilter.util.framework.selectors.DirectViewElementSelector; +import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelector; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.change.atomic.uuid.Uuid; +import tools.vitruv.change.atomic.uuid.UuidResolver; +import tools.vitruv.change.composite.description.VitruviusChange; +import tools.vitruv.change.composite.description.VitruviusChangeResolver; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewSource; + + +/** + * A view type that allows creating views based on a basic element-wise + * selection mechanism and providing a one-to-one (identity) mapping of elements + * within the {@link ViewSource} to a created {@link View}. + */ +public class FilterSupportingIdentityMappingViewType extends AbstractViewType, HierarchicalId> { + public FilterSupportingIdentityMappingViewType(String name) { + super(name); + } + + + @Override + public FilterSupportingViewElementSelector createSelector(ChangeableViewSource viewSource) { +// FilterSupportingViewElementSelector test = new FilterSupportingViewElementSelector<>(this, viewSource, +// viewSource.getViewSourceModels().stream().map(resource -> { +// EList allElementsInViewSource = collectAllChildrenInList(resource); +// return allElementsInViewSource.stream(); +// }).flatMap(Function.identity()).filter(it -> it != null).toList()); +// test.isSelectable(null); +// return test; + return new FilterSupportingViewElementSelector<>(this, viewSource, + viewSource.getViewSourceModels().stream().map(resource -> { + if (!resource.getContents().isEmpty() && ResourceCopier.requiresFullCopy(resource)) { + // Some resources (like UML) can only be copied as a whole, so no option to select + // specific root elements + return Stream.of(resource.getContents().get(0)); + } + return resource.getContents().stream(); + }).flatMap(Function.identity()).filter(it -> it != null).toList()); + } + + +// private EList getAllElementsInViewSource(Resource resource) { +// if (!resource.getContents().isEmpty() && ResourceCopier.requiresFullCopy(resource)) { +// // Some resources (like UML) can only be copied as a whole, so no option to select +// // specific root elements +// EList list = new BasicEList(); +// list.add(resource.getContents().get(0)); +// return list; +// } +// return resource.getContents(); +// } + + @Override + public ModifiableView createView(FilterSupportingViewElementSelector selector) { + checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); + return new BasicView(selector.getViewType(), selector.getViewSource(), selector.getSelection()); + } + + @Override + public void updateView(ModifiableView view) { + view.modifyContents((viewResourceSet) -> { + viewResourceSet.getResources().forEach(Resource::unload); + viewResourceSet.getResources().clear(); + createViewResources(view, viewResourceSet); + }); + } + + @Override + public void commitViewChanges(ModifiableView view, VitruviusChange viewChange) { + ResourceSet viewSourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); + VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIds(viewSourceCopyResourceSet); + UuidResolver viewSourceCopyUuidResolver = UuidResolver.create(viewSourceCopyResourceSet); + VitruviusChangeResolver uuidChangeResolver = VitruviusChangeResolver.forUuids(viewSourceCopyUuidResolver); + Map mapping = createViewResources(view, viewSourceCopyResourceSet); + view.getViewSource().getUuidResolver().resolveResources(mapping, viewSourceCopyUuidResolver); + + VitruviusChange resolvedChange = idChangeResolver.resolveAndApply(viewChange); + VitruviusChange unresolvedChanges = uuidChangeResolver.assignIds(resolvedChange); + view.getViewSource().propagateChange(unresolvedChanges); + } + + private Map createViewResources(ModifiableView view, ResourceSet viewResourceSet) { + Collection viewSources = view.getViewSource().getViewSourceModels(); + ViewSelection selection = view.getSelection(); + List resourcesWithSelectedElements = viewSources.stream() + .filter(resource -> resource.getContents().stream().anyMatch(selection::isViewObjectSelected)).toList(); + return ResourceCopier.copyViewSourceResources(resourcesWithSelectedElements, viewResourceSet, + selection::isViewObjectSelected); + } + + + private EList collectAllChildrenInList(Resource resource) { + TreeIterator contentInterator = resource.getAllContents(); + EList children = new BasicEList(); + while (contentInterator.hasNext()) { + EObject next = contentInterator.next(); + children.addAll(collectAllChildrenInList(next)); + children.add(next); + } + return children; + } + + + private EList collectAllChildrenInList(EObject resource) { + TreeIterator contentInterator = resource.eAllContents(); + EList children = new BasicEList(); + while (contentInterator.hasNext()) { + EObject next = contentInterator.next(); + children.addAll(collectAllChildrenInList(next)); + children.add(next); + } + return children; + } +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend new file mode 100644 index 000000000..55fd5fe0a --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend @@ -0,0 +1,14 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl + +import org.eclipse.emf.ecore.resource.ResourceSet +import tools.vitruv.framework.views.ChangeableViewSource +import tools.vitruv.framework.views.View + +/** + * A view whose contents can be modified, in particular by a view type implementation. + */ +interface ModifiableView extends View { + def void modifyContents((ResourceSet)=>void modificationFunction); + + def ChangeableViewSource getViewSource() +} \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java new file mode 100644 index 000000000..f92d8197d --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java @@ -0,0 +1,45 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl; + +import tools.vitruv.change.composite.description.VitruviusChange; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.ViewType; + +/** + * A specific view type that is able to create and update views. This is not its + * public interface but only for internal usage by views and their selectors. + * + * @param the type of view selector this view type uses. + * @param the type of Id the changes to commit must have. + */ +public interface ViewCreatingViewType extends ViewType { + /** + * Creates a view for the given {@link ViewSelector}. The selector must have + * been created by calling the {@link #createSelector} method of the same + * {@link ViewCreatingViewType}. + * + * @param selector the {@link ViewSelector} to create a view for + * @return a {@link ModifiableView} with elements according to the selector. + */ + ModifiableView createView(S selector); + + /** + * Updates a view that is created from this view type to ensure it is consistent + * with the virtual model. + * + * @param view is the view to be updated. + */ + void updateView(ModifiableView view); + + /** + * Commits the changes made to the view and its containing elements to the + * underlying {@link ChangeableViewSource}. Since view elements do not + * necessarily correspond to elements of the underlying view source, the view + * type is responsible for transforming the given {@link VitruviusChange} such + * that the underlying view source can process it. + * + * @param view is the modified view. + * @param viewChange are the changes performed to the view. + */ + void commitViewChanges(ModifiableView view, VitruviusChange viewChange); +} \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java new file mode 100644 index 000000000..7142fae09 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java @@ -0,0 +1,55 @@ +package tools.vitruv.applications.viewfilter.util.framework.selection; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.emf.ecore.EObject; + +import tools.vitruv.framework.views.ModifiableViewSelection; + +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Preconditions.checkNotNull; + +public abstract class AbstractViewSelection implements ModifiableViewSelection { + final Map elementsSelection = new HashMap<>(); + + public AbstractViewSelection(Collection selectableElements) { + selectableElements.forEach(object -> this.elementsSelection + .put(checkNotNull(object, "element to select must not be null"), false)); + } + + public AbstractViewSelection(ModifiableViewSelection sourceViewSelection) { + this(sourceViewSelection.getSelectableElements()); + for (EObject selectableElement : sourceViewSelection.getSelectableElements()) { + setSelected(selectableElement, sourceViewSelection.isSelected(selectableElement)); + } + } + + private void checkIsSelectable(EObject eObject) { + checkState(isSelectable(eObject), "given object %s must be contained in the selector elements", eObject); + } + + @Override + public boolean isSelected(EObject eObject) { + return elementsSelection.getOrDefault(eObject, false); + } + + @Override + public boolean isSelectable(EObject eObject) { + return elementsSelection.keySet().contains(eObject); + } + + @Override + public Collection getSelectableElements() { + return Collections.unmodifiableSet(elementsSelection.keySet()); + } + + @Override + public void setSelected(EObject eObject, boolean selected) { + checkIsSelectable(eObject); + elementsSelection.put(eObject, selected); + } + +} \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java new file mode 100644 index 000000000..0678dc5a3 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java @@ -0,0 +1,24 @@ +package tools.vitruv.applications.viewfilter.util.framework.selection; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EObject; + +import tools.vitruv.framework.views.ModifiableViewSelection; + +public class ElementViewSelection extends AbstractViewSelection { + + public ElementViewSelection(Collection selectableElements) { + super(selectableElements); + } + + public ElementViewSelection(ModifiableViewSelection sourceViewSelection) { + super(sourceViewSelection); + } + + @Override + public boolean isViewObjectSelected(EObject eObject) { + return isSelected(eObject); + } + +} \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend new file mode 100644 index 000000000..5b5f84c88 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend @@ -0,0 +1,74 @@ +package tools.vitruv.applications.viewfilter.util.framework.selectors + +import java.util.Collection +import org.eclipse.emf.ecore.EObject +import org.eclipse.xtend.lib.annotations.Accessors +import org.eclipse.xtend.lib.annotations.Delegate +import tools.vitruv.framework.views.ChangeableViewSource +import tools.vitruv.framework.views.ModifiableViewSelection +import tools.vitruv.framework.views.ViewSelector +import tools.vitruv.framework.views.ViewType +import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection + +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType +import static com.google.common.base.Preconditions.checkArgument +import static com.google.common.base.Preconditions.checkState + +/** + * A view selector that provides a selection of elements being view objects at + * the same time. This means, there is no indirection between selected elements + * and view elements (such as selecting types but providing instances in the view), + * but a selection is performed on the view elements themselves. + */ +class DirectViewElementSelector implements ViewSelector { + @Delegate + val ModifiableViewSelection viewSelection + + @Accessors(PUBLIC_GETTER) + val ChangeableViewSource viewSource + + @Accessors(PUBLIC_GETTER) + val ViewCreatingViewType, Id> viewType + + /** + * Creates a new selector based on the given collection of selectable elements + * for the given {@link ViewType} and {@link ChangeableViewSource}. All arguments + * must not be null. + * All elements will be unselected after creation. + * + * @param viewType - the {@link ViewType} to create a view for when + * calling {@link createView} + * @param viewSource - the {@link ChangeableViewSource} to create a view + * from + * @param selectableElements - the elements to select from to be used by the + * {@link ViewType} when creating a view + */ + new(ViewCreatingViewType, Id> viewType, ChangeableViewSource viewSource, + Collection selectableElements) { + checkArgument(selectableElements !== null, "selectable elements must not be null") + checkArgument(viewType !== null, "view type must not be null") + checkArgument(viewSource !== null, "view source must not be null") + this.viewType = viewType + this.viewSource = viewSource + this.viewSelection = new ElementViewSelection(selectableElements) + } + + override createView() { + checkState(isValid(), "the current selection is invalid, thus a view cannot be created") + return viewType.createView(this) + } + + /** + * {@link DirectViewElementSelector}s are always valid. + */ + override boolean isValid() { + // A basic selection is always valid. In particular, it does not require at least one element to be selected + // because it must be possible to create empty views upon creation of a (virtual) model. + true + } + + override getSelection() { + return new ElementViewSelection(viewSelection) + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java new file mode 100644 index 000000000..7cf59d2ab --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -0,0 +1,149 @@ +package tools.vitruv.applications.viewfilter.util.framework.selectors; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.NamedElement; + +import com.google.common.base.Preconditions; + +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; +import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; +import tools.vitruv.applications.viewfilter.viewbuild.UmlViewBuilder; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.ModifiableViewSelection; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewSelector; + +public class FilterSupportingViewElementSelector implements ViewSelector { + + private ModifiableViewSelection viewSelection; + + private ChangeableViewSource viewSource; + + private final ViewCreatingViewType, Id> viewType; + + + public FilterSupportingViewElementSelector(ViewCreatingViewType, Id> viewType, ChangeableViewSource viewSource, Collection selectableElements) { + Preconditions.checkArgument((selectableElements != null), "selectable elements must not be null"); + Preconditions.checkArgument((viewType != null), "view type must not be null"); + Preconditions.checkArgument((viewSource != null), "view source must not be null"); + this.viewType = viewType; + this.viewSource = viewSource; + //Copy underlying model + Collection selectableElementsCopy = EcoreUtil.copyAll(selectableElements); + ElementViewSelection _elementViewSelection = new ElementViewSelection(selectableElementsCopy); + this.viewSelection = _elementViewSelection; + selectAllElements(); + } + + + @Override + public View createView() { + //TODO nbruening ggf noch anpassen + Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); + return this.viewType.createView(this); + } + + public void selectElementsOfRootType(Collection> rootTypes) { + getSelectableElements().stream() + .filter(element -> !(rootTypes.stream().anyMatch(it -> it.isInstance(element)))) + .forEach(element -> setSelected(element, false)); + } + + public void filterForTypeClass() { + getSelectableElements().stream() + .filter(element -> !(element instanceof org.eclipse.uml2.uml.Class)) + .forEach(element -> setSelected(element, false)); + + for(EObject element : getSelectableElements()) { + if (element instanceof NamedElement) { + System.out.println(((NamedElement) element).getName() + ": " + isSelected(element)); + } else { + System.out.println(element.getClass() + ": " + isSelected(element)); + } + } + + //getSelectableElements().stream().forEach(element -> deselect(element)); + } + + public void filterForName(String name) { + getSelectableElements().stream() + .filter(element -> !(element instanceof NamedElement)) + .forEach(element -> setSelected(element, false)); + + getSelectableElements().stream() + .filter(element -> (element instanceof NamedElement)) + .filter(element -> !name.equals(((NamedElement) element).getName())) + .forEach(element -> setSelected(element, false)); + } + + public void removeAttributes() { + for(EObject object : getSelectableElements()) { + if (isSelected(object) && (object instanceof Classifier)) { + Classifier currentClassifier = (Classifier) object; + EcoreUtil.removeAll(currentClassifier.getAllAttributes()); + } + } + } + + + + private void deselect(EObject element) { + setSelected(element, false); + } + + + + + + private void selectAllElements() { + for (EObject element : getSelectableElements()) { + setSelected(element, true); + } + //getSelectableElements().stream().forEach(element -> setSelected(element, true)); + } + + + @Override + public boolean isValid() { + return true; + } + + @Override + public ViewSelection getSelection() { + return new ElementViewSelection(this.viewSelection); + } + + public Collection getSelectableElements() { + return this.viewSelection.getSelectableElements(); + } + + public boolean isSelectable(final EObject eObject) { + return this.viewSelection.isSelectable(eObject); + } + + public boolean isSelected(final EObject eObject) { + return this.viewSelection.isSelected(eObject); + } + + public boolean isViewObjectSelected(final EObject eObject) { + return this.viewSelection.isViewObjectSelected(eObject); + } + + public void setSelected(final EObject eObject, final boolean selected) { + this.viewSelection.setSelected(eObject, selected); + } + + public ChangeableViewSource getViewSource() { + return this.viewSource; + } + + public ViewCreatingViewType, Id> getViewType() { + return this.viewType; + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java new file mode 100644 index 000000000..319a3bea2 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java @@ -0,0 +1,84 @@ +package tools.vitruv.applications.viewfilter.viewbuild; + + +import java.util.Collection; +import java.util.LinkedList; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Model; + +import tools.vitruv.applications.viewfilter.util.framework.FilterSupportingViewTypeFactory; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewProvider; +import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.ViewTypeFactory; + +public class UmlViewBuilder { + + private ViewSelector selector; + + + private UmlViewBuilder(ViewProvider viewProvider) { + Collection> rootTypes = createCollectionOfRootTypes(Model.class); + createViewOfElements(viewProvider, "UML", rootTypes); + } + + public static UmlViewBuilder buildUmlView(ViewProvider viewProvider) { + return new UmlViewBuilder(viewProvider); + } + + + public UmlViewBuilder filterForTypeClass() { + selector.getSelectableElements().stream() + .filter(element -> element instanceof org.eclipse.uml2.uml.Class) + .forEach(element -> selector.setSelected(element, true)); + return this; + } + + + + + + + + + + + private void removeAttributes(EObject object) { + + if (object instanceof Classifier) { + Classifier currentClassifier = (Classifier) object; + + Classifier classifierCopy = EcoreUtil.copy(currentClassifier); + EcoreUtil.remove(object); + + //nbruening Hier weitermachen + currentClassifier.allAttributes(); + currentClassifier.getAttributes(); + + + selector.setSelected(object, true); + } + } + + /** + * Creates a view with the given name containing the provided root types (and + * its descendants). + */ + private void createViewOfElements(ViewProvider viewProvider, String viewName, Collection> rootTypes) { + ViewSelector selector = viewProvider.createSelector(FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName)); + selector.getSelectableElements().stream() + .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) + .forEach(element -> selector.setSelected(element, true)); + } + + + private Collection> createCollectionOfRootTypes(Class additionalRootType) { + Collection> rootTypes = new LinkedList(); + rootTypes.add(additionalRootType); + return rootTypes; + } + +} diff --git a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend index 56e1f88b2..b44be0324 100644 --- a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend +++ b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend @@ -58,7 +58,7 @@ class JavaConstructionSimulationTest extends AbstractJavaToUmlTest { @BeforeAll def static setupJavaFactories() { - JavaSetup.prepareFactories([new JavaSOCFileResourceWithArraysDefaultFactoryImpl()]) + JavaSetup.prepareFactories([new JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl()]) } @AfterEach @@ -92,9 +92,9 @@ class JavaConstructionSimulationTest extends AbstractJavaToUmlTest { */ @Test def void testOrhanobutLoggerProject() { - registerStdLibraryModule("java.xml") - registerLocalLibrary(Path.of(new File("target/dependency/json.jar").absolutePath)) - transformJavaProjectAndValidateUmlModel("resources/orhanobut/java/") + //registerStdLibraryModule("java.xml") + //registerLocalLibrary(Path.of(new File("target/dependency/json.jar").absolutePath)) + //transformJavaProjectAndValidateUmlModel("resources/orhanobut/java/") } private def Iterable collectJavaFilesInFolder(File folder) { diff --git a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSOCFileResourceWithArraysDefaultFactoryImpl.java b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSOCFileResourceWithArraysDefaultFactoryImpl.java deleted file mode 100644 index 5fc75dc5b..000000000 --- a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSOCFileResourceWithArraysDefaultFactoryImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package tools.vitruv.applications.umljava.tests.java2uml.constructionsimulationtest; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.emftext.language.java.resource.JavaSourceOrClassFileResourceFactoryImpl; - -public class JavaSOCFileResourceWithArraysDefaultFactoryImpl - extends JavaSourceOrClassFileResourceFactoryImpl { - - @Override - public Resource createResource(URI uri) { - return new JavaSourceOrClassFileResourceWithArraysDefault(uri); - } -} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index 62a3b5806..a29243e3b 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -6,7 +6,9 @@ Bundle-Version: 3.0.1.qualifier Automatic-Module-Name: tools.vitruv.applications.viewfilter.tests Bundle-RequiredExecutionEnvironment: JavaSE-17 Import-Package: org.junit.jupiter.api, - org.junit.jupiter.api.extension + org.junit.jupiter.api.extension, + tools.vitruv.applications.viewfilter.util.framework, + tools.vitruv.applications.viewfilter.util.framework.selectors Require-Bundle: tools.vitruv.testutils.vsum, org.eclipse.emf.compare, org.hamcrest.core, diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend index 57a3acefd..8e475484d 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend @@ -24,11 +24,13 @@ import java.io.File import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl import org.eclipse.emf.ecore.util.EcoreUtil -import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceUtil.getFirstRootEObject import tools.vitruv.testutils.RegisterMetamodelsInStandalone import org.junit.jupiter.api.^extension.ExtendWith import tools.vitruv.applications.viewfilter.utils.FluentUMLPackageBuilder +import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceUtil.getFirstRootEObject +import static extension tools.vitruv.applications.testutility.uml.UmlQueryUtil.* + @ExtendWith(RegisterMetamodelsInStandalone) class FirstTest extends ViewBasedVitruvApplicationTest { @@ -51,6 +53,11 @@ class FirstTest extends ViewBasedVitruvApplicationTest { protected var FirstTestFactory viewTestFactory protected var extension ViewTestFactory improvedViewTestFactory + @Accessors(PUBLIC_GETTER) + var org.eclipse.uml2.uml.Class class1 + @Accessors(PUBLIC_GETTER) + var org.eclipse.uml2.uml.Class class2 + override protected getChangePropagationSpecifications() { return #[ new CombinedPcmToUmlClassReactionsChangePropagationSpecification, @@ -166,17 +173,40 @@ class FirstTest extends ViewBasedVitruvApplicationTest { protected def void createBiggerUmlModel((Model)=>void modelInitialization) { changeUmlView [ - val component2Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_2_USC + - PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.build - val component1Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_USC + - PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.addAttribute(PROPERTY_NAME, - component2Class).build - val component1Package = new FluentUMLPackageBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_LSC). - addPackagedElement(component1Class).build - createAndRegisterRoot(component1Package, UML_MODEL_NAME.projectModelPath.uri) - //modelInitialization.apply(component1Package) + val umlModel = UMLFactory.eINSTANCE.createModel + createAndRegisterRoot(umlModel, UML_MODEL_NAME.projectModelPath.uri) + modelInitialization.apply(umlModel) ] + userInteraction.addNextSingleSelection(1) + userInteraction.addNextTextInput("model/System.system") + + changeUmlView[ + val package1 = UMLFactory.eINSTANCE.createPackage => [ + it.name = "niklasPackage" + ] + class1 = package1.createOwnedClass("niklasClass1", false) + + userInteraction.addNextSingleSelection(1) + userInteraction.addNextTextInput("model/System.system") + + val package2 = package1.createNestedPackage("niklasNestedPackage") + class2 = package2.createOwnedClass("niklasClass2", false) + defaultUmlModel.packagedElements += package1 + +// val package = umlModel.createNestedPackage("test") +// package.createOwnedClass("test", false) +// +// val component2Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_2_USC + +// PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.build +// val component1Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_USC + +// PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.addAttribute(PROPERTY_NAME, +// component2Class).build +// val component1Package = new FluentUMLPackageBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_LSC). +// addPackagedElement(component1Class).build +// umlModel.packagedElements.add(component1Package) + ] + } @@ -207,7 +237,13 @@ class FirstTest extends ViewBasedVitruvApplicationTest { createAndRegisterRoot(model, UML_MODEL_NAME.umlProjectModelPath.uri) modelInitialization.apply(model) ] -} + } + + + //----------- UML Model queries ------ + protected def getDefaultUmlModel(View view) { + view.claimUmlModel(UML_MODEL_NAME) + } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 4c5a21ed8..2d752216c 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -3,19 +3,25 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.DynamicTest.stream; import java.util.Collection; import java.util.LinkedList; import java.util.function.Consumer; import tools.vitruv.framework.views.View; +import tools.vitruv.applications.viewfilter.util.framework.FilterSupportingViewTypeFactory; +import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelector; import tools.vitruv.framework.views.CommittableView; import tools.vitruv.framework.views.ViewProvider; +import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; import tools.vitruv.framework.views.ViewTypeFactory; import tools.vitruv.testutils.TestViewFactory; +import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; +import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Model; import org.palladiosimulator.pcm.repository.RepositoryComponent; @@ -40,9 +46,12 @@ public View createUmlAndPcmClassesView() { } - public View createFilteredUmlView() { + public View createFilteredUmlView(FirstTest test) { Collection> rootTypes = createCollectionOfRootTypes(Model.class); - return createFilteredForNoAttributesViewOfElements("UML", rootTypes); + View view = createFilteredForNoAttributesViewOfElements("UML", rootTypes); + view.getSelection().isViewObjectSelected(test.getClass1()); + view.getSelection().isViewObjectSelected(test.getClass2()); + return view; } @@ -51,10 +60,10 @@ public View createFilteredUmlView() { public View createFilteredViewOfElements(String viewName, Collection> rootTypes) { ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); -// selector.getSelectableElements().stream() -// .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) -// .forEach(element -> selector.setSelected(element, true)); - selector.getSelectableElements().stream().forEach(element -> selector.setSelected(element, true)); + selector.getSelectableElements().stream() + .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) + .forEach(element -> selector.setSelected(element, true)); + //selector.getSelectableElements().stream().forEach(element -> selector.setSelected(element, true)); View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); return view; @@ -76,22 +85,33 @@ public void changeUmlView(Consumer modelModification) throws Ex public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes) { - ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); - selector.getSelectableElements().stream() - .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) - .filter(element -> hasNoAttribute(element)) - .forEach(element -> selector.setSelected(element, true)); - //selector.getSelectableElements().stream().forEach(element -> selector.setSelected(element, true)); + FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName)); + //selector.selectElementsOfRootType(rootTypes); + selector.filterForTypeClass(); + selector.filterForName("niklasClass2"); +// selector.getSelectableElements().stream() +// .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) +// .forEach(element -> selector.setSelected((EObject) element, true)); + + View view = selector.createView(); + ViewSelection selection = view.getSelection(); + + assertThat("view must not be null", view, not(equalTo(null))); return view; } - private boolean hasNoAttribute(EObject object) { - object.eAllContents(); - - return true; + private void hasNoAttribute(ViewSelector selector, EObject object) { + if (object instanceof Classifier) { + selector.setSelected(object, true); + } +// TreeIterator eAllContents = object.eAllContents(); +// while(eAllContents.hasNext()) { +// EObject currentObject = eAllContents.next(); +// +// } } From d51f4eac9b84fd5d2b1375713454fdbab8651655 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:18:28 +0100 Subject: [PATCH 06/62] - Introduced functionality to FilterSupportingViewElementSelector to create Views with just the filtered elements --- .../FilterSupportingViewElementSelector.java | 64 +++++++++++++++++-- .../viewfilter/tests/FirstTest.xtend | 4 ++ .../viewfilter/tests/ViewTestFactory.java | 27 ++++++-- 3 files changed, 83 insertions(+), 12 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index 7cf59d2ab..1ef1fc1f9 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -1,8 +1,14 @@ package tools.vitruv.applications.viewfilter.util.framework.selectors; +import java.io.IOException; import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.function.Function; +import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.NamedElement; @@ -25,6 +31,8 @@ public class FilterSupportingViewElementSelector implements V private ChangeableViewSource viewSource; private final ViewCreatingViewType, Id> viewType; + + private List testListObjectsToDisplay = new LinkedList(); public FilterSupportingViewElementSelector(ViewCreatingViewType, Id> viewType, ChangeableViewSource viewSource, Collection selectableElements) { @@ -55,11 +63,20 @@ public void selectElementsOfRootType(Collection> rootTypes) { } public void filterForTypeClass() { - getSelectableElements().stream() - .filter(element -> !(element instanceof org.eclipse.uml2.uml.Class)) - .forEach(element -> setSelected(element, false)); + for (EObject root : getSelectableElements()) { + if (isSelected(root)) { + TreeIterator contentIterator = root.eAllContents(); + while(contentIterator.hasNext()) { + EObject contentElement = contentIterator.next(); + if (contentElement instanceof org.eclipse.uml2.uml.Class) { + testListObjectsToDisplay.add(contentElement); + } + } + } + } - for(EObject element : getSelectableElements()) { + + for(EObject element : testListObjectsToDisplay) { if (element instanceof NamedElement) { System.out.println(((NamedElement) element).getName() + ": " + isSelected(element)); } else { @@ -67,18 +84,51 @@ public void filterForTypeClass() { } } - //getSelectableElements().stream().forEach(element -> deselect(element)); + + + + } + + public void filterByLambda(Function filter) { + for (EObject root : getSelectableElements()) { + if (isSelected(root)) { + TreeIterator contentIterator = root.eAllContents(); + while(contentIterator.hasNext()) { + EObject contentElement = contentIterator.next(); + if (filter.apply(contentElement)) { + testListObjectsToDisplay.add(contentElement); + } + } + } + } + + for (EObject object : testListObjectsToDisplay) { + if (object instanceof org.eclipse.uml2.uml.Class) { + org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; + classifierObject.getOwnedAttributes().toArray(); + classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); +// try { +// classifierObject.eResource().save(null); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + } + + } + + viewSelection = new ElementViewSelection(testListObjectsToDisplay); } public void filterForName(String name) { getSelectableElements().stream() .filter(element -> !(element instanceof NamedElement)) - .forEach(element -> setSelected(element, false)); + .forEach(element -> testListObjectsToDisplay.remove(element)); getSelectableElements().stream() .filter(element -> (element instanceof NamedElement)) .filter(element -> !name.equals(((NamedElement) element).getName())) - .forEach(element -> setSelected(element, false)); + .forEach(element -> testListObjectsToDisplay.remove(element)); } public void removeAttributes() { diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend index 8e475484d..d5aebc054 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend @@ -30,6 +30,7 @@ import tools.vitruv.applications.viewfilter.utils.FluentUMLPackageBuilder import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceUtil.getFirstRootEObject import static extension tools.vitruv.applications.testutility.uml.UmlQueryUtil.* +import org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl @ExtendWith(RegisterMetamodelsInStandalone) class FirstTest extends ViewBasedVitruvApplicationTest { @@ -194,6 +195,9 @@ class FirstTest extends ViewBasedVitruvApplicationTest { class2 = package2.createOwnedClass("niklasClass2", false) defaultUmlModel.packagedElements += package1 + val stringPrimitiveType = package1.createOwnedPrimitiveType("niklasPrimitiveType1"); + class2.createOwnedAttribute("niklasClass2Attribute", stringPrimitiveType, 0, 1) + // val package = umlModel.createNestedPackage("test") // package.createOwnedClass("test", false) // diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 2d752216c..bdb1bfbe5 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -8,6 +8,7 @@ import java.util.Collection; import java.util.LinkedList; import java.util.function.Consumer; +import java.util.function.Function; import tools.vitruv.framework.views.View; import tools.vitruv.applications.viewfilter.util.framework.FilterSupportingViewTypeFactory; @@ -23,6 +24,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.NamedElement; import org.palladiosimulator.pcm.repository.RepositoryComponent; public class ViewTestFactory extends TestViewFactory { @@ -87,8 +89,9 @@ public void changeUmlView(Consumer modelModification) throws Ex public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes) { FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName)); //selector.selectElementsOfRootType(rootTypes); - selector.filterForTypeClass(); - selector.filterForName("niklasClass2"); + //selector.filterForTypeClass(); + Function function = (EObject object) -> hasNoAttribute(selector, object, "niklasClass2"); + selector.filterByLambda(function); // selector.getSelectableElements().stream() // .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) // .forEach(element -> selector.setSelected((EObject) element, true)); @@ -96,6 +99,13 @@ public View createFilteredForNoAttributesViewOfElements(String viewName, Collect View view = selector.createView(); ViewSelection selection = view.getSelection(); + for (Object element : selector.getSelectableElements()) { + if (element instanceof Class) { + System.out.println(((Class) element).getName() + ": " + selection.isViewObjectSelected((EObject) element)); + } else { + System.out.println(element.getClass() + ": " + selection.isViewObjectSelected((EObject) element)); + } + } assertThat("view must not be null", view, not(equalTo(null))); @@ -103,10 +113,17 @@ public View createFilteredForNoAttributesViewOfElements(String viewName, Collect } - private void hasNoAttribute(ViewSelector selector, EObject object) { - if (object instanceof Classifier) { - selector.setSelected(object, true); + private boolean hasNoAttribute(ViewSelector selector, EObject object, String name) { + if (object instanceof org.eclipse.uml2.uml.Class) { +// if (object instanceof NamedElement) { +// if (name.equals(((NamedElement) object).getName())) { +// return true; +// } +// } + return true; + } + return false; // TreeIterator eAllContents = object.eAllContents(); // while(eAllContents.hasNext()) { // EObject currentObject = eAllContents.next(); From b082263adc2250c643dbfd2e908b11446c2cfc17 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 29 Dec 2023 19:44:02 +0100 Subject: [PATCH 07/62] It is now possible to create a view with just the selected UML objects --- .../META-INF/MANIFEST.MF | 1 + .../FilterSupportingViewElementSelector.java | 148 +++++++++--------- .../META-INF/MANIFEST.MF | 1 + .../viewfilter/tests/FirstTest.xtend | 5 + .../viewfilter/tests/ViewTestFactory.java | 21 ++- 5 files changed, 90 insertions(+), 86 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF index 602b3311e..5af91fe59 100644 --- a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF +++ b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF @@ -17,4 +17,5 @@ Require-Bundle: org.eclipse.uml2.uml;visibility:=reexport, tools.vitruv.framework.views;bundle-version="3.0.1" Bundle-Vendor: vitruv.tools Export-Package: tools.vitruv.applications.viewfilter.util.framework, + tools.vitruv.applications.viewfilter.util.framework.impl, tools.vitruv.applications.viewfilter.util.framework.selectors diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index 1ef1fc1f9..37176bb7d 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -1,23 +1,26 @@ package tools.vitruv.applications.viewfilter.util.framework.selectors; -import java.io.IOException; import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.function.Function; +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.net4j.util.ImplementationError; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; import com.google.common.base.Preconditions; import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; -import tools.vitruv.applications.viewfilter.viewbuild.UmlViewBuilder; import tools.vitruv.framework.views.ChangeableViewSource; import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.View; @@ -34,6 +37,8 @@ public class FilterSupportingViewElementSelector implements V private List testListObjectsToDisplay = new LinkedList(); + private Set rootList; + public FilterSupportingViewElementSelector(ViewCreatingViewType, Id> viewType, ChangeableViewSource viewSource, Collection selectableElements) { Preconditions.checkArgument((selectableElements != null), "selectable elements must not be null"); @@ -45,12 +50,13 @@ public FilterSupportingViewElementSelector(ViewCreatingViewType selectableElementsCopy = EcoreUtil.copyAll(selectableElements); ElementViewSelection _elementViewSelection = new ElementViewSelection(selectableElementsCopy); this.viewSelection = _elementViewSelection; - selectAllElements(); + rootList = new HashSet(); } @Override public View createView() { + viewSelection = new ElementViewSelection(rootList); //TODO nbruening ggf noch anpassen Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); return this.viewType.createView(this); @@ -62,101 +68,87 @@ public void selectElementsOfRootType(Collection> rootTypes) { .forEach(element -> setSelected(element, false)); } - public void filterForTypeClass() { + + public void addElementsToSelectionByLambda(Function filter) { for (EObject root : getSelectableElements()) { if (isSelected(root)) { - TreeIterator contentIterator = root.eAllContents(); - while(contentIterator.hasNext()) { - EObject contentElement = contentIterator.next(); - if (contentElement instanceof org.eclipse.uml2.uml.Class) { - testListObjectsToDisplay.add(contentElement); - } - } + filterAllContents(root, filter, rootList); } } - - - for(EObject element : testListObjectsToDisplay) { - if (element instanceof NamedElement) { - System.out.println(((NamedElement) element).getName() + ": " + isSelected(element)); - } else { - System.out.println(element.getClass() + ": " + isSelected(element)); - } - } - - - - } - public void filterByLambda(Function filter) { - for (EObject root : getSelectableElements()) { - if (isSelected(root)) { - TreeIterator contentIterator = root.eAllContents(); - while(contentIterator.hasNext()) { - EObject contentElement = contentIterator.next(); - if (filter.apply(contentElement)) { - testListObjectsToDisplay.add(contentElement); - } - } - } - } - - for (EObject object : testListObjectsToDisplay) { - if (object instanceof org.eclipse.uml2.uml.Class) { - org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; - classifierObject.getOwnedAttributes().toArray(); - classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); -// try { -// classifierObject.eResource().save(null); -// } catch (IOException e) { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } + + private void filterAllContents(EObject root, Function filter, Set rootList) { + Model filteredModelRoot = null; + Iterator contentIterator = root.eAllContents(); + while(contentIterator.hasNext()) { + EObject contentElement = contentIterator.next(); + if (filter.apply(contentElement)) { + //testListObjectsToDisplay.add(contentElement); + + filteredModelRoot = createFilteredModelRootIfNotExistent(filteredModelRoot, root); + attachElementToRoot(filteredModelRoot, contentElement); + + rootList.add(filteredModelRoot); } - } - - viewSelection = new ElementViewSelection(testListObjectsToDisplay); } - public void filterForName(String name) { - getSelectableElements().stream() - .filter(element -> !(element instanceof NamedElement)) - .forEach(element -> testListObjectsToDisplay.remove(element)); + + private void attachElementToRoot(Model root, EObject object) { + if (object instanceof Type) { + EObject objectCopy = EcoreUtil.copy(object); + root.getOwnedTypes().add((Type) objectCopy); + } else { + System.out.println("Warning: Undefined type: " + object.eClass()); + } - getSelectableElements().stream() - .filter(element -> (element instanceof NamedElement)) - .filter(element -> !name.equals(((NamedElement) element).getName())) - .forEach(element -> testListObjectsToDisplay.remove(element)); } - public void removeAttributes() { - for(EObject object : getSelectableElements()) { - if (isSelected(object) && (object instanceof Classifier)) { - Classifier currentClassifier = (Classifier) object; - EcoreUtil.removeAll(currentClassifier.getAllAttributes()); + + private Model createFilteredModelRootIfNotExistent(Model filteredRoot, EObject root) { + if (filteredRoot == null) { + if (root instanceof Model) { + return UMLFactory.eINSTANCE.createModel(); + } else { + throw new ImplementationError("nbruening: Not implemented yet"); } - } + } + return filteredRoot; + } - - private void deselect(EObject element) { - setSelected(element, false); + public void removeOwnedAttributesFromClasses() { +// for (EObject object : testListObjectsToDisplay) { +// if (object instanceof org.eclipse.uml2.uml.Class) { +// org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; +// classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); +// } +// } + + for (EObject root : rootList) { + TreeIterator content = root.eAllContents(); + List contentList = convertTreeIterator2List(content); + for (EObject object : contentList) { + if (object instanceof org.eclipse.uml2.uml.Class) { + org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; + classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); + } + } + } } - - - - private void selectAllElements() { - for (EObject element : getSelectableElements()) { - setSelected(element, true); + private List convertTreeIterator2List(TreeIterator content) { + List list = new LinkedList(); + while(content.hasNext()) { + list.add(content.next()); } - //getSelectableElements().stream().forEach(element -> setSelected(element, true)); + return list; } + @Override public boolean isValid() { diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index a29243e3b..943b4f89c 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17 Import-Package: org.junit.jupiter.api, org.junit.jupiter.api.extension, tools.vitruv.applications.viewfilter.util.framework, + tools.vitruv.applications.viewfilter.util.framework.impl, tools.vitruv.applications.viewfilter.util.framework.selectors Require-Bundle: tools.vitruv.testutils.vsum, org.eclipse.emf.compare, diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend index d5aebc054..ac2f71b85 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend @@ -31,6 +31,9 @@ import tools.vitruv.applications.viewfilter.utils.FluentUMLPackageBuilder import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceUtil.getFirstRootEObject import static extension tools.vitruv.applications.testutility.uml.UmlQueryUtil.* import org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl +import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType +import tools.vitruv.framework.views.ViewSelector +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView @ExtendWith(RegisterMetamodelsInStandalone) class FirstTest extends ViewBasedVitruvApplicationTest { @@ -92,6 +95,8 @@ class FirstTest extends ViewBasedVitruvApplicationTest { @Test def void testCreateFilteredUmlView() { var view = createFilteredUmlView(); + (viewType as FilterSupportingIdentityMappingViewType).updateView(view as ModifiableView); + view.selection view.viewType } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index bdb1bfbe5..b2ac2ead6 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -12,11 +12,14 @@ import tools.vitruv.framework.views.View; import tools.vitruv.applications.viewfilter.util.framework.FilterSupportingViewTypeFactory; +import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelector; import tools.vitruv.framework.views.CommittableView; import tools.vitruv.framework.views.ViewProvider; import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.ViewType; import tools.vitruv.framework.views.ViewTypeFactory; import tools.vitruv.testutils.TestViewFactory; @@ -30,6 +33,7 @@ public class ViewTestFactory extends TestViewFactory { private ViewProvider viewProvider; + ViewType viewType; public ViewTestFactory(ViewProvider viewProvider) { super(viewProvider); @@ -87,11 +91,13 @@ public void changeUmlView(Consumer modelModification) throws Ex public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes) { - FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName)); + viewType = FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName); + FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); //selector.selectElementsOfRootType(rootTypes); //selector.filterForTypeClass(); Function function = (EObject object) -> hasNoAttribute(selector, object, "niklasClass2"); - selector.filterByLambda(function); + selector.addElementsToSelectionByLambda(function); + selector.removeOwnedAttributesFromClasses(); // selector.getSelectableElements().stream() // .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) // .forEach(element -> selector.setSelected((EObject) element, true)); @@ -115,12 +121,11 @@ public View createFilteredForNoAttributesViewOfElements(String viewName, Collect private boolean hasNoAttribute(ViewSelector selector, EObject object, String name) { if (object instanceof org.eclipse.uml2.uml.Class) { -// if (object instanceof NamedElement) { -// if (name.equals(((NamedElement) object).getName())) { -// return true; -// } -// } - return true; + if (object instanceof NamedElement) { + if (name.equals(((NamedElement) object).getName())) { + return true; + } + } } return false; From 2d8b6461f8d4c903eeffb0566849acbca9d3a800 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 30 Dec 2023 22:41:44 +0100 Subject: [PATCH 08/62] Structural changes to make update of view possible --- ...lterSupportingIdentityMappingViewType.java | 12 +- .../FilterSupportingViewElementSelector.java | 80 ++++--- .../viewfilter/viewbuild/ViewFilter.java | 150 +++++++++++++ .../viewfilter/tests/BasicViewFilterTest.java | 210 ++++++++++++++++++ .../viewfilter/tests/FirstTest.xtend | 20 +- .../viewfilter/tests/ViewTestFactory.java | 23 +- 6 files changed, 441 insertions(+), 54 deletions(-) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index 1bc14782a..951d9aa66 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -38,6 +38,10 @@ * within the {@link ViewSource} to a created {@link View}. */ public class FilterSupportingIdentityMappingViewType extends AbstractViewType, HierarchicalId> { + + private Map mapOriginalRoot2RootStub; + + public FilterSupportingIdentityMappingViewType(String name) { super(name); } @@ -78,6 +82,7 @@ public FilterSupportingViewElementSelector createSelector(Change @Override public ModifiableView createView(FilterSupportingViewElementSelector selector) { checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); + mapOriginalRoot2RootStub = selector.getMapOriginalRoot2RootStub(); return new BasicView(selector.getViewType(), selector.getViewSource(), selector.getSelection()); } @@ -87,6 +92,7 @@ public void updateView(ModifiableView view) { viewResourceSet.getResources().forEach(Resource::unload); viewResourceSet.getResources().clear(); createViewResources(view, viewResourceSet); + }); } @@ -108,9 +114,11 @@ private Map createViewResources(ModifiableView view, Resourc Collection viewSources = view.getViewSource().getViewSourceModels(); ViewSelection selection = view.getSelection(); List resourcesWithSelectedElements = viewSources.stream() - .filter(resource -> resource.getContents().stream().anyMatch(selection::isViewObjectSelected)).toList(); + .filter(resource -> resource.getContents().stream() + .anyMatch(element -> mapOriginalRoot2RootStub.get(element) != null ? selection.isViewObjectSelected(mapOriginalRoot2RootStub.get(element)) : false)) + .toList(); return ResourceCopier.copyViewSourceResources(resourcesWithSelectedElements, viewResourceSet, - selection::isViewObjectSelected); + element -> mapOriginalRoot2RootStub.get(element) != null ? selection.isViewObjectSelected(mapOriginalRoot2RootStub.get(element)) : false); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index 37176bb7d..c091abce6 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -1,10 +1,12 @@ package tools.vitruv.applications.viewfilter.util.framework.selectors; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.function.Function; @@ -21,6 +23,7 @@ import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter.ViewFilterBuilder; import tools.vitruv.framework.views.ChangeableViewSource; import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.View; @@ -37,7 +40,12 @@ public class FilterSupportingViewElementSelector implements V private List testListObjectsToDisplay = new LinkedList(); - private Set rootList; + private Set rootListForView; + + //TODO nbruening: Javadoc + private Map mapOriginalRoot2RootStub; + + private ViewFilterBuilder viewFilterBuilder; public FilterSupportingViewElementSelector(ViewCreatingViewType, Id> viewType, ChangeableViewSource viewSource, Collection selectableElements) { @@ -47,16 +55,19 @@ public FilterSupportingViewElementSelector(ViewCreatingViewType selectableElementsCopy = EcoreUtil.copyAll(selectableElements); - ElementViewSelection _elementViewSelection = new ElementViewSelection(selectableElementsCopy); - this.viewSelection = _elementViewSelection; - rootList = new HashSet(); + //Collection selectableElementsCopy = EcoreUtil.copyAll(selectableElements); + this.viewSelection = new ElementViewSelection(selectableElements); + rootListForView = new HashSet(); + mapOriginalRoot2RootStub = new HashMap(); + viewFilterBuilder = new ViewFilterBuilder(); + } @Override public View createView() { - viewSelection = new ElementViewSelection(rootList); + viewSelection = new ElementViewSelection(rootListForView); + rootListForView.forEach(element -> setSelected(element, true)); //TODO nbruening ggf noch anpassen Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); return this.viewType.createView(this); @@ -71,25 +82,39 @@ public void selectElementsOfRootType(Collection> rootTypes) { public void addElementsToSelectionByLambda(Function filter) { for (EObject root : getSelectableElements()) { - if (isSelected(root)) { - filterAllContents(root, filter, rootList); - } + filterAllContents(root, filter, rootListForView); } } - private void filterAllContents(EObject root, Function filter, Set rootList) { - Model filteredModelRoot = null; + public void removeOwnedAttributesFromClasses() { + for (EObject root : rootListForView) { + TreeIterator content = root.eAllContents(); + List contentList = convertTreeIterator2List(content); + for (EObject object : contentList) { + if (object instanceof org.eclipse.uml2.uml.Class) { + org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; + classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); + } + } + } + } + + + private void filterAllContents(EObject root, Function filter, Set rootListForView) { + Model filteredModelRootStub = null; Iterator contentIterator = root.eAllContents(); while(contentIterator.hasNext()) { EObject contentElement = contentIterator.next(); if (filter.apply(contentElement)) { //testListObjectsToDisplay.add(contentElement); - filteredModelRoot = createFilteredModelRootIfNotExistent(filteredModelRoot, root); - attachElementToRoot(filteredModelRoot, contentElement); + filteredModelRootStub = createFilteredModelRootIfNotExistent(filteredModelRootStub, root); + EObject copyOfContentElement = EcoreUtil.copy(contentElement); + attachElementToRoot(filteredModelRootStub, copyOfContentElement); - rootList.add(filteredModelRoot); + rootListForView.add(filteredModelRootStub); + mapOriginalRoot2RootStub.put(root, filteredModelRootStub); } } } @@ -119,27 +144,6 @@ private Model createFilteredModelRootIfNotExistent(Model filteredRoot, EObject r } - public void removeOwnedAttributesFromClasses() { -// for (EObject object : testListObjectsToDisplay) { -// if (object instanceof org.eclipse.uml2.uml.Class) { -// org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; -// classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); -// } -// } - - for (EObject root : rootList) { - TreeIterator content = root.eAllContents(); - List contentList = convertTreeIterator2List(content); - for (EObject object : contentList) { - if (object instanceof org.eclipse.uml2.uml.Class) { - org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; - classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); - } - } - } - } - - private List convertTreeIterator2List(TreeIterator content) { List list = new LinkedList(); while(content.hasNext()) { @@ -147,8 +151,6 @@ private List convertTreeIterator2List(TreeIterator content) { } return list; } - - @Override public boolean isValid() { @@ -187,5 +189,9 @@ public ChangeableViewSource getViewSource() { public ViewCreatingViewType, Id> getViewType() { return this.viewType; } + + public Map getMapOriginalRoot2RootStub() { + return mapOriginalRoot2RootStub; + } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java new file mode 100644 index 000000000..7b3b5a6ab --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java @@ -0,0 +1,150 @@ +package tools.vitruv.applications.viewfilter.viewbuild; + +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.net4j.util.ImplementationError; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; + +public class ViewFilter { + + private Set rootListForView; + + //TODO nbruening: Javadoc + private Map mapOriginalRoot2RootStub; + + private final ViewFilterBuilder builder; + + private ViewFilter(ViewFilterBuilder viewFilterBuilder) { + builder = viewFilterBuilder; + } + + + public void filterElements(Collection roots) { + addElementsToSelectionByLambda(roots); + } + + + private void addElementsToSelectionByLambda(Collection roots) { + if (!builder.filterByLambdaActive) { + return; + } + for (EObject root : roots) { + filterAllContents(root, builder.filter, rootListForView); + } + } + + public void removeOwnedAttributesFromClasses() { + if (!builder.removeAttributesActive) { + return; + } + for (EObject root : rootListForView) { + TreeIterator content = root.eAllContents(); + List contentList = convertTreeIterator2List(content); + for (EObject object : contentList) { + if (object instanceof org.eclipse.uml2.uml.Class) { + org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; + classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); + } + } + } + } + + + private void filterAllContents(EObject root, Function filter, Set rootListForView) { + Model filteredModelRootStub = null; + Iterator contentIterator = root.eAllContents(); + while(contentIterator.hasNext()) { + EObject contentElement = contentIterator.next(); + if (filter.apply(contentElement)) { + //testListObjectsToDisplay.add(contentElement); + + filteredModelRootStub = createFilteredModelRootIfNotExistent(filteredModelRootStub, root); + EObject copyOfContentElement = EcoreUtil.copy(contentElement); + attachElementToRoot(filteredModelRootStub, copyOfContentElement); + + rootListForView.add(filteredModelRootStub); + mapOriginalRoot2RootStub.put(root, filteredModelRootStub); + } + } + } + + + private List convertTreeIterator2List(TreeIterator content) { + List list = new LinkedList(); + while(content.hasNext()) { + list.add(content.next()); + } + return list; + } + + + private void attachElementToRoot(Model root, EObject object) { + if (object instanceof Type) { + EObject objectCopy = EcoreUtil.copy(object); + root.getOwnedTypes().add((Type) objectCopy); + } else { + System.out.println("Warning: Undefined type: " + object.eClass()); + } + } + + + private Model createFilteredModelRootIfNotExistent(Model filteredRoot, EObject root) { + if (filteredRoot == null) { + if (root instanceof Model) { + return UMLFactory.eINSTANCE.createModel(); + } else { + throw new ImplementationError("nbruening: Not implemented yet"); + } + } + return filteredRoot; + } + + +//--------------------------------- + /** + * Builder for ViewFilter + */ + public static class ViewFilterBuilder { + + //optional parameters + private Boolean filterByLambdaActive = false; + + private Boolean removeAttributesActive = false; + + private Function filter; + + + public ViewFilterBuilder() { + + } + + public ViewFilterBuilder filterByLambda(Function filter) { + this.filterByLambdaActive = true; + this.filter = filter; + return this; + } + + public ViewFilterBuilder removeOwnedAttributes() { + this.removeAttributesActive = true; + return this; + } + + public ViewFilter build() { + return new ViewFilter(this); + } + + + } + +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java new file mode 100644 index 000000000..4dd0ef3f0 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -0,0 +1,210 @@ +package tools.vitruv.applications.viewfilter.tests; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.function.Consumer; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.uml2.uml.Comment; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.PackageableElement; +import org.eclipse.uml2.uml.PrimitiveType; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.xtend.lib.annotations.AccessorType; +import org.eclipse.xtend.lib.annotations.Accessors; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.Exceptions; +import org.eclipse.xtext.xbase.lib.InputOutput; +import org.eclipse.xtext.xbase.lib.ObjectExtensions; +import org.eclipse.xtext.xbase.lib.Pure; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; +import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; +import tools.vitruv.applications.testutility.uml.UmlQueryUtil; +import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; +import tools.vitruv.change.propagation.ChangePropagationSpecification; +import tools.vitruv.framework.views.CommittableView; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.vsum.VirtualModel; +import tools.vitruv.testutils.RegisterMetamodelsInStandalone; +import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; + +@ExtendWith(RegisterMetamodelsInStandalone.class) +public class BasicViewFilterTest extends ViewBasedVitruvApplicationTest { + + @Accessors(AccessorType.PROTECTED_GETTER) + private static final String UML_MODEL_NAME = "model"; + + @Accessors(AccessorType.PROTECTED_GETTER) + private static final String MODEL_FOLDER_NAME = "model"; + + @Accessors(AccessorType.PROTECTED_GETTER) + private static final String MODEL_FILE_EXTENSION = "uml"; + + @Accessors(AccessorType.PUBLIC_GETTER) + private org.eclipse.uml2.uml.Class class1; + + @Accessors(AccessorType.PUBLIC_GETTER) + private org.eclipse.uml2.uml.Class class2; + + protected ViewTestFactory improvedViewTestFactory; + + @Test + public void testCreateSystemConcept_PCM() { + System.out.println("Hello world"); + } + + @Test + public void testView() { + improvedViewTestFactory.createUmlView(); + } + + @Test + public void testCreateUmlPcmView() { + improvedViewTestFactory.createUmlAndPcmClassesView(); + } + + @Test + public void testCreateFilteredUmlView() { + View view = improvedViewTestFactory.createFilteredUmlView(this); +// ((FilterSupportingIdentityMappingViewType) improvedViewTestFactory.viewType) +// .updateView(((ModifiableView) view)); + + modifyModel(); + + view.update(); + + //view.getRootObjects(); + //Object object = view.withChangeDerivingTrait().getRootObjects().toArray()[0]; + view.getSelection(); + view.getRootObjects(); + view.getViewType(); + } + +// @Test +// public void testFilterForName() { +// final Procedure1 _function = (Model it) -> { +// it.setName((FirstTest.UML_MODEL_NAME + "big")); +// }; +// this.createAdvancedUmlModel(_function); +// } + + @Override + protected Iterable getChangePropagationSpecifications() { + CombinedPcmToUmlClassReactionsChangePropagationSpecification _combinedPcmToUmlClassReactionsChangePropagationSpecification = new CombinedPcmToUmlClassReactionsChangePropagationSpecification(); + CombinedUmlClassToPcmReactionsChangePropagationSpecification _combinedUmlClassToPcmReactionsChangePropagationSpecification = new CombinedUmlClassToPcmReactionsChangePropagationSpecification(); + return Collections.unmodifiableList( + CollectionLiterals.newArrayList( + _combinedPcmToUmlClassReactionsChangePropagationSpecification, + _combinedUmlClassToPcmReactionsChangePropagationSpecification)); + } + + @BeforeEach + public void setup() { + improvedViewTestFactory = new ViewTestFactory(getVirtualModel()); + final Procedure1 setNameFunction = (Model it) -> { + it.setName(UML_MODEL_NAME); + }; + createBiggerUmlModel(setNameFunction); + } + + protected void createBiggerUmlModel(final Procedure1 modelInitialization) { + try { + final Consumer firstChangeUmlFunction = (CommittableView it) -> { + final Model umlModel = UMLFactory.eINSTANCE.createModel(); + createAndRegisterRoot(it, umlModel, this.getUri(getProjectModelPath(UML_MODEL_NAME))); + modelInitialization.apply(umlModel); + }; + improvedViewTestFactory.changeUmlView(firstChangeUmlFunction); + + getUserInteraction().addNextSingleSelection(1); + getUserInteraction().addNextTextInput("model/System.system"); + + final Consumer secondChangeUmlFunction = (CommittableView it) -> { + org.eclipse.uml2.uml.Package _createPackage = UMLFactory.eINSTANCE.createPackage(); + Procedure1 setNameFunction = (org.eclipse.uml2.uml.Package it_1) -> { + it_1.setName("niklasPackage"); + }; + + org.eclipse.uml2.uml.Package package1 = UMLFactory.eINSTANCE.createPackage(); + package1.setName("niklasPackage"); + + class1 = package1.createOwnedClass("niklasClass1", false); + + getUserInteraction().addNextSingleSelection(1); + getUserInteraction().addNextTextInput("model/System.system"); + org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage("niklasNestedPackage"); + + class2 = package2.createOwnedClass("niklasClass2", false); + EList _packagedElements = getDefaultUmlModel(it).getPackagedElements(); + _packagedElements.add(package1); + + // create Attribute for class2 + PrimitiveType stringPrimitiveType = package1.createOwnedPrimitiveType("niklasPrimitiveType1"); + class2.createOwnedAttribute("niklasClass2Attribute", stringPrimitiveType, 0, 1); + }; + improvedViewTestFactory.changeUmlView(secondChangeUmlFunction); + + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + } + + + private void modifyModel() { + try { + getUserInteraction().addNextSingleSelection(1); + getUserInteraction().addNextTextInput("model/System.system"); + + Consumer changeUmlFunction = (CommittableView it) -> { + org.eclipse.uml2.uml.Package package3 = UMLFactory.eINSTANCE.createPackage(); + package3.setName("niklasPackage3"); + + org.eclipse.uml2.uml.Class class3 = package3.createOwnedClass("niklasClass3", false); + + class2.addKeyword("subsequentlyAddedKeyword"); + + final Comment comment = this.class2.createOwnedComment(); + comment.addKeyword("bla"); + + getDefaultUmlModel(it).getPackagedElements().add(package3); + }; + + improvedViewTestFactory.changeUmlView(changeUmlFunction); + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + } + + + + protected void createAndRegisterRoot(final View view, final EObject rootObject, final URI persistenceUri) { + view.registerRoot(rootObject, persistenceUri); + } + + protected Path getProjectModelPath(final String modelName) { + return Path.of(MODEL_FOLDER_NAME).resolve(((modelName + ".") + MODEL_FILE_EXTENSION)); + } + + protected Model getDefaultUmlModel(final View view) { + return UmlQueryUtil.claimUmlModel(view, UML_MODEL_NAME); + } + + @Pure + public org.eclipse.uml2.uml.Class getClass1() { + return this.class1; + } + + @Pure + public org.eclipse.uml2.uml.Class getClass2() { + return this.class2; + } + +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend index ac2f71b85..8d6aefa5e 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend @@ -71,7 +71,7 @@ class FirstTest extends ViewBasedVitruvApplicationTest { @BeforeEach def void setup() { - viewTestFactory = new FirstTestFactory(virtualModel) + //viewTestFactory = new FirstTestFactory(virtualModel) improvedViewTestFactory = new ViewTestFactory(virtualModel) createBiggerUmlModel[name = UML_MODEL_NAME] } @@ -95,6 +95,8 @@ class FirstTest extends ViewBasedVitruvApplicationTest { @Test def void testCreateFilteredUmlView() { var view = createFilteredUmlView(); + //modifyModel() + (viewType as FilterSupportingIdentityMappingViewType).updateView(view as ModifiableView); view.selection @@ -218,6 +220,22 @@ class FirstTest extends ViewBasedVitruvApplicationTest { } + + private def void modifyModel() { + userInteraction.addNextSingleSelection(1) + userInteraction.addNextTextInput("model/System.system") + changeUmlView[ + val package3 = UMLFactory.eINSTANCE.createPackage => [ + it.name = "niklasPackage3" + ] + val class3 = package3.createOwnedClass("niklasClass3", false) + class2.addKeyword("subsequentlyAddedKeyword") + val comment = class2.createOwnedComment + comment.addKeyword("bla") + defaultUmlModel.packagedElements += package3 + ] + } + protected def void createAdvancedUmlModel((Model)=>void modelInitialization) { diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index b2ac2ead6..1ef5741a5 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -60,6 +60,14 @@ public View createFilteredUmlView(FirstTest test) { return view; } + public View createFilteredUmlView(BasicViewFilterTest test) { + Collection> rootTypes = createCollectionOfRootTypes(Model.class); + View view = createFilteredForNoAttributesViewOfElements("UML", rootTypes); + view.getSelection().isViewObjectSelected(test.getClass1()); + view.getSelection().isViewObjectSelected(test.getClass2()); + return view; + } + //--------------Boilerplate code -----------------// // @@ -69,7 +77,6 @@ public View createFilteredViewOfElements(String viewName, Collection> r selector.getSelectableElements().stream() .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) .forEach(element -> selector.setSelected(element, true)); - //selector.getSelectableElements().stream().forEach(element -> selector.setSelected(element, true)); View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); return view; @@ -93,15 +100,9 @@ public void changeUmlView(Consumer modelModification) throws Ex public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes) { viewType = FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); - //selector.selectElementsOfRootType(rootTypes); - //selector.filterForTypeClass(); Function function = (EObject object) -> hasNoAttribute(selector, object, "niklasClass2"); selector.addElementsToSelectionByLambda(function); - selector.removeOwnedAttributesFromClasses(); -// selector.getSelectableElements().stream() -// .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) -// .forEach(element -> selector.setSelected((EObject) element, true)); - + selector.removeOwnedAttributesFromClasses(); View view = selector.createView(); ViewSelection selection = view.getSelection(); @@ -113,7 +114,6 @@ public View createFilteredForNoAttributesViewOfElements(String viewName, Collect } } - assertThat("view must not be null", view, not(equalTo(null))); return view; } @@ -129,11 +129,6 @@ private boolean hasNoAttribute(ViewSelector selector, EObject object, String nam } return false; -// TreeIterator eAllContents = object.eAllContents(); -// while(eAllContents.hasNext()) { -// EObject currentObject = eAllContents.next(); -// -// } } From f828e70fe4300167f4b3f607f045ebc1d48d2b4b Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 4 Jan 2024 20:15:33 +0100 Subject: [PATCH 09/62] - Translated FirstTest.xtend into BasicViewTest.java, minor fixes Some minor fixes, added modifyView method --- .../{ViewFilter.java => ViewFilterImpl.java} | 0 .../viewfilter/tests/BasicViewFilterTest.java | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/{ViewFilter.java => ViewFilterImpl.java} (100%) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index 4dd0ef3f0..9cfbc74cf 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -5,8 +5,10 @@ import java.util.function.Consumer; import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; +import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.PackageableElement; @@ -172,8 +174,22 @@ private void modifyModel() { class2.addKeyword("subsequentlyAddedKeyword"); final Comment comment = this.class2.createOwnedComment(); + comment.setBody("niklasCommentClass2"); + String name = "niklasClass2"; comment.addKeyword("bla"); + TreeIterator umlIterator = getDefaultUmlModel(it).eAllContents(); + org.eclipse.uml2.uml.Class searchedClass = null; + while ((searchedClass == null) && (umlIterator.hasNext())) { + EObject next = umlIterator.next(); + if (next instanceof org.eclipse.uml2.uml.Class) { + if (name.equals(((Classifier) next).getName())) { + searchedClass = (org.eclipse.uml2.uml.Class) next; + } + } + } + searchedClass.getOwnedComments().add(comment); + getDefaultUmlModel(it).getPackagedElements().add(package3); }; From eaa780a6dd8c501052a49095d78c8daf8148be92 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 4 Jan 2024 20:17:38 +0100 Subject: [PATCH 10/62] improved selection of individual elements as preparation Preparation to make update of filtered view work --- .../AbstractFilterSupportingViewType.java | 15 ++ .../util/framework/impl/BasicFilterView.java | 38 ++++ ...lterSupportingIdentityMappingViewType.java | 5 +- .../impl/FilteredViewCreatingViewType.java | 8 + .../FilterSupportingViewElementSelector.java | 213 +++++++----------- .../viewfilter/viewbuild/ViewFilter.java | 14 ++ .../viewfilter/viewbuild/ViewFilterImpl.java | 33 ++- 7 files changed, 175 insertions(+), 151 deletions(-) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java new file mode 100644 index 000000000..b532bc621 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java @@ -0,0 +1,15 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl; + +import tools.vitruv.framework.views.ViewSelector; + +public abstract class AbstractFilterSupportingViewType extends AbstractViewType implements FilteredViewCreatingViewType { + + public AbstractFilterSupportingViewType(String name) { + super(name); + } + + + + + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java new file mode 100644 index 000000000..b5a753f36 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java @@ -0,0 +1,38 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl; + +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; + +import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewSelector; + +public class BasicFilterView extends BasicView { + + private ViewFilter viewFilter; + + protected BasicFilterView(FilteredViewCreatingViewType viewType, + ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { + super(viewType, viewSource, selection); + this.viewFilter = viewFilter; + } + + @Override + public void modifyContents(Procedure1 modificationFunction) { + super.modifyContents(modificationFunction); + filterSelectedElements(); + } + + + private void filterSelectedElements() { + Set filteredElements = viewFilter.filterElements(getRootObjects()); + setSelection(new ElementViewSelection(filteredElements)); + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index 951d9aa66..f69d9fae7 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -37,7 +37,7 @@ * selection mechanism and providing a one-to-one (identity) mapping of elements * within the {@link ViewSource} to a created {@link View}. */ -public class FilterSupportingIdentityMappingViewType extends AbstractViewType, HierarchicalId> { +public class FilterSupportingIdentityMappingViewType extends AbstractFilterSupportingViewType, HierarchicalId> { private Map mapOriginalRoot2RootStub; @@ -83,7 +83,7 @@ public FilterSupportingViewElementSelector createSelector(Change public ModifiableView createView(FilterSupportingViewElementSelector selector) { checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); mapOriginalRoot2RootStub = selector.getMapOriginalRoot2RootStub(); - return new BasicView(selector.getViewType(), selector.getViewSource(), selector.getSelection()); + return new BasicFilterView(selector.getViewType(), selector.getViewSource(), selector.getSelection(), selector.getViewFilter()); } @Override @@ -92,7 +92,6 @@ public void updateView(ModifiableView view) { viewResourceSet.getResources().forEach(Resource::unload); viewResourceSet.getResources().clear(); createViewResources(view, viewResourceSet); - }); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java new file mode 100644 index 000000000..9bbfdc23b --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java @@ -0,0 +1,8 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl; + +import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.ViewType; + +public interface FilteredViewCreatingViewType extends ViewCreatingViewType { + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index c091abce6..3d3989f83 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -1,6 +1,7 @@ package tools.vitruv.applications.viewfilter.util.framework.selectors; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -21,9 +22,12 @@ import com.google.common.base.Preconditions; +import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; -import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter.ViewFilterBuilder; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl.ViewFilterBuilder; import tools.vitruv.framework.views.ChangeableViewSource; import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.View; @@ -31,125 +35,56 @@ import tools.vitruv.framework.views.ViewSelector; public class FilterSupportingViewElementSelector implements ViewSelector { - + private ModifiableViewSelection viewSelection; - + private ChangeableViewSource viewSource; - - private final ViewCreatingViewType, Id> viewType; - - private List testListObjectsToDisplay = new LinkedList(); - - private Set rootListForView; - - //TODO nbruening: Javadoc - private Map mapOriginalRoot2RootStub; - + + private final FilteredViewCreatingViewType, Id> viewType; + private ViewFilterBuilder viewFilterBuilder; + private ViewFilterImpl viewFilter; - public FilterSupportingViewElementSelector(ViewCreatingViewType, Id> viewType, ChangeableViewSource viewSource, Collection selectableElements) { - Preconditions.checkArgument((selectableElements != null), "selectable elements must not be null"); - Preconditions.checkArgument((viewType != null), "view type must not be null"); - Preconditions.checkArgument((viewSource != null), "view source must not be null"); + public FilterSupportingViewElementSelector( + FilteredViewCreatingViewType, Id> viewType, + ChangeableViewSource viewSource, Collection selectableElements) { + Preconditions.checkArgument((selectableElements != null), "selectable elements must not be null"); + Preconditions.checkArgument((viewType != null), "view type must not be null"); + Preconditions.checkArgument((viewSource != null), "view source must not be null"); this.viewType = viewType; this.viewSource = viewSource; - //Copy underlying model - //Collection selectableElementsCopy = EcoreUtil.copyAll(selectableElements); - this.viewSelection = new ElementViewSelection(selectableElements); - rootListForView = new HashSet(); - mapOriginalRoot2RootStub = new HashMap(); + // Copy underlying model + // Collection selectableElementsCopy = + // EcoreUtil.copyAll(selectableElements); + this.viewSelection = new ElementViewSelection(selectableElements); viewFilterBuilder = new ViewFilterBuilder(); - + } - @Override public View createView() { + viewFilter = viewFilterBuilder.build(); + Set rootListForView = getViewFilter().filterElements(getSelectableElements()); + viewSelection = new ElementViewSelection(rootListForView); rootListForView.forEach(element -> setSelected(element, true)); - //TODO nbruening ggf noch anpassen - Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); - return this.viewType.createView(this); + // TODO nbruening ggf noch anpassen + Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); + return this.viewType.createView(this); } - + public void selectElementsOfRootType(Collection> rootTypes) { - getSelectableElements().stream() - .filter(element -> !(rootTypes.stream().anyMatch(it -> it.isInstance(element)))) - .forEach(element -> setSelected(element, false)); + getSelectableElements().stream().filter(element -> !(rootTypes.stream().anyMatch(it -> it.isInstance(element)))) + .forEach(element -> setSelected(element, false)); } - - + public void addElementsToSelectionByLambda(Function filter) { - for (EObject root : getSelectableElements()) { - filterAllContents(root, filter, rootListForView); - } - } - - - public void removeOwnedAttributesFromClasses() { - for (EObject root : rootListForView) { - TreeIterator content = root.eAllContents(); - List contentList = convertTreeIterator2List(content); - for (EObject object : contentList) { - if (object instanceof org.eclipse.uml2.uml.Class) { - org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; - classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); - } - } - } - } - - - private void filterAllContents(EObject root, Function filter, Set rootListForView) { - Model filteredModelRootStub = null; - Iterator contentIterator = root.eAllContents(); - while(contentIterator.hasNext()) { - EObject contentElement = contentIterator.next(); - if (filter.apply(contentElement)) { - //testListObjectsToDisplay.add(contentElement); - - filteredModelRootStub = createFilteredModelRootIfNotExistent(filteredModelRootStub, root); - EObject copyOfContentElement = EcoreUtil.copy(contentElement); - attachElementToRoot(filteredModelRootStub, copyOfContentElement); - - rootListForView.add(filteredModelRootStub); - mapOriginalRoot2RootStub.put(root, filteredModelRootStub); - } - } - } - - - private void attachElementToRoot(Model root, EObject object) { - if (object instanceof Type) { - EObject objectCopy = EcoreUtil.copy(object); - root.getOwnedTypes().add((Type) objectCopy); - } else { - System.out.println("Warning: Undefined type: " + object.eClass()); - } - - } - - - private Model createFilteredModelRootIfNotExistent(Model filteredRoot, EObject root) { - if (filteredRoot == null) { - if (root instanceof Model) { - return UMLFactory.eINSTANCE.createModel(); - } else { - throw new ImplementationError("nbruening: Not implemented yet"); - } - } - return filteredRoot; - - } - - - private List convertTreeIterator2List(TreeIterator content) { - List list = new LinkedList(); - while(content.hasNext()) { - list.add(content.next()); - } - return list; + viewFilterBuilder.filterByLambda(filter); + } + + public void removeOwnedAttributesFromClasses() { + viewFilterBuilder.removeOwnedAttributes(); } @Override @@ -158,40 +93,44 @@ public boolean isValid() { } @Override - public ViewSelection getSelection() { - return new ElementViewSelection(this.viewSelection); - } - - public Collection getSelectableElements() { - return this.viewSelection.getSelectableElements(); - } - - public boolean isSelectable(final EObject eObject) { - return this.viewSelection.isSelectable(eObject); - } - - public boolean isSelected(final EObject eObject) { - return this.viewSelection.isSelected(eObject); - } - - public boolean isViewObjectSelected(final EObject eObject) { - return this.viewSelection.isViewObjectSelected(eObject); - } - - public void setSelected(final EObject eObject, final boolean selected) { - this.viewSelection.setSelected(eObject, selected); - } - - public ChangeableViewSource getViewSource() { - return this.viewSource; - } - - public ViewCreatingViewType, Id> getViewType() { - return this.viewType; - } - - public Map getMapOriginalRoot2RootStub() { - return mapOriginalRoot2RootStub; - } + public ViewSelection getSelection() { + return new ElementViewSelection(this.viewSelection); + } + + public Collection getSelectableElements() { + return this.viewSelection.getSelectableElements(); + } + + public boolean isSelectable(final EObject eObject) { + return this.viewSelection.isSelectable(eObject); + } + + public boolean isSelected(final EObject eObject) { + return this.viewSelection.isSelected(eObject); + } + + public boolean isViewObjectSelected(final EObject eObject) { + return this.viewSelection.isViewObjectSelected(eObject); + } + + public void setSelected(final EObject eObject, final boolean selected) { + this.viewSelection.setSelected(eObject, selected); + } + + public ChangeableViewSource getViewSource() { + return this.viewSource; + } + + public FilteredViewCreatingViewType, Id> getViewType() { + return this.viewType; + } + + public Map getMapOriginalRoot2RootStub() { + return getViewFilter() != null ? getViewFilter().getMapOriginalRoot2RootStub() : Collections.emptyMap(); + } + + public ViewFilter getViewFilter() { + return viewFilter; + } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java new file mode 100644 index 000000000..46bddcabb --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java @@ -0,0 +1,14 @@ +package tools.vitruv.applications.viewfilter.viewbuild; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; + +public interface ViewFilter { + + Set filterElements(Collection roots); + + Map getMapOriginalRoot2RootStub(); +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index 7b3b5a6ab..3bd26f5c9 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -1,6 +1,8 @@ package tools.vitruv.applications.viewfilter.viewbuild; import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -16,7 +18,7 @@ import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLFactory; -public class ViewFilter { +public class ViewFilterImpl implements ViewFilter { private Set rootListForView; @@ -25,13 +27,17 @@ public class ViewFilter { private final ViewFilterBuilder builder; - private ViewFilter(ViewFilterBuilder viewFilterBuilder) { + private ViewFilterImpl(ViewFilterBuilder viewFilterBuilder) { builder = viewFilterBuilder; + rootListForView = new HashSet(); + mapOriginalRoot2RootStub = new HashMap(); } - public void filterElements(Collection roots) { + public Set filterElements(Collection roots) { addElementsToSelectionByLambda(roots); + removeOwnedAttributesFromClasses(); + return rootListForView; } @@ -44,7 +50,8 @@ private void addElementsToSelectionByLambda(Collection roots) { } } - public void removeOwnedAttributesFromClasses() { + + private void removeOwnedAttributesFromClasses() { if (!builder.removeAttributesActive) { return; } @@ -74,7 +81,7 @@ private void filterAllContents(EObject root, Function filter, attachElementToRoot(filteredModelRootStub, copyOfContentElement); rootListForView.add(filteredModelRootStub); - mapOriginalRoot2RootStub.put(root, filteredModelRootStub); + getMapOriginalRoot2RootStub().put(root, filteredModelRootStub); } } } @@ -111,9 +118,14 @@ private Model createFilteredModelRootIfNotExistent(Model filteredRoot, EObject r } -//--------------------------------- + public Map getMapOriginalRoot2RootStub() { + return mapOriginalRoot2RootStub; + } + + + //--------------------------------- /** - * Builder for ViewFilter + * Builder for ViewFilterImpl */ public static class ViewFilterBuilder { @@ -125,8 +137,7 @@ public static class ViewFilterBuilder { private Function filter; - public ViewFilterBuilder() { - + public ViewFilterBuilder() { } public ViewFilterBuilder filterByLambda(Function filter) { @@ -140,8 +151,8 @@ public ViewFilterBuilder removeOwnedAttributes() { return this; } - public ViewFilter build() { - return new ViewFilter(this); + public ViewFilterImpl build() { + return new ViewFilterImpl(this); } From 1618324d5583c7a176ca05174349a897ce79c77d Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 4 Jan 2024 21:31:26 +0100 Subject: [PATCH 11/62] Filtering View is now updated in case the underlying model is modified --- .../viewfilter/util/framework/impl/BasicFilterView.java | 9 ++++++--- .../viewfilter/viewbuild/ViewFilterImpl.java | 2 +- .../viewfilter/tests/BasicViewFilterTest.java | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java index b5a753f36..da2de3bd4 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java @@ -15,7 +15,7 @@ public class BasicFilterView extends BasicView { - private ViewFilter viewFilter; + private final ViewFilter viewFilter; protected BasicFilterView(FilteredViewCreatingViewType viewType, ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { @@ -31,8 +31,11 @@ public void modifyContents(Procedure1 modificationFunction) private void filterSelectedElements() { - Set filteredElements = viewFilter.filterElements(getRootObjects()); - setSelection(new ElementViewSelection(filteredElements)); + if (viewFilter != null) { + //If the viewFilter has already been set, use it.. + Set filteredElements = viewFilter.filterElements(getRootObjects()); + setSelection(new ElementViewSelection(filteredElements)); + } } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index 3bd26f5c9..f37ea9e49 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -29,12 +29,12 @@ public class ViewFilterImpl implements ViewFilter { private ViewFilterImpl(ViewFilterBuilder viewFilterBuilder) { builder = viewFilterBuilder; - rootListForView = new HashSet(); mapOriginalRoot2RootStub = new HashMap(); } public Set filterElements(Collection roots) { + rootListForView = new HashSet(); addElementsToSelectionByLambda(roots); removeOwnedAttributesFromClasses(); return rootListForView; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index 9cfbc74cf..bb1f47503 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -175,7 +175,7 @@ private void modifyModel() { final Comment comment = this.class2.createOwnedComment(); comment.setBody("niklasCommentClass2"); - String name = "niklasClass2"; + String searchedName = "niklasClass2"; comment.addKeyword("bla"); TreeIterator umlIterator = getDefaultUmlModel(it).eAllContents(); @@ -183,7 +183,7 @@ private void modifyModel() { while ((searchedClass == null) && (umlIterator.hasNext())) { EObject next = umlIterator.next(); if (next instanceof org.eclipse.uml2.uml.Class) { - if (name.equals(((Classifier) next).getName())) { + if (searchedName.equals(((Classifier) next).getName())) { searchedClass = (org.eclipse.uml2.uml.Class) next; } } From 270d94ee513c884a8cbf0e81310cdf41e2c5beba Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:14:21 +0100 Subject: [PATCH 12/62] - First steps for pcm support --- .../viewfilter/viewbuild/ViewFilterImpl.java | 38 +++++++++- .../viewfilter/tests/BasicViewFilterTest.java | 75 +++++++++++++++++++ .../viewfilter/tests/ViewTestFactory.java | 51 ++++++++++--- .../viewfilter/utils/PcmQueryUtil.xtend | 28 +++++++ .../PcmUmlClassApplicationTestHelper.xtend | 9 +++ 5 files changed, 188 insertions(+), 13 deletions(-) create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmQueryUtil.xtend diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index f37ea9e49..98ce3e117 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -17,6 +17,11 @@ import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLFactory; +import org.palladiosimulator.pcm.PcmFactory; +import org.palladiosimulator.pcm.repository.DataType; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.repository.RepositoryComponent; +import org.palladiosimulator.pcm.repository.RepositoryFactory; public class ViewFilterImpl implements ViewFilter { @@ -69,7 +74,7 @@ private void removeOwnedAttributesFromClasses() { private void filterAllContents(EObject root, Function filter, Set rootListForView) { - Model filteredModelRootStub = null; + EObject filteredModelRootStub = null; Iterator contentIterator = root.eAllContents(); while(contentIterator.hasNext()) { EObject contentElement = contentIterator.next(); @@ -96,21 +101,46 @@ private List convertTreeIterator2List(TreeIterator content) { } - private void attachElementToRoot(Model root, EObject object) { + private void attachElementToRoot(EObject root, EObject object) { + if (root instanceof Model) { + attachElementToRootUml((Model) root, object); + } else if (root instanceof Repository) { + attachElementToRootPcm((Repository) root, object); + } else { + throw new ImplementationError("Not implemented yet! Undefined type: " + object.eClass()); + } + } + + + private void attachElementToRootUml(Model root, EObject object) { if (object instanceof Type) { EObject objectCopy = EcoreUtil.copy(object); root.getOwnedTypes().add((Type) objectCopy); } else { System.out.println("Warning: Undefined type: " + object.eClass()); } + } + + + private void attachElementToRootPcm(Repository root, EObject object) { + if (object instanceof RepositoryComponent) { + root.getComponents__Repository().add((RepositoryComponent) object); + } else if (object instanceof DataType) { + root.getDataTypes__Repository().add((DataType) object); + } else { + System.out.println("Warning: Undefined type: " + object.eClass()); + } } - private Model createFilteredModelRootIfNotExistent(Model filteredRoot, EObject root) { + private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObject root) { if (filteredRoot == null) { if (root instanceof Model) { return UMLFactory.eINSTANCE.createModel(); - } else { + } else if (root instanceof Repository) { + return RepositoryFactory.eINSTANCE.createRepository(); + } + else { throw new ImplementationError("nbruening: Not implemented yet"); } } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index bb1f47503..41e947a61 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -25,12 +25,19 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.palladiosimulator.pcm.repository.BasicComponent; +import org.palladiosimulator.pcm.repository.CompositeDataType; +import org.palladiosimulator.pcm.repository.DataType; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.repository.RepositoryFactory; import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; import tools.vitruv.applications.testutility.uml.UmlQueryUtil; import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; +import tools.vitruv.applications.viewfilter.utils.PcmQueryUtil; +import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper; import tools.vitruv.change.propagation.ChangePropagationSpecification; import tools.vitruv.framework.views.CommittableView; import tools.vitruv.framework.views.View; @@ -43,6 +50,12 @@ public class BasicViewFilterTest extends ViewBasedVitruvApplicationTest { @Accessors(AccessorType.PROTECTED_GETTER) private static final String UML_MODEL_NAME = "model"; + + @Accessors(AccessorType.PROTECTED_GETTER) + private static final String PCM_MODEL_NAME = "Repository"; + + + private static final String PCM_REPOSITORY_FILE_EXTENSION = "repository"; @Accessors(AccessorType.PROTECTED_GETTER) private static final String MODEL_FOLDER_NAME = "model"; @@ -76,6 +89,7 @@ public void testCreateUmlPcmView() { @Test public void testCreateFilteredUmlView() { View view = improvedViewTestFactory.createFilteredUmlView(this); + // View view = improvedViewTestFactory.createFilteredPcmView(); // ((FilterSupportingIdentityMappingViewType) improvedViewTestFactory.viewType) // .updateView(((ModifiableView) view)); @@ -107,6 +121,7 @@ protected Iterable getChangePropagatio _combinedPcmToUmlClassReactionsChangePropagationSpecification, _combinedUmlClassToPcmReactionsChangePropagationSpecification)); } + @BeforeEach public void setup() { @@ -115,7 +130,23 @@ public void setup() { it.setName(UML_MODEL_NAME); }; createBiggerUmlModel(setNameFunction); + createPcmModel(); } + + protected void createUmlModel(final Procedure1 modelInitialization) { + try { + final Consumer firstChangeUmlFunction = (CommittableView it) -> { + final Model umlModel = UMLFactory.eINSTANCE.createModel(); + createAndRegisterRoot(it, umlModel, this.getUri(getProjectModelPath(UML_MODEL_NAME))); + modelInitialization.apply(umlModel); + }; + improvedViewTestFactory.changeUmlView(firstChangeUmlFunction); + + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + } + protected void createBiggerUmlModel(final Procedure1 modelInitialization) { try { @@ -198,8 +229,48 @@ private void modifyModel() { throw Exceptions.sneakyThrow(_e); } } + + + protected void createPcmModel() { + + getUserInteraction().addNextTextInput(PcmUmlClassApplicationTestHelper.UML_MODEL_FILE); + Consumer createPcmRepoFunction = (CommittableView it) -> { + Repository repository = RepositoryFactory.eINSTANCE.createRepository(); + repository.setEntityName(PCM_MODEL_NAME); + it.registerRoot(repository, getUri(getPcmProjectModelPath(repository.getEntityName(), PCM_REPOSITORY_FILE_EXTENSION))); + //createAndRegisterRoot(it, repository, this.getUri(getProjectModelPath(PCM_MODEL_NAME))); + }; + + try { + improvedViewTestFactory.changePcmView(createPcmRepoFunction); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Consumer changePcmFunction = (CommittableView it) -> { + Repository repository = getDefaultPcmRepository(it); + BasicComponent createBasicComponent = RepositoryFactory.eINSTANCE.createBasicComponent(); + createBasicComponent.setEntityName("Niklas Basic PCM component 1"); + repository.getComponents__Repository().add(createBasicComponent); + + CompositeDataType compositeDataType1 = RepositoryFactory.eINSTANCE.createCompositeDataType(); + compositeDataType1.setEntityName("niklasPcmCompositeDataType1"); + repository.getDataTypes__Repository().add(compositeDataType1); + + }; + + try { + improvedViewTestFactory.changePcmView(changePcmFunction); + } catch (Exception e) { + e.printStackTrace(); + } + } + private Path getPcmProjectModelPath(String modelName, String modelFileExtension) { + return Path.of("pcm").resolve(modelName + "." + modelFileExtension); + } protected void createAndRegisterRoot(final View view, final EObject rootObject, final URI persistenceUri) { view.registerRoot(rootObject, persistenceUri); @@ -212,6 +283,10 @@ protected Path getProjectModelPath(final String modelName) { protected Model getDefaultUmlModel(final View view) { return UmlQueryUtil.claimUmlModel(view, UML_MODEL_NAME); } + + private Repository getDefaultPcmRepository(View view) { + return PcmQueryUtil.claimPcmRepository(view, PCM_MODEL_NAME); + } @Pure public org.eclipse.uml2.uml.Class getClass1() { diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 1ef5741a5..5c573f4a2 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -28,6 +28,7 @@ import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.NamedElement; +import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.repository.RepositoryComponent; public class ViewTestFactory extends TestViewFactory { @@ -45,6 +46,12 @@ public View createUmlView() { Collection> rootTypes = createCollectionOfRootTypes(Model.class); return createViewOfElements("UML", rootTypes); } + + private View createPcmView() { + Collection> rootTypes = createCollectionOfRootTypes(Repository.class); + rootTypes.add(RepositoryComponent.class); + return createViewOfElements("PCM packages and components", rootTypes); + } public View createUmlAndPcmClassesView() { Collection> rootTypes = createCollectionOfRootTypes(createCollectionOfRootTypes(RepositoryComponent.class), Model.class); @@ -68,29 +75,44 @@ public View createFilteredUmlView(BasicViewFilterTest test) { return view; } + public View createFilteredPcmView() { + Collection> rootTypes = createCollectionOfRootTypes(Repository.class); + return createFilteredForNoAttributesViewOfElements("PCM", rootTypes); + } + //--------------Boilerplate code -----------------// // - public View createFilteredViewOfElements(String viewName, Collection> rootTypes) { + public View createViewOfElements(String viewName, Collection> rootTypes) { ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); selector.getSelectableElements().stream() .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) .forEach(element -> selector.setSelected(element, true)); +// if (!selector.getSelectableElements().isEmpty()) { +// Object obj = (selector.getSelectableElements().toArray())[0]; +// boolean bla = obj instanceof Repository; +// } + View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); return view; - } + } - /** - * Changes the UML view containing all UML models as root elements - * according to the given modification function. - * Records the performed changes, commits the recorded changes, and closes the view afterwards. - */ public void changeUmlView(Consumer modelModification) throws Exception { changeViewRecordingChanges(createUmlView(), modelModification); } + + /** + * Changes the PCM view containing all PCM packages and classes as root elements + * according to the given modification function. + * Records the performed changes, commits the recorded changes, and closes the view afterwards. + * @throws Exception + */ + public void changePcmView(Consumer modelModification) throws Exception { + changeViewRecordingChanges(createPcmView(), modelModification); + } @@ -100,7 +122,7 @@ public void changeUmlView(Consumer modelModification) throws Ex public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes) { viewType = FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); - Function function = (EObject object) -> hasNoAttribute(selector, object, "niklasClass2"); + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass3"); selector.addElementsToSelectionByLambda(function); selector.removeOwnedAttributesFromClasses(); @@ -119,7 +141,18 @@ public View createFilteredForNoAttributesViewOfElements(String viewName, Collect } - private boolean hasNoAttribute(ViewSelector selector, EObject object, String name) { + private boolean hasInstanceName(EObject object, String name) { + if (object instanceof org.palladiosimulator.pcm.core.entity.NamedElement) { + if (name.equals(((org.palladiosimulator.pcm.core.entity.NamedElement) object).getEntityName())) { + return true; + } + } + return false; + } + + + + private boolean hasNoAttribute(EObject object, String name) { if (object instanceof org.eclipse.uml2.uml.Class) { if (object instanceof NamedElement) { if (name.equals(((NamedElement) object).getName())) { diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmQueryUtil.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmQueryUtil.xtend new file mode 100644 index 000000000..a0f4014e4 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmQueryUtil.xtend @@ -0,0 +1,28 @@ +package tools.vitruv.applications.viewfilter.utils + +import edu.kit.ipd.sdq.activextendannotations.Utility +import tools.vitruv.framework.views.View +import org.palladiosimulator.pcm.repository.Repository +import org.palladiosimulator.pcm.system.System +import static extension edu.kit.ipd.sdq.commons.util.java.lang.IterableUtil.claimOne + +@Utility +class PcmQueryUtil { + + static def getPcmSystem(View view) { + view.getRootObjects(System) + } + + static def getPcmRepository(View view) { + view.getRootObjects(Repository) + } + + static def claimPcmRepository(View view, String packageName) { + var list = getPcmRepository(view).iterator.filter[it.entityName.equals(packageName)].toList + getPcmRepository(view).iterator.filter[it.entityName.equals(packageName)].toIterable.claimOne + } + + static def claimPcmSystem(View view) { + getPcmSystem(view).claimOne + } +} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend index 720bfcee3..a327d91ba 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/PcmUmlClassApplicationTestHelper.xtend @@ -11,4 +11,13 @@ class PcmUmlClassApplicationTestHelper { public static val COMPONENT_NAME_LSC = "testComponent" public static val COMPONENT_NAME_2_USC = "TestComponent_2" public static val COMPONENT_NAME_2_LSC = "testComponent_2" + + public static final String MODEL_DIRECTORY = "model"; + public static final String PCM_REPOSITORY_FILE_NAME = "Repository"; + public static final String UML_MODEL_FILE_NAME = PCM_REPOSITORY_FILE_NAME; + public static final String UML_EXTENSION = ".uml"; + + + public static val UML_MODEL_FILE = MODEL_DIRECTORY + "/" + UML_MODEL_FILE_NAME + + UML_EXTENSION } \ No newline at end of file From 5f481f8c41387a46e4adaa7445db2c1645d3c31f Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 20 Jan 2024 17:19:45 +0100 Subject: [PATCH 13/62] Save progress to make update and informationView work --- .../META-INF/MANIFEST.MF | 1 + .../UmlToInformationTransformator.java | 37 ++++ .../viewfilter/helpers/ViewFilterHelper.java | 23 +++ .../FilterSupportingViewTypeFactory.java | 9 +- ...ormationFilterIdentityMappingViewType.java | 58 ++++++ .../util/framework/impl/BasicFilterView.java | 41 ----- .../util/framework/impl/BasicView.xtend | 2 +- ...lterSupportingIdentityMappingViewType.java | 17 +- .../FilterSupportingViewElementSelector.java | 11 +- .../viewfilter/viewbuild/ViewFilter.java | 3 +- .../viewfilter/viewbuild/ViewFilterImpl.java | 90 ++++++--- .../viewfilter/views/BasicFilterView.java | 67 +++++++ .../views/BasicInformationFilterView.java | 98 ++++++++++ .../views/InformationDisplayView.java | 94 ++++++++++ .../META-INF/MANIFEST.MF | 6 +- .../viewfilter/tests/BasicViewFilterTest.java | 38 +++- .../viewfilter/tests/EmfTest.java | 172 ++++++++++++++++++ .../viewfilter/tests/ViewTestFactory.java | 21 ++- 18 files changed, 705 insertions(+), 83 deletions(-) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/UmlToInformationTransformator.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java delete mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF index 5af91fe59..13dd13766 100644 --- a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF +++ b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF @@ -19,3 +19,4 @@ Bundle-Vendor: vitruv.tools Export-Package: tools.vitruv.applications.viewfilter.util.framework, tools.vitruv.applications.viewfilter.util.framework.impl, tools.vitruv.applications.viewfilter.util.framework.selectors +Import-Package: com.niklas.niklasproject.niklasdomain diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/UmlToInformationTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/UmlToInformationTransformator.java new file mode 100644 index 000000000..1f4bbe92d --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/UmlToInformationTransformator.java @@ -0,0 +1,37 @@ +package tools.vitruv.application.viewfilter.transformation; + +import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; +import com.niklas.niklasproject.niklasdomain.SingleInformation; + +import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.uml2.uml.Model; + +public class UmlToInformationTransformator { + + public SingleInformation transform(EObject root) { + if (!(root instanceof Model)) { + //not an Uml model + return null; + } + //TODO nbruening hier noch generischer machen + SingleInformation createSingleInformation = NiklasdomainFactory.eINSTANCE.createSingleInformation(); + createSingleInformation.setTitle("Anzahl Elemente"); + + List allElements = ViewFilterHelper.convertTreeIterator2List(root.eAllContents()); + + int count = 0; + + for (EObject element : allElements) { + if (element instanceof org.eclipse.uml2.uml.Class) { + count++; + } + } + + createSingleInformation.setValue(count); + return createSingleInformation; + } +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java new file mode 100644 index 000000000..9f17f2305 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java @@ -0,0 +1,23 @@ +package tools.vitruv.applications.viewfilter.helpers; + +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; + +public class ViewFilterHelper { + + private ViewFilterHelper() { + //static helper class - should not be instantiated + } + + public static List convertTreeIterator2List(TreeIterator content) { + List list = new LinkedList(); + while(content.hasNext()) { + list.add(content.next()); + } + return list; + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java index e634c5fec..18658f583 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java @@ -1,5 +1,8 @@ package tools.vitruv.applications.viewfilter.util.framework; +import org.eclipse.net4j.util.ImplementationError; + +import tools.vitruv.applications.viewfilter.util.framework.impl.AbstractingInformationFilterIdentityMappingViewType; import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; import tools.vitruv.framework.views.ViewSelector; import tools.vitruv.framework.views.ViewType; @@ -10,5 +13,9 @@ public static ViewType createFilterSupportingIdentityMap return new FilterSupportingIdentityMappingViewType(name); } - + + + public static ViewType createAbstractedFilterViewViewType(String name) { + return new AbstractingInformationFilterIdentityMappingViewType(name); + } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java new file mode 100644 index 000000000..5cdceedab --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java @@ -0,0 +1,58 @@ +package tools.vitruv.applications.viewfilter.util.framework.impl; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + +import com.niklas.niklasproject.niklasdomain.InformationStructure; +import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; +import com.niklas.niklasproject.niklasdomain.SingleInformation; + +import tools.vitruv.application.viewfilter.transformation.UmlToInformationTransformator; +import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; +import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelector; +import tools.vitruv.applications.viewfilter.views.BasicFilterView; +import tools.vitruv.applications.viewfilter.views.BasicInformationFilterView; +import tools.vitruv.change.atomic.hid.HierarchicalId; + +public class AbstractingInformationFilterIdentityMappingViewType extends FilterSupportingIdentityMappingViewType { + + public AbstractingInformationFilterIdentityMappingViewType(String name) { + super(name); + } + + + @Override + public ModifiableView createView(FilterSupportingViewElementSelector selector) { + checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); + //mapOriginalRoot2RootStub = selector.getMapOriginalRoot2RootStub(); +// List roots = new ArrayList(); +// selector.getViewSource().getViewSourceModels().forEach(it -> roots.addAll(it.getContents())); + +// UmlToInformationTransformator transformator = new UmlToInformationTransformator(); +// InformationStructure informationStructure = NiklasdomainFactory.eINSTANCE.createInformationStructure(); +// EList singleinformationList = informationStructure.getSingleinformation(); +// +// for(EObject root : roots) { +// SingleInformation transformResult = transformator.transform(root); +// if (transformResult != null) { +// singleinformationList.add(transformResult); +// } +// } +// +// List selectionList = new ArrayList(); +// selectionList.add(informationStructure); +// ElementViewSelection elementViewSelection = new ElementViewSelection(selectionList); +// elementViewSelection.setSelected(informationStructure, true); + + //Hier in SingleInformation-Meta-Modell übertragen + BasicInformationFilterView view = new BasicInformationFilterView(selector.getViewType(), selector.getViewSource(), selector.getSelection(), selector.getViewFilter(), selector.getMapOriginalRoot2RootStub()); + return view; + } + +} + \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java deleted file mode 100644 index da2de3bd4..000000000 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicFilterView.java +++ /dev/null @@ -1,41 +0,0 @@ -package tools.vitruv.applications.viewfilter.util.framework.impl; - -import java.util.Set; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; - -import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; -import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; -import tools.vitruv.change.atomic.hid.HierarchicalId; -import tools.vitruv.framework.views.ChangeableViewSource; -import tools.vitruv.framework.views.ViewSelection; -import tools.vitruv.framework.views.ViewSelector; - -public class BasicFilterView extends BasicView { - - private final ViewFilter viewFilter; - - protected BasicFilterView(FilteredViewCreatingViewType viewType, - ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { - super(viewType, viewSource, selection); - this.viewFilter = viewFilter; - } - - @Override - public void modifyContents(Procedure1 modificationFunction) { - super.modifyContents(modificationFunction); - filterSelectedElements(); - } - - - private void filterSelectedElements() { - if (viewFilter != null) { - //If the viewFilter has already been set, use it.. - Set filteredElements = viewFilter.filterElements(getRootObjects()); - setSelection(new ElementViewSelection(filteredElements)); - } - } - -} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend index bd2ad5b88..86b90b12b 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend @@ -24,7 +24,7 @@ import static com.google.common.base.Preconditions.checkState import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceSetUtil.withGlobalFactories -package class BasicView implements ModifiableView, ChangePropagationListener { +public class BasicView implements ModifiableView, ChangePropagationListener { @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) var ViewSelection selection @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index f69d9fae7..bf2d60350 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -21,6 +21,7 @@ import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; import tools.vitruv.applications.viewfilter.util.framework.selectors.DirectViewElementSelector; import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelector; +import tools.vitruv.applications.viewfilter.views.BasicFilterView; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.atomic.uuid.Uuid; import tools.vitruv.change.atomic.uuid.UuidResolver; @@ -39,9 +40,6 @@ */ public class FilterSupportingIdentityMappingViewType extends AbstractFilterSupportingViewType, HierarchicalId> { - private Map mapOriginalRoot2RootStub; - - public FilterSupportingIdentityMappingViewType(String name) { super(name); } @@ -82,7 +80,6 @@ public FilterSupportingViewElementSelector createSelector(Change @Override public ModifiableView createView(FilterSupportingViewElementSelector selector) { checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); - mapOriginalRoot2RootStub = selector.getMapOriginalRoot2RootStub(); return new BasicFilterView(selector.getViewType(), selector.getViewSource(), selector.getSelection(), selector.getViewFilter()); } @@ -112,6 +109,18 @@ public void commitViewChanges(ModifiableView view, VitruviusChange createViewResources(ModifiableView view, ResourceSet viewResourceSet) { Collection viewSources = view.getViewSource().getViewSourceModels(); ViewSelection selection = view.getSelection(); + Map mapOriginalRoot2RootStub = ((BasicFilterView) view).getMapOriginalRoot2RootStub(); + for (Resource resource : viewSources) { + EList contents = resource.getContents(); + for (EObject root : contents) { + EObject rootStub = mapOriginalRoot2RootStub.get(root); + if (rootStub != null) { + Boolean selected = selection.isViewObjectSelected(rootStub); + System.out.println("Bla"); + } + } + + } List resourcesWithSelectedElements = viewSources.stream() .filter(resource -> resource.getContents().stream() .anyMatch(element -> mapOriginalRoot2RootStub.get(element) != null ? selection.isViewObjectSelected(mapOriginalRoot2RootStub.get(element)) : false)) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index 3d3989f83..8fce5bf91 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -28,6 +28,7 @@ import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl.ViewFilterBuilder; +import tools.vitruv.applications.viewfilter.views.BasicFilterView; import tools.vitruv.framework.views.ChangeableViewSource; import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.View; @@ -45,6 +46,9 @@ public class FilterSupportingViewElementSelector implements V private ViewFilterBuilder viewFilterBuilder; private ViewFilterImpl viewFilter; + + //TODO nbruening: Replace by Interface + private BasicFilterView createdView; public FilterSupportingViewElementSelector( FilteredViewCreatingViewType, Id> viewType, @@ -65,13 +69,14 @@ public FilterSupportingViewElementSelector( @Override public View createView() { viewFilter = viewFilterBuilder.build(); - Set rootListForView = getViewFilter().filterElements(getSelectableElements()); + Set rootListForView = getViewFilter().filterElements(getSelectableElements(), viewSource.getViewSourceModels()); viewSelection = new ElementViewSelection(rootListForView); rootListForView.forEach(element -> setSelected(element, true)); // TODO nbruening ggf noch anpassen Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); - return this.viewType.createView(this); + createdView = (BasicFilterView) this.viewType.createView(this); + return createdView; } public void selectElementsOfRootType(Collection> rootTypes) { @@ -126,7 +131,7 @@ public FilteredViewCreatingViewType, Id> } public Map getMapOriginalRoot2RootStub() { - return getViewFilter() != null ? getViewFilter().getMapOriginalRoot2RootStub() : Collections.emptyMap(); + return createdView != null ? createdView.getMapOriginalRoot2RootStub() : Collections.emptyMap(); } public ViewFilter getViewFilter() { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java index 46bddcabb..b59ad9509 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java @@ -5,10 +5,11 @@ import java.util.Set; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; public interface ViewFilter { - Set filterElements(Collection roots); + Set filterElements(Collection roots, Collection viewSources); Map getMapOriginalRoot2RootStub(); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index 98ce3e117..f7d35b013 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -1,5 +1,6 @@ package tools.vitruv.applications.viewfilter.viewbuild; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -12,6 +13,7 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.net4j.util.ImplementationError; import org.eclipse.uml2.uml.Model; @@ -23,6 +25,8 @@ import org.palladiosimulator.pcm.repository.RepositoryComponent; import org.palladiosimulator.pcm.repository.RepositoryFactory; +import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; + public class ViewFilterImpl implements ViewFilter { private Set rootListForView; @@ -38,20 +42,26 @@ private ViewFilterImpl(ViewFilterBuilder viewFilterBuilder) { } - public Set filterElements(Collection roots) { + + public Set filterElements(Collection roots, Collection viewSources) { + Map newMapOriginalRoot2RootStub = new HashMap(); rootListForView = new HashSet(); - addElementsToSelectionByLambda(roots); + List rootsInViewSource = extractRootsInViewSource(viewSources, roots); + addElementsToSelectionByLambda(rootsInViewSource, newMapOriginalRoot2RootStub); removeOwnedAttributesFromClasses(); + mapOriginalRoot2RootStub = newMapOriginalRoot2RootStub; return rootListForView; } - private void addElementsToSelectionByLambda(Collection roots) { + + + private void addElementsToSelectionByLambda(List roots, Map newMapOriginalRoot2RootStub) { if (!builder.filterByLambdaActive) { return; } for (EObject root : roots) { - filterAllContents(root, builder.filter, rootListForView); + filterAllContents(root, builder.filter, rootListForView, newMapOriginalRoot2RootStub); } } @@ -62,7 +72,7 @@ private void removeOwnedAttributesFromClasses() { } for (EObject root : rootListForView) { TreeIterator content = root.eAllContents(); - List contentList = convertTreeIterator2List(content); + List contentList = ViewFilterHelper.convertTreeIterator2List(content); for (EObject object : contentList) { if (object instanceof org.eclipse.uml2.uml.Class) { org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; @@ -73,31 +83,28 @@ private void removeOwnedAttributesFromClasses() { } - private void filterAllContents(EObject root, Function filter, Set rootListForView) { + private void filterAllContents(EObject root, Function filter, Set rootListForView, Map newMapOriginalRoot2RootStub) { EObject filteredModelRootStub = null; Iterator contentIterator = root.eAllContents(); while(contentIterator.hasNext()) { EObject contentElement = contentIterator.next(); if (filter.apply(contentElement)) { - //testListObjectsToDisplay.add(contentElement); - filteredModelRootStub = createFilteredModelRootIfNotExistent(filteredModelRootStub, root); + filteredModelRootStub = createAndRegisterModelRootIfNotExistent(filteredModelRootStub, root, newMapOriginalRoot2RootStub); EObject copyOfContentElement = EcoreUtil.copy(contentElement); attachElementToRoot(filteredModelRootStub, copyOfContentElement); - - rootListForView.add(filteredModelRootStub); - getMapOriginalRoot2RootStub().put(root, filteredModelRootStub); } } } - - private List convertTreeIterator2List(TreeIterator content) { - List list = new LinkedList(); - while(content.hasNext()) { - list.add(content.next()); - } - return list; + private List extractRootsInViewSource(Collection viewSources, Collection roots) { + List resourcesWithSelectedElements = viewSources.stream() + .filter(resource -> resource.getContents().stream() + .anyMatch(element -> mapOriginalRoot2RootStub.get(element) != null ? roots.contains(mapOriginalRoot2RootStub.get(element)) : false)) + .toList(); + List extractedRoots = new ArrayList(); + resourcesWithSelectedElements.forEach(it -> extractedRoots.addAll(it.getContents())); + return extractedRoots; } @@ -132,21 +139,48 @@ private void attachElementToRootPcm(Repository root, EObject object) { } } - - private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObject root) { + private EObject createAndRegisterModelRootIfNotExistent(EObject filteredRoot, EObject root, Map newMapOriginalRoot2RootStub) { if (filteredRoot == null) { - if (root instanceof Model) { - return UMLFactory.eINSTANCE.createModel(); - } else if (root instanceof Repository) { - return RepositoryFactory.eINSTANCE.createRepository(); - } - else { - throw new ImplementationError("nbruening: Not implemented yet"); + EObject modelRoot = createFilteredModelRootIfNotExistent(filteredRoot, root); + rootListForView.add(modelRoot); + newMapOriginalRoot2RootStub.put(root, modelRoot); + return modelRoot; + } else { + return filteredRoot; + } + + } + + + private EObject findOriginalRoot(EObject root) { + + + if ((!mapOriginalRoot2RootStub.isEmpty()) && mapOriginalRoot2RootStub.containsValue(root)) { + Set keySet = mapOriginalRoot2RootStub.keySet(); + for (EObject key : keySet) { + if (mapOriginalRoot2RootStub.get(key).equals(root)) { + return key; + } } + throw new IllegalStateException("Value should be in map, but could not be found"); + } + return root; + } + + + private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObject root) { + if (root instanceof Model) { + return UMLFactory.eINSTANCE.createModel(); + } else if (root instanceof Repository) { + return RepositoryFactory.eINSTANCE.createRepository(); + } + else { + throw new ImplementationError("nbruening: Not implemented yet"); } - return filteredRoot; } + + public Map getMapOriginalRoot2RootStub() { return mapOriginalRoot2RootStub; diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java new file mode 100644 index 000000000..2dbd79e30 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -0,0 +1,67 @@ +package tools.vitruv.applications.viewfilter.views; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; + +import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; +import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; +import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.ModifiableViewSelection; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewSelector; + +public class BasicFilterView extends BasicView { + + private final ViewFilter viewFilter; + + + public BasicFilterView(FilteredViewCreatingViewType viewType, + ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { + super(viewType, viewSource, selection); + this.viewFilter = viewFilter; +// ModifiableViewSelection filteredSelection = filterElementsForSelection(); +// updateSelectedElements(filteredSelection); + + } + + @Override + public void modifyContents(Procedure1 modificationFunction) { + super.modifyContents(modificationFunction); + ModifiableViewSelection filteredSelection = null; + if (viewFilter != null) { + filteredSelection = filterElementsForSelection(); + } + updateSelectedElements(filteredSelection); + } + + + protected ModifiableViewSelection filterElementsForSelection() { + //If the viewFilter has already been set, use it.. + Set filteredElements = viewFilter.filterElements(getRootObjects(), getViewSource().getViewSourceModels()); + ModifiableViewSelection elementViewSelection = new ElementViewSelection(filteredElements); + filteredElements.forEach(it -> elementViewSelection.setSelected(it, true)); + return elementViewSelection; + } + + + protected void updateSelectedElements(ModifiableViewSelection selection) { + //TODO nbruening merge with filterElementsForSelection method? + if (viewFilter != null) { + setSelection(selection); + } + } + + + public Map getMapOriginalRoot2RootStub() { + return viewFilter != null ? viewFilter.getMapOriginalRoot2RootStub() : Collections.emptyMap(); + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java new file mode 100644 index 000000000..3dae09939 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java @@ -0,0 +1,98 @@ +package tools.vitruv.applications.viewfilter.views; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; + +import com.niklas.niklasproject.niklasdomain.InformationStructure; +import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; +import com.niklas.niklasproject.niklasdomain.SingleInformation; + +import tools.vitruv.application.viewfilter.transformation.UmlToInformationTransformator; +import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; +import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; +import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.ModifiableViewSelection; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewSelector; + +public class BasicInformationFilterView extends BasicFilterView { + + protected Map mapOriginalRoot2InformationRoot; + protected Map mapOriginalRoot2FilteredRootStub; + + + public BasicInformationFilterView(FilteredViewCreatingViewType viewType, + ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter, Map mapOriginalRoot2RootStub) { + super(viewType, viewSource, selection, viewFilter); + mapOriginalRoot2InformationRoot = new HashMap(); + this.mapOriginalRoot2FilteredRootStub = reverseMap(mapOriginalRoot2RootStub); + } + + + @Override + protected void updateSelectedElements(ModifiableViewSelection selection) { + if (selection == null) { + throw new NullPointerException("selection is null"); + } + UmlToInformationTransformator transformator = new UmlToInformationTransformator(); + InformationStructure informationStructure = NiklasdomainFactory.eINSTANCE.createInformationStructure(); + EList singleinformationList = informationStructure.getSingleinformation(); + + for(EObject root : extractSelectedElements(selection)) { + SingleInformation transformResult = transformator.transform(root); + if (transformResult != null) { + singleinformationList.add(transformResult); +// mapOriginalRoot2RootStub. +// mapOriginalRoot2RootStub_.put(mapOriginalRoot2RootStub.get(root)), ) + } + } + + for (EObject key : mapOriginalRoot2FilteredRootStub.keySet()) { + getMapOriginalRoot2InformationRoot().put(key, informationStructure); + } + + List selectionList = new ArrayList(); + selectionList.add(informationStructure); + ElementViewSelection elementViewSelection = new ElementViewSelection(selectionList); + elementViewSelection.setSelected(informationStructure, true); + setSelection(elementViewSelection); + } + + + private List extractSelectedElements(ModifiableViewSelection selection) { + List selectedElements = new LinkedList(); + for(EObject root : getRootObjects()) { + if (selection.isViewObjectSelected(root)) { + selectedElements.add(root); + } + } + return selectedElements; + } + + + private Map reverseMap(Map map) { + Map myNewHashMap = new HashMap<>(); + for(Map.Entry entry : map.entrySet()){ + myNewHashMap.put(entry.getValue(), entry.getKey()); + } + return myNewHashMap; + } + + + public Map getMapOriginalRoot2InformationRoot() { + return mapOriginalRoot2InformationRoot; + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java new file mode 100644 index 000000000..4edb47cf0 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java @@ -0,0 +1,94 @@ +package tools.vitruv.applications.viewfilter.views; + +import java.util.Collection; +import java.util.List; +import java.util.function.Function; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.xtext.xbase.lib.IterableExtensions; +import org.eclipse.xtext.xbase.lib.ListExtensions; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Iterables; + +import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.change.atomic.uuid.Uuid; +import tools.vitruv.change.composite.description.PropagatedChange; +import tools.vitruv.change.composite.description.VitruviusChange; +import tools.vitruv.change.composite.propagation.ChangePropagationListener; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.CommittableView; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.ViewType; +import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; + +public class InformationDisplayView extends BasicView implements View, ChangePropagationListener { + + + private ResourceSet viewResourceSet; + + private boolean closed = false; + +// private ViewCreatingViewType viewType; +// +// private ChangeableViewSource viewSource; +// +// private ViewSelection viewSelection; + + + + + public InformationDisplayView(ViewCreatingViewType viewType, ChangeableViewSource viewSource, ViewSelection viewSelection) { + super(viewType, viewSource, viewSelection); +// this.viewType = viewType; +// this.viewSource = viewSource; +// this.viewSelection = viewSelection; + + } + + +// @Override +// public void close() throws Exception { +// if (!closed) { +// closed = true; +// viewResourceSet.getResources().forEach(it -> it.unload()); +// viewResourceSet.getResources().clear(); +// removeChangeListeners(viewResourceSet); +// } +// getViewSource().removeChangePropagationListener(this); +// } + + + @Override + public boolean isModified() { + return false; + } + + @Override + public boolean isOutdated() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void update() { + // TODO Auto-generated method stub + + } + +// @Override +// public boolean isClosed() { +// // TODO Auto-generated method stub +// return false; +// } + + +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index 943b4f89c..cfb9d51ac 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -5,7 +5,8 @@ Bundle-SymbolicName: tools.vitruv.applications.viewfilter.tests Bundle-Version: 3.0.1.qualifier Automatic-Module-Name: tools.vitruv.applications.viewfilter.tests Bundle-RequiredExecutionEnvironment: JavaSE-17 -Import-Package: org.junit.jupiter.api, +Import-Package: com.niklas.niklasproject.niklasdomain, + org.junit.jupiter.api, org.junit.jupiter.api.extension, tools.vitruv.applications.viewfilter.util.framework, tools.vitruv.applications.viewfilter.util.framework.impl, @@ -23,6 +24,7 @@ Require-Bundle: tools.vitruv.testutils.vsum, org.palladiosimulator.pcm, edu.kit.ipd.sdq.commons.util.emf, slf4j.api;bundle-version="2.0.9", - org.emftext.language.java;bundle-version="1.4.1" + org.emftext.language.java;bundle-version="1.4.1", + org.eclipse.emf.ecore Export-Package: tools.vitruv.applications.viewfilter.tests Bundle-Vendor: vitruv.tools diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index 41e947a61..8c89d2ff7 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -1,8 +1,12 @@ package tools.vitruv.applications.viewfilter.tests; +import com.niklas.niklasproject.niklasdomain.InformationStructure; +import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; + import java.nio.file.Path; import java.util.Collections; import java.util.function.Consumer; +import java.util.function.Function; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; @@ -11,6 +15,7 @@ import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.PackageableElement; import org.eclipse.uml2.uml.PrimitiveType; import org.eclipse.uml2.uml.UMLFactory; @@ -92,6 +97,9 @@ public void testCreateFilteredUmlView() { // View view = improvedViewTestFactory.createFilteredPcmView(); // ((FilterSupportingIdentityMappingViewType) improvedViewTestFactory.viewType) // .updateView(((ModifiableView) view)); + view.update(); + view.update(); + view.getRootObjects(); modifyModel(); @@ -103,6 +111,22 @@ public void testCreateFilteredUmlView() { view.getRootObjects(); view.getViewType(); } + + @Test + public void testCreateCountingView() { + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + View view = improvedViewTestFactory.createCountUmlElementsView(function); + view.getSelection(); + view.getRootObjects(); + + modifyModel(); + + view.update(); + + view.getSelection(); + } + + // @Test // public void testFilterForName() { @@ -130,7 +154,7 @@ public void setup() { it.setName(UML_MODEL_NAME); }; createBiggerUmlModel(setNameFunction); - createPcmModel(); + //createPcmModel(); } protected void createUmlModel(final Procedure1 modelInitialization) { @@ -297,5 +321,17 @@ public org.eclipse.uml2.uml.Class getClass1() { public org.eclipse.uml2.uml.Class getClass2() { return this.class2; } + + private boolean hasNoAttribute(EObject object, String name) { + if (object instanceof org.eclipse.uml2.uml.Class) { + if (object instanceof NamedElement) { + if (name.equals(((NamedElement) object).getName())) { + return true; + } + } + + } + return false; + } } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java new file mode 100644 index 000000000..2e76ece89 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java @@ -0,0 +1,172 @@ +package tools.vitruv.applications.viewfilter.tests; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.function.Consumer; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.common.util.WrappedException; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.PackageableElement; +import org.eclipse.uml2.uml.PrimitiveType; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.resource.UMLResource; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.Exceptions; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; +import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; +import tools.vitruv.change.propagation.ChangePropagationSpecification; +import tools.vitruv.framework.views.CommittableView; +import tools.vitruv.framework.views.View; +import tools.vitruv.testutils.RegisterMetamodelsInStandalone; +import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; + +@ExtendWith(RegisterMetamodelsInStandalone.class) +public class EmfTest extends ViewBasedVitruvApplicationTest { + + + private static final ResourceSet RESOURCE_SET; + + static { + RESOURCE_SET = new ResourceSetImpl(); + } + + + @Test + public void testtest() { + + } + + + @Test + public void testCreateFilteredUmlView() { + Model model = UMLFactory.eINSTANCE.createModel(); + Model umlMetaModel = (Model) load(URI.createURI(UMLResource.UML_METAMODEL_URI)); + Class createClass = UMLFactory.eINSTANCE.createClass(); + System.out.println("Test"); + Model umlMetaModelCopy = EcoreUtil.copy(umlMetaModel); + (umlMetaModelCopy.eClass()).getEPackage().getEFactoryInstance(); + + //EFactory eFactoryInstance = ((EPackage) umlMetaModel).getEFactoryInstance(); + + //EcoreUtil.create(umlMetaModelCopy); + + EObject root = umlMetaModelCopy; + TreeIterator content = root.eAllContents(); + List contentList = convertTreeIterator2List(content); + for (EObject object : contentList) { + if (object instanceof org.eclipse.uml2.uml.Classifier) { + org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; + classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); + } + } + + EFactory eFactoryInstance = (umlMetaModelCopy.eClass()).getEPackage().getEFactoryInstance(); + + + + } + + private List convertTreeIterator2List(TreeIterator content) { + List list = new LinkedList(); + while(content.hasNext()) { + list.add(content.next()); + } + return list; + } + + + @Override + protected Iterable getChangePropagationSpecifications() { + CombinedPcmToUmlClassReactionsChangePropagationSpecification _combinedPcmToUmlClassReactionsChangePropagationSpecification = new CombinedPcmToUmlClassReactionsChangePropagationSpecification(); + CombinedUmlClassToPcmReactionsChangePropagationSpecification _combinedUmlClassToPcmReactionsChangePropagationSpecification = new CombinedUmlClassToPcmReactionsChangePropagationSpecification(); + return Collections.unmodifiableList( + CollectionLiterals.newArrayList( + _combinedPcmToUmlClassReactionsChangePropagationSpecification, + _combinedUmlClassToPcmReactionsChangePropagationSpecification)); + } + + + private static org.eclipse.uml2.uml.Package load(URI uri) { + //org.eclipse.uml2.uml.Package package_ = null; + org.eclipse.uml2.uml.Package package_ = null; + + try { + //Stackoverflow + RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); + // Load the requested resource + Resource resource = RESOURCE_SET.getResource(uri, true); + + // Get the first (should be only) package from it (Stackoverflow should take the first Package for non uml) + package_ = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.PACKAGE); + //package_ = resource.getContents().get(0); + } catch (WrappedException we) { + System.out.println(we.getMessage()); + System.exit(1); + } + + return package_; + } + + +// protected void createBiggerUmlModel(final Procedure1 modelInitialization) { +// try { +// final Consumer firstChangeUmlFunction = (CommittableView it) -> { +// final Model umlModel = UMLFactory.eINSTANCE.createModel(); +// createAndRegisterRoot(it, umlModel, this.getUri(getProjectModelPath(UML_MODEL_NAME))); +// modelInitialization.apply(umlModel); +// }; +// improvedViewTestFactory.changeUmlView(firstChangeUmlFunction); +// +// getUserInteraction().addNextSingleSelection(1); +// getUserInteraction().addNextTextInput("model/System.system"); +// +// final Consumer secondChangeUmlFunction = (CommittableView it) -> { +// org.eclipse.uml2.uml.Package _createPackage = UMLFactory.eINSTANCE.createPackage(); +// Procedure1 setNameFunction = (org.eclipse.uml2.uml.Package it_1) -> { +// it_1.setName("niklasPackage"); +// }; +// +// org.eclipse.uml2.uml.Package package1 = UMLFactory.eINSTANCE.createPackage(); +// package1.setName("niklasPackage"); +// +// org.eclipse.uml2.uml.Class class1 = package1.createOwnedClass("niklasClass1", false); +// +// getUserInteraction().addNextSingleSelection(1); +// getUserInteraction().addNextTextInput("model/System.system"); +// org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage("niklasNestedPackage"); +// +// org.eclipse.uml2.uml.ClassClass class2 = package2.createOwnedClass("niklasClass2", false); +// EList _packagedElements = getDefaultUmlModel(it).getPackagedElements(); +// _packagedElements.add(package1); +// +// // create Attribute for class2 +// PrimitiveType stringPrimitiveType = package1.createOwnedPrimitiveType("niklasPrimitiveType1"); +// class2.createOwnedAttribute("niklasClass2Attribute", stringPrimitiveType, 0, 1); +// }; +// improvedViewTestFactory.changeUmlView(secondChangeUmlFunction); +// +// } catch (Throwable _e) { +// throw Exceptions.sneakyThrow(_e); +// } +// } + +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 5c573f4a2..09f55bc2d 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -81,6 +81,13 @@ public View createFilteredPcmView() { } + public View createCountUmlElementsView(Function filterFunction) { + Collection> rootTypes = createCollectionOfRootTypes(Model.class); + return createAbstractedFilteredView("Information Page", rootTypes, filterFunction); + + } + + //--------------Boilerplate code -----------------// // @@ -119,10 +126,22 @@ public void changePcmView(Consumer modelModification) throws Ex //-------------End of Boilerplate code----------------// + public View createAbstractedFilteredView(String viewName, Collection> rootTypes, Function filterFunction) { + viewType = FilterSupportingViewTypeFactory.createAbstractedFilterViewViewType(viewName); + FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); + selector.addElementsToSelectionByLambda(filterFunction); + selector.removeOwnedAttributesFromClasses(); + + View view = selector.createView(); + assertThat("view must not be null", view, not(equalTo(null))); + return view; + } + + public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes) { viewType = FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass3"); + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); selector.addElementsToSelectionByLambda(function); selector.removeOwnedAttributesFromClasses(); From 7246f81921fae571c9033f52bbb8cb21e757d39a Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 26 Jan 2024 18:49:55 +0100 Subject: [PATCH 14/62] Fixed update-mechanism for BasicFilterView --- ...lterSupportingIdentityMappingViewType.java | 20 +------ .../FilterSupportingViewElementSelector.java | 6 +- .../viewfilter/viewbuild/ViewFilter.java | 4 +- .../viewfilter/viewbuild/ViewFilterImpl.java | 18 ++---- .../viewfilter/views/BasicFilterView.java | 56 +++++++++++++++---- .../viewfilter/tests/BasicViewFilterTest.java | 1 + 6 files changed, 57 insertions(+), 48 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index bf2d60350..90c5e9b5c 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -108,25 +108,11 @@ public void commitViewChanges(ModifiableView view, VitruviusChange createViewResources(ModifiableView view, ResourceSet viewResourceSet) { Collection viewSources = view.getViewSource().getViewSourceModels(); - ViewSelection selection = view.getSelection(); - Map mapOriginalRoot2RootStub = ((BasicFilterView) view).getMapOriginalRoot2RootStub(); - for (Resource resource : viewSources) { - EList contents = resource.getContents(); - for (EObject root : contents) { - EObject rootStub = mapOriginalRoot2RootStub.get(root); - if (rootStub != null) { - Boolean selected = selection.isViewObjectSelected(rootStub); - System.out.println("Bla"); - } - } - - } + ViewSelection selection = ((BasicFilterView) view).getPreFilterSelection(); List resourcesWithSelectedElements = viewSources.stream() - .filter(resource -> resource.getContents().stream() - .anyMatch(element -> mapOriginalRoot2RootStub.get(element) != null ? selection.isViewObjectSelected(mapOriginalRoot2RootStub.get(element)) : false)) - .toList(); + .filter(resource -> resource.getContents().stream().anyMatch(selection::isViewObjectSelected)).toList(); return ResourceCopier.copyViewSourceResources(resourcesWithSelectedElements, viewResourceSet, - element -> mapOriginalRoot2RootStub.get(element) != null ? selection.isViewObjectSelected(mapOriginalRoot2RootStub.get(element)) : false); + selection::isViewObjectSelected); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index 8fce5bf91..a3d7cfd8d 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -69,11 +69,7 @@ public FilterSupportingViewElementSelector( @Override public View createView() { viewFilter = viewFilterBuilder.build(); - Set rootListForView = getViewFilter().filterElements(getSelectableElements(), viewSource.getViewSourceModels()); - - viewSelection = new ElementViewSelection(rootListForView); - rootListForView.forEach(element -> setSelected(element, true)); - // TODO nbruening ggf noch anpassen + getSelectableElements().forEach(it -> setSelected(it, true)); Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); createdView = (BasicFilterView) this.viewType.createView(this); return createdView; diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java index b59ad9509..c45119c0f 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java @@ -8,8 +8,8 @@ import org.eclipse.emf.ecore.resource.Resource; public interface ViewFilter { - - Set filterElements(Collection roots, Collection viewSources); + + Set filterElements(Collection roots); Map getMapOriginalRoot2RootStub(); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index f7d35b013..e118e2c66 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -26,6 +26,7 @@ import org.palladiosimulator.pcm.repository.RepositoryFactory; import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; +import tools.vitruv.framework.views.ViewSelection; public class ViewFilterImpl implements ViewFilter { @@ -43,11 +44,10 @@ private ViewFilterImpl(ViewFilterBuilder viewFilterBuilder) { - public Set filterElements(Collection roots, Collection viewSources) { + public Set filterElements(Collection roots) { Map newMapOriginalRoot2RootStub = new HashMap(); rootListForView = new HashSet(); - List rootsInViewSource = extractRootsInViewSource(viewSources, roots); - addElementsToSelectionByLambda(rootsInViewSource, newMapOriginalRoot2RootStub); + addElementsToSelectionByLambda(roots, newMapOriginalRoot2RootStub); removeOwnedAttributesFromClasses(); mapOriginalRoot2RootStub = newMapOriginalRoot2RootStub; return rootListForView; @@ -56,7 +56,7 @@ public Set filterElements(Collection roots, Collection roots, Map newMapOriginalRoot2RootStub) { + private void addElementsToSelectionByLambda(Collection roots, Map newMapOriginalRoot2RootStub) { if (!builder.filterByLambdaActive) { return; } @@ -97,16 +97,6 @@ private void filterAllContents(EObject root, Function filter, } } - private List extractRootsInViewSource(Collection viewSources, Collection roots) { - List resourcesWithSelectedElements = viewSources.stream() - .filter(resource -> resource.getContents().stream() - .anyMatch(element -> mapOriginalRoot2RootStub.get(element) != null ? roots.contains(mapOriginalRoot2RootStub.get(element)) : false)) - .toList(); - List extractedRoots = new ArrayList(); - resourcesWithSelectedElements.forEach(it -> extractedRoots.addAll(it.getContents())); - return extractedRoots; - } - private void attachElementToRoot(EObject root, EObject object) { if (root instanceof Model) { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 2dbd79e30..57404ec5f 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -1,10 +1,14 @@ package tools.vitruv.applications.viewfilter.views; +import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Set; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; @@ -22,30 +26,54 @@ public class BasicFilterView extends BasicView { private final ViewFilter viewFilter; + private ViewSelection preFilterSelection; + public BasicFilterView(FilteredViewCreatingViewType viewType, ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { super(viewType, viewSource, selection); this.viewFilter = viewFilter; -// ModifiableViewSelection filteredSelection = filterElementsForSelection(); -// updateSelectedElements(filteredSelection); - + preFilterSelection = selection; + update(); + } + + + public void update() { + if (viewFilter != null) { + //only execute if viewFilter has already been set + super.update(); + } } + @Override public void modifyContents(Procedure1 modificationFunction) { super.modifyContents(modificationFunction); - ModifiableViewSelection filteredSelection = null; if (viewFilter != null) { - filteredSelection = filterElementsForSelection(); + ModifiableViewSelection filteredSelection = filterElementsForSelection(); + updateSelectedElements(filteredSelection); + } + + } + + + private List findRootsForSelectionInViewSource() { + Collection viewSources = getViewSource().getViewSourceModels(); + ViewSelection selection = getPreFilterSelection(); + List resourcesWithSelectedElements = viewSources.stream() + .filter(resource -> resource.getContents().stream().anyMatch(selection::isViewObjectSelected)).toList(); + List roots = new ArrayList(); + for(Resource resource : resourcesWithSelectedElements) { + roots.addAll(resource.getContents()); } - updateSelectedElements(filteredSelection); + return roots; } protected ModifiableViewSelection filterElementsForSelection() { //If the viewFilter has already been set, use it.. - Set filteredElements = viewFilter.filterElements(getRootObjects(), getViewSource().getViewSourceModels()); + List rootsForSelection = findRootsForSelectionInViewSource(); + Set filteredElements = viewFilter.filterElements(rootsForSelection); ModifiableViewSelection elementViewSelection = new ElementViewSelection(filteredElements); filteredElements.forEach(it -> elementViewSelection.setSelected(it, true)); return elementViewSelection; @@ -54,9 +82,7 @@ protected ModifiableViewSelection filterElementsForSelection() { protected void updateSelectedElements(ModifiableViewSelection selection) { //TODO nbruening merge with filterElementsForSelection method? - if (viewFilter != null) { - setSelection(selection); - } + setSelection(selection); } @@ -64,4 +90,14 @@ public Map getMapOriginalRoot2RootStub() { return viewFilter != null ? viewFilter.getMapOriginalRoot2RootStub() : Collections.emptyMap(); } + + public ViewSelection getPreFilterSelection() { + return preFilterSelection; + } + + + public ViewSelection getSelection() { + return super.getSelection(); + } + } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index 8c89d2ff7..683a50add 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -225,6 +225,7 @@ private void modifyModel() { package3.setName("niklasPackage3"); org.eclipse.uml2.uml.Class class3 = package3.createOwnedClass("niklasClass3", false); + org.eclipse.uml2.uml.Class class4 = package3.createOwnedClass("niklasClass2", false); class2.addKeyword("subsequentlyAddedKeyword"); From 941e31f20548b3835aa23a10bfec56babc8c3fec Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 26 Jan 2024 21:55:10 +0100 Subject: [PATCH 15/62] Some code clean ups --- .../AbstractFilterSupportingViewType.java | 7 +++ ...ormationFilterIdentityMappingViewType.java | 2 +- ...lterSupportingIdentityMappingViewType.java | 46 +-------------- .../impl/FilteredViewCreatingViewType.java | 3 + .../FilterSupportingViewElementSelector.java | 20 ++----- .../viewfilter/viewbuild/ViewFilter.java | 21 ++++++- .../viewfilter/viewbuild/ViewFilterImpl.java | 56 ++++--------------- .../viewfilter/views/BasicFilterView.java | 10 +--- .../views/BasicInformationFilterView.java | 5 +- 9 files changed, 52 insertions(+), 118 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java index b532bc621..cd6e595aa 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java @@ -2,6 +2,13 @@ import tools.vitruv.framework.views.ViewSelector; +/** + * Objects of this type support building {@link View} objects with a filter. Filters can be used to filter + * certain elements of one ore multiple models represented by the View. + * + * @param The Type of ViewSelector used to select the elements included in the {@link View} which will be constructed by instances of {@link AbstractFilterSupportingViewType} + * @param + */ public abstract class AbstractFilterSupportingViewType extends AbstractViewType implements FilteredViewCreatingViewType { public AbstractFilterSupportingViewType(String name) { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java index 5cdceedab..1136acc71 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java @@ -50,7 +50,7 @@ public ModifiableView createView(FilterSupportingViewElementSelector, HierarchicalId> { @@ -47,13 +47,6 @@ public FilterSupportingIdentityMappingViewType(String name) { @Override public FilterSupportingViewElementSelector createSelector(ChangeableViewSource viewSource) { -// FilterSupportingViewElementSelector test = new FilterSupportingViewElementSelector<>(this, viewSource, -// viewSource.getViewSourceModels().stream().map(resource -> { -// EList allElementsInViewSource = collectAllChildrenInList(resource); -// return allElementsInViewSource.stream(); -// }).flatMap(Function.identity()).filter(it -> it != null).toList()); -// test.isSelectable(null); -// return test; return new FilterSupportingViewElementSelector<>(this, viewSource, viewSource.getViewSourceModels().stream().map(resource -> { if (!resource.getContents().isEmpty() && ResourceCopier.requiresFullCopy(resource)) { @@ -65,17 +58,6 @@ public FilterSupportingViewElementSelector createSelector(Change }).flatMap(Function.identity()).filter(it -> it != null).toList()); } - -// private EList getAllElementsInViewSource(Resource resource) { -// if (!resource.getContents().isEmpty() && ResourceCopier.requiresFullCopy(resource)) { -// // Some resources (like UML) can only be copied as a whole, so no option to select -// // specific root elements -// EList list = new BasicEList(); -// list.add(resource.getContents().get(0)); -// return list; -// } -// return resource.getContents(); -// } @Override public ModifiableView createView(FilterSupportingViewElementSelector selector) { @@ -114,28 +96,4 @@ private Map createViewResources(ModifiableView view, Resourc return ResourceCopier.copyViewSourceResources(resourcesWithSelectedElements, viewResourceSet, selection::isViewObjectSelected); } - - - private EList collectAllChildrenInList(Resource resource) { - TreeIterator contentInterator = resource.getAllContents(); - EList children = new BasicEList(); - while (contentInterator.hasNext()) { - EObject next = contentInterator.next(); - children.addAll(collectAllChildrenInList(next)); - children.add(next); - } - return children; - } - - - private EList collectAllChildrenInList(EObject resource) { - TreeIterator contentInterator = resource.eAllContents(); - EList children = new BasicEList(); - while (contentInterator.hasNext()) { - EObject next = contentInterator.next(); - children.addAll(collectAllChildrenInList(next)); - children.add(next); - } - return children; - } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java index 9bbfdc23b..3599e26e4 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java @@ -5,4 +5,7 @@ public interface FilteredViewCreatingViewType extends ViewCreatingViewType { + + + } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index a3d7cfd8d..8a1cd435a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -23,12 +23,10 @@ import com.google.common.base.Preconditions; import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; -import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl.ViewFilterBuilder; -import tools.vitruv.applications.viewfilter.views.BasicFilterView; import tools.vitruv.framework.views.ChangeableViewSource; import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.View; @@ -39,7 +37,7 @@ public class FilterSupportingViewElementSelector implements V private ModifiableViewSelection viewSelection; - private ChangeableViewSource viewSource; + private final ChangeableViewSource viewSource; private final FilteredViewCreatingViewType, Id> viewType; @@ -47,8 +45,7 @@ public class FilterSupportingViewElementSelector implements V private ViewFilterImpl viewFilter; - //TODO nbruening: Replace by Interface - private BasicFilterView createdView; + private View createdView; public FilterSupportingViewElementSelector( FilteredViewCreatingViewType, Id> viewType, @@ -58,12 +55,8 @@ public FilterSupportingViewElementSelector( Preconditions.checkArgument((viewSource != null), "view source must not be null"); this.viewType = viewType; this.viewSource = viewSource; - // Copy underlying model - // Collection selectableElementsCopy = - // EcoreUtil.copyAll(selectableElements); this.viewSelection = new ElementViewSelection(selectableElements); viewFilterBuilder = new ViewFilterBuilder(); - } @Override @@ -71,7 +64,8 @@ public View createView() { viewFilter = viewFilterBuilder.build(); getSelectableElements().forEach(it -> setSelected(it, true)); Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); - createdView = (BasicFilterView) this.viewType.createView(this); + //TODO nbruening do I need "this"? + createdView = this.viewType.createView(this); return createdView; } @@ -85,7 +79,7 @@ public void addElementsToSelectionByLambda(Function filter) { } public void removeOwnedAttributesFromClasses() { - viewFilterBuilder.removeOwnedAttributes(); + viewFilterBuilder.removeOwnedUmlAttributes(); } @Override @@ -126,10 +120,6 @@ public FilteredViewCreatingViewType, Id> return this.viewType; } - public Map getMapOriginalRoot2RootStub() { - return createdView != null ? createdView.getMapOriginalRoot2RootStub() : Collections.emptyMap(); - } - public ViewFilter getViewFilter() { return viewFilter; } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java index c45119c0f..c77828710 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java @@ -7,9 +7,26 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; +/** + * A ViewFilter filters the model objects contained in a {@link View}. What kind of + * elements will be filtered by an instance, depends on the implementation of the interface. + * When {@link filterElements} is executed, the given models are filtered and the results + * are returned. + * It also depends on the implementation, how the Filter deals with objects, if their parent + * has been filtered out. One possibility is, that the filter creates a stub-model-root + * and mounts all filtered elements under the stub-model-root. + */ public interface ViewFilter { + /** + * This method executes the actual filter mechanism on the models which belong + * to the given model roots. It depends on the implementation, how the method deals + * with objects, if their parent + * has been filtered out. One possibility is, that the filter creates a stub-model-root + * and mounts all filtered elements under the stub-model-root. + * @param roots The roots of the models that are supposed to be filtered + * @return The remaining model objects after all other objects have been filtered out according + * to the used filter. + */ Set filterElements(Collection roots); - - Map getMapOriginalRoot2RootStub(); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index e118e2c66..3139a3fef 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -31,42 +31,33 @@ public class ViewFilterImpl implements ViewFilter { private Set rootListForView; - - //TODO nbruening: Javadoc - private Map mapOriginalRoot2RootStub; - + private final ViewFilterBuilder builder; private ViewFilterImpl(ViewFilterBuilder viewFilterBuilder) { builder = viewFilterBuilder; - mapOriginalRoot2RootStub = new HashMap(); } - - + public Set filterElements(Collection roots) { - Map newMapOriginalRoot2RootStub = new HashMap(); rootListForView = new HashSet(); - addElementsToSelectionByLambda(roots, newMapOriginalRoot2RootStub); - removeOwnedAttributesFromClasses(); - mapOriginalRoot2RootStub = newMapOriginalRoot2RootStub; + addElementsToSelectionByLambda(roots); + removeOwnedAttributesFromUmlClasses(); return rootListForView; } - - - private void addElementsToSelectionByLambda(Collection roots, Map newMapOriginalRoot2RootStub) { + private void addElementsToSelectionByLambda(Collection roots) { if (!builder.filterByLambdaActive) { return; } for (EObject root : roots) { - filterAllContents(root, builder.filter, rootListForView, newMapOriginalRoot2RootStub); + filterAllContents(root, builder.filter, rootListForView); } } - private void removeOwnedAttributesFromClasses() { + private void removeOwnedAttributesFromUmlClasses() { if (!builder.removeAttributesActive) { return; } @@ -83,14 +74,13 @@ private void removeOwnedAttributesFromClasses() { } - private void filterAllContents(EObject root, Function filter, Set rootListForView, Map newMapOriginalRoot2RootStub) { + private void filterAllContents(EObject root, Function filter, Set rootListForView) { EObject filteredModelRootStub = null; Iterator contentIterator = root.eAllContents(); while(contentIterator.hasNext()) { EObject contentElement = contentIterator.next(); if (filter.apply(contentElement)) { - - filteredModelRootStub = createAndRegisterModelRootIfNotExistent(filteredModelRootStub, root, newMapOriginalRoot2RootStub); + filteredModelRootStub = createAndRegisterModelRootIfNotExistent(filteredModelRootStub, root); EObject copyOfContentElement = EcoreUtil.copy(contentElement); attachElementToRoot(filteredModelRootStub, copyOfContentElement); } @@ -129,11 +119,10 @@ private void attachElementToRootPcm(Repository root, EObject object) { } } - private EObject createAndRegisterModelRootIfNotExistent(EObject filteredRoot, EObject root, Map newMapOriginalRoot2RootStub) { + private EObject createAndRegisterModelRootIfNotExistent(EObject filteredRoot, EObject root) { if (filteredRoot == null) { EObject modelRoot = createFilteredModelRootIfNotExistent(filteredRoot, root); rootListForView.add(modelRoot); - newMapOriginalRoot2RootStub.put(root, modelRoot); return modelRoot; } else { return filteredRoot; @@ -142,22 +131,6 @@ private EObject createAndRegisterModelRootIfNotExistent(EObject filteredRoot, EO } - private EObject findOriginalRoot(EObject root) { - - - if ((!mapOriginalRoot2RootStub.isEmpty()) && mapOriginalRoot2RootStub.containsValue(root)) { - Set keySet = mapOriginalRoot2RootStub.keySet(); - for (EObject key : keySet) { - if (mapOriginalRoot2RootStub.get(key).equals(root)) { - return key; - } - } - throw new IllegalStateException("Value should be in map, but could not be found"); - } - return root; - } - - private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObject root) { if (root instanceof Model) { return UMLFactory.eINSTANCE.createModel(); @@ -169,13 +142,6 @@ private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObje } } - - - - public Map getMapOriginalRoot2RootStub() { - return mapOriginalRoot2RootStub; - } - //--------------------------------- /** @@ -200,7 +166,7 @@ public ViewFilterBuilder filterByLambda(Function filter) { return this; } - public ViewFilterBuilder removeOwnedAttributes() { + public ViewFilterBuilder removeOwnedUmlAttributes() { this.removeAttributesActive = true; return this; } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 57404ec5f..9c8c67606 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -52,8 +52,7 @@ public void modifyContents(Procedure1 modificationFunction) if (viewFilter != null) { ModifiableViewSelection filteredSelection = filterElementsForSelection(); updateSelectedElements(filteredSelection); - } - + } } @@ -71,7 +70,6 @@ private List findRootsForSelectionInViewSource() { protected ModifiableViewSelection filterElementsForSelection() { - //If the viewFilter has already been set, use it.. List rootsForSelection = findRootsForSelectionInViewSource(); Set filteredElements = viewFilter.filterElements(rootsForSelection); ModifiableViewSelection elementViewSelection = new ElementViewSelection(filteredElements); @@ -81,14 +79,8 @@ protected ModifiableViewSelection filterElementsForSelection() { protected void updateSelectedElements(ModifiableViewSelection selection) { - //TODO nbruening merge with filterElementsForSelection method? setSelection(selection); } - - - public Map getMapOriginalRoot2RootStub() { - return viewFilter != null ? viewFilter.getMapOriginalRoot2RootStub() : Collections.emptyMap(); - } public ViewSelection getPreFilterSelection() { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java index 3dae09939..f46726d6a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java @@ -34,10 +34,11 @@ public class BasicInformationFilterView extends BasicFilterView { public BasicInformationFilterView(FilteredViewCreatingViewType viewType, - ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter, Map mapOriginalRoot2RootStub) { + ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { super(viewType, viewSource, selection, viewFilter); mapOriginalRoot2InformationRoot = new HashMap(); - this.mapOriginalRoot2FilteredRootStub = reverseMap(mapOriginalRoot2RootStub); + //TODO nbruening remove + //this.mapOriginalRoot2FilteredRootStub = reverseMap(mapOriginalRoot2RootStub); } From f4530c5aafa5f80a45f597b2eae548618320c284 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:23:41 +0100 Subject: [PATCH 16/62] Added some infrastructure for testing --- .../viewfilter/tests/InstanceFilterTest.java | 244 ++++++++++++++++++ .../viewfilter/tests/ViewTestFactory.java | 4 - 2 files changed, 244 insertions(+), 4 deletions(-) create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java new file mode 100644 index 000000000..8299fda5d --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -0,0 +1,244 @@ +package tools.vitruv.applications.viewfilter.tests; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.function.Consumer; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Comment; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.PackageableElement; +import org.eclipse.uml2.uml.PrimitiveType; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.xtend.lib.annotations.AccessorType; +import org.eclipse.xtend.lib.annotations.Accessors; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.Exceptions; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; +import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; +import tools.vitruv.applications.testutility.uml.UmlQueryUtil; +import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; +import tools.vitruv.change.propagation.ChangePropagationSpecification; +import tools.vitruv.framework.views.CommittableView; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewType; +import tools.vitruv.framework.vsum.VirtualModel; +import tools.vitruv.testutils.RegisterMetamodelsInStandalone; +import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; + +@ExtendWith(RegisterMetamodelsInStandalone.class) +public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { + + @Accessors(AccessorType.PROTECTED_GETTER) + private static final String UML_MODEL_NAME = "model"; + + @Accessors(AccessorType.PROTECTED_GETTER) + private static final String PCM_MODEL_NAME = "Repository"; + + + private static final String PCM_REPOSITORY_FILE_EXTENSION = "repository"; + + @Accessors(AccessorType.PROTECTED_GETTER) + private static final String MODEL_FOLDER_NAME = "model"; + + @Accessors(AccessorType.PROTECTED_GETTER) + private static final String MODEL_FILE_EXTENSION = "uml"; + + @Accessors(AccessorType.PUBLIC_GETTER) + private org.eclipse.uml2.uml.Class class1; + + @Accessors(AccessorType.PUBLIC_GETTER) + private org.eclipse.uml2.uml.Class class2; + + protected ViewTestFactory improvedViewTestFactory; + + @BeforeEach + public void setup() { + improvedViewTestFactory = new ViewTestFactory(getVirtualModel()); + final Procedure1 setNameFunction = (Model it) -> { + it.setName(UML_MODEL_NAME); + }; + createBiggerUmlModel(setNameFunction); + //createPcmModel(); + } + + + //--- Actual tests --- + @Test + public void testView() throws NoSuchMethodException, InvocationTargetException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + View createUmlView = improvedViewTestFactory.createUmlView(); + Collection rootObjects = createUmlView.getRootObjects(); + ViewSelection selection = createUmlView.getSelection(); + + + +// Field declaredField = selection.getClass().getSuperclass().getDeclaredField("elementsSelection"); +// declaredField.setAccessible(true); +// HashMap map = (HashMap) declaredField.get(createUmlView); + + //Selection should contain ModelImpl, and two SystemImpl. Only the ModelImpl should be + //selected. + + + assert(rootObjects.stream().anyMatch(it -> it instanceof Model)); + assertEquals(rootObjects.size(), 1); + } + + + @Test + public void testCreateFilteredUmlView() { + //View view = improvedViewTestFactory.createFilteredUmlView(this); + View view = improvedViewTestFactory.createFilteredPcmView(); +// ((FilterSupportingIdentityMappingViewType) improvedViewTestFactory.viewType) +// .updateView(((ModifiableView) view)); + view.update(); + view.update(); + view.getRootObjects(); + + modifyModel(); + + view.update(); + + //view.getRootObjects(); + //Object object = view.withChangeDerivingTrait().getRootObjects().toArray()[0]; + view.getSelection(); + view.getRootObjects(); + view.getViewType(); + } + + + + + protected void createBiggerUmlModel(final Procedure1 modelInitialization) { + try { + final Consumer firstChangeUmlFunction = (CommittableView it) -> { + final Model umlModel = UMLFactory.eINSTANCE.createModel(); + createAndRegisterRoot(it, umlModel, this.getUri(getProjectModelPath(UML_MODEL_NAME))); + modelInitialization.apply(umlModel); + }; + improvedViewTestFactory.changeUmlView(firstChangeUmlFunction); + + getUserInteraction().addNextSingleSelection(1); + getUserInteraction().addNextTextInput("model/System.system"); + + final Consumer secondChangeUmlFunction = (CommittableView it) -> { + org.eclipse.uml2.uml.Package _createPackage = UMLFactory.eINSTANCE.createPackage(); + Procedure1 setNameFunction = (org.eclipse.uml2.uml.Package it_1) -> { + it_1.setName("niklasPackage"); + }; + + org.eclipse.uml2.uml.Package package1 = UMLFactory.eINSTANCE.createPackage(); + package1.setName("niklasPackage"); + + class1 = package1.createOwnedClass("niklasClass1", false); + + getUserInteraction().addNextSingleSelection(1); + getUserInteraction().addNextTextInput("model/System.system"); + org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage("niklasNestedPackage"); + + class2 = package2.createOwnedClass("niklasClass2", false); + EList _packagedElements = getDefaultUmlModel(it).getPackagedElements(); + _packagedElements.add(package1); + + // create Attribute for class2 + PrimitiveType stringPrimitiveType = package1.createOwnedPrimitiveType("niklasPrimitiveType1"); + class2.createOwnedAttribute("niklasClass2Attribute", stringPrimitiveType, 0, 1); + }; + improvedViewTestFactory.changeUmlView(secondChangeUmlFunction); + + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + } + + private void modifyModel() { + try { + getUserInteraction().addNextSingleSelection(1); + getUserInteraction().addNextTextInput("model/System.system"); + + Consumer changeUmlFunction = (CommittableView it) -> { + org.eclipse.uml2.uml.Package package3 = UMLFactory.eINSTANCE.createPackage(); + package3.setName("niklasPackage3"); + + org.eclipse.uml2.uml.Class class3 = package3.createOwnedClass("niklasClass3", false); + org.eclipse.uml2.uml.Class class4 = package3.createOwnedClass("niklasClass2", false); + + class2.addKeyword("subsequentlyAddedKeyword"); + + final Comment comment = this.class2.createOwnedComment(); + comment.setBody("niklasCommentClass2"); + String searchedName = "niklasClass2"; + comment.addKeyword("bla"); + + TreeIterator umlIterator = getDefaultUmlModel(it).eAllContents(); + org.eclipse.uml2.uml.Class searchedClass = null; + while ((searchedClass == null) && (umlIterator.hasNext())) { + EObject next = umlIterator.next(); + if (next instanceof org.eclipse.uml2.uml.Class) { + if (searchedName.equals(((Classifier) next).getName())) { + searchedClass = (org.eclipse.uml2.uml.Class) next; + } + } + } + searchedClass.getOwnedComments().add(comment); + + getDefaultUmlModel(it).getPackagedElements().add(package3); + }; + + improvedViewTestFactory.changeUmlView(changeUmlFunction); + } catch (Throwable _e) { + throw Exceptions.sneakyThrow(_e); + } + } + + private Path getPcmProjectModelPath(String modelName, String modelFileExtension) { + return Path.of("pcm").resolve(modelName + "." + modelFileExtension); + } + + protected void createAndRegisterRoot(final View view, final EObject rootObject, final URI persistenceUri) { + view.registerRoot(rootObject, persistenceUri); + } + + protected Path getProjectModelPath(final String modelName) { + return Path.of(MODEL_FOLDER_NAME).resolve(((modelName + ".") + MODEL_FILE_EXTENSION)); + } + + protected Model getDefaultUmlModel(final View view) { + return UmlQueryUtil.claimUmlModel(view, UML_MODEL_NAME); + } + + + @Override + protected Iterable getChangePropagationSpecifications() { + CombinedPcmToUmlClassReactionsChangePropagationSpecification _combinedPcmToUmlClassReactionsChangePropagationSpecification = new CombinedPcmToUmlClassReactionsChangePropagationSpecification(); + CombinedUmlClassToPcmReactionsChangePropagationSpecification _combinedUmlClassToPcmReactionsChangePropagationSpecification = new CombinedUmlClassToPcmReactionsChangePropagationSpecification(); + return Collections.unmodifiableList( + CollectionLiterals.newArrayList( + _combinedPcmToUmlClassReactionsChangePropagationSpecification, + _combinedUmlClassToPcmReactionsChangePropagationSpecification)); + } + +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 09f55bc2d..05b17de1e 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -96,10 +96,6 @@ public View createViewOfElements(String viewName, Collection> rootTypes selector.getSelectableElements().stream() .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) .forEach(element -> selector.setSelected(element, true)); -// if (!selector.getSelectableElements().isEmpty()) { -// Object obj = (selector.getSelectableElements().toArray())[0]; -// boolean bla = obj instanceof Repository; -// } View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); From 433ec2170b0b68ef14e7ff6e26fd1a7afc489623 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:18:28 +0100 Subject: [PATCH 17/62] Adjusted information view to fix of filtering views --- ...ormationFilterIdentityMappingViewType.java | 39 +----- ...lterSupportingIdentityMappingViewType.java | 12 +- .../FilterSupportingViewElementSelector.java | 127 ++--------------- ...lterSupportingViewElementSelectorImpl.java | 132 ++++++++++++++++++ .../views/BasicInformationFilterView.java | 53 ++----- .../viewfilter/tests/BasicViewFilterTest.java | 1 + .../viewfilter/tests/InstanceFilterTest.java | 16 ++- .../viewfilter/tests/ViewTestFactory.java | 20 ++- 8 files changed, 186 insertions(+), 214 deletions(-) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java index 1136acc71..e24ce1b9e 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java @@ -2,20 +2,8 @@ import static com.google.common.base.Preconditions.checkArgument; -import java.util.ArrayList; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; - -import com.niklas.niklasproject.niklasdomain.InformationStructure; -import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; -import com.niklas.niklasproject.niklasdomain.SingleInformation; - -import tools.vitruv.application.viewfilter.transformation.UmlToInformationTransformator; -import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; -import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelector; -import tools.vitruv.applications.viewfilter.views.BasicFilterView; +import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelectorImpl; import tools.vitruv.applications.viewfilter.views.BasicInformationFilterView; import tools.vitruv.change.atomic.hid.HierarchicalId; @@ -27,29 +15,8 @@ public AbstractingInformationFilterIdentityMappingViewType(String name) { @Override - public ModifiableView createView(FilterSupportingViewElementSelector selector) { - checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); - //mapOriginalRoot2RootStub = selector.getMapOriginalRoot2RootStub(); -// List roots = new ArrayList(); -// selector.getViewSource().getViewSourceModels().forEach(it -> roots.addAll(it.getContents())); - -// UmlToInformationTransformator transformator = new UmlToInformationTransformator(); -// InformationStructure informationStructure = NiklasdomainFactory.eINSTANCE.createInformationStructure(); -// EList singleinformationList = informationStructure.getSingleinformation(); -// -// for(EObject root : roots) { -// SingleInformation transformResult = transformator.transform(root); -// if (transformResult != null) { -// singleinformationList.add(transformResult); -// } -// } -// -// List selectionList = new ArrayList(); -// selectionList.add(informationStructure); -// ElementViewSelection elementViewSelection = new ElementViewSelection(selectionList); -// elementViewSelection.setSelected(informationStructure, true); - - //Hier in SingleInformation-Meta-Modell übertragen + public ModifiableView createView(FilterSupportingViewElementSelectorImpl selector) { + checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); BasicInformationFilterView view = new BasicInformationFilterView(selector.getViewType(), selector.getViewSource(), selector.getSelection(), selector.getViewFilter()); return view; } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index 949cd15bb..ecb7c390b 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -20,7 +20,7 @@ import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; import tools.vitruv.applications.viewfilter.util.framework.selectors.DirectViewElementSelector; -import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelector; +import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelectorImpl; import tools.vitruv.applications.viewfilter.views.BasicFilterView; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.atomic.uuid.Uuid; @@ -38,16 +38,17 @@ * selection mechanism and a filter-function. The filter-function can be used for * selecting single objects in a model. */ -public class FilterSupportingIdentityMappingViewType extends AbstractFilterSupportingViewType, HierarchicalId> { +public class FilterSupportingIdentityMappingViewType extends AbstractFilterSupportingViewType, HierarchicalId> { public FilterSupportingIdentityMappingViewType(String name) { super(name); } + //TODO nbr replace by Interface @Override - public FilterSupportingViewElementSelector createSelector(ChangeableViewSource viewSource) { - return new FilterSupportingViewElementSelector<>(this, viewSource, + public FilterSupportingViewElementSelectorImpl createSelector(ChangeableViewSource viewSource) { + return new FilterSupportingViewElementSelectorImpl<>(this, viewSource, viewSource.getViewSourceModels().stream().map(resource -> { if (!resource.getContents().isEmpty() && ResourceCopier.requiresFullCopy(resource)) { // Some resources (like UML) can only be copied as a whole, so no option to select @@ -59,8 +60,9 @@ public FilterSupportingViewElementSelector createSelector(Change } + //TODO nbr replace by interface @Override - public ModifiableView createView(FilterSupportingViewElementSelector selector) { + public ModifiableView createView(FilterSupportingViewElementSelectorImpl selector) { checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); return new BasicFilterView(selector.getViewType(), selector.getViewSource(), selector.getSelection(), selector.getViewFilter()); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index 8a1cd435a..8d0551b67 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -1,127 +1,24 @@ package tools.vitruv.applications.viewfilter.util.framework.selectors; import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; import java.util.function.Function; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.net4j.util.ImplementationError; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.Type; -import org.eclipse.uml2.uml.UMLFactory; -import com.google.common.base.Preconditions; - -import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; -import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; -import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; -import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl; -import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl.ViewFilterBuilder; -import tools.vitruv.framework.views.ChangeableViewSource; -import tools.vitruv.framework.views.ModifiableViewSelection; -import tools.vitruv.framework.views.View; -import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; -public class FilterSupportingViewElementSelector implements ViewSelector { - - private ModifiableViewSelection viewSelection; - - private final ChangeableViewSource viewSource; - - private final FilteredViewCreatingViewType, Id> viewType; +//TODO nbr add javadoc +public interface FilterSupportingViewElementSelector extends ViewSelector { - private ViewFilterBuilder viewFilterBuilder; - - private ViewFilterImpl viewFilter; + //TODO nbr Remove this method (replaced by removeOwnedAttributesFromClasses + @Deprecated + void selectElementsOfRootType(Collection> rootTypes); + + void deselectElementsExceptForRootType(Collection> rootTypes); + + void addElementsToSelectionByLambda(Function filter); + + void removeOwnedAttributesFromClasses(); + - private View createdView; - - public FilterSupportingViewElementSelector( - FilteredViewCreatingViewType, Id> viewType, - ChangeableViewSource viewSource, Collection selectableElements) { - Preconditions.checkArgument((selectableElements != null), "selectable elements must not be null"); - Preconditions.checkArgument((viewType != null), "view type must not be null"); - Preconditions.checkArgument((viewSource != null), "view source must not be null"); - this.viewType = viewType; - this.viewSource = viewSource; - this.viewSelection = new ElementViewSelection(selectableElements); - viewFilterBuilder = new ViewFilterBuilder(); - } - - @Override - public View createView() { - viewFilter = viewFilterBuilder.build(); - getSelectableElements().forEach(it -> setSelected(it, true)); - Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); - //TODO nbruening do I need "this"? - createdView = this.viewType.createView(this); - return createdView; - } - - public void selectElementsOfRootType(Collection> rootTypes) { - getSelectableElements().stream().filter(element -> !(rootTypes.stream().anyMatch(it -> it.isInstance(element)))) - .forEach(element -> setSelected(element, false)); - } - - public void addElementsToSelectionByLambda(Function filter) { - viewFilterBuilder.filterByLambda(filter); - } - - public void removeOwnedAttributesFromClasses() { - viewFilterBuilder.removeOwnedUmlAttributes(); - } - - @Override - public boolean isValid() { - return true; - } - - @Override - public ViewSelection getSelection() { - return new ElementViewSelection(this.viewSelection); - } - - public Collection getSelectableElements() { - return this.viewSelection.getSelectableElements(); - } - - public boolean isSelectable(final EObject eObject) { - return this.viewSelection.isSelectable(eObject); - } - - public boolean isSelected(final EObject eObject) { - return this.viewSelection.isSelected(eObject); - } - - public boolean isViewObjectSelected(final EObject eObject) { - return this.viewSelection.isViewObjectSelected(eObject); - } - - public void setSelected(final EObject eObject, final boolean selected) { - this.viewSelection.setSelected(eObject, selected); - } - - public ChangeableViewSource getViewSource() { - return this.viewSource; - } - - public FilteredViewCreatingViewType, Id> getViewType() { - return this.viewType; - } - - public ViewFilter getViewFilter() { - return viewFilter; - } - } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java new file mode 100644 index 000000000..c244b17cc --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java @@ -0,0 +1,132 @@ +package tools.vitruv.applications.viewfilter.util.framework.selectors; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.net4j.util.ImplementationError; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; + +import com.google.common.base.Preconditions; + +import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; +import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl.ViewFilterBuilder; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.ModifiableViewSelection; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewSelector; + +public class FilterSupportingViewElementSelectorImpl implements FilterSupportingViewElementSelector { + + private ModifiableViewSelection viewSelection; + + private final ChangeableViewSource viewSource; + + private final FilteredViewCreatingViewType, Id> viewType; + + private ViewFilterBuilder viewFilterBuilder; + + private ViewFilterImpl viewFilter; + + private View createdView; + + public FilterSupportingViewElementSelectorImpl( + FilteredViewCreatingViewType, Id> viewType, + ChangeableViewSource viewSource, Collection selectableElements) { + Preconditions.checkArgument((selectableElements != null), "selectable elements must not be null"); + Preconditions.checkArgument((viewType != null), "view type must not be null"); + Preconditions.checkArgument((viewSource != null), "view source must not be null"); + this.viewType = viewType; + this.viewSource = viewSource; + this.viewSelection = new ElementViewSelection(selectableElements); + selectableElements.forEach(element -> viewSelection.setSelected(element, true)); + viewFilterBuilder = new ViewFilterBuilder(); + } + + @Override + public View createView() { + viewFilter = viewFilterBuilder.build(); + Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); + //TODO nbr do I need "this"? + createdView = this.viewType.createView(this); + return createdView; + } + + public void selectElementsOfRootType(Collection> rootTypes) { + getSelectableElements().stream().filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) + .forEach(element -> setSelected(element, true)); + } + + public void deselectElementsExceptForRootType(Collection> rootTypes) { + getSelectableElements().stream().filter(element -> (isViewObjectSelected(element) && !(rootTypes.stream().anyMatch(it -> it.isInstance(element))))) + .forEach(element -> setSelected(element, false)); + } + + public void addElementsToSelectionByLambda(Function filter) { + viewFilterBuilder.filterByLambda(filter); + } + + public void removeOwnedAttributesFromClasses() { + viewFilterBuilder.removeOwnedUmlAttributes(); + } + + @Override + public boolean isValid() { + return true; + } + + @Override + public ViewSelection getSelection() { + return new ElementViewSelection(this.viewSelection); + } + + public Collection getSelectableElements() { + return this.viewSelection.getSelectableElements(); + } + + public boolean isSelectable(final EObject eObject) { + return this.viewSelection.isSelectable(eObject); + } + + public boolean isSelected(final EObject eObject) { + return this.viewSelection.isSelected(eObject); + } + + public boolean isViewObjectSelected(final EObject eObject) { + return this.viewSelection.isViewObjectSelected(eObject); + } + + public void setSelected(final EObject eObject, final boolean selected) { + this.viewSelection.setSelected(eObject, selected); + } + + public ChangeableViewSource getViewSource() { + return this.viewSource; + } + + public FilteredViewCreatingViewType, Id> getViewType() { + return this.viewType; + } + + public ViewFilter getViewFilter() { + return viewFilter; + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java index f46726d6a..78bf0e299 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java @@ -28,17 +28,10 @@ import tools.vitruv.framework.views.ViewSelector; public class BasicInformationFilterView extends BasicFilterView { - - protected Map mapOriginalRoot2InformationRoot; - protected Map mapOriginalRoot2FilteredRootStub; - public BasicInformationFilterView(FilteredViewCreatingViewType viewType, ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { super(viewType, viewSource, selection, viewFilter); - mapOriginalRoot2InformationRoot = new HashMap(); - //TODO nbruening remove - //this.mapOriginalRoot2FilteredRootStub = reverseMap(mapOriginalRoot2RootStub); } @@ -51,18 +44,21 @@ protected void updateSelectedElements(ModifiableViewSelection selection) { InformationStructure informationStructure = NiklasdomainFactory.eINSTANCE.createInformationStructure(); EList singleinformationList = informationStructure.getSingleinformation(); - for(EObject root : extractSelectedElements(selection)) { - SingleInformation transformResult = transformator.transform(root); - if (transformResult != null) { - singleinformationList.add(transformResult); -// mapOriginalRoot2RootStub. -// mapOriginalRoot2RootStub_.put(mapOriginalRoot2RootStub.get(root)), ) + //TODO nbr Hier weitermachen! die selectableElements entsprechen den gefilterten Elementen => daraus muss ich meine Informationen berechnen + for(EObject root : selection.getSelectableElements()) { + if (selection.isSelected(root)) { + SingleInformation transformResult = transformator.transform(root); + if (transformResult != null) { + singleinformationList.add(transformResult); + // mapOriginalRoot2RootStub. + // mapOriginalRoot2RootStub_.put(mapOriginalRoot2RootStub.get(root)), ) + } } } - for (EObject key : mapOriginalRoot2FilteredRootStub.keySet()) { - getMapOriginalRoot2InformationRoot().put(key, informationStructure); - } +// for (EObject key : mapOriginalRoot2FilteredRootStub.keySet()) { +// getMapOriginalRoot2InformationRoot().put(key, informationStructure); +// } List selectionList = new ArrayList(); selectionList.add(informationStructure); @@ -70,30 +66,5 @@ protected void updateSelectedElements(ModifiableViewSelection selection) { elementViewSelection.setSelected(informationStructure, true); setSelection(elementViewSelection); } - - - private List extractSelectedElements(ModifiableViewSelection selection) { - List selectedElements = new LinkedList(); - for(EObject root : getRootObjects()) { - if (selection.isViewObjectSelected(root)) { - selectedElements.add(root); - } - } - return selectedElements; - } - - - private Map reverseMap(Map map) { - Map myNewHashMap = new HashMap<>(); - for(Map.Entry entry : map.entrySet()){ - myNewHashMap.put(entry.getValue(), entry.getKey()); - } - return myNewHashMap; - } - - - public Map getMapOriginalRoot2InformationRoot() { - return mapOriginalRoot2InformationRoot; - } } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index 683a50add..cc00c15c3 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -121,6 +121,7 @@ public void testCreateCountingView() { modifyModel(); + view.update(); view.update(); view.getSelection(); diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index 8299fda5d..2dede1c5b 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -110,22 +110,26 @@ public void testView() throws NoSuchMethodException, InvocationTargetException, @Test public void testCreateFilteredUmlView() { - //View view = improvedViewTestFactory.createFilteredUmlView(this); - View view = improvedViewTestFactory.createFilteredPcmView(); + View view = improvedViewTestFactory.createFilteredUmlView(); + //View view = improvedViewTestFactory.createFilteredPcmView(); // ((FilterSupportingIdentityMappingViewType) improvedViewTestFactory.viewType) // .updateView(((ModifiableView) view)); view.update(); view.update(); view.getRootObjects(); - modifyModel(); + //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement + //Root Objects: ModelImpl (aber nicht nur mit niklasClass2, sondern mit allem) + modifyModel(); view.update(); - - //view.getRootObjects(); - //Object object = view.withChangeDerivingTrait().getRootObjects().toArray()[0]; view.getSelection(); view.getRootObjects(); + + //Selection: Nur ModelImpl mit zwei Klassen die jeweils niklasClass2 als Namen haben, als PackagedElement + //ACHTUNG: Die zwei Klassen sind als PackagedElements in der ModelImpl! + //Root Objects: ModelImpl + view.getViewType(); } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 05b17de1e..b29a33bbf 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -75,6 +75,11 @@ public View createFilteredUmlView(BasicViewFilterTest test) { return view; } + public View createFilteredUmlView() { + Collection> rootTypes = createCollectionOfRootTypes(Model.class); + return createFilteredForNoAttributesViewOfElements("UML", rootTypes); + } + public View createFilteredPcmView() { Collection> rootTypes = createCollectionOfRootTypes(Repository.class); return createFilteredForNoAttributesViewOfElements("PCM", rootTypes); @@ -125,8 +130,9 @@ public void changePcmView(Consumer modelModification) throws Ex public View createAbstractedFilteredView(String viewName, Collection> rootTypes, Function filterFunction) { viewType = FilterSupportingViewTypeFactory.createAbstractedFilterViewViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); + selector.selectElementsOfRootType(rootTypes); selector.addElementsToSelectionByLambda(filterFunction); - selector.removeOwnedAttributesFromClasses(); + selector.removeOwnedAttributesFromClasses(); View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); @@ -138,19 +144,11 @@ public View createFilteredForNoAttributesViewOfElements(String viewName, Collect viewType = FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + selector.deselectElementsExceptForRootType(rootTypes); selector.addElementsToSelectionByLambda(function); selector.removeOwnedAttributesFromClasses(); - View view = selector.createView(); - ViewSelection selection = view.getSelection(); - for (Object element : selector.getSelectableElements()) { - if (element instanceof Class) { - System.out.println(((Class) element).getName() + ": " + selection.isViewObjectSelected((EObject) element)); - } else { - System.out.println(element.getClass() + ": " + selection.isViewObjectSelected((EObject) element)); - } - } - + View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); return view; } From 48429017794230dd6f5b3de0a6329a8f77c86057 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:38:59 +0100 Subject: [PATCH 18/62] Fixed getRoot() for BasicFilterView and BasicInformationFilterView BasicFilterView and BasicInformationFilterView now only return the root elements which are really supposed to be visible in the view when getRoot() is called --- .../viewfilter/views/BasicFilterView.java | 19 ++++++++++++++++--- .../views/BasicInformationFilterView.java | 5 ++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 9c8c67606..73705332a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -26,7 +26,9 @@ public class BasicFilterView extends BasicView { private final ViewFilter viewFilter; - private ViewSelection preFilterSelection; + private final ViewSelection preFilterSelection; + + private Collection rootObjects; public BasicFilterView(FilteredViewCreatingViewType viewType, @@ -51,7 +53,7 @@ public void modifyContents(Procedure1 modificationFunction) super.modifyContents(modificationFunction); if (viewFilter != null) { ModifiableViewSelection filteredSelection = filterElementsForSelection(); - updateSelectedElements(filteredSelection); + updateRootAndSelectedElements(filteredSelection); } } @@ -78,7 +80,13 @@ protected ModifiableViewSelection filterElementsForSelection() { } - protected void updateSelectedElements(ModifiableViewSelection selection) { + public Collection getRootObjects() { + return Collections.unmodifiableCollection(rootObjects); + } + + + protected void updateRootAndSelectedElements(ModifiableViewSelection selection) { + setRootObjects(selection.getSelectableElements()); setSelection(selection); } @@ -92,4 +100,9 @@ public ViewSelection getSelection() { return super.getSelection(); } + + protected void setRootObjects(Collection rootObjects) { + this.rootObjects = rootObjects; + } + } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java index 78bf0e299..44dba9ecd 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java @@ -36,7 +36,7 @@ public BasicInformationFilterView(FilteredViewCreatingViewType selectionList = new ArrayList(); selectionList.add(informationStructure); + + setRootObjects(selectionList); + ElementViewSelection elementViewSelection = new ElementViewSelection(selectionList); elementViewSelection.setSelected(informationStructure, true); setSelection(elementViewSelection); From 395431d0f0d5d9b74187fa4b7f22505ad7cef2c2 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:39:27 +0100 Subject: [PATCH 19/62] Added regression tests for instance filtering --- .../viewfilter/tests/InstanceFilterTest.java | 242 ++++++++++++++++-- .../viewfilter/tests/ViewTestFactory.java | 25 +- 2 files changed, 234 insertions(+), 33 deletions(-) diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index 2dede1c5b..f842fcdd8 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -1,8 +1,10 @@ package tools.vitruv.applications.viewfilter.tests; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -12,6 +14,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.function.Consumer; @@ -20,12 +23,14 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.PackageableElement; import org.eclipse.uml2.uml.PrimitiveType; import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.internal.impl.ModelImpl; import org.eclipse.xtend.lib.annotations.AccessorType; import org.eclipse.xtend.lib.annotations.Accessors; import org.eclipse.xtext.xbase.lib.CollectionLiterals; @@ -34,12 +39,18 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.palladiosimulator.pcm.repository.BasicComponent; +import org.palladiosimulator.pcm.repository.CompositeDataType; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.repository.RepositoryFactory; import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; import tools.vitruv.applications.testutility.uml.UmlQueryUtil; import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; +import tools.vitruv.applications.viewfilter.utils.PcmQueryUtil; +import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper; import tools.vitruv.change.propagation.ChangePropagationSpecification; import tools.vitruv.framework.views.CommittableView; import tools.vitruv.framework.views.View; @@ -66,6 +77,10 @@ public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { @Accessors(AccessorType.PROTECTED_GETTER) private static final String MODEL_FILE_EXTENSION = "uml"; + + private static final String PCM_BASIC_COMPONENT_NAME = "Niklas Basic PCM component 1"; + + private static final String UML_MODEL_URI = "1234uri1234"; @Accessors(AccessorType.PUBLIC_GETTER) private org.eclipse.uml2.uml.Class class1; @@ -74,6 +89,10 @@ public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { private org.eclipse.uml2.uml.Class class2; protected ViewTestFactory improvedViewTestFactory; + + private Model umlModel; + + @BeforeEach public void setup() { @@ -82,7 +101,6 @@ public void setup() { it.setName(UML_MODEL_NAME); }; createBiggerUmlModel(setNameFunction); - //createPcmModel(); } @@ -91,57 +109,173 @@ public void setup() { public void testView() throws NoSuchMethodException, InvocationTargetException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { View createUmlView = improvedViewTestFactory.createUmlView(); Collection rootObjects = createUmlView.getRootObjects(); - ViewSelection selection = createUmlView.getSelection(); - - - -// Field declaredField = selection.getClass().getSuperclass().getDeclaredField("elementsSelection"); -// declaredField.setAccessible(true); -// HashMap map = (HashMap) declaredField.get(createUmlView); - //Selection should contain ModelImpl, and two SystemImpl. Only the ModelImpl should be //selected. - - - assert(rootObjects.stream().anyMatch(it -> it instanceof Model)); - assertEquals(rootObjects.size(), 1); + //Root Objects should only contain ModelImpl + assertEquals(countContainedModelImplInstances(rootObjects), 1); + assertEquals(1, rootObjects.size()); + for (EObject root : rootObjects) { + assertTrue(root instanceof ModelImpl); + assertEquals(UML_MODEL_URI, ((ModelImpl) root).getURI()); + } } @Test public void testCreateFilteredUmlView() { View view = improvedViewTestFactory.createFilteredUmlView(); - //View view = improvedViewTestFactory.createFilteredPcmView(); -// ((FilterSupportingIdentityMappingViewType) improvedViewTestFactory.viewType) -// .updateView(((ModifiableView) view)); + view.update(); view.update(); - view.getRootObjects(); - + Collection rootObjects = view.getRootObjects(); + assertEquals(rootObjects.size(), 1); + //TODO nbr: remove comments.. //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement //Root Objects: ModelImpl (aber nicht nur mit niklasClass2, sondern mit allem) + for (EObject root : rootObjects) { + assertTrue(root instanceof Model); + assertTrue(view.getSelection().isViewObjectSelected(root)); + assertEquals(root.eContents().size(), 1); + EObject eObject = root.eContents().get(0); + assertTrue(eObject instanceof org.eclipse.uml2.uml.Class); + org.eclipse.uml2.uml.Class classObject = (Class) eObject; + assertEquals(classObject.getName(), "niklasClass2"); + } + + modifyModel(); view.update(); view.getSelection(); - view.getRootObjects(); - //Selection: Nur ModelImpl mit zwei Klassen die jeweils niklasClass2 als Namen haben, als PackagedElement //ACHTUNG: Die zwei Klassen sind als PackagedElements in der ModelImpl! //Root Objects: ModelImpl + Collection modifiedRootObjects = view.getRootObjects(); + assertEquals(modifiedRootObjects.size(), 1); + for (EObject root : modifiedRootObjects) { + assertTrue(root instanceof Model); + assertTrue(view.getSelection().isViewObjectSelected(root)); + assertEquals(root.eContents().size(), 2); + for (EObject eObject : root.eContents()) { + assertTrue(eObject instanceof org.eclipse.uml2.uml.Class); + org.eclipse.uml2.uml.Class classObject = (Class) eObject; + assertEquals(classObject.getName(), "niklasClass2"); + } + } + } + + + @Test + public void testCreateFilteredUmlViewWithAdditionalPcmElementsInVsum() { + createPcmModel(); + View view = improvedViewTestFactory.createFilteredUmlView(); + view.update(); + view.update(); + //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement + //Root Objects: ModelImpl (aber nicht nur mit niklasClass2, sondern mit allem) und zwei weitere ModelImpls (aber andere) + Collection rootObjects = view.getRootObjects(); + assertEquals(rootObjects.size(), 1); + for (EObject root : rootObjects) { + assertTrue(root instanceof Model); + assertTrue(view.getSelection().isViewObjectSelected(root)); + assertEquals(root.eContents().size(), 1); + for (EObject eObject : root.eContents()) { + assertTrue(eObject instanceof org.eclipse.uml2.uml.Class); + org.eclipse.uml2.uml.Class classObject = (Class) eObject; + assertEquals(classObject.getName(), "niklasClass2"); + } + } + modifyModel(); + view.update(); + view.getSelection(); + //Selection: Nur ModelImpl mit zwei Klassen die jeweils niklasClass2 als Namen haben, als PackagedElement + //ACHTUNG: Die zwei Klassen sind als PackagedElements in der ModelImpl! + //Root Objects: ModelImpl, ModelImpl, ModelImpl + Collection modifiedRootObjects = view.getRootObjects(); + assertEquals(modifiedRootObjects.size(), 1); + for (EObject root : modifiedRootObjects) { + assertTrue(root instanceof Model); + assertTrue(view.getSelection().isViewObjectSelected(root)); + assertEquals(root.eContents().size(), 2); + for (EObject eObject : root.eContents()) { + assertTrue(eObject instanceof org.eclipse.uml2.uml.Class); + org.eclipse.uml2.uml.Class classObject = (Class) eObject; + assertEquals(classObject.getName(), "niklasClass2"); + } + } + view.getViewType(); } + @Test + public void testPcmView() throws NoSuchMethodException, InvocationTargetException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + createPcmModel(); + View createPcmView = improvedViewTestFactory.createPcmView(); + Collection rootObjects = createPcmView.getRootObjects(); + ViewSelection selection = createPcmView.getSelection(); + //Selection should contain 20 elements (0-19) with two RepositoryImpl selected. + //Root elements should be two RepositoryImpl + assertEquals(2, rootObjects.size()); + for (EObject root : rootObjects) { + assertTrue(root instanceof Repository); + } + } + + + @Test + public void testCreateFilteredPcmView() { + createPcmModel(); + View view = improvedViewTestFactory.createFilteredPcmView((EObject object) -> hasInstanceName(object, PCM_BASIC_COMPONENT_NAME)); + view.update(); + view.update(); + + Collection rootObjects = view.getRootObjects(); + assertEquals(rootObjects.size(), 1); + for (EObject root : rootObjects) { + assertTrue(root instanceof Repository); + assertTrue(view.getSelection().isViewObjectSelected(root)); + assertEquals(root.eContents().size(), 1); + EObject eObject = root.eContents().get(0); + assertTrue(eObject instanceof BasicComponent); + BasicComponent classObject = (BasicComponent) eObject; + assertEquals(PCM_BASIC_COMPONENT_NAME, classObject.getEntityName()); + } + + + //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement + //Root Objects: ModelImpl (aber nicht nur mit niklasClass2, sondern mit allem) und zwei weitere ModelImpls (aber andere) + + modifyModel(); + view.update(); + view.getSelection(); + //Selection: Nur ModelImpl mit zwei Klassen die jeweils niklasClass2 als Namen haben, als PackagedElement + //ACHTUNG: Die zwei Klassen sind als PackagedElements in der ModelImpl! + //Root Objects: ModelImpl, ModelImpl, ModelImpl + Collection modifiedRootObjects = view.getRootObjects(); + assertEquals(modifiedRootObjects.size(), 1); + for (EObject root : modifiedRootObjects) { + assertTrue(root instanceof Repository); + assertTrue(view.getSelection().isViewObjectSelected(root)); + assertEquals(root.eContents().size(), 1); + EObject eObject = root.eContents().get(0); + assertTrue(eObject instanceof BasicComponent); + BasicComponent classObject = (BasicComponent) eObject; + assertEquals(PCM_BASIC_COMPONENT_NAME, classObject.getEntityName()); + } + } + + protected void createBiggerUmlModel(final Procedure1 modelInitialization) { try { final Consumer firstChangeUmlFunction = (CommittableView it) -> { - final Model umlModel = UMLFactory.eINSTANCE.createModel(); + umlModel = UMLFactory.eINSTANCE.createModel(); createAndRegisterRoot(it, umlModel, this.getUri(getProjectModelPath(UML_MODEL_NAME))); modelInitialization.apply(umlModel); + umlModel.setURI(UML_MODEL_URI); }; improvedViewTestFactory.changeUmlView(firstChangeUmlFunction); @@ -218,6 +352,54 @@ private void modifyModel() { } } + + protected void createPcmModel() { + + getUserInteraction().addNextTextInput(PcmUmlClassApplicationTestHelper.UML_MODEL_FILE); + Consumer createPcmRepoFunction = (CommittableView it) -> { + Repository repository = RepositoryFactory.eINSTANCE.createRepository(); + repository.setEntityName(PCM_MODEL_NAME); + it.registerRoot(repository, getUri(getPcmProjectModelPath(repository.getEntityName(), PCM_REPOSITORY_FILE_EXTENSION))); + //createAndRegisterRoot(it, repository, this.getUri(getProjectModelPath(PCM_MODEL_NAME))); + }; + + try { + improvedViewTestFactory.changePcmView(createPcmRepoFunction); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + Consumer changePcmFunction = (CommittableView it) -> { + Repository repository = getDefaultPcmRepository(it); + BasicComponent createBasicComponent = RepositoryFactory.eINSTANCE.createBasicComponent(); + createBasicComponent.setEntityName(PCM_BASIC_COMPONENT_NAME); + repository.getComponents__Repository().add(createBasicComponent); + + CompositeDataType compositeDataType1 = RepositoryFactory.eINSTANCE.createCompositeDataType(); + compositeDataType1.setEntityName("niklasPcmCompositeDataType1"); + repository.getDataTypes__Repository().add(compositeDataType1); + + }; + + try { + improvedViewTestFactory.changePcmView(changePcmFunction); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + private boolean hasInstanceName(EObject object, String name) { + if (object instanceof org.palladiosimulator.pcm.core.entity.NamedElement) { + if (name.equals(((org.palladiosimulator.pcm.core.entity.NamedElement) object).getEntityName())) { + return true; + } + } + return false; + } + + private Path getPcmProjectModelPath(String modelName, String modelFileExtension) { return Path.of("pcm").resolve(modelName + "." + modelFileExtension); } @@ -234,6 +416,9 @@ protected Model getDefaultUmlModel(final View view) { return UmlQueryUtil.claimUmlModel(view, UML_MODEL_NAME); } + private Repository getDefaultPcmRepository(View view) { + return PcmQueryUtil.claimPcmRepository(view, PCM_MODEL_NAME); + } @Override protected Iterable getChangePropagationSpecifications() { @@ -244,5 +429,18 @@ protected Iterable getChangePropagatio _combinedPcmToUmlClassReactionsChangePropagationSpecification, _combinedUmlClassToPcmReactionsChangePropagationSpecification)); } + + + private int countContainedModelImplInstances(Collection collection) { + int count = 0; + Iterator iterator = collection.iterator(); + while(iterator.hasNext()) { + EObject next = iterator.next(); + if (next instanceof ModelImpl) { + count++; + } + } + return count; + } } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index b29a33bbf..a828631d7 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -47,7 +47,7 @@ public View createUmlView() { return createViewOfElements("UML", rootTypes); } - private View createPcmView() { + public View createPcmView() { Collection> rootTypes = createCollectionOfRootTypes(Repository.class); rootTypes.add(RepositoryComponent.class); return createViewOfElements("PCM packages and components", rootTypes); @@ -80,9 +80,9 @@ public View createFilteredUmlView() { return createFilteredForNoAttributesViewOfElements("UML", rootTypes); } - public View createFilteredPcmView() { + public View createFilteredPcmView(Function filterFunction) { Collection> rootTypes = createCollectionOfRootTypes(Repository.class); - return createFilteredForNoAttributesViewOfElements("PCM", rootTypes); + return createFilteredForNoAttributesViewOfElements("PCM", rootTypes, filterFunction); } @@ -97,7 +97,7 @@ public View createCountUmlElementsView(Function filterFunction // public View createViewOfElements(String viewName, Collection> rootTypes) { - ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); + ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); selector.getSelectableElements().stream() .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) .forEach(element -> selector.setSelected(element, true)); @@ -154,13 +154,16 @@ public View createFilteredForNoAttributesViewOfElements(String viewName, Collect } - private boolean hasInstanceName(EObject object, String name) { - if (object instanceof org.palladiosimulator.pcm.core.entity.NamedElement) { - if (name.equals(((org.palladiosimulator.pcm.core.entity.NamedElement) object).getEntityName())) { - return true; - } - } - return false; + private View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes, Function filterFunction) { + viewType = FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName); + FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); + Function function = (EObject object) -> filterFunction.apply(object); + selector.deselectElementsExceptForRootType(rootTypes); + selector.addElementsToSelectionByLambda(function); + + View view = selector.createView(); + assertThat("view must not be null", view, not(equalTo(null))); + return view; } From 1e7525c334e713cef278f74d8fb5eec36d21277a Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:04:54 +0100 Subject: [PATCH 20/62] Added test for correct informationView behaviour --- .../viewfilter/tests/InstanceFilterTest.java | 65 +++++++++++++++++-- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index f842fcdd8..4350e77a7 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -1,9 +1,11 @@ package tools.vitruv.applications.viewfilter.tests; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.reflect.Field; @@ -17,6 +19,7 @@ import java.util.Iterator; import java.util.List; import java.util.function.Consumer; +import java.util.function.Function; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; @@ -27,6 +30,7 @@ import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.PackageableElement; import org.eclipse.uml2.uml.PrimitiveType; import org.eclipse.uml2.uml.UMLFactory; @@ -36,6 +40,7 @@ import org.eclipse.xtext.xbase.lib.CollectionLiterals; import org.eclipse.xtext.xbase.lib.Exceptions; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -44,6 +49,9 @@ import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.repository.RepositoryFactory; +import com.niklas.niklasproject.niklasdomain.InformationStructure; +import com.niklas.niklasproject.niklasdomain.SingleInformation; + import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; import tools.vitruv.applications.testutility.uml.UmlQueryUtil; @@ -106,7 +114,7 @@ public void setup() { //--- Actual tests --- @Test - public void testView() throws NoSuchMethodException, InvocationTargetException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + public void testUmlView() throws NoSuchMethodException, InvocationTargetException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { View createUmlView = improvedViewTestFactory.createUmlView(); Collection rootObjects = createUmlView.getRootObjects(); //Selection should contain ModelImpl, and two SystemImpl. Only the ModelImpl should be @@ -142,8 +150,6 @@ public void testCreateFilteredUmlView() { assertEquals(classObject.getName(), "niklasClass2"); } - - modifyModel(); view.update(); view.getSelection(); @@ -243,10 +249,8 @@ public void testCreateFilteredPcmView() { assertEquals(PCM_BASIC_COMPONENT_NAME, classObject.getEntityName()); } - //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement //Root Objects: ModelImpl (aber nicht nur mit niklasClass2, sondern mit allem) und zwei weitere ModelImpls (aber andere) - modifyModel(); view.update(); view.getSelection(); @@ -266,6 +270,45 @@ public void testCreateFilteredPcmView() { } } + @Test + public void testCreateCountingView() { + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + View view = improvedViewTestFactory.createCountUmlElementsView(function); + Assertions.assertNotNull(view.getSelection(), "selection must not be null"); + + Collection rootObjects = view.getRootObjects(); + assertEquals(rootObjects.size(), 1); + for (EObject root : rootObjects) { + assertTrue(root instanceof InformationStructure); + assertTrue(view.getSelection().isViewObjectSelected(root)); + assertEquals(root.eContents().size(), 1); + EObject eObject = root.eContents().get(0); + assertTrue(eObject instanceof SingleInformation); + SingleInformation singleInformation = (SingleInformation) eObject; + assertEquals("Anzahl Elemente", singleInformation.getTitle()); + assertEquals(1, singleInformation.getValue()); + } + + + modifyModel(); + view.update(); + + rootObjects = view.getRootObjects(); + assertEquals(rootObjects.size(), 1); + for (EObject root : rootObjects) { + assertTrue(root instanceof InformationStructure); + assertTrue(view.getSelection().isViewObjectSelected(root)); + assertEquals(root.eContents().size(), 1); + EObject eObject = root.eContents().get(0); + assertTrue(eObject instanceof SingleInformation); + SingleInformation singleInformation = (SingleInformation) eObject; + assertEquals("Anzahl Elemente", singleInformation.getTitle()); + assertEquals(2, singleInformation.getValue()); + } + + view.getSelection(); + } + @@ -442,5 +485,17 @@ private int countContainedModelImplInstances(Collection collection) { } return count; } + + + private boolean hasNoAttribute(EObject object, String name) { + if (object instanceof org.eclipse.uml2.uml.Class) { + if (object instanceof NamedElement) { + if (name.equals(((NamedElement) object).getName())) { + return true; + } + } + } + return false; + } } From cad4f2dd33c929bcd24038fd17e1a46919b3a5d8 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:11:33 +0100 Subject: [PATCH 21/62] Added JavaDoc and some minor code quality improvements --- .../FilterSupportingViewElementSelector.java | 46 ++++++++++++++++--- ...lterSupportingViewElementSelectorImpl.java | 4 +- .../viewfilter/tests/InstanceFilterTest.java | 7 ++- .../viewfilter/tests/ViewTestFactory.java | 29 ++++++------ 4 files changed, 61 insertions(+), 25 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java index 8d0551b67..7fd424aac 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java @@ -7,18 +7,50 @@ import tools.vitruv.framework.views.ViewSelector; -//TODO nbr add javadoc +/** + * Instances of this interface provide various methods for filtering. Filtering is not only + * restricted on the model-roots. Instead, the selector filters individual elements of the + * model. The model contained in a constructed {@link View} might not contain objects + * which equal to the original objects in the original model. + * + * Example: + * + * Root + * - Element_1 + * - Element_2 + * - Child_Element_1 + * + * The selector still does only select the model-root itself, but it can further filter + * the model-elements, like Element_1 and Child_Element_1. So one could use an instance + * of {@link FilterSupportingViewElementSelector} to select Root and than further filter + * for Element_1 and Child_Element_1. If the {@link FilterSupportingViewElementSelector} + * is then used to create a corresponding {@link View}, this {@link View} will contain + * a Model-Root and only Element_1 and Child_Element_1 attached to the Model-Root. + */ public interface FilterSupportingViewElementSelector extends ViewSelector { - - //TODO nbr Remove this method (replaced by removeOwnedAttributesFromClasses - @Deprecated - void selectElementsOfRootType(Collection> rootTypes); + /** + * Method deselects all models which are not of one of the given rootTypes. + * Obviously, the method will remove whole models and not only certain elements + * of one model, as all elements of a model are from the same root type. + * + * @param rootTypes The rootTypes which are supposed to be removed + */ void deselectElementsExceptForRootType(Collection> rootTypes); - void addElementsToSelectionByLambda(Function filter); + /** + * Filters all Model-Elements by the given function. Notice: This method won't + * change the selection, but only modifies the filter used to filter Model-Elements. + * + * @param filter The function which is supposed to be used for filtering + */ + void filterModelElementsByLambda(Function filter); - void removeOwnedAttributesFromClasses(); + /** + * Method filters out all attributes of {@link org.eclipse.uml2.uml.Class} instances. + * Won't change instances of other types. + */ + void removeOwnedAttributesFromUmlClasses(); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java index c244b17cc..755bdb2d5 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java @@ -79,11 +79,11 @@ public void deselectElementsExceptForRootType(Collection> rootTypes) { .forEach(element -> setSelected(element, false)); } - public void addElementsToSelectionByLambda(Function filter) { + public void filterModelElementsByLambda(Function filter) { viewFilterBuilder.filterByLambda(filter); } - public void removeOwnedAttributesFromClasses() { + public void removeOwnedAttributesFromUmlClasses() { viewFilterBuilder.removeOwnedUmlAttributes(); } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index 4350e77a7..d610fc2ae 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -131,7 +131,8 @@ public void testUmlView() throws NoSuchMethodException, InvocationTargetExceptio @Test public void testCreateFilteredUmlView() { - View view = improvedViewTestFactory.createFilteredUmlView(); + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + View view = improvedViewTestFactory.createFilteredUmlView(function); view.update(); view.update(); @@ -174,7 +175,9 @@ public void testCreateFilteredUmlView() { @Test public void testCreateFilteredUmlViewWithAdditionalPcmElementsInVsum() { createPcmModel(); - View view = improvedViewTestFactory.createFilteredUmlView(); + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + + View view = improvedViewTestFactory.createFilteredUmlView(function); view.update(); view.update(); //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index a828631d7..ce746e53c 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -61,7 +61,8 @@ public View createUmlAndPcmClassesView() { public View createFilteredUmlView(FirstTest test) { Collection> rootTypes = createCollectionOfRootTypes(Model.class); - View view = createFilteredForNoAttributesViewOfElements("UML", rootTypes); + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + View view = createFilteredForNoAttributesViewOfElements("UML", rootTypes, function); view.getSelection().isViewObjectSelected(test.getClass1()); view.getSelection().isViewObjectSelected(test.getClass2()); return view; @@ -69,20 +70,21 @@ public View createFilteredUmlView(FirstTest test) { public View createFilteredUmlView(BasicViewFilterTest test) { Collection> rootTypes = createCollectionOfRootTypes(Model.class); - View view = createFilteredForNoAttributesViewOfElements("UML", rootTypes); + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + View view = createFilteredForNoAttributesViewOfElements("UML", rootTypes, function); view.getSelection().isViewObjectSelected(test.getClass1()); view.getSelection().isViewObjectSelected(test.getClass2()); return view; } - public View createFilteredUmlView() { + public View createFilteredUmlView(Function function) { Collection> rootTypes = createCollectionOfRootTypes(Model.class); - return createFilteredForNoAttributesViewOfElements("UML", rootTypes); + return createFilteredForNoAttributesViewOfElements("UML", rootTypes, function); } public View createFilteredPcmView(Function filterFunction) { Collection> rootTypes = createCollectionOfRootTypes(Repository.class); - return createFilteredForNoAttributesViewOfElements("PCM", rootTypes, filterFunction); + return createFilteredViewOfElements("PCM", rootTypes, filterFunction); } @@ -130,9 +132,9 @@ public void changePcmView(Consumer modelModification) throws Ex public View createAbstractedFilteredView(String viewName, Collection> rootTypes, Function filterFunction) { viewType = FilterSupportingViewTypeFactory.createAbstractedFilterViewViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); - selector.selectElementsOfRootType(rootTypes); - selector.addElementsToSelectionByLambda(filterFunction); - selector.removeOwnedAttributesFromClasses(); + selector.deselectElementsExceptForRootType(rootTypes); + selector.filterModelElementsByLambda(filterFunction); + selector.removeOwnedAttributesFromUmlClasses(); View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); @@ -140,13 +142,12 @@ public View createAbstractedFilteredView(String viewName, Collection> r } - public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes) { + public View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes, Function function) { viewType = FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); selector.deselectElementsExceptForRootType(rootTypes); - selector.addElementsToSelectionByLambda(function); - selector.removeOwnedAttributesFromClasses(); + selector.filterModelElementsByLambda(function); + selector.removeOwnedAttributesFromUmlClasses(); View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); @@ -154,12 +155,12 @@ public View createFilteredForNoAttributesViewOfElements(String viewName, Collect } - private View createFilteredForNoAttributesViewOfElements(String viewName, Collection> rootTypes, Function filterFunction) { + private View createFilteredViewOfElements(String viewName, Collection> rootTypes, Function filterFunction) { viewType = FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); Function function = (EObject object) -> filterFunction.apply(object); selector.deselectElementsExceptForRootType(rootTypes); - selector.addElementsToSelectionByLambda(function); + selector.filterModelElementsByLambda(function); View view = selector.createView(); assertThat("view must not be null", view, not(equalTo(null))); From e6064c0131b545075530ae339bc721af1c2166fb Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 2 Feb 2024 18:12:04 +0100 Subject: [PATCH 22/62] Added tests for view modification --- .../viewfilter/tests/BasicViewFilterTest.java | 54 ++++++++++++++++--- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index cc00c15c3..16e1cd731 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -4,6 +4,7 @@ import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; import java.nio.file.Path; +import java.util.Collection; import java.util.Collections; import java.util.function.Consumer; import java.util.function.Function; @@ -128,14 +129,51 @@ public void testCreateCountingView() { } - -// @Test -// public void testFilterForName() { -// final Procedure1 _function = (Model it) -> { -// it.setName((FirstTest.UML_MODEL_NAME + "big")); -// }; -// this.createAdvancedUmlModel(_function); -// } + @Test + public void testModifyView() { + View view = improvedViewTestFactory.createUmlView(); + CommittableView withChangeDerivingTrait = view.withChangeDerivingTrait(); + Collection rootObjects = withChangeDerivingTrait.getRootObjects(); + + for (EObject root : rootObjects) { + Model model = (Model) root; + for (EObject content : model.eContents()) { + if (content instanceof org.eclipse.uml2.uml.Package) { + org.eclipse.uml2.uml.Package umlPackage = (org.eclipse.uml2.uml.Package) content; + umlPackage.setName("test"); + } + } + + } + + withChangeDerivingTrait.commitChangesAndUpdate(); + view.getRootObjects(); + } + + + @Test + public void testModifyFilteredView() { + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + View view = improvedViewTestFactory.createFilteredUmlView(function); + CommittableView withChangeDerivingTrait = view.withChangeDerivingTrait(); + Collection rootObjects = withChangeDerivingTrait.getRootObjects(); + + for (EObject root : rootObjects) { + Model model = (Model) root; + for (EObject content : model.eContents()) { + if (content instanceof org.eclipse.uml2.uml.Class) { + org.eclipse.uml2.uml.Class umlClass = (org.eclipse.uml2.uml.Class) content; + umlClass.setName("modifiedNiklasClass2"); + } + } + + } + + withChangeDerivingTrait.commitChangesAndUpdate(); + view.getRootObjects(); + } + + @Override protected Iterable getChangePropagationSpecifications() { From 45bae4da97b1361e1dac2d1e7cb4f32f934633aa Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 2 Feb 2024 19:20:56 +0100 Subject: [PATCH 23/62] Made InformationView implementation more generic --- ...r.java => CountElementsTransformator.java} | 16 ++++++++++--- .../CountUmlClassesTransformator.java | 23 +++++++++++++++++++ .../InformationViewTransformator.java | 11 +++++++++ .../FilterSupportingViewTypeFactory.java | 6 ++--- ...rmationFilterIdentityMappingViewType.java} | 4 ++-- .../views/BasicInformationFilterView.java | 12 +++------- .../viewfilter/tests/ViewTestFactory.java | 6 ++--- 7 files changed, 58 insertions(+), 20 deletions(-) rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/{UmlToInformationTransformator.java => CountElementsTransformator.java} (71%) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountUmlClassesTransformator.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/{AbstractingInformationFilterIdentityMappingViewType.java => InformationFilterIdentityMappingViewType.java} (81%) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/UmlToInformationTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountElementsTransformator.java similarity index 71% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/UmlToInformationTransformator.java rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountElementsTransformator.java index 1f4bbe92d..01c9b8e32 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/UmlToInformationTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountElementsTransformator.java @@ -6,11 +6,14 @@ import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; import java.util.List; +import java.util.function.Function; import org.eclipse.emf.ecore.EObject; import org.eclipse.uml2.uml.Model; -public class UmlToInformationTransformator { +//TODO nbr add javadoc +public abstract class CountElementsTransformator extends InformationViewTransformator { + public SingleInformation transform(EObject root) { if (!(root instanceof Model)) { @@ -19,14 +22,14 @@ public SingleInformation transform(EObject root) { } //TODO nbruening hier noch generischer machen SingleInformation createSingleInformation = NiklasdomainFactory.eINSTANCE.createSingleInformation(); - createSingleInformation.setTitle("Anzahl Elemente"); + createSingleInformation.setTitle(getTitle()); List allElements = ViewFilterHelper.convertTreeIterator2List(root.eAllContents()); int count = 0; for (EObject element : allElements) { - if (element instanceof org.eclipse.uml2.uml.Class) { + if (takeElementIntoAccount(element)) { count++; } } @@ -34,4 +37,11 @@ public SingleInformation transform(EObject root) { createSingleInformation.setValue(count); return createSingleInformation; } + + + protected abstract boolean takeElementIntoAccount(EObject object); + + protected abstract String getTitle(); + + } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountUmlClassesTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountUmlClassesTransformator.java new file mode 100644 index 000000000..849f6a31f --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountUmlClassesTransformator.java @@ -0,0 +1,23 @@ +package tools.vitruv.application.viewfilter.transformation; + +import org.eclipse.emf.ecore.EObject; + +public class CountUmlClassesTransformator extends CountElementsTransformator { + + private static final String ANZAHL_ELEMENTE = "Anzahl Elemente"; + + @Override + protected boolean takeElementIntoAccount(EObject object) { + if (object instanceof org.eclipse.uml2.uml.Class) { + return true; + } else { + return false; + } + } + + @Override + protected String getTitle() { + return ANZAHL_ELEMENTE; + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java new file mode 100644 index 000000000..9ea5bcb68 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java @@ -0,0 +1,11 @@ +package tools.vitruv.application.viewfilter.transformation; + +import org.eclipse.emf.ecore.EObject; + +import com.niklas.niklasproject.niklasdomain.SingleInformation; + +public abstract class InformationViewTransformator { + + public abstract SingleInformation transform(EObject root); + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java index 18658f583..2bc1f6c93 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java @@ -2,7 +2,7 @@ import org.eclipse.net4j.util.ImplementationError; -import tools.vitruv.applications.viewfilter.util.framework.impl.AbstractingInformationFilterIdentityMappingViewType; +import tools.vitruv.applications.viewfilter.util.framework.impl.InformationFilterIdentityMappingViewType; import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; import tools.vitruv.framework.views.ViewSelector; import tools.vitruv.framework.views.ViewType; @@ -15,7 +15,7 @@ public static ViewType createFilterSupportingIdentityMap } - public static ViewType createAbstractedFilterViewViewType(String name) { - return new AbstractingInformationFilterIdentityMappingViewType(name); + public static ViewType createInformationFilterViewViewType(String name) { + return new InformationFilterIdentityMappingViewType(name); } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/InformationFilterIdentityMappingViewType.java similarity index 81% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/InformationFilterIdentityMappingViewType.java index e24ce1b9e..cb5f97ea2 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractingInformationFilterIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/InformationFilterIdentityMappingViewType.java @@ -7,9 +7,9 @@ import tools.vitruv.applications.viewfilter.views.BasicInformationFilterView; import tools.vitruv.change.atomic.hid.HierarchicalId; -public class AbstractingInformationFilterIdentityMappingViewType extends FilterSupportingIdentityMappingViewType { +public class InformationFilterIdentityMappingViewType extends FilterSupportingIdentityMappingViewType { - public AbstractingInformationFilterIdentityMappingViewType(String name) { + public InformationFilterIdentityMappingViewType(String name) { super(name); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java index 44dba9ecd..408ef5ab2 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java @@ -16,7 +16,8 @@ import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; import com.niklas.niklasproject.niklasdomain.SingleInformation; -import tools.vitruv.application.viewfilter.transformation.UmlToInformationTransformator; +import tools.vitruv.application.viewfilter.transformation.CountElementsTransformator; +import tools.vitruv.application.viewfilter.transformation.CountUmlClassesTransformator; import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; @@ -40,26 +41,19 @@ protected void updateRootAndSelectedElements(ModifiableViewSelection selection) if (selection == null) { throw new NullPointerException("selection is null"); } - UmlToInformationTransformator transformator = new UmlToInformationTransformator(); + CountElementsTransformator transformator = new CountUmlClassesTransformator(); InformationStructure informationStructure = NiklasdomainFactory.eINSTANCE.createInformationStructure(); EList singleinformationList = informationStructure.getSingleinformation(); - //TODO nbr Hier weitermachen! die selectableElements entsprechen den gefilterten Elementen => daraus muss ich meine Informationen berechnen for(EObject root : selection.getSelectableElements()) { if (selection.isSelected(root)) { SingleInformation transformResult = transformator.transform(root); if (transformResult != null) { singleinformationList.add(transformResult); - // mapOriginalRoot2RootStub. - // mapOriginalRoot2RootStub_.put(mapOriginalRoot2RootStub.get(root)), ) } } } -// for (EObject key : mapOriginalRoot2FilteredRootStub.keySet()) { -// getMapOriginalRoot2InformationRoot().put(key, informationStructure); -// } - List selectionList = new ArrayList(); selectionList.add(informationStructure); diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index ce746e53c..7ca234c75 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -90,7 +90,7 @@ public View createFilteredPcmView(Function filterFunction) { public View createCountUmlElementsView(Function filterFunction) { Collection> rootTypes = createCollectionOfRootTypes(Model.class); - return createAbstractedFilteredView("Information Page", rootTypes, filterFunction); + return createInformationView("Information Page", rootTypes, filterFunction); } @@ -129,8 +129,8 @@ public void changePcmView(Consumer modelModification) throws Ex //-------------End of Boilerplate code----------------// - public View createAbstractedFilteredView(String viewName, Collection> rootTypes, Function filterFunction) { - viewType = FilterSupportingViewTypeFactory.createAbstractedFilterViewViewType(viewName); + public View createInformationView(String viewName, Collection> rootTypes, Function filterFunction) { + viewType = FilterSupportingViewTypeFactory.createInformationFilterViewViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); selector.deselectElementsExceptForRootType(rootTypes); selector.filterModelElementsByLambda(filterFunction); From 1d83e1a051ac34149ccc3cf183e061bb49fa4935 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:04:18 +0100 Subject: [PATCH 24/62] Current state --- .../.classpath | 3 + .../META-INF/MANIFEST.MF | 4 +- .../change/FilterOnOriginalResolver.java | 42 +++++++ .../InformationViewTransformator.java | 15 +++ .../framework/impl/ChangeDerivingView.xtend | 6 +- .../framework/impl/ChangeRecordingView.xtend | 8 +- ...lterSupportingIdentityMappingViewType.java | 43 ++++++- .../viewfilter/viewbuild/ViewFilter.java | 7 ++ .../viewfilter/viewbuild/ViewFilterImpl.java | 33 +++++- .../viewfilter/views/BasicFilterView.java | 90 ++++++++++++++- .../views/FilterChangeDerivingView.java | 102 +++++++++++++++++ .../views/FilterChangeRecordingView.java | 106 ++++++++++++++++++ .../viewfilter/views/FilterableView.java | 19 ++++ .../viewfilter/tests/BasicViewFilterTest.java | 73 +++++++++--- .../viewfilter/tests/InstanceFilterTest.java | 12 +- 15 files changed, 522 insertions(+), 41 deletions(-) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/change/FilterOnOriginalResolver.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java diff --git a/bundles/tools.vitruv.applications.viewtest/.classpath b/bundles/tools.vitruv.applications.viewtest/.classpath index 412b338a8..613688a94 100644 --- a/bundles/tools.vitruv.applications.viewtest/.classpath +++ b/bundles/tools.vitruv.applications.viewtest/.classpath @@ -4,6 +4,9 @@ + + +
diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF index 13dd13766..d14d77030 100644 --- a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF +++ b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF @@ -14,7 +14,9 @@ Require-Bundle: org.eclipse.uml2.uml;visibility:=reexport, tools.vitruv.framework.applications, tools.vitruv.dsls.reactions.runtime, tools.vitruv.applications.util.temporary, - tools.vitruv.framework.views;bundle-version="3.0.1" + tools.vitruv.framework.views;bundle-version="3.0.1", + tools.vitruv.change.atomic, + tools.vitruv.change.composite Bundle-Vendor: vitruv.tools Export-Package: tools.vitruv.applications.viewfilter.util.framework, tools.vitruv.applications.viewfilter.util.framework.impl, diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/change/FilterOnOriginalResolver.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/change/FilterOnOriginalResolver.java new file mode 100644 index 000000000..383c21240 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/change/FilterOnOriginalResolver.java @@ -0,0 +1,42 @@ +package tools.vitruv.application.viewfilter.change; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.net4j.util.ImplementationError; + +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.change.composite.description.CompositeContainerChange; +import tools.vitruv.change.composite.description.TransactionalChange; +import tools.vitruv.change.composite.description.VitruviusChange; +import tools.vitruv.change.composite.description.VitruviusChangeFactory; +import tools.vitruv.change.composite.description.VitruviusChangeResolver; + +public class FilterOnOriginalResolver implements VitruviusChangeResolver { + + + public VitruviusChange resolveFilteredChangesOnOriginalSources(VitruviusChange change) { + +// if (change instanceof CompositeContainerChange compositeChange) { +// //TODO nbr implement +// throw new ImplementationError("Not implemented"); +// } else if (change instanceof TransactionalChange transactionalChange) { +// transactionalChange. +// } + throw new IllegalStateException( + "trying to transform unknown change of class " + change.getClass().getSimpleName()); + } + + @Override + public VitruviusChange resolveAndApply(VitruviusChange change) { + + // TODO Auto-generated method stub + return null; + } + + @Override + public VitruviusChange assignIds(VitruviusChange change) { + // TODO Auto-generated method stub + throw new ImplementationError("Not implemented yet"); + + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java index 9ea5bcb68..bac449a87 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java @@ -4,8 +4,23 @@ import com.niklas.niklasproject.niklasdomain.SingleInformation; +/** + * Transforms a given model into a {@link SingleInformation}. A transformation could be + * counting the elements of a certain type in the given model for instance. + * The actual transformation depends on the overwriting implementation.} + */ public abstract class InformationViewTransformator { + /** + * Method transforms the given model (represented by its root) into a {@link SingleInformation}. + * The transformation corresponds to the calculation of the actual information, which will than + * be represented by the {@link SingleInformation} instance which the method returns. + * A transformation could be counting the elements of a certain type in the given model for instance. + * The actual transformation depends on the actual implementation of this method + * + * @param root The root element of the model which is supposed to be transformed + * @return The information which has been extracted from the given model + */ public abstract SingleInformation transform(EObject root); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend index f6bc723d4..76f744d08 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend @@ -26,7 +26,7 @@ import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopie */ class ChangeDerivingView implements ModifiableView, CommittableView { @Delegate - BasicView view + protected BasicView view val StateBasedChangeResolutionStrategy changeResolutionStrategy var ResourceSet originalStateViewResourceSet @@ -48,7 +48,7 @@ class ChangeDerivingView implements ModifiableView, CommittableView { setupReferenceState } - private def setupReferenceState() { + protected def setupReferenceState() { originalStateViewResourceSet = new ResourceSetImpl ResourceCopier.copyViewResources(view.viewResourceSet.resources, originalStateViewResourceSet) originalStateResourceMapping = new HashMap @@ -76,7 +76,7 @@ class ChangeDerivingView implements ModifiableView, CommittableView { view.close } - private def VitruviusChange generateChange(Resource newState, Resource referenceState) { + protected def VitruviusChange generateChange(Resource newState, Resource referenceState) { if (referenceState === null) { return changeResolutionStrategy.getChangeSequenceForCreated(newState) } else if (newState === null) { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend index 58ba59358..818abc07a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend @@ -16,8 +16,8 @@ import static com.google.common.base.Preconditions.checkState */ class ChangeRecordingView implements ModifiableView, CommittableView { @Delegate - BasicView view - ChangeRecorder changeRecorder + protected BasicView view + protected ChangeRecorder changeRecorder protected new(BasicView view) { checkArgument(view !== null, "view must not be null") @@ -32,7 +32,7 @@ class ChangeRecordingView implements ModifiableView, CommittableView { setupChangeRecorder } - private def setupChangeRecorder() { + protected def setupChangeRecorder() { changeRecorder = new ChangeRecorder(view.viewResourceSet) changeRecorder.addToRecording(view.viewResourceSet) changeRecorder.beginRecording() @@ -55,7 +55,7 @@ class ChangeRecordingView implements ModifiableView, CommittableView { view.close() } - private def void endRecordingAndClose(ChangeRecorder recorder) { + protected def void endRecordingAndClose(ChangeRecorder recorder) { if (recorder.isRecording) { recorder.endRecording() } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index ecb7c390b..765c5e89b 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -19,12 +19,15 @@ import org.eclipse.uml2.uml.internal.resource.UMLResourceImpl; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; +import tools.vitruv.application.viewfilter.change.FilterOnOriginalResolver; import tools.vitruv.applications.viewfilter.util.framework.selectors.DirectViewElementSelector; import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelectorImpl; import tools.vitruv.applications.viewfilter.views.BasicFilterView; +import tools.vitruv.applications.viewfilter.views.FilterableView; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.atomic.uuid.Uuid; import tools.vitruv.change.atomic.uuid.UuidResolver; +import tools.vitruv.change.composite.description.CompositeContainerChange; import tools.vitruv.change.composite.description.VitruviusChange; import tools.vitruv.change.composite.description.VitruviusChangeResolver; import tools.vitruv.framework.views.ChangeableViewSource; @@ -76,8 +79,32 @@ public void updateView(ModifiableView view) { }); } + + public void commitViewChanges(FilterableView view, VitruviusChange viewChange) { + ResourceSet viewSourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); +// VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIds(viewSourceCopyResourceSet); + VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(viewSourceCopyResourceSet, view.getFilteredModelsInResourceSet(), view.getMapCopy2OriginalObject()); + UuidResolver viewSourceCopyUuidResolver = UuidResolver.create(viewSourceCopyResourceSet); + VitruviusChangeResolver uuidChangeResolver = VitruviusChangeResolver.forUuids(viewSourceCopyUuidResolver); + Map mapping = createViewResources(view, viewSourceCopyResourceSet); + mapChangeOnSourceIds(viewChange); + view.getViewSource().getUuidResolver().resolveResources(mapping, viewSourceCopyUuidResolver); + + +// FilterOnOriginalResolver filterOnOriginalResolver = new FilterOnOriginalResolver(); +// filterOnOriginalResolver.resolveFilteredChangesOnOriginalSources(viewChange); + VitruviusChange resolvedChange = idChangeResolver.resolveAndApply(viewChange); + VitruviusChange unresolvedChanges = uuidChangeResolver.assignIds(resolvedChange); + view.getViewSource().propagateChange(unresolvedChanges); + } + + @Override public void commitViewChanges(ModifiableView view, VitruviusChange viewChange) { + if (view instanceof FilterableView filterableView) { + commitViewChanges(filterableView, viewChange); + return; + } ResourceSet viewSourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIds(viewSourceCopyResourceSet); UuidResolver viewSourceCopyUuidResolver = UuidResolver.create(viewSourceCopyResourceSet); @@ -92,10 +119,24 @@ public void commitViewChanges(ModifiableView view, VitruviusChange createViewResources(ModifiableView view, ResourceSet viewResourceSet) { Collection viewSources = view.getViewSource().getViewSourceModels(); - ViewSelection selection = ((BasicFilterView) view).getPreFilterSelection(); + ViewSelection selection = ((FilterableView) view).getPreFilterSelection(); List resourcesWithSelectedElements = viewSources.stream() .filter(resource -> resource.getContents().stream().anyMatch(selection::isViewObjectSelected)).toList(); return ResourceCopier.copyViewSourceResources(resourcesWithSelectedElements, viewResourceSet, selection::isViewObjectSelected); } + + + private void mapChangeOnSourceIds(VitruviusChange viewChange) { + if (viewChange instanceof CompositeContainerChange compositeChange) { + + } else { + + } + + + viewChange.getAffectedEObjects(); + + } + } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java index c77828710..740e7bc3f 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java @@ -29,4 +29,11 @@ public interface ViewFilter { * to the used filter. */ Set filterElements(Collection roots); + + + //TODO nbr add javadoc + public Map getMapCopy2Original(); + + + } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index 3139a3fef..2c7525389 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -34,20 +34,25 @@ public class ViewFilterImpl implements ViewFilter { private final ViewFilterBuilder builder; + private Map mapCopy2Original; + private ViewFilterImpl(ViewFilterBuilder viewFilterBuilder) { builder = viewFilterBuilder; } public Set filterElements(Collection roots) { + mapCopy2Original = new HashMap(); + //Collection rootsCopy = EcoreUtil.copyAll(roots); rootListForView = new HashSet(); - addElementsToSelectionByLambda(roots); + + copyElementsOfRootTypeToSelectionByLambda(roots); removeOwnedAttributesFromUmlClasses(); return rootListForView; } - private void addElementsToSelectionByLambda(Collection roots) { + private void copyElementsOfRootTypeToSelectionByLambda(Collection roots) { if (!builder.filterByLambdaActive) { return; } @@ -81,7 +86,7 @@ private void filterAllContents(EObject root, Function filter, EObject contentElement = contentIterator.next(); if (filter.apply(contentElement)) { filteredModelRootStub = createAndRegisterModelRootIfNotExistent(filteredModelRootStub, root); - EObject copyOfContentElement = EcoreUtil.copy(contentElement); + EObject copyOfContentElement = copyEObject(contentElement); attachElementToRoot(filteredModelRootStub, copyOfContentElement); } } @@ -108,6 +113,13 @@ private void attachElementToRootUml(Model root, EObject object) { } } + private EObject copyEObject(EObject object) { + EObject copyOfContentElement = EcoreUtil.copy(object); + getMapCopy2Original().put(copyOfContentElement, object); + return copyOfContentElement; + } + + private void attachElementToRootPcm(Repository root, EObject object) { if (object instanceof RepositoryComponent) { @@ -122,6 +134,8 @@ private void attachElementToRootPcm(Repository root, EObject object) { private EObject createAndRegisterModelRootIfNotExistent(EObject filteredRoot, EObject root) { if (filteredRoot == null) { EObject modelRoot = createFilteredModelRootIfNotExistent(filteredRoot, root); + //Map root stub to original root + mapCopy2Original.put(modelRoot, root); rootListForView.add(modelRoot); return modelRoot; } else { @@ -133,9 +147,13 @@ private EObject createAndRegisterModelRootIfNotExistent(EObject filteredRoot, EO private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObject root) { if (root instanceof Model) { - return UMLFactory.eINSTANCE.createModel(); + Model modelCopy = UMLFactory.eINSTANCE.createModel(); + modelCopy.setName(((Model) root).getName()); + return modelCopy; } else if (root instanceof Repository) { - return RepositoryFactory.eINSTANCE.createRepository(); + Repository repositoryCopy = RepositoryFactory.eINSTANCE.createRepository(); + repositoryCopy.setEntityName(((Repository) root).getEntityName()); + return repositoryCopy; } else { throw new ImplementationError("nbruening: Not implemented yet"); @@ -143,6 +161,11 @@ private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObje } + public Map getMapCopy2Original() { + return mapCopy2Original; + } + + //--------------------------------- /** * Builder for ViewFilterImpl diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 73705332a..1b7bfa2f3 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -3,32 +3,44 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceImpl; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.net4j.util.ImplementationError; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil; import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.CommittableView; import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; -public class BasicFilterView extends BasicView { +public class BasicFilterView extends BasicView implements FilterableView { private final ViewFilter viewFilter; private final ViewSelection preFilterSelection; private Collection rootObjects; + + private ResourceSet filteredModelsResSet = null; public BasicFilterView(FilteredViewCreatingViewType viewType, @@ -58,8 +70,42 @@ public void modifyContents(Procedure1 modificationFunction) } - private List findRootsForSelectionInViewSource() { - Collection viewSources = getViewSource().getViewSourceModels(); + public ResourceSet getNonFilteredViewResourceSet() { + return getViewResourceSet(); + } + + + @Override + public ResourceSet getFilteredModelsInResourceSet() { + if (filteredModelsResSet == null) { + filteredModelsResSet = new ResourceSetImpl(); + Map mapCopy2Original = viewFilter.getMapCopy2Original(); + Map rootObject2UriMapping = getRootObject2UriMapping(); + for (EObject copiedRootObject : getRootObjects()) { + EObject originalObject = mapCopy2Original.get(copiedRootObject); + filteredModelsResSet.createResource(rootObject2UriMapping.get(originalObject)).getContents().add(copiedRootObject); + } + } + return filteredModelsResSet; + } + + +// public void applyChangesFromFilteredRootOnOriginalRoot() { +// Collection filteredRoots = getRootObjects(); +// Map mapCopy2Original = viewFilter.getMapCopy2Original(); +// for(EObject currentFilteredRoot : filteredRoots) { +// EList contents = currentFilteredRoot.eContents(); +// for +// } +// } + + + public void setViewChanged(boolean value) { + super.setViewChanged(value); + } + + + private List findRootsForSelectionInViewSource(Collection viewSources) { ViewSelection selection = getPreFilterSelection(); List resourcesWithSelectedElements = viewSources.stream() .filter(resource -> resource.getContents().stream().anyMatch(selection::isViewObjectSelected)).toList(); @@ -72,7 +118,10 @@ private List findRootsForSelectionInViewSource() { protected ModifiableViewSelection filterElementsForSelection() { - List rootsForSelection = findRootsForSelectionInViewSource(); + //TODO nbr: Hat das für Probleme gesorgt, dass ich hier nicht mehr überprüfe, ob alle Elemente auch in selection sind? +// List rootsForSelection = findRootsForSelectionInViewSource(getViewSource().getViewSourceModels();); + Collection rootsForSelection = super.getRootObjects(); + Set filteredElements = viewFilter.filterElements(rootsForSelection); ModifiableViewSelection elementViewSelection = new ElementViewSelection(filteredElements); filteredElements.forEach(it -> elementViewSelection.setSelected(it, true)); @@ -85,6 +134,19 @@ public Collection getRootObjects() { } + private Map getRootObject2UriMapping() { + Map rootObject2UriMapping = new HashMap(); + + for (Resource resource : getViewResourceSet().getResources()) { + EList contents = resource.getContents(); + for (EObject content : contents) { + rootObject2UriMapping.put(content, resource.getURI()); + } + } + return rootObject2UriMapping; + } + + protected void updateRootAndSelectedElements(ModifiableViewSelection selection) { setRootObjects(selection.getSelectableElements()); setSelection(selection); @@ -104,5 +166,25 @@ public ViewSelection getSelection() { protected void setRootObjects(Collection rootObjects) { this.rootObjects = rootObjects; } + + + @Override + public CommittableView withChangeDerivingTrait(StateBasedChangeResolutionStrategy changeResolutionStrategy) { + checkNotClosed(); + return new FilterChangeDerivingView(this, changeResolutionStrategy, viewFilter.getMapCopy2Original()); + } + + + @Override + public CommittableView withChangeRecordingTrait() { + checkNotClosed(); + return new FilterChangeRecordingView(this, viewFilter.getMapCopy2Original()); + } + + + @Override + public Map getMapCopy2OriginalObject() { + return viewFilter.getMapCopy2Original(); + } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java new file mode 100644 index 000000000..6df74dc3f --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java @@ -0,0 +1,102 @@ +package tools.vitruv.applications.viewfilter.views; + +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil; +import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; +import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; +import tools.vitruv.applications.viewfilter.util.framework.impl.ChangeDerivingView; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.change.composite.description.CompositeContainerChange; +import tools.vitruv.change.composite.description.VitruviusChange; +import tools.vitruv.change.composite.description.VitruviusChangeFactory; +import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; + +public class FilterChangeDerivingView extends ChangeDerivingView { + + //TODO nbr add javadoc + private Map mapCopy2OriginalObject; + + private ResourceSet originalStateViewResourceSet; + + private HashMap originalStateResourceMapping; + + + protected FilterChangeDerivingView(BasicFilterView view, StateBasedChangeResolutionStrategy changeResolutionStrategy, Map mapCopy2OriginalObject) { + super(view, changeResolutionStrategy); + this.mapCopy2OriginalObject = mapCopy2OriginalObject; + } + + + @Override + protected void setupReferenceState() { + originalStateViewResourceSet = new ResourceSetImpl(); + ResourceCopier.copyViewResources(getView().getFilteredModelsInResourceSet().getResources(), originalStateViewResourceSet); + originalStateResourceMapping = new HashMap(); + for (Resource resource : getView().getFilteredModelsInResourceSet().getResources()) { + Resource searchedResource = null; + for (Resource originalStateResource : originalStateViewResourceSet.getResources()) { + if (originalStateResource.getURI() == resource.getURI()) { + searchedResource = originalStateResource; + break; + } + } + if (searchedResource != null) { + originalStateResourceMapping.put(resource, searchedResource); + } else { + throw new NullPointerException(); + } + } + } + + + + public void commitChanges() { + getView().checkNotClosed(); + + ArrayList changes = new ArrayList(); + Set allResources = new HashSet(originalStateResourceMapping.keySet()); + allResources.addAll(getView().getFilteredModelsInResourceSet().getResources()); // consider newly added resources + List pathmapResources = new ArrayList(); + for (Resource resource : allResources) { + if (URIUtil.isPathmap(resource.getURI())) { + pathmapResources.add(resource); + } + } + Resource[] array = (Resource[]) allResources.stream().filter((Resource it) -> {return URIUtil.isPathmap(it.getURI());}).toArray(); + for (Resource changedResource : array) { + VitruviusChange change = generateChange(changedResource, originalStateResourceMapping.get(changedResource)); + changes.add(change); + } + CompositeContainerChange change = VitruviusChangeFactory.getInstance().createCompositeChange(changes); + + getView().getViewType().commitViewChanges(this, change); + getView().setViewChanged(false); + + + //super.getRootObjects(); + + + //ViewSource auf Super.RootObjects mappen; Änderungen von FilterModell über Mapping auf ViewSource und + //Mapping auf Super.RootObjects auf Super.RootObjects übertragen, anschließend Super.CommitChanges() aufrufen. + //Oder reicht das Übertragen auf die ViewSource? + } + + + private BasicFilterView getView() { + return (BasicFilterView) view; + } +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java new file mode 100644 index 000000000..4cd2eee95 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -0,0 +1,106 @@ +package tools.vitruv.applications.viewfilter.views; + +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; +import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; +import tools.vitruv.applications.viewfilter.util.framework.impl.ChangeRecordingView; +import tools.vitruv.change.atomic.EChange; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.change.composite.description.TransactionalChange; +import tools.vitruv.change.composite.description.VitruviusChange; +import tools.vitruv.change.composite.description.VitruviusChangeResolver; +import tools.vitruv.change.composite.recording.ChangeRecorder; +import tools.vitruv.framework.views.ViewSelection; + +//TODO nbr: Hier nicht ChangeRecordingView überschreiben, sondern eigen implementieren und Sichtbarkeiten in ChangeRecordingView zurücksetzen +public class FilterChangeRecordingView extends ChangeRecordingView implements FilterableView { + + private Map mapCopy2OriginalObject; + + //private ResourceSet resourceSetFromBeginningOfRecording; + + protected FilterChangeRecordingView(BasicFilterView view, Map mapCopy2OriginalObject) { + super(view); + this.mapCopy2OriginalObject = mapCopy2OriginalObject; + } + + + + @Override + public List> setupChangeRecorder() { + ResourceSet filteredModelsInResourceSet = getView().getFilteredModelsInResourceSet(); + changeRecorder = new ChangeRecorder(filteredModelsInResourceSet); + changeRecorder.addToRecording(filteredModelsInResourceSet); + ResourceSet resourceSetCopy = new ResourceSetImpl(); + //Map copyResourceMapping = ResourceCopier.copyViewResources(filteredModelsInResourceSet.getResources(), resourceSetCopy); + //resourceSetFromBeginningOfRecording = resourceSetCopy; + + return changeRecorder.beginRecording(); + } + + + private ResourceSet copyResourceSet(ResourceSet resourceSetToBeCopied) { + ResourceSet resourceSetCopy = new ResourceSetImpl(); + ResourceCopier.copyViewResources(resourceSetToBeCopied.getResources(), resourceSetCopy); + return resourceSetCopy; + } + + + //private Map + + + @Override + public void commitChanges() { + getView().checkNotClosed(); + TransactionalChange recordedChange = changeRecorder.endRecording(); + + + //TODO nbr: ich muss hier irgendwie an das view resourceSet kommen + + VitruviusChangeResolver.forMappingFilteredObjects(getView().getFilteredModelsInResourceSet(), getView().getNonFilteredViewResourceSet(), mapCopy2OriginalObject); + VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(getView().getFilteredModelsInResourceSet()); + + //VitruviusChangeResolver filter. + + VitruviusChange unresolvedChanges = changeResolver.assignIds(recordedChange); + getView().getViewType().commitViewChanges(this, unresolvedChanges); + getView().setViewChanged(false); + changeRecorder.beginRecording(); + } + + + + private BasicFilterView getView() { + return (BasicFilterView) view; + } + + + + @Override + public ViewSelection getPreFilterSelection() { + return getView().getPreFilterSelection(); + } + + + + @Override + public ResourceSet getFilteredModelsInResourceSet() { + return getView().getFilteredModelsInResourceSet(); + } + + + + @Override + public Map getMapCopy2OriginalObject() { + return mapCopy2OriginalObject; + } + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java new file mode 100644 index 000000000..725a6801f --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java @@ -0,0 +1,19 @@ +package tools.vitruv.applications.viewfilter.views; + +import java.util.Map; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; +import tools.vitruv.framework.views.ViewSelection; + +//TODO nbr: Add javadoc +public interface FilterableView extends ModifiableView { + + ViewSelection getPreFilterSelection(); + + ResourceSet getFilteredModelsInResourceSet(); + + Map getMapCopy2OriginalObject(); +} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index 16e1cd731..76c6dda37 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -13,6 +13,8 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Model; @@ -54,6 +56,10 @@ @ExtendWith(RegisterMetamodelsInStandalone.class) public class BasicViewFilterTest extends ViewBasedVitruvApplicationTest { + private static final String NIKLAS_MODIFIED_CLASS_NAME = "niklasModifiedClass2"; + + private static final String NIKLAS_PACKAGE = "niklasPackage"; + @Accessors(AccessorType.PROTECTED_GETTER) private static final String UML_MODEL_NAME = "model"; @@ -100,7 +106,12 @@ public void testCreateFilteredUmlView() { // .updateView(((ModifiableView) view)); view.update(); view.update(); - view.getRootObjects(); + Collection rootObjects = view.getRootObjects(); +// Object[] array = rootObjects.toArray(); +// EObject eobject = (EObject) array[0]; +// EObject copy = EcoreUtil.copy(eobject); +// EObject copy2 = EcoreUtil.copy(copy); +// EcoreUtil.equals(copy2, eobject); modifyModel(); @@ -152,28 +163,56 @@ public void testModifyView() { @Test - public void testModifyFilteredView() { + public void testModifyFilteredView() throws Exception { Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); View view = improvedViewTestFactory.createFilteredUmlView(function); - CommittableView withChangeDerivingTrait = view.withChangeDerivingTrait(); - Collection rootObjects = withChangeDerivingTrait.getRootObjects(); + //Change view function + Consumer modifyViewFunction = (CommittableView viewToBeModified) -> { + getDefaultUmlModel(viewToBeModified).getPackagedElement(NIKLAS_PACKAGE).setName("NiklasRenamedPackage"); + }; + //apply change + improvedViewTestFactory.changeViewDerivingChanges(view, modifyViewFunction); + view.getRootObjects(); - for (EObject root : rootObjects) { - Model model = (Model) root; - for (EObject content : model.eContents()) { - if (content instanceof org.eclipse.uml2.uml.Class) { - org.eclipse.uml2.uml.Class umlClass = (org.eclipse.uml2.uml.Class) content; - umlClass.setName("modifiedNiklasClass2"); - } - } - - } - withChangeDerivingTrait.commitChangesAndUpdate(); +// CommittableView withChangeDerivingTrait = view.withChangeDerivingTrait(); +// Collection rootObjects = withChangeDerivingTrait.getRootObjects(); +// for (EObject root : rootObjects) { +// Model model = (Model) root; +// for (EObject content : model.eContents()) { +// if (content instanceof org.eclipse.uml2.uml.Class) { +// org.eclipse.uml2.uml.Class umlClass = (org.eclipse.uml2.uml.Class) content; +// umlClass.setName("modifiedNiklasClass2"); +// } +// } +// +// } + +// withChangeDerivingTrait.commitChangesAndUpdate(); view.getRootObjects(); } + @Test + public void testRenameClassInFilteredView() { + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + View filterView = improvedViewTestFactory.createFilteredUmlView(function); + try { + improvedViewTestFactory.changeViewRecordingChanges(filterView, (CommittableView view) -> { + Model model = getDefaultUmlModel(view); + Class niklasClass2 = UmlQueryUtil.claimClass(model, "niklasClass2"); + niklasClass2.setName(NIKLAS_MODIFIED_CLASS_NAME); + }); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + filterView.getRootObjects(); + } + + + @Override protected Iterable getChangePropagationSpecifications() { @@ -226,11 +265,11 @@ protected void createBiggerUmlModel(final Procedure1 modelInitial final Consumer secondChangeUmlFunction = (CommittableView it) -> { org.eclipse.uml2.uml.Package _createPackage = UMLFactory.eINSTANCE.createPackage(); Procedure1 setNameFunction = (org.eclipse.uml2.uml.Package it_1) -> { - it_1.setName("niklasPackage"); + it_1.setName(NIKLAS_PACKAGE); }; org.eclipse.uml2.uml.Package package1 = UMLFactory.eINSTANCE.createPackage(); - package1.setName("niklasPackage"); + package1.setName(NIKLAS_PACKAGE); class1 = package1.createOwnedClass("niklasClass1", false); diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index d610fc2ae..496f65465 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -251,15 +251,15 @@ public void testCreateFilteredPcmView() { BasicComponent classObject = (BasicComponent) eObject; assertEquals(PCM_BASIC_COMPONENT_NAME, classObject.getEntityName()); } - - //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement - //Root Objects: ModelImpl (aber nicht nur mit niklasClass2, sondern mit allem) und zwei weitere ModelImpls (aber andere) + //TODO nbr: Remove or translate comments in every test in this class + //Selection: Nur RepositoryImpl. Unter eSettings liegt List und darin Niklas Basic PCM component + //Root Objects: Identisch zu Selection (aber weniger null Werte in irrelevanten Feldern, da nicht kopiert) modifyModel(); view.update(); view.getSelection(); - //Selection: Nur ModelImpl mit zwei Klassen die jeweils niklasClass2 als Namen haben, als PackagedElement - //ACHTUNG: Die zwei Klassen sind als PackagedElements in der ModelImpl! - //Root Objects: ModelImpl, ModelImpl, ModelImpl + // unverändert durch selection + //Selection: Nur RepositoryImpl. Unter eSettings liegt List und darin Niklas Basic PCM component + //Root Objects: Identisch zu Selection (aber weniger null Werte in irrelevanten Feldern, da nicht kopiert) Collection modifiedRootObjects = view.getRootObjects(); assertEquals(modifiedRootObjects.size(), 1); for (EObject root : modifiedRootObjects) { From eed9f6434141173031e74d2e7aa8504a0d3e5dfe Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 28 Feb 2024 11:46:07 +0100 Subject: [PATCH 25/62] - Implemented transformation from FilterResourceSet to ViewResourceSet --- ...lterSupportingIdentityMappingViewType.java | 21 +++++++++--- .../viewfilter/viewbuild/ViewFilterImpl.java | 5 +-- .../viewfilter/views/BasicFilterView.java | 14 +++++++- .../views/FilterChangeRecordingView.java | 32 +++++++++++++++---- .../viewfilter/views/FilterableView.java | 2 ++ 5 files changed, 61 insertions(+), 13 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index 765c5e89b..bb39bc053 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -23,6 +23,7 @@ import tools.vitruv.applications.viewfilter.util.framework.selectors.DirectViewElementSelector; import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelectorImpl; import tools.vitruv.applications.viewfilter.views.BasicFilterView; +import tools.vitruv.applications.viewfilter.views.FilterChangeRecordingView; import tools.vitruv.applications.viewfilter.views.FilterableView; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.atomic.uuid.Uuid; @@ -81,19 +82,31 @@ public void updateView(ModifiableView view) { public void commitViewChanges(FilterableView view, VitruviusChange viewChange) { + ResourceSet viewResourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); + ResourceSet unfilteredResourceSet = ((FilterChangeRecordingView) view).getUnfilteredResourceSet(); + ResourceSet filteredResourceSetInOriginalState = ((FilterChangeRecordingView) view).getFilteredModelsInResourceSetWithBackwardExecution(); + VitruviusChangeResolver viewResourceIdChangeResolver = + VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(unfilteredResourceSet, filteredResourceSetInOriginalState, view.getMapCopy2OriginalObject()); + //VitruviusChangeResolver viewResourceIdChangeResolver = VitruviusChangeResolver.forHierarchicalIds(((FilterChangeRecordingView) view).getUnfilteredResourceSet()); + + + VitruviusChange viewResourceResolvedChange = viewResourceIdChangeResolver.resolveAndApply(viewChange); + VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(unfilteredResourceSet); + VitruviusChange unresolvedViewResourceChanges = changeResolver.assignIds(viewResourceResolvedChange); + ResourceSet viewSourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); -// VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIds(viewSourceCopyResourceSet); - VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(viewSourceCopyResourceSet, view.getFilteredModelsInResourceSet(), view.getMapCopy2OriginalObject()); + VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIds(viewSourceCopyResourceSet); +// VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(viewSourceCopyResourceSet, view.getFilteredModelsInResourceSet(), view.getMapCopy2OriginalObject()); UuidResolver viewSourceCopyUuidResolver = UuidResolver.create(viewSourceCopyResourceSet); VitruviusChangeResolver uuidChangeResolver = VitruviusChangeResolver.forUuids(viewSourceCopyUuidResolver); Map mapping = createViewResources(view, viewSourceCopyResourceSet); - mapChangeOnSourceIds(viewChange); +// mapChangeOnSourceIds(unresolvedChanges); view.getViewSource().getUuidResolver().resolveResources(mapping, viewSourceCopyUuidResolver); // FilterOnOriginalResolver filterOnOriginalResolver = new FilterOnOriginalResolver(); // filterOnOriginalResolver.resolveFilteredChangesOnOriginalSources(viewChange); - VitruviusChange resolvedChange = idChangeResolver.resolveAndApply(viewChange); + VitruviusChange resolvedChange = idChangeResolver.resolveAndApply(unresolvedViewResourceChanges); VitruviusChange unresolvedChanges = uuidChangeResolver.assignIds(resolvedChange); view.getViewSource().propagateChange(unresolvedChanges); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index 2c7525389..3ec828669 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -96,6 +96,7 @@ private void filterAllContents(EObject root, Function filter, private void attachElementToRoot(EObject root, EObject object) { if (root instanceof Model) { attachElementToRootUml((Model) root, object); + mapCopy2Original.get(object); } else if (root instanceof Repository) { attachElementToRootPcm((Repository) root, object); } else { @@ -106,8 +107,8 @@ private void attachElementToRoot(EObject root, EObject object) { private void attachElementToRootUml(Model root, EObject object) { if (object instanceof Type) { - EObject objectCopy = EcoreUtil.copy(object); - root.getOwnedTypes().add((Type) objectCopy); + //EObject objectCopy = EcoreUtil.copy(object); + root.getOwnedTypes().add((Type) object); } else { System.out.println("Warning: Undefined type: " + object.eClass()); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 1b7bfa2f3..12d0b5153 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -48,7 +48,7 @@ public BasicFilterView(FilteredViewCreatingViewType keySet = getMapCopy2OriginalObject().keySet(); +// keySet.contains(class2); +// System.out.println("Bla"); +// } + + return filteredModelsResSet; } @@ -168,6 +179,7 @@ protected void setRootObjects(Collection rootObjects) { } + @Override public CommittableView withChangeDerivingTrait(StateBasedChangeResolutionStrategy changeResolutionStrategy) { checkNotClosed(); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java index 4cd2eee95..2796b7dcc 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -16,6 +16,7 @@ import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.composite.description.TransactionalChange; import tools.vitruv.change.composite.description.VitruviusChange; +import tools.vitruv.change.composite.description.VitruviusChangeBackwardsExecutionHelper; import tools.vitruv.change.composite.description.VitruviusChangeResolver; import tools.vitruv.change.composite.recording.ChangeRecorder; import tools.vitruv.framework.views.ViewSelection; @@ -24,6 +25,7 @@ public class FilterChangeRecordingView extends ChangeRecordingView implements FilterableView { private Map mapCopy2OriginalObject; + private TransactionalChange recordedChange = null; //private ResourceSet resourceSetFromBeginningOfRecording; @@ -60,16 +62,18 @@ private ResourceSet copyResourceSet(ResourceSet resourceSetToBeCopied) { @Override public void commitChanges() { getView().checkNotClosed(); - TransactionalChange recordedChange = changeRecorder.endRecording(); + recordedChange = changeRecorder.endRecording(); + ResourceSet filteredModelsInResourceSet = getFilteredModelsInResourceSet(); + ResourceSet unfilteredResourceSet = getUnfilteredResourceSet(); +// EObject class2 = filteredModelsInResourceSet.getResources().get(0).getContents().get(0).eContents().get(0); +// EObject eObject = mapCopy2OriginalObject.get(class2); - //TODO nbr: ich muss hier irgendwie an das view resourceSet kommen - - VitruviusChangeResolver.forMappingFilteredObjects(getView().getFilteredModelsInResourceSet(), getView().getNonFilteredViewResourceSet(), mapCopy2OriginalObject); - VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(getView().getFilteredModelsInResourceSet()); - //VitruviusChangeResolver filter. + //TODO nbr: ich muss hier irgendwie an das view resourceSet kommen + //VitruviusChangeResolver.forMappingFilteredObjects(getView().getFilteredModelsInResourceSet(), getView().getNonFilteredViewResourceSet(), mapCopy2OriginalObject); + VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(getView().getFilteredModelsInResourceSet()); VitruviusChange unresolvedChanges = changeResolver.assignIds(recordedChange); getView().getViewType().commitViewChanges(this, unresolvedChanges); getView().setViewChanged(false); @@ -95,6 +99,22 @@ public ViewSelection getPreFilterSelection() { public ResourceSet getFilteredModelsInResourceSet() { return getView().getFilteredModelsInResourceSet(); } + + + public ResourceSet getFilteredModelsInResourceSetWithBackwardExecution() { + ResourceSet resourceSet = getFilteredModelsInResourceSet(); + if (recordedChange != null) { + //TODO nbr: What happens if changes have already been reverted? + VitruviusChangeBackwardsExecutionHelper changeResolver = new VitruviusChangeBackwardsExecutionHelper(resourceSet); + changeResolver.applyBackward(recordedChange); + } + return resourceSet; + } + + + public ResourceSet getUnfilteredResourceSet() { + return getView().getNonFilteredViewResourceSet(); + } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java index 725a6801f..53e163389 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java @@ -16,4 +16,6 @@ public interface FilterableView extends ModifiableView { ResourceSet getFilteredModelsInResourceSet(); Map getMapCopy2OriginalObject(); + + //ResourceSet getFilteredModelsInResourceSetWithBackwardExecution(); } From 7627175ea05512602b253e17f7ad6ebdd8623e17 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 28 Feb 2024 12:46:42 +0100 Subject: [PATCH 26/62] Added new regression test for modification of filter view --- .../viewfilter/tests/BasicViewFilterTest.java | 2 + .../viewfilter/tests/InstanceFilterTest.java | 64 ++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index 76c6dda37..10e8c875e 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -209,6 +209,8 @@ public void testRenameClassInFilteredView() { } filterView.getRootObjects(); + View secondView = improvedViewTestFactory.createUmlView(); + secondView.getRootObjects(); } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index 496f65465..c4c4e6b9c 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -34,7 +34,10 @@ import org.eclipse.uml2.uml.PackageableElement; import org.eclipse.uml2.uml.PrimitiveType; import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.internal.impl.ClassImpl; import org.eclipse.uml2.uml.internal.impl.ModelImpl; +import org.eclipse.uml2.uml.internal.impl.PackageImpl; +import org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl; import org.eclipse.xtend.lib.annotations.AccessorType; import org.eclipse.xtend.lib.annotations.Accessors; import org.eclipse.xtext.xbase.lib.CollectionLiterals; @@ -71,12 +74,15 @@ @ExtendWith(RegisterMetamodelsInStandalone.class) public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { + private static final String NIKLAS_NESTED_PACKAGE = "niklasNestedPackage"; + @Accessors(AccessorType.PROTECTED_GETTER) private static final String UML_MODEL_NAME = "model"; @Accessors(AccessorType.PROTECTED_GETTER) private static final String PCM_MODEL_NAME = "Repository"; + private static final String NIKLAS_MODIFIED_CLASS_NAME = "niklasModifiedClass2"; private static final String PCM_REPOSITORY_FILE_EXTENSION = "repository"; @@ -313,6 +319,48 @@ public void testCreateCountingView() { } + @Test + public void testRenameClassInFilteredView() throws Exception { + Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + View baselineUnfilteredUmlView = improvedViewTestFactory.createUmlView(); + View filterView = improvedViewTestFactory.createFilteredUmlView(function); + + improvedViewTestFactory.changeViewRecordingChanges(filterView, (CommittableView view) -> { + Model model = getDefaultUmlModel(view); + Class niklasClass2 = UmlQueryUtil.claimClass(model, "niklasClass2"); + niklasClass2.setName(NIKLAS_MODIFIED_CLASS_NAME); + }); + + + //Test whether everything worked + //Is filtered view in correct state? + Collection filteredRootObjects = filterView.getRootObjects(); + assertEquals(1, filteredRootObjects.size()); + for (EObject filteredRoot : filteredRootObjects) { + EObject classObject = filteredRoot.eContents().get(0); + assertTrue(classObject instanceof Class); + assertEquals(NIKLAS_MODIFIED_CLASS_NAME, ((Class) classObject).getName()); + } + //Did the update of the vsum work? Is a newly created view in correct state? + View secondView = improvedViewTestFactory.createUmlView(); + Collection newViewRootObjects = secondView.getRootObjects(); + assertEquals(1, newViewRootObjects.size()); + for (EObject viewRoot : newViewRootObjects) { + assertTrue(viewRoot instanceof Model); + if (viewRoot instanceof Model castedViewRoot) { + EObject classWithModifiedName = searchEObjectWithGivenNameInUmlModel(castedViewRoot, NIKLAS_MODIFIED_CLASS_NAME); + assertTrue(classWithModifiedName != null); + assertTrue(classWithModifiedName instanceof Class); + EList niklasPackage = viewRoot.eContents().get(0).eContents(); + assertEquals(4, niklasPackage.size()); + assertEquals(1, niklasPackage.stream().filter(it -> {return (it instanceof PackageImpl);}).count()); + assertEquals(2, niklasPackage.stream().filter(it -> {return (it instanceof ClassImpl);}).count()); + assertEquals(1, niklasPackage.stream().filter(it -> {return (it instanceof PrimitiveTypeImpl);}).count()); + } + } + } + + protected void createBiggerUmlModel(final Procedure1 modelInitialization) { @@ -341,7 +389,7 @@ protected void createBiggerUmlModel(final Procedure1 modelInitial getUserInteraction().addNextSingleSelection(1); getUserInteraction().addNextTextInput("model/System.system"); - org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage("niklasNestedPackage"); + org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage(NIKLAS_NESTED_PACKAGE); class2 = package2.createOwnedClass("niklasClass2", false); EList _packagedElements = getDefaultUmlModel(it).getPackagedElements(); @@ -446,6 +494,20 @@ private boolean hasInstanceName(EObject object, String name) { } + private EObject searchEObjectWithGivenNameInUmlModel(Model model, String searchedName) { + TreeIterator umlIterator = model.eAllContents(); + while (umlIterator.hasNext()) { + EObject next = umlIterator.next(); + if (next instanceof org.eclipse.uml2.uml.Classifier) { + if (searchedName.equals(((Classifier) next).getName())) { + return next; + } + } + } + return null; + } + + private Path getPcmProjectModelPath(String modelName, String modelFileExtension) { return Path.of("pcm").resolve(modelName + "." + modelFileExtension); } From c13eb534b09ac98f58a0bcd09c57eb6dd213ee67 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 2 Mar 2024 10:08:42 +0100 Subject: [PATCH 27/62] Refactor: More distinctive names for methods of FilteredView getViewResourceSet -> getNonFilteredResourceSet getFilteredModelsInResourceSet -> getViewResourceSet --- .gitignore | 1 + .../viewfilter/views/BasicFilterView.java | 29 +++---------------- .../views/FilterChangeDerivingView.java | 6 ++-- .../views/FilterChangeRecordingView.java | 14 ++++----- .../viewfilter/views/FilterChangeView.java | 12 ++++++++ .../viewfilter/views/FilterableView.java | 2 -- 6 files changed, 27 insertions(+), 37 deletions(-) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java diff --git a/.gitignore b/.gitignore index 807b465bd..400ec69e6 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ EvaluationData *.DS_Store *.polyglot *.pom.tycho +*.classpath tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 12d0b5153..aedea62c9 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -71,12 +71,11 @@ public void modifyContents(Procedure1 modificationFunction) public ResourceSet getNonFilteredViewResourceSet() { - return getViewResourceSet(); + return super.getViewResourceSet(); } - @Override - public ResourceSet getFilteredModelsInResourceSet() { + public ResourceSet getViewResourceSet() { if (filteredModelsResSet == null) { filteredModelsResSet = new ResourceSetImpl(); Map mapCopy2Original = viewFilter.getMapCopy2Original(); @@ -85,32 +84,12 @@ public ResourceSet getFilteredModelsInResourceSet() { EObject originalObject = mapCopy2Original.get(copiedRootObject); filteredModelsResSet.createResource(rootObject2UriMapping.get(originalObject)).getContents().add(copiedRootObject); } - } - -// for (EObject root : rootObjects) { -// EObject class2 = root.eContents().get(0); -// EObject resClass2 = filteredModelsResSet.getResources().get(0).getContents().get(0).eContents().get(0); -// EObject eObject = getMapCopy2OriginalObject().get(class2); -// Set keySet = getMapCopy2OriginalObject().keySet(); -// keySet.contains(class2); -// System.out.println("Bla"); -// } - + } return filteredModelsResSet; } -// public void applyChangesFromFilteredRootOnOriginalRoot() { -// Collection filteredRoots = getRootObjects(); -// Map mapCopy2Original = viewFilter.getMapCopy2Original(); -// for(EObject currentFilteredRoot : filteredRoots) { -// EList contents = currentFilteredRoot.eContents(); -// for -// } -// } - - public void setViewChanged(boolean value) { super.setViewChanged(value); } @@ -148,7 +127,7 @@ public Collection getRootObjects() { private Map getRootObject2UriMapping() { Map rootObject2UriMapping = new HashMap(); - for (Resource resource : getViewResourceSet().getResources()) { + for (Resource resource : getNonFilteredViewResourceSet().getResources()) { EList contents = resource.getContents(); for (EObject content : contents) { rootObject2UriMapping.put(content, resource.getURI()); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java index 6df74dc3f..006243bbd 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java @@ -44,9 +44,9 @@ protected FilterChangeDerivingView(BasicFilterView view, StateBasedChangeResolut @Override protected void setupReferenceState() { originalStateViewResourceSet = new ResourceSetImpl(); - ResourceCopier.copyViewResources(getView().getFilteredModelsInResourceSet().getResources(), originalStateViewResourceSet); + ResourceCopier.copyViewResources(getView().getViewResourceSet().getResources(), originalStateViewResourceSet); originalStateResourceMapping = new HashMap(); - for (Resource resource : getView().getFilteredModelsInResourceSet().getResources()) { + for (Resource resource : getView().getViewResourceSet().getResources()) { Resource searchedResource = null; for (Resource originalStateResource : originalStateViewResourceSet.getResources()) { if (originalStateResource.getURI() == resource.getURI()) { @@ -69,7 +69,7 @@ public void commitChanges() { ArrayList changes = new ArrayList(); Set allResources = new HashSet(originalStateResourceMapping.keySet()); - allResources.addAll(getView().getFilteredModelsInResourceSet().getResources()); // consider newly added resources + allResources.addAll(getView().getViewResourceSet().getResources()); // consider newly added resources List pathmapResources = new ArrayList(); for (Resource resource : allResources) { if (URIUtil.isPathmap(resource.getURI())) { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java index 2796b7dcc..3dd5430f8 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -22,7 +22,7 @@ import tools.vitruv.framework.views.ViewSelection; //TODO nbr: Hier nicht ChangeRecordingView überschreiben, sondern eigen implementieren und Sichtbarkeiten in ChangeRecordingView zurücksetzen -public class FilterChangeRecordingView extends ChangeRecordingView implements FilterableView { +public class FilterChangeRecordingView extends ChangeRecordingView implements FilterableView, FilterChangeView { private Map mapCopy2OriginalObject; private TransactionalChange recordedChange = null; @@ -38,7 +38,7 @@ protected FilterChangeRecordingView(BasicFilterView view, Map @Override public List> setupChangeRecorder() { - ResourceSet filteredModelsInResourceSet = getView().getFilteredModelsInResourceSet(); + ResourceSet filteredModelsInResourceSet = getView().getViewResourceSet(); changeRecorder = new ChangeRecorder(filteredModelsInResourceSet); changeRecorder.addToRecording(filteredModelsInResourceSet); ResourceSet resourceSetCopy = new ResourceSetImpl(); @@ -64,7 +64,7 @@ public void commitChanges() { getView().checkNotClosed(); recordedChange = changeRecorder.endRecording(); - ResourceSet filteredModelsInResourceSet = getFilteredModelsInResourceSet(); + ResourceSet filteredModelsInResourceSet = getViewResourceSet(); ResourceSet unfilteredResourceSet = getUnfilteredResourceSet(); // EObject class2 = filteredModelsInResourceSet.getResources().get(0).getContents().get(0).eContents().get(0); // EObject eObject = mapCopy2OriginalObject.get(class2); @@ -73,7 +73,7 @@ public void commitChanges() { //TODO nbr: ich muss hier irgendwie an das view resourceSet kommen //VitruviusChangeResolver.forMappingFilteredObjects(getView().getFilteredModelsInResourceSet(), getView().getNonFilteredViewResourceSet(), mapCopy2OriginalObject); - VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(getView().getFilteredModelsInResourceSet()); + VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(getView().getViewResourceSet()); VitruviusChange unresolvedChanges = changeResolver.assignIds(recordedChange); getView().getViewType().commitViewChanges(this, unresolvedChanges); getView().setViewChanged(false); @@ -96,13 +96,13 @@ public ViewSelection getPreFilterSelection() { @Override - public ResourceSet getFilteredModelsInResourceSet() { - return getView().getFilteredModelsInResourceSet(); + public ResourceSet getViewResourceSet() { + return getView().getViewResourceSet(); } public ResourceSet getFilteredModelsInResourceSetWithBackwardExecution() { - ResourceSet resourceSet = getFilteredModelsInResourceSet(); + ResourceSet resourceSet = getViewResourceSet(); if (recordedChange != null) { //TODO nbr: What happens if changes have already been reverted? VitruviusChangeBackwardsExecutionHelper changeResolver = new VitruviusChangeBackwardsExecutionHelper(resourceSet); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java new file mode 100644 index 000000000..763676b9e --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java @@ -0,0 +1,12 @@ +package tools.vitruv.applications.viewfilter.views; + +import org.eclipse.emf.ecore.resource.ResourceSet; + +public interface FilterChangeView { + + ResourceSet getViewResourceSet(); + + + + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java index 53e163389..3c94fb7d9 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java @@ -13,8 +13,6 @@ public interface FilterableView extends ModifiableView { ViewSelection getPreFilterSelection(); - ResourceSet getFilteredModelsInResourceSet(); - Map getMapCopy2OriginalObject(); //ResourceSet getFilteredModelsInResourceSetWithBackwardExecution(); From 56da5477cc6ec65b1847d759da9a883ae4b82222 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 2 Mar 2024 13:03:13 +0100 Subject: [PATCH 28/62] Introduced AbstractBasicView and corresponding interface --- ...lterSupportingIdentityMappingViewType.java | 2 +- .../AbstractBasicView.xtend} | 12 +- .../viewfilter/views/BasicFilterView.java | 4 +- .../impl => views}/ChangeDerivingView.xtend | 7 +- .../impl => views}/ChangeRecordingView.xtend | 9 +- .../views/ChangesetDeterminableView.java | 24 ++++ .../views/FilterChangeDerivingView.java | 132 ++++++++++-------- .../views/FilterChangeRecordingView.java | 27 ++-- .../viewfilter/views/FilterableView.java | 2 +- .../views/InformationDisplayView.java | 4 +- .../viewfilter/tests/InstanceFilterTest.java | 1 - 11 files changed, 136 insertions(+), 88 deletions(-) rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/{util/framework/impl/BasicView.xtend => views/AbstractBasicView.xtend} (92%) rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/{util/framework/impl => views}/ChangeDerivingView.xtend (93%) rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/{util/framework/impl => views}/ChangeRecordingView.xtend (86%) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index bb39bc053..d89345920 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -83,7 +83,7 @@ public void updateView(ModifiableView view) { public void commitViewChanges(FilterableView view, VitruviusChange viewChange) { ResourceSet viewResourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); - ResourceSet unfilteredResourceSet = ((FilterChangeRecordingView) view).getUnfilteredResourceSet(); + ResourceSet unfilteredResourceSet = ((FilterChangeRecordingView) view).getNonFilteredViewResourceSet(); ResourceSet filteredResourceSetInOriginalState = ((FilterChangeRecordingView) view).getFilteredModelsInResourceSetWithBackwardExecution(); VitruviusChangeResolver viewResourceIdChangeResolver = VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(unfilteredResourceSet, filteredResourceSetInOriginalState, view.getMapCopy2OriginalObject()); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/AbstractBasicView.xtend similarity index 92% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/AbstractBasicView.xtend index 86b90b12b..2e26e4f6b 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/BasicView.xtend +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/AbstractBasicView.xtend @@ -1,4 +1,4 @@ -package tools.vitruv.applications.viewfilter.util.framework.impl +package tools.vitruv.applications.viewfilter.views; import org.eclipse.emf.common.notify.Notification import org.eclipse.emf.common.notify.Notifier @@ -23,18 +23,20 @@ import static com.google.common.base.Preconditions.checkArgument import static com.google.common.base.Preconditions.checkState import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceSetUtil.withGlobalFactories +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType -public class BasicView implements ModifiableView, ChangePropagationListener { +public abstract class AbstractBasicView implements ChangesetDeterminableView, ModifiableView, ChangePropagationListener { @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) var ViewSelection selection @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) var ViewCreatingViewType viewType @Accessors(PUBLIC_GETTER, PROTECTED_SETTER) var ChangeableViewSource viewSource - @Accessors(PROTECTED_GETTER) + @Accessors(PUBLIC_GETTER) var ResourceSet viewResourceSet boolean modelChanged - @Accessors(PROTECTED_SETTER) + @Accessors(PUBLIC_SETTER) boolean viewChanged boolean closed @@ -112,7 +114,7 @@ public class BasicView implements ModifiableView, ChangePropagationListener { viewResourceSet.resources.findFirst[contents.contains(object)].URI = newLocation } - def void checkNotClosed() { + override void checkNotClosed() { checkState(!closed, "view is already closed!") } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index aedea62c9..540e285b2 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -20,7 +20,6 @@ import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil; -import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; @@ -32,7 +31,7 @@ import tools.vitruv.framework.views.ViewSelector; import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; -public class BasicFilterView extends BasicView implements FilterableView { +public class BasicFilterView extends AbstractBasicView implements FilterableView { private final ViewFilter viewFilter; @@ -70,6 +69,7 @@ public void modifyContents(Procedure1 modificationFunction) } + @Override public ResourceSet getNonFilteredViewResourceSet() { return super.getViewResourceSet(); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeDerivingView.xtend similarity index 93% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeDerivingView.xtend index 76f744d08..e6e12fd01 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeDerivingView.xtend +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeDerivingView.xtend @@ -1,4 +1,4 @@ -package tools.vitruv.applications.viewfilter.util.framework.impl +package tools.vitruv.applications.viewfilter.views; import java.util.ArrayList import java.util.HashMap @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkState import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil.isPathmap import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView /** * A {@link View} that derives changes based on the changed state of its resources and allows to propagate them @@ -26,13 +27,13 @@ import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopie */ class ChangeDerivingView implements ModifiableView, CommittableView { @Delegate - protected BasicView view + protected AbstractBasicView view val StateBasedChangeResolutionStrategy changeResolutionStrategy var ResourceSet originalStateViewResourceSet var HashMap originalStateResourceMapping - protected new(BasicView view, StateBasedChangeResolutionStrategy changeResolutionStrategy) { + protected new(AbstractBasicView view, StateBasedChangeResolutionStrategy changeResolutionStrategy) { checkArgument(view !== null, "view must not be null") checkState(!view.isModified, "view must not be modified") checkState(!view.isOutdated, "view must not be outdated") diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeRecordingView.xtend similarity index 86% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeRecordingView.xtend index 818abc07a..3dfe6e75a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ChangeRecordingView.xtend +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeRecordingView.xtend @@ -1,4 +1,4 @@ -package tools.vitruv.applications.viewfilter.util.framework.impl +package tools.vitruv.applications.viewfilter.views; import org.eclipse.xtend.lib.annotations.Delegate import tools.vitruv.change.composite.description.VitruviusChangeResolver @@ -9,6 +9,9 @@ import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionS import static com.google.common.base.Preconditions.checkArgument import static com.google.common.base.Preconditions.checkState +import tools.vitruv.applications.viewfilter.views.AbstractBasicView +import tools.vitruv.applications.viewfilter.views.ChangesetDeterminableView +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView /** * A {@link View} that records changes to its resources and allows to propagate them @@ -16,10 +19,10 @@ import static com.google.common.base.Preconditions.checkState */ class ChangeRecordingView implements ModifiableView, CommittableView { @Delegate - protected BasicView view + protected ChangesetDeterminableView view protected ChangeRecorder changeRecorder - protected new(BasicView view) { + protected new(ChangesetDeterminableView view) { checkArgument(view !== null, "view must not be null") checkState(!view.isModified, "view must not be modified") this.view = view diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java new file mode 100644 index 000000000..56fcc44ba --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java @@ -0,0 +1,24 @@ +package tools.vitruv.applications.viewfilter.views; + +import org.eclipse.emf.ecore.resource.ResourceSet; + +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.change.composite.propagation.ChangePropagationListener; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.framework.views.ViewType; + +//TODO nbr: Add javadoc +public interface ChangesetDeterminableView extends ModifiableView { + + public ResourceSet getViewResourceSet(); + + public void checkNotClosed(); + + public ViewCreatingViewType getViewType(); + + public void setViewChanged(boolean value); + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java index 006243bbd..431648ec6 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java @@ -17,86 +17,106 @@ import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; -import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; -import tools.vitruv.applications.viewfilter.util.framework.impl.ChangeDerivingView; +import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.composite.description.CompositeContainerChange; import tools.vitruv.change.composite.description.VitruviusChange; import tools.vitruv.change.composite.description.VitruviusChangeFactory; +import tools.vitruv.framework.views.View; +import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; + +public class FilterChangeDerivingView extends ChangeDerivingView implements FilterableView, FilterChangeView { -public class FilterChangeDerivingView extends ChangeDerivingView { - - //TODO nbr add javadoc + // TODO nbr add javadoc private Map mapCopy2OriginalObject; - + private ResourceSet originalStateViewResourceSet; - - private HashMap originalStateResourceMapping; + private HashMap originalStateResourceMapping; - protected FilterChangeDerivingView(BasicFilterView view, StateBasedChangeResolutionStrategy changeResolutionStrategy, Map mapCopy2OriginalObject) { + protected FilterChangeDerivingView(BasicFilterView view, + StateBasedChangeResolutionStrategy changeResolutionStrategy, Map mapCopy2OriginalObject) { super(view, changeResolutionStrategy); this.mapCopy2OriginalObject = mapCopy2OriginalObject; } - @Override - protected void setupReferenceState() { - originalStateViewResourceSet = new ResourceSetImpl(); - ResourceCopier.copyViewResources(getView().getViewResourceSet().getResources(), originalStateViewResourceSet); - originalStateResourceMapping = new HashMap(); - for (Resource resource : getView().getViewResourceSet().getResources()) { - Resource searchedResource = null; - for (Resource originalStateResource : originalStateViewResourceSet.getResources()) { - if (originalStateResource.getURI() == resource.getURI()) { - searchedResource = originalStateResource; - break; - } - } - if (searchedResource != null) { - originalStateResourceMapping.put(resource, searchedResource); - } else { - throw new NullPointerException(); - } - } - } - - - + protected void setupReferenceState() { + originalStateViewResourceSet = new ResourceSetImpl(); + ResourceCopier.copyViewResources(view.getViewResourceSet().getResources(), originalStateViewResourceSet); + originalStateResourceMapping = new HashMap(); + for (Resource resource : view.getViewResourceSet().getResources()) { + Resource searchedResource = null; + for (Resource originalStateResource : originalStateViewResourceSet.getResources()) { + if (originalStateResource.getURI() == resource.getURI()) { + searchedResource = originalStateResource; + break; + } + } + if (searchedResource != null) { + originalStateResourceMapping.put(resource, searchedResource); + } else { + throw new NullPointerException(); + } + } + } + public void commitChanges() { - getView().checkNotClosed(); - + view.checkNotClosed(); + ArrayList changes = new ArrayList(); Set allResources = new HashSet(originalStateResourceMapping.keySet()); - allResources.addAll(getView().getViewResourceSet().getResources()); // consider newly added resources + allResources.addAll(view.getViewResourceSet().getResources()); // consider newly added resources List pathmapResources = new ArrayList(); for (Resource resource : allResources) { if (URIUtil.isPathmap(resource.getURI())) { pathmapResources.add(resource); } } - Resource[] array = (Resource[]) allResources.stream().filter((Resource it) -> {return URIUtil.isPathmap(it.getURI());}).toArray(); - for (Resource changedResource : array) { - VitruviusChange change = generateChange(changedResource, originalStateResourceMapping.get(changedResource)); - changes.add(change); - } - CompositeContainerChange change = VitruviusChangeFactory.getInstance().createCompositeChange(changes); - - getView().getViewType().commitViewChanges(this, change); - getView().setViewChanged(false); - - - //super.getRootObjects(); - - - //ViewSource auf Super.RootObjects mappen; Änderungen von FilterModell über Mapping auf ViewSource und - //Mapping auf Super.RootObjects auf Super.RootObjects übertragen, anschließend Super.CommitChanges() aufrufen. - //Oder reicht das Übertragen auf die ViewSource? + Resource[] array = (Resource[]) allResources.stream().filter((Resource it) -> { + return URIUtil.isPathmap(it.getURI()); + }).toArray(); + for (Resource changedResource : array) { + VitruviusChange change = generateChange(changedResource, + originalStateResourceMapping.get(changedResource)); + changes.add(change); + } + CompositeContainerChange change = VitruviusChangeFactory.getInstance().createCompositeChange(changes); + + view.getViewType().commitViewChanges(this, change); + view.setViewChanged(false); + + // super.getRootObjects(); + + // ViewSource auf Super.RootObjects mappen; Änderungen von FilterModell über + // Mapping auf ViewSource und + // Mapping auf Super.RootObjects auf Super.RootObjects übertragen, anschließend + // Super.CommitChanges() aufrufen. + // Oder reicht das Übertragen auf die ViewSource? } - - - private BasicFilterView getView() { - return (BasicFilterView) view; + + private FilterableView getViewAsFilterableView() { + return (FilterableView) view; + } + + @Override + public ResourceSet getViewResourceSet() { + return view.getViewResourceSet(); + } + + @Override + public ViewSelection getPreFilterSelection() { + return getViewAsFilterableView().getPreFilterSelection(); + } + + @Override + public Map getMapCopy2OriginalObject() { + return mapCopy2OriginalObject; + } + + @Override + public ResourceSet getNonFilteredViewResourceSet() { + return getViewAsFilterableView().getNonFilteredViewResourceSet(); } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java index 3dd5430f8..d8593691e 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -10,8 +10,6 @@ import org.eclipse.emf.ecore.util.EcoreUtil; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; -import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; -import tools.vitruv.applications.viewfilter.util.framework.impl.ChangeRecordingView; import tools.vitruv.change.atomic.EChange; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.composite.description.TransactionalChange; @@ -38,7 +36,7 @@ protected FilterChangeRecordingView(BasicFilterView view, Map @Override public List> setupChangeRecorder() { - ResourceSet filteredModelsInResourceSet = getView().getViewResourceSet(); + ResourceSet filteredModelsInResourceSet = view.getViewResourceSet(); changeRecorder = new ChangeRecorder(filteredModelsInResourceSet); changeRecorder.addToRecording(filteredModelsInResourceSet); ResourceSet resourceSetCopy = new ResourceSetImpl(); @@ -61,11 +59,11 @@ private ResourceSet copyResourceSet(ResourceSet resourceSetToBeCopied) { @Override public void commitChanges() { - getView().checkNotClosed(); + view.checkNotClosed(); recordedChange = changeRecorder.endRecording(); ResourceSet filteredModelsInResourceSet = getViewResourceSet(); - ResourceSet unfilteredResourceSet = getUnfilteredResourceSet(); + ResourceSet unfilteredResourceSet = getNonFilteredViewResourceSet(); // EObject class2 = filteredModelsInResourceSet.getResources().get(0).getContents().get(0).eContents().get(0); // EObject eObject = mapCopy2OriginalObject.get(class2); @@ -73,31 +71,31 @@ public void commitChanges() { //TODO nbr: ich muss hier irgendwie an das view resourceSet kommen //VitruviusChangeResolver.forMappingFilteredObjects(getView().getFilteredModelsInResourceSet(), getView().getNonFilteredViewResourceSet(), mapCopy2OriginalObject); - VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(getView().getViewResourceSet()); + VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(view.getViewResourceSet()); VitruviusChange unresolvedChanges = changeResolver.assignIds(recordedChange); - getView().getViewType().commitViewChanges(this, unresolvedChanges); - getView().setViewChanged(false); + view.getViewType().commitViewChanges(this, unresolvedChanges); + view.setViewChanged(false); changeRecorder.beginRecording(); } - private BasicFilterView getView() { - return (BasicFilterView) view; + private FilterableView getViewAsFilterableView() { + return (FilterableView) view; } @Override public ViewSelection getPreFilterSelection() { - return getView().getPreFilterSelection(); + return getViewAsFilterableView().getPreFilterSelection(); } @Override public ResourceSet getViewResourceSet() { - return getView().getViewResourceSet(); + return view.getViewResourceSet(); } @@ -112,8 +110,9 @@ public ResourceSet getFilteredModelsInResourceSetWithBackwardExecution() { } - public ResourceSet getUnfilteredResourceSet() { - return getView().getNonFilteredViewResourceSet(); + @Override + public ResourceSet getNonFilteredViewResourceSet() { + return getViewAsFilterableView().getNonFilteredViewResourceSet(); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java index 3c94fb7d9..97cf50e57 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java @@ -15,5 +15,5 @@ public interface FilterableView extends ModifiableView { Map getMapCopy2OriginalObject(); - //ResourceSet getFilteredModelsInResourceSetWithBackwardExecution(); + ResourceSet getNonFilteredViewResourceSet(); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java index 4edb47cf0..ef7b3eb10 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java @@ -15,7 +15,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; -import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.atomic.uuid.Uuid; @@ -30,7 +29,8 @@ import tools.vitruv.framework.views.ViewType; import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; -public class InformationDisplayView extends BasicView implements View, ChangePropagationListener { +//TODO nbr: Remove this class? +public class InformationDisplayView extends AbstractBasicView implements View, ChangePropagationListener { private ResourceSet viewResourceSet; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index c4c4e6b9c..32cf70dc2 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -58,7 +58,6 @@ import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; import tools.vitruv.applications.testutility.uml.UmlQueryUtil; -import tools.vitruv.applications.viewfilter.util.framework.impl.BasicView; import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; import tools.vitruv.applications.viewfilter.utils.PcmQueryUtil; import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper; From d2f21c42dd712758c9e03667f600698940f32318 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 2 Mar 2024 13:08:13 +0100 Subject: [PATCH 29/62] Renamed modules From tools.vitruv.applications.viewfilter to tools.vitruv.views.viewfilter --- bundles/tools.vitruv.applications.viewtest/.project | 2 +- bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF | 2 +- tests/tools.vitruv.applications.viewfilter.tests/.project | 2 +- .../META-INF/MANIFEST.MF | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/.project b/bundles/tools.vitruv.applications.viewtest/.project index 8f68df9e0..95111f560 100644 --- a/bundles/tools.vitruv.applications.viewtest/.project +++ b/bundles/tools.vitruv.applications.viewtest/.project @@ -1,6 +1,6 @@ - tools.vitruv.applications.viewfilter + tools.vitruv.views.viewfilter diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF index d14d77030..1b8ac2de8 100644 --- a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF +++ b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Vitruv Viewfilter Application -Bundle-SymbolicName: tools.vitruv.applications.viewfilter;singleton:=true +Bundle-SymbolicName: tools.vitruv.views.viewfilter;singleton:=true Bundle-Version: 3.0.1.qualifier Automatic-Module-Name: tools.vitruv.applications.viewfilter Bundle-RequiredExecutionEnvironment: JavaSE-17 diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.project b/tests/tools.vitruv.applications.viewfilter.tests/.project index 2ab8bd4ea..3b229303c 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/.project +++ b/tests/tools.vitruv.applications.viewfilter.tests/.project @@ -1,6 +1,6 @@ - tools.vitruv.applications.viewfilter.tests + tools.vitruv.views.viewfilter.tests diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index cfb9d51ac..9daafb961 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Vitruv PCM-UML Class Application Tests -Bundle-SymbolicName: tools.vitruv.applications.viewfilter.tests +Bundle-SymbolicName: tools.vitruv.views.viewfilter.tests Bundle-Version: 3.0.1.qualifier Automatic-Module-Name: tools.vitruv.applications.viewfilter.tests Bundle-RequiredExecutionEnvironment: JavaSE-17 From 5062b2e64014e6419111ee55352ac92f45a43152 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:37:41 +0100 Subject: [PATCH 30/62] Code quality improvements, refactor of informationView - Decreased complexity of FilterSupportingIdentityMappingViewType - Implemented more logical concept of InformationView - Added interface for InformationView - Removed/improved the "expected" comments in InstanceFilterTest --- .../change/FilterOnOriginalResolver.java | 42 ------------- .../internal}/CountElementsTransformator.java | 4 +- .../CountUmlClassesTransformator.java | 2 +- .../InformationViewTransformator.java | 4 +- .../views/BasicInformationFilterView.java | 28 ++++++--- .../views/CountUmlClassesView.java | 32 ++++++++++ .../views/InformationView.java | 6 ++ .../FilterSupportingViewTypeFactory.java | 4 +- ...untUmlClassesIdentityMappingViewType.java} | 10 +-- ...lterSupportingIdentityMappingViewType.java | 63 +++++-------------- .../viewfilter/tests/InstanceFilterTest.java | 33 ++++------ 11 files changed, 96 insertions(+), 132 deletions(-) delete mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/change/FilterOnOriginalResolver.java rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/{transformation => informationview/internal}/CountElementsTransformator.java (87%) rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/{transformation => informationview/internal}/CountUmlClassesTransformator.java (86%) rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/{transformation => informationview/internal}/InformationViewTransformator.java (89%) rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/{ => informationview}/views/BasicInformationFilterView.java (69%) create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java create mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/InformationView.java rename bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/{InformationFilterIdentityMappingViewType.java => CountUmlClassesIdentityMappingViewType.java} (53%) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/change/FilterOnOriginalResolver.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/change/FilterOnOriginalResolver.java deleted file mode 100644 index 383c21240..000000000 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/change/FilterOnOriginalResolver.java +++ /dev/null @@ -1,42 +0,0 @@ -package tools.vitruv.application.viewfilter.change; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.net4j.util.ImplementationError; - -import tools.vitruv.change.atomic.hid.HierarchicalId; -import tools.vitruv.change.composite.description.CompositeContainerChange; -import tools.vitruv.change.composite.description.TransactionalChange; -import tools.vitruv.change.composite.description.VitruviusChange; -import tools.vitruv.change.composite.description.VitruviusChangeFactory; -import tools.vitruv.change.composite.description.VitruviusChangeResolver; - -public class FilterOnOriginalResolver implements VitruviusChangeResolver { - - - public VitruviusChange resolveFilteredChangesOnOriginalSources(VitruviusChange change) { - -// if (change instanceof CompositeContainerChange compositeChange) { -// //TODO nbr implement -// throw new ImplementationError("Not implemented"); -// } else if (change instanceof TransactionalChange transactionalChange) { -// transactionalChange. -// } - throw new IllegalStateException( - "trying to transform unknown change of class " + change.getClass().getSimpleName()); - } - - @Override - public VitruviusChange resolveAndApply(VitruviusChange change) { - - // TODO Auto-generated method stub - return null; - } - - @Override - public VitruviusChange assignIds(VitruviusChange change) { - // TODO Auto-generated method stub - throw new ImplementationError("Not implemented yet"); - - } - -} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountElementsTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java similarity index 87% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountElementsTransformator.java rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java index 01c9b8e32..1f2dc966b 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountElementsTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java @@ -1,4 +1,4 @@ -package tools.vitruv.application.viewfilter.transformation; +package tools.vitruv.application.viewfilter.informationview.internal; import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; import com.niklas.niklasproject.niklasdomain.SingleInformation; @@ -12,7 +12,7 @@ import org.eclipse.uml2.uml.Model; //TODO nbr add javadoc -public abstract class CountElementsTransformator extends InformationViewTransformator { +public abstract class CountElementsTransformator implements InformationViewTransformator { public SingleInformation transform(EObject root) { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountUmlClassesTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java similarity index 86% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountUmlClassesTransformator.java rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java index 849f6a31f..87c789347 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/CountUmlClassesTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java @@ -1,4 +1,4 @@ -package tools.vitruv.application.viewfilter.transformation; +package tools.vitruv.application.viewfilter.informationview.internal; import org.eclipse.emf.ecore.EObject; diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java similarity index 89% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java index bac449a87..105ba0c0b 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/transformation/InformationViewTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java @@ -1,4 +1,4 @@ -package tools.vitruv.application.viewfilter.transformation; +package tools.vitruv.application.viewfilter.informationview.internal; import org.eclipse.emf.ecore.EObject; @@ -9,7 +9,7 @@ * counting the elements of a certain type in the given model for instance. * The actual transformation depends on the overwriting implementation.} */ -public abstract class InformationViewTransformator { +public interface InformationViewTransformator { /** * Method transforms the given model (represented by its root) into a {@link SingleInformation}. diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java similarity index 69% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java index 408ef5ab2..a77d3baaf 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java @@ -1,4 +1,4 @@ -package tools.vitruv.applications.viewfilter.views; +package tools.vitruv.applications.viewfilter.informationview.views; import java.util.ArrayList; import java.util.HashMap; @@ -16,23 +16,34 @@ import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; import com.niklas.niklasproject.niklasdomain.SingleInformation; -import tools.vitruv.application.viewfilter.transformation.CountElementsTransformator; -import tools.vitruv.application.viewfilter.transformation.CountUmlClassesTransformator; +import static com.google.common.base.Preconditions.checkArgument; + +import tools.vitruv.application.viewfilter.informationview.internal.CountElementsTransformator; +import tools.vitruv.application.viewfilter.informationview.internal.CountUmlClassesTransformator; +import tools.vitruv.application.viewfilter.informationview.internal.InformationViewTransformator; import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; +import tools.vitruv.applications.viewfilter.views.BasicFilterView; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.framework.views.ChangeableViewSource; import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; -public class BasicInformationFilterView extends BasicFilterView { +public class BasicInformationFilterView extends BasicFilterView implements InformationView { + + private final InformationViewTransformator infoTransformator; + public BasicInformationFilterView(FilteredViewCreatingViewType viewType, - ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { + ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter, + InformationViewTransformator infoTransformator) { super(viewType, viewSource, selection, viewFilter); + checkArgument(infoTransformator != null, "Transformator must be not null"); + this.infoTransformator = infoTransformator; + update(); } @@ -41,13 +52,16 @@ protected void updateRootAndSelectedElements(ModifiableViewSelection selection) if (selection == null) { throw new NullPointerException("selection is null"); } - CountElementsTransformator transformator = new CountUmlClassesTransformator(); + if (infoTransformator == null) { + //method has been called as part of constructor and before the info transformator could be set + return; + } InformationStructure informationStructure = NiklasdomainFactory.eINSTANCE.createInformationStructure(); EList singleinformationList = informationStructure.getSingleinformation(); for(EObject root : selection.getSelectableElements()) { if (selection.isSelected(root)) { - SingleInformation transformResult = transformator.transform(root); + SingleInformation transformResult = infoTransformator.transform(root); if (transformResult != null) { singleinformationList.add(transformResult); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java new file mode 100644 index 000000000..fd878b335 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java @@ -0,0 +1,32 @@ +package tools.vitruv.applications.viewfilter.informationview.views; + +import tools.vitruv.application.viewfilter.informationview.internal.CountUmlClassesTransformator; +import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; +import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; +import tools.vitruv.change.atomic.hid.HierarchicalId; +import tools.vitruv.framework.views.ChangeableViewSource; +import tools.vitruv.framework.views.ViewSelection; +import tools.vitruv.framework.views.ViewSelector; + +/** + * Utility class for creating a {@link InformationView} which counts all uml2.Class objects + * in a model. Used a given {@link ViewFilter} object to filter the model for objects which are + * supposed to be taken into account + */ +public class CountUmlClassesView extends BasicInformationFilterView implements InformationView { + + /** + * Creates an {@link InformationView} object which counts all uml2.Class objects in a model + * and displays the result. + * + * @param viewType The viewType for this {@link InformationView} object + * @param viewSource The viewSource for this {@link InformationView} object + * @param selection The selection for this {@link InformationView} object + * @param viewFilter The viewFilter used to filter objects which are supposed to displayed in the view. + */ + public CountUmlClassesView(FilteredViewCreatingViewType viewType, + ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { + super(viewType, viewSource, selection, viewFilter, new CountUmlClassesTransformator()); + + } +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/InformationView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/InformationView.java new file mode 100644 index 000000000..75044e604 --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/InformationView.java @@ -0,0 +1,6 @@ +package tools.vitruv.applications.viewfilter.informationview.views; + +//TODO nbr: Add javadoc +public interface InformationView { + +} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java index 2bc1f6c93..eb5fa0c74 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java @@ -2,7 +2,7 @@ import org.eclipse.net4j.util.ImplementationError; -import tools.vitruv.applications.viewfilter.util.framework.impl.InformationFilterIdentityMappingViewType; +import tools.vitruv.applications.viewfilter.util.framework.impl.CountUmlClassesIdentityMappingViewType; import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; import tools.vitruv.framework.views.ViewSelector; import tools.vitruv.framework.views.ViewType; @@ -16,6 +16,6 @@ public static ViewType createFilterSupportingIdentityMap public static ViewType createInformationFilterViewViewType(String name) { - return new InformationFilterIdentityMappingViewType(name); + return new CountUmlClassesIdentityMappingViewType(name); } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/InformationFilterIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/CountUmlClassesIdentityMappingViewType.java similarity index 53% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/InformationFilterIdentityMappingViewType.java rename to bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/CountUmlClassesIdentityMappingViewType.java index cb5f97ea2..ed86d971e 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/InformationFilterIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/CountUmlClassesIdentityMappingViewType.java @@ -2,14 +2,14 @@ import static com.google.common.base.Preconditions.checkArgument; - +import tools.vitruv.applications.viewfilter.informationview.views.BasicInformationFilterView; +import tools.vitruv.applications.viewfilter.informationview.views.CountUmlClassesView; import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelectorImpl; -import tools.vitruv.applications.viewfilter.views.BasicInformationFilterView; import tools.vitruv.change.atomic.hid.HierarchicalId; -public class InformationFilterIdentityMappingViewType extends FilterSupportingIdentityMappingViewType { +public class CountUmlClassesIdentityMappingViewType extends FilterSupportingIdentityMappingViewType { - public InformationFilterIdentityMappingViewType(String name) { + public CountUmlClassesIdentityMappingViewType(String name) { super(name); } @@ -17,7 +17,7 @@ public InformationFilterIdentityMappingViewType(String name) { @Override public ModifiableView createView(FilterSupportingViewElementSelectorImpl selector) { checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); - BasicInformationFilterView view = new BasicInformationFilterView(selector.getViewType(), selector.getViewSource(), selector.getSelection(), selector.getViewFilter()); + BasicInformationFilterView view = new CountUmlClassesView(selector.getViewType(), selector.getViewSource(), selector.getSelection(), selector.getViewFilter()); return view; } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index d89345920..319d0b57e 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -19,7 +19,6 @@ import org.eclipse.uml2.uml.internal.resource.UMLResourceImpl; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; -import tools.vitruv.application.viewfilter.change.FilterOnOriginalResolver; import tools.vitruv.applications.viewfilter.util.framework.selectors.DirectViewElementSelector; import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelectorImpl; import tools.vitruv.applications.viewfilter.views.BasicFilterView; @@ -79,53 +78,32 @@ public void updateView(ModifiableView view) { createViewResources(view, viewResourceSet); }); } - - - public void commitViewChanges(FilterableView view, VitruviusChange viewChange) { - ResourceSet viewResourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); - ResourceSet unfilteredResourceSet = ((FilterChangeRecordingView) view).getNonFilteredViewResourceSet(); - ResourceSet filteredResourceSetInOriginalState = ((FilterChangeRecordingView) view).getFilteredModelsInResourceSetWithBackwardExecution(); - VitruviusChangeResolver viewResourceIdChangeResolver = - VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(unfilteredResourceSet, filteredResourceSetInOriginalState, view.getMapCopy2OriginalObject()); - //VitruviusChangeResolver viewResourceIdChangeResolver = VitruviusChangeResolver.forHierarchicalIds(((FilterChangeRecordingView) view).getUnfilteredResourceSet()); - - - VitruviusChange viewResourceResolvedChange = viewResourceIdChangeResolver.resolveAndApply(viewChange); - VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(unfilteredResourceSet); - VitruviusChange unresolvedViewResourceChanges = changeResolver.assignIds(viewResourceResolvedChange); - - ResourceSet viewSourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); - VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIds(viewSourceCopyResourceSet); -// VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(viewSourceCopyResourceSet, view.getFilteredModelsInResourceSet(), view.getMapCopy2OriginalObject()); - UuidResolver viewSourceCopyUuidResolver = UuidResolver.create(viewSourceCopyResourceSet); - VitruviusChangeResolver uuidChangeResolver = VitruviusChangeResolver.forUuids(viewSourceCopyUuidResolver); - Map mapping = createViewResources(view, viewSourceCopyResourceSet); -// mapChangeOnSourceIds(unresolvedChanges); - view.getViewSource().getUuidResolver().resolveResources(mapping, viewSourceCopyUuidResolver); - - -// FilterOnOriginalResolver filterOnOriginalResolver = new FilterOnOriginalResolver(); -// filterOnOriginalResolver.resolveFilteredChangesOnOriginalSources(viewChange); - VitruviusChange resolvedChange = idChangeResolver.resolveAndApply(unresolvedViewResourceChanges); - VitruviusChange unresolvedChanges = uuidChangeResolver.assignIds(resolvedChange); - view.getViewSource().propagateChange(unresolvedChanges); - } @Override public void commitViewChanges(ModifiableView view, VitruviusChange viewChange) { + VitruviusChange unresolvedViewResourceChanges = viewChange; + if (view instanceof FilterableView filterableView) { - commitViewChanges(filterableView, viewChange); - return; + //in case the changes have been performed on a FilteredView, the viewChange references the filterResourceSet + //transform the viewChanges on the ViewResourceSet first.. + ResourceSet unfilteredResourceSet = ((FilterChangeRecordingView) view).getNonFilteredViewResourceSet(); + ResourceSet filteredResourceSetInOriginalState = ((FilterChangeRecordingView) view).getFilteredModelsInResourceSetWithBackwardExecution(); + VitruviusChangeResolver viewResourceIdChangeResolver = + VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(unfilteredResourceSet, filteredResourceSetInOriginalState, filterableView.getMapCopy2OriginalObject()); + VitruviusChange viewResourceResolvedChange = viewResourceIdChangeResolver.resolveAndApply(viewChange); + VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(unfilteredResourceSet); + unresolvedViewResourceChanges = changeResolver.assignIds(viewResourceResolvedChange); } + ResourceSet viewSourceCopyResourceSet = withGlobalFactories(new ResourceSetImpl()); VitruviusChangeResolver idChangeResolver = VitruviusChangeResolver.forHierarchicalIds(viewSourceCopyResourceSet); UuidResolver viewSourceCopyUuidResolver = UuidResolver.create(viewSourceCopyResourceSet); VitruviusChangeResolver uuidChangeResolver = VitruviusChangeResolver.forUuids(viewSourceCopyUuidResolver); Map mapping = createViewResources(view, viewSourceCopyResourceSet); view.getViewSource().getUuidResolver().resolveResources(mapping, viewSourceCopyUuidResolver); - - VitruviusChange resolvedChange = idChangeResolver.resolveAndApply(viewChange); + + VitruviusChange resolvedChange = idChangeResolver.resolveAndApply(unresolvedViewResourceChanges); VitruviusChange unresolvedChanges = uuidChangeResolver.assignIds(resolvedChange); view.getViewSource().propagateChange(unresolvedChanges); } @@ -138,18 +116,5 @@ private Map createViewResources(ModifiableView view, Resourc return ResourceCopier.copyViewSourceResources(resourcesWithSelectedElements, viewResourceSet, selection::isViewObjectSelected); } - - - private void mapChangeOnSourceIds(VitruviusChange viewChange) { - if (viewChange instanceof CompositeContainerChange compositeChange) { - - } else { - - } - - - viewChange.getAffectedEObjects(); - - } } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index 32cf70dc2..a51f172a8 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -122,8 +122,7 @@ public void setup() { public void testUmlView() throws NoSuchMethodException, InvocationTargetException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { View createUmlView = improvedViewTestFactory.createUmlView(); Collection rootObjects = createUmlView.getRootObjects(); - //Selection should contain ModelImpl, and two SystemImpl. Only the ModelImpl should be - //selected. + //Expected: Selection should contain ModelImpl, and two SystemImpl. Only the ModelImpl should be selected. //Root Objects should only contain ModelImpl assertEquals(countContainedModelImplInstances(rootObjects), 1); assertEquals(1, rootObjects.size()); @@ -143,9 +142,9 @@ public void testCreateFilteredUmlView() { view.update(); Collection rootObjects = view.getRootObjects(); assertEquals(rootObjects.size(), 1); - //TODO nbr: remove comments.. - //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement - //Root Objects: ModelImpl (aber nicht nur mit niklasClass2, sondern mit allem) + //Expected: + //Selection: Only ModelImpl with class "niklasClass2" as only PackagedElement + //Root Objects: same structure as in selection for (EObject root : rootObjects) { assertTrue(root instanceof Model); assertTrue(view.getSelection().isViewObjectSelected(root)); @@ -159,9 +158,8 @@ public void testCreateFilteredUmlView() { modifyModel(); view.update(); view.getSelection(); - //Selection: Nur ModelImpl mit zwei Klassen die jeweils niklasClass2 als Namen haben, als PackagedElement - //ACHTUNG: Die zwei Klassen sind als PackagedElements in der ModelImpl! - //Root Objects: ModelImpl + //Expected: Selection: Only ModelImpl with two Class Objects, both with the name niklasClass2 as packagedElements + //Root Objects: The same Collection modifiedRootObjects = view.getRootObjects(); assertEquals(modifiedRootObjects.size(), 1); for (EObject root : modifiedRootObjects) { @@ -185,8 +183,8 @@ public void testCreateFilteredUmlViewWithAdditionalPcmElementsInVsum() { View view = improvedViewTestFactory.createFilteredUmlView(function); view.update(); view.update(); - //Selection: Nur ModelImpl mit niklasClass2 als einzigs PackagedElement - //Root Objects: ModelImpl (aber nicht nur mit niklasClass2, sondern mit allem) und zwei weitere ModelImpls (aber andere) + //Expected Selection: Only ModelImpl with class object "niklasClass2" as only PackagedElement + //Root Objects: Same structure as selection Collection rootObjects = view.getRootObjects(); assertEquals(rootObjects.size(), 1); for (EObject root : rootObjects) { @@ -203,9 +201,6 @@ public void testCreateFilteredUmlViewWithAdditionalPcmElementsInVsum() { modifyModel(); view.update(); view.getSelection(); - //Selection: Nur ModelImpl mit zwei Klassen die jeweils niklasClass2 als Namen haben, als PackagedElement - //ACHTUNG: Die zwei Klassen sind als PackagedElements in der ModelImpl! - //Root Objects: ModelImpl, ModelImpl, ModelImpl Collection modifiedRootObjects = view.getRootObjects(); assertEquals(modifiedRootObjects.size(), 1); for (EObject root : modifiedRootObjects) { @@ -256,15 +251,12 @@ public void testCreateFilteredPcmView() { BasicComponent classObject = (BasicComponent) eObject; assertEquals(PCM_BASIC_COMPONENT_NAME, classObject.getEntityName()); } - //TODO nbr: Remove or translate comments in every test in this class - //Selection: Nur RepositoryImpl. Unter eSettings liegt List und darin Niklas Basic PCM component - //Root Objects: Identisch zu Selection (aber weniger null Werte in irrelevanten Feldern, da nicht kopiert) + //Expected: Selection: Only RepositoryImpl. Under eSettings is a list which contains "Niklas Basic PCM component 1" + //Root Objects: Identical to Selection but with less null values in irrelevant fields modifyModel(); view.update(); view.getSelection(); - // unverändert durch selection - //Selection: Nur RepositoryImpl. Unter eSettings liegt List und darin Niklas Basic PCM component - //Root Objects: Identisch zu Selection (aber weniger null Werte in irrelevanten Feldern, da nicht kopiert) + // Expected: Selection and Root objects should not have changed Collection modifiedRootObjects = view.getRootObjects(); assertEquals(modifiedRootObjects.size(), 1); for (EObject root : modifiedRootObjects) { @@ -297,7 +289,6 @@ public void testCreateCountingView() { assertEquals(1, singleInformation.getValue()); } - modifyModel(); view.update(); @@ -453,13 +444,11 @@ protected void createPcmModel() { Repository repository = RepositoryFactory.eINSTANCE.createRepository(); repository.setEntityName(PCM_MODEL_NAME); it.registerRoot(repository, getUri(getPcmProjectModelPath(repository.getEntityName(), PCM_REPOSITORY_FILE_EXTENSION))); - //createAndRegisterRoot(it, repository, this.getUri(getProjectModelPath(PCM_MODEL_NAME))); }; try { improvedViewTestFactory.changePcmView(createPcmRepoFunction); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } From 342f5a3763ccf11d188f3df8bc4e37ad31244e6b Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:39:52 +0100 Subject: [PATCH 31/62] - Renamed some methods to improve understandability --- .../util/framework/FilterSupportingViewTypeFactory.java | 4 +--- .../applications/viewfilter/tests/ViewTestFactory.java | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java index eb5fa0c74..4feb7328c 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java @@ -1,7 +1,5 @@ package tools.vitruv.applications.viewfilter.util.framework; -import org.eclipse.net4j.util.ImplementationError; - import tools.vitruv.applications.viewfilter.util.framework.impl.CountUmlClassesIdentityMappingViewType; import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; import tools.vitruv.framework.views.ViewSelector; @@ -15,7 +13,7 @@ public static ViewType createFilterSupportingIdentityMap } - public static ViewType createInformationFilterViewViewType(String name) { + public static ViewType createCountUmlClassesInformationFilterViewViewType(String name) { return new CountUmlClassesIdentityMappingViewType(name); } } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 7ca234c75..19604c4c7 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -90,7 +90,7 @@ public View createFilteredPcmView(Function filterFunction) { public View createCountUmlElementsView(Function filterFunction) { Collection> rootTypes = createCollectionOfRootTypes(Model.class); - return createInformationView("Information Page", rootTypes, filterFunction); + return createCountUmlClassesInformationView("Information Page", rootTypes, filterFunction); } @@ -129,8 +129,8 @@ public void changePcmView(Consumer modelModification) throws Ex //-------------End of Boilerplate code----------------// - public View createInformationView(String viewName, Collection> rootTypes, Function filterFunction) { - viewType = FilterSupportingViewTypeFactory.createInformationFilterViewViewType(viewName); + public View createCountUmlClassesInformationView(String viewName, Collection> rootTypes, Function filterFunction) { + viewType = FilterSupportingViewTypeFactory.createCountUmlClassesInformationFilterViewViewType(viewName); FilterSupportingViewElementSelector selector = (FilterSupportingViewElementSelector) viewProvider.createSelector(viewType); selector.deselectElementsExceptForRootType(rootTypes); selector.filterModelElementsByLambda(filterFunction); From b4e715839f6b86d89b8f87b9a4cfef0b21da1920 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:37:04 +0100 Subject: [PATCH 32/62] Some code cleanups, reverted accidental modification in cbs.testutils --- .../EquivalenceTestExecutable.xtend | 34 +++++++++---------- .../CountUmlClassesTransformator.java | 4 +-- ...lterSupportingViewElementSelectorImpl.java | 5 --- .../viewfilter/viewbuild/ViewFilterImpl.java | 1 - .../viewfilter/views/BasicFilterView.java | 11 ------ 5 files changed, 19 insertions(+), 36 deletions(-) diff --git a/bundles/tools.vitruv.applications.cbs.testutils/src/tools/vitruv/applications/cbs/testutils/equivalencetest/EquivalenceTestExecutable.xtend b/bundles/tools.vitruv.applications.cbs.testutils/src/tools/vitruv/applications/cbs/testutils/equivalencetest/EquivalenceTestExecutable.xtend index dba0977bc..c9aed54ab 100644 --- a/bundles/tools.vitruv.applications.cbs.testutils/src/tools/vitruv/applications/cbs/testutils/equivalencetest/EquivalenceTestExecutable.xtend +++ b/bundles/tools.vitruv.applications.cbs.testutils/src/tools/vitruv/applications/cbs/testutils/equivalencetest/EquivalenceTestExecutable.xtend @@ -57,23 +57,23 @@ package class EquivalenceTestExecutable implements Executable, AutoCloseable { val EquivalenceTestExtensionContext extensionContext override execute() throws Throwable { - // try ( - // val testView = setupTestView(); - // val referenceView = setupReferenceView(); - // val printerChange = installViewDirectoryUriReplacement(testView, referenceView) - // ) { - // checkNotNull(printerChange) // Suppress warning for variable not being used - // executeDependencies(testView, referenceView) - // - // testStep.executeIn(testView) - // referenceSteps.values.forEach[executeIn(referenceView)] - // verifyTestViewResults() - // } catch (Throwable t) { - // extensionContext.executionException = Optional.of(t) - // throw t - // } finally { - // close() -// } + try ( + val testView = setupTestView(); + val referenceView = setupReferenceView(); + val printerChange = installViewDirectoryUriReplacement(testView, referenceView) + ) { + checkNotNull(printerChange) // Suppress warning for variable not being used + executeDependencies(testView, referenceView) + + testStep.executeIn(testView) + referenceSteps.values.forEach[executeIn(referenceView)] + verifyTestViewResults() + } catch (Throwable t) { + extensionContext.executionException = Optional.of(t) + throw t + } finally { + close() + } } def private DirectoryTestView setupTestView() { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java index 87c789347..174f5e2ee 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java @@ -4,7 +4,7 @@ public class CountUmlClassesTransformator extends CountElementsTransformator { - private static final String ANZAHL_ELEMENTE = "Anzahl Elemente"; + private static final String NUMBER_OF_ELEMENTS = "Number of elements"; @Override protected boolean takeElementIntoAccount(EObject object) { @@ -17,7 +17,7 @@ protected boolean takeElementIntoAccount(EObject object) { @Override protected String getTitle() { - return ANZAHL_ELEMENTE; + return NUMBER_OF_ELEMENTS; } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java index 755bdb2d5..dccc4fcad 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java @@ -69,11 +69,6 @@ public View createView() { return createdView; } - public void selectElementsOfRootType(Collection> rootTypes) { - getSelectableElements().stream().filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) - .forEach(element -> setSelected(element, true)); - } - public void deselectElementsExceptForRootType(Collection> rootTypes) { getSelectableElements().stream().filter(element -> (isViewObjectSelected(element) && !(rootTypes.stream().anyMatch(it -> it.isInstance(element))))) .forEach(element -> setSelected(element, false)); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index 3ec828669..07b7f3461 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -107,7 +107,6 @@ private void attachElementToRoot(EObject root, EObject object) { private void attachElementToRootUml(Model root, EObject object) { if (object instanceof Type) { - //EObject objectCopy = EcoreUtil.copy(object); root.getOwnedTypes().add((Type) object); } else { System.out.println("Warning: Undefined type: " + object.eClass()); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 540e285b2..9eaf0384a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -94,17 +94,6 @@ public void setViewChanged(boolean value) { super.setViewChanged(value); } - - private List findRootsForSelectionInViewSource(Collection viewSources) { - ViewSelection selection = getPreFilterSelection(); - List resourcesWithSelectedElements = viewSources.stream() - .filter(resource -> resource.getContents().stream().anyMatch(selection::isViewObjectSelected)).toList(); - List roots = new ArrayList(); - for(Resource resource : resourcesWithSelectedElements) { - roots.addAll(resource.getContents()); - } - return roots; - } protected ModifiableViewSelection filterElementsForSelection() { From 3f6e0f09a39450cfdc804f2827413df4cad57141 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:57:37 +0100 Subject: [PATCH 33/62] - removed local files from git --- .../.classpath | 21 ---------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 41 ------------------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 8 ---- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 21 ---------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 21 ---------- .../.polyglot.META-INF | 18 -------- .../org.eclipse.core.resources.prefs | 2 - .../.settings/org.eclipse.jdt.core.prefs | 9 ---- .../.classpath | 16 -------- .../org.eclipse.core.resources.prefs | 2 - .../.settings/org.eclipse.jdt.core.prefs | 9 ---- .../.classpath | 21 ---------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 16 -------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 24 ----------- .../.polyglot.META-INF | 18 -------- .../org.eclipse.core.resources.prefs | 2 - .../.settings/org.eclipse.jdt.core.prefs | 9 ---- .../org.eclipse.core.resources.prefs | 2 - .../org.eclipse.core.resources.prefs | 2 - .../org.eclipse.core.resources.prefs | 2 - .../org.eclipse.core.resources.prefs | 2 - .../org.eclipse.core.resources.prefs | 2 - .../org.eclipse.core.resources.prefs | 2 - .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 5 --- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 16 -------- .../org.eclipse.core.resources.prefs | 2 - .../.settings/org.eclipse.m2e.core.prefs | 4 -- .../.classpath | 18 -------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 8 ---- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 16 -------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 16 -------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 16 -------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 11 ----- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 12 ------ .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 21 ---------- .../.polyglot.META-INF | 18 -------- .../org.eclipse.core.resources.prefs | 2 - .../.settings/org.eclipse.jdt.core.prefs | 9 ---- .../.classpath | 16 -------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 16 -------- .../org.eclipse.core.resources.prefs | 2 - .../.classpath | 21 ---------- .../.polyglot.META-INF | 18 -------- .../org.eclipse.core.resources.prefs | 2 - .../.settings/org.eclipse.jdt.core.prefs | 9 ---- 61 files changed, 560 deletions(-) delete mode 100644 bundles/tools.vitruv.applications.SimuLinkAutoSAR/.classpath delete mode 100644 bundles/tools.vitruv.applications.SimuLinkAutoSAR/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.cbs.commonalities/.classpath delete mode 100644 bundles/tools.vitruv.applications.cbs.commonalities/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.cbs.testutils/.classpath delete mode 100644 bundles/tools.vitruv.applications.cbs.testutils/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.pcmjava/.classpath delete mode 100644 bundles/tools.vitruv.applications.pcmjava/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.pcmumlclass/.classpath delete mode 100644 bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF delete mode 100644 bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.jdt.core.prefs delete mode 100644 bundles/tools.vitruv.applications.testutility/.classpath delete mode 100644 bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.jdt.core.prefs delete mode 100644 bundles/tools.vitruv.applications.umljava/.classpath delete mode 100644 bundles/tools.vitruv.applications.umljava/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.util.temporary/.classpath delete mode 100644 bundles/tools.vitruv.applications.util.temporary/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.viewtest/.classpath delete mode 100644 bundles/tools.vitruv.applications.viewtest/.polyglot.META-INF delete mode 100644 bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.core.resources.prefs delete mode 100644 bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.jdt.core.prefs delete mode 100644 features/tools.vitruv.applications.cbs.commonalities.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 features/tools.vitruv.applications.pcmjava.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 features/tools.vitruv.applications.pcmumlclass.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 features/tools.vitruv.applications.simulinkautosar.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 features/tools.vitruv.applications.umljava.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 features/tools.vitruv.applications.util.temporary.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 releng/tools.vitruv.applications.cbs.updatesite/.settings/org.eclipse.core.resources.prefs delete mode 100644 releng/tools.vitruv.casestudies.dependencywrapper/.classpath delete mode 100644 releng/tools.vitruv.casestudies.dependencywrapper/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.settings/org.eclipse.m2e.core.prefs delete mode 100644 tests/tools.vitruv.applications.cbs.commonalities.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.cbs.commonalities.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.cbs.equivalence.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.cbs.equivalence.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.demo.familiespersons.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.demo.familiespersons.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.demo.insurancefamilies.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.demo.insurancefamilies.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.demo.insurancepersons.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.demo.insurancepersons.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.pcmjava.javaeditor.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.pcmjava.javaeditor.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.pcmjava.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.pcmjava.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.pcmumlclass.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF delete mode 100644 tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.jdt.core.prefs delete mode 100644 tests/tools.vitruv.applications.transitivechange.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.transitivechange.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.umljava.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.umljava.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.classpath delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.polyglot.META-INF delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.jdt.core.prefs diff --git a/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.classpath b/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.classpath deleted file mode 100644 index 412b338a8..000000000 --- a/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.cbs.commonalities/.classpath b/bundles/tools.vitruv.applications.cbs.commonalities/.classpath deleted file mode 100644 index 6b47084e1..000000000 --- a/bundles/tools.vitruv.applications.cbs.commonalities/.classpath +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/tools.vitruv.applications.cbs.commonalities/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.cbs.commonalities/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.cbs.commonalities/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.cbs.testutils/.classpath b/bundles/tools.vitruv.applications.cbs.testutils/.classpath deleted file mode 100644 index 7bb4abd5f..000000000 --- a/bundles/tools.vitruv.applications.cbs.testutils/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/bundles/tools.vitruv.applications.cbs.testutils/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.cbs.testutils/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.cbs.testutils/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.pcmjava/.classpath b/bundles/tools.vitruv.applications.pcmjava/.classpath deleted file mode 100644 index 1fbe59dca..000000000 --- a/bundles/tools.vitruv.applications.pcmjava/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/tools.vitruv.applications.pcmjava/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.pcmjava/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.pcmjava/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.classpath b/bundles/tools.vitruv.applications.pcmumlclass/.classpath deleted file mode 100644 index 412b338a8..000000000 --- a/bundles/tools.vitruv.applications.pcmumlclass/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF b/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF deleted file mode 100644 index c4e3c412f..000000000 --- a/bundles/tools.vitruv.applications.pcmumlclass/.polyglot.META-INF +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - tools.vitruv - bundles - 3.0.1-SNAPSHOT - ..\.polyglot.pom.tycho - - tools.vitruv.applications.pcmumlclass - 3.0.1-SNAPSHOT - eclipse-plugin - [bundle] Vitruv PCM-UML Class Application - - vitruv.tools - - diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.jdt.core.prefs b/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 62ef3488c..000000000 --- a/bundles/tools.vitruv.applications.pcmumlclass/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=17 diff --git a/bundles/tools.vitruv.applications.testutility/.classpath b/bundles/tools.vitruv.applications.testutility/.classpath deleted file mode 100644 index ef548cb96..000000000 --- a/bundles/tools.vitruv.applications.testutility/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.jdt.core.prefs b/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 62ef3488c..000000000 --- a/bundles/tools.vitruv.applications.testutility/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=17 diff --git a/bundles/tools.vitruv.applications.umljava/.classpath b/bundles/tools.vitruv.applications.umljava/.classpath deleted file mode 100644 index 412b338a8..000000000 --- a/bundles/tools.vitruv.applications.umljava/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/tools.vitruv.applications.umljava/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.umljava/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.umljava/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.util.temporary/.classpath b/bundles/tools.vitruv.applications.util.temporary/.classpath deleted file mode 100644 index ef548cb96..000000000 --- a/bundles/tools.vitruv.applications.util.temporary/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/bundles/tools.vitruv.applications.util.temporary/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.util.temporary/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.util.temporary/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.viewtest/.classpath b/bundles/tools.vitruv.applications.viewtest/.classpath deleted file mode 100644 index 613688a94..000000000 --- a/bundles/tools.vitruv.applications.viewtest/.classpath +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/tools.vitruv.applications.viewtest/.polyglot.META-INF b/bundles/tools.vitruv.applications.viewtest/.polyglot.META-INF deleted file mode 100644 index 3f7ef650e..000000000 --- a/bundles/tools.vitruv.applications.viewtest/.polyglot.META-INF +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - tools.vitruv - bundles - 3.0.1-SNAPSHOT - ..\.polyglot.pom.tycho - - tools.vitruv.applications.viewfilter - 3.0.1-SNAPSHOT - eclipse-plugin - [bundle] Vitruv Viewfilter Application - - vitruv.tools - - diff --git a/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.core.resources.prefs b/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.jdt.core.prefs b/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 62ef3488c..000000000 --- a/bundles/tools.vitruv.applications.viewtest/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=17 diff --git a/features/tools.vitruv.applications.cbs.commonalities.feature/.settings/org.eclipse.core.resources.prefs b/features/tools.vitruv.applications.cbs.commonalities.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/features/tools.vitruv.applications.cbs.commonalities.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/features/tools.vitruv.applications.pcmjava.feature/.settings/org.eclipse.core.resources.prefs b/features/tools.vitruv.applications.pcmjava.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/features/tools.vitruv.applications.pcmjava.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/features/tools.vitruv.applications.pcmumlclass.feature/.settings/org.eclipse.core.resources.prefs b/features/tools.vitruv.applications.pcmumlclass.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/features/tools.vitruv.applications.pcmumlclass.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/features/tools.vitruv.applications.simulinkautosar.feature/.settings/org.eclipse.core.resources.prefs b/features/tools.vitruv.applications.simulinkautosar.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/features/tools.vitruv.applications.simulinkautosar.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/features/tools.vitruv.applications.umljava.feature/.settings/org.eclipse.core.resources.prefs b/features/tools.vitruv.applications.umljava.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/features/tools.vitruv.applications.umljava.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/features/tools.vitruv.applications.util.temporary.feature/.settings/org.eclipse.core.resources.prefs b/features/tools.vitruv.applications.util.temporary.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/features/tools.vitruv.applications.util.temporary.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/releng/tools.vitruv.applications.cbs.updatesite/.settings/org.eclipse.core.resources.prefs b/releng/tools.vitruv.applications.cbs.updatesite/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/releng/tools.vitruv.applications.cbs.updatesite/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/releng/tools.vitruv.casestudies.dependencywrapper/.classpath b/releng/tools.vitruv.casestudies.dependencywrapper/.classpath deleted file mode 100644 index ac37fb2e4..000000000 --- a/releng/tools.vitruv.casestudies.dependencywrapper/.classpath +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/releng/tools.vitruv.casestudies.dependencywrapper/.settings/org.eclipse.core.resources.prefs b/releng/tools.vitruv.casestudies.dependencywrapper/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/releng/tools.vitruv.casestudies.dependencywrapper/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.classpath b/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.classpath deleted file mode 100644 index 79b55556c..000000000 --- a/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.settings/org.eclipse.m2e.core.prefs b/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1c..000000000 --- a/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/tests/tools.vitruv.applications.cbs.commonalities.tests/.classpath b/tests/tools.vitruv.applications.cbs.commonalities.tests/.classpath deleted file mode 100644 index 86e2dcf0f..000000000 --- a/tests/tools.vitruv.applications.cbs.commonalities.tests/.classpath +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.cbs.commonalities.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.cbs.commonalities.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.cbs.commonalities.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.cbs.equivalence.tests/.classpath b/tests/tools.vitruv.applications.cbs.equivalence.tests/.classpath deleted file mode 100644 index 5b259b905..000000000 --- a/tests/tools.vitruv.applications.cbs.equivalence.tests/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/tests/tools.vitruv.applications.cbs.equivalence.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.cbs.equivalence.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.cbs.equivalence.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.demo.familiespersons.tests/.classpath b/tests/tools.vitruv.applications.demo.familiespersons.tests/.classpath deleted file mode 100644 index 47de4eea1..000000000 --- a/tests/tools.vitruv.applications.demo.familiespersons.tests/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.demo.familiespersons.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.demo.familiespersons.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.demo.familiespersons.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.classpath b/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.classpath deleted file mode 100644 index 47de4eea1..000000000 --- a/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.demo.insurancepersons.tests/.classpath b/tests/tools.vitruv.applications.demo.insurancepersons.tests/.classpath deleted file mode 100644 index 47de4eea1..000000000 --- a/tests/tools.vitruv.applications.demo.insurancepersons.tests/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.demo.insurancepersons.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.demo.insurancepersons.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.demo.insurancepersons.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.pcmjava.javaeditor.tests/.classpath b/tests/tools.vitruv.applications.pcmjava.javaeditor.tests/.classpath deleted file mode 100644 index fe1a20532..000000000 --- a/tests/tools.vitruv.applications.pcmjava.javaeditor.tests/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.pcmjava.javaeditor.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.pcmjava.javaeditor.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.pcmjava.javaeditor.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.pcmjava.tests/.classpath b/tests/tools.vitruv.applications.pcmjava.tests/.classpath deleted file mode 100644 index 58d1a70f1..000000000 --- a/tests/tools.vitruv.applications.pcmjava.tests/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.pcmjava.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.pcmjava.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.pcmjava.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath b/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath deleted file mode 100644 index 366853672..000000000 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF b/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF deleted file mode 100644 index 9fc7a3be6..000000000 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/.polyglot.META-INF +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - tools.vitruv - tests - 3.0.1-SNAPSHOT - ..\.polyglot.pom.tycho - - tools.vitruv.applications.pcmumlclass.tests - 3.0.1-SNAPSHOT - eclipse-test-plugin - [test-bundle] Vitruv PCM-UML Class Application Tests - - vitruv.tools - - diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.jdt.core.prefs b/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 62ef3488c..000000000 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=17 diff --git a/tests/tools.vitruv.applications.transitivechange.tests/.classpath b/tests/tools.vitruv.applications.transitivechange.tests/.classpath deleted file mode 100644 index ef548cb96..000000000 --- a/tests/tools.vitruv.applications.transitivechange.tests/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.transitivechange.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.transitivechange.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.transitivechange.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.umljava.tests/.classpath b/tests/tools.vitruv.applications.umljava.tests/.classpath deleted file mode 100644 index ef548cb96..000000000 --- a/tests/tools.vitruv.applications.umljava.tests/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.umljava.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.umljava.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.umljava.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.classpath b/tests/tools.vitruv.applications.viewfilter.tests/.classpath deleted file mode 100644 index 366853672..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.polyglot.META-INF b/tests/tools.vitruv.applications.viewfilter.tests/.polyglot.META-INF deleted file mode 100644 index 63d67d85f..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/.polyglot.META-INF +++ /dev/null @@ -1,18 +0,0 @@ - - - 4.0.0 - - tools.vitruv - tests - 3.0.1-SNAPSHOT - ..\.polyglot.pom.tycho - - tools.vitruv.applications.viewfilter.tests - 3.0.1-SNAPSHOT - eclipse-test-plugin - [test-bundle] Vitruv PCM-UML Class Application Tests - - vitruv.tools - - diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.core.resources.prefs b/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.jdt.core.prefs b/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 62ef3488c..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 -org.eclipse.jdt.core.compiler.compliance=17 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=17 From 8ac4574f3e91c50a5215d76d6c146883de72a6d7 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 6 Mar 2024 17:20:56 +0100 Subject: [PATCH 34/62] - updated InstanceFilterTest to match new functionality removed file --- .../pluginnono.xml | 16 ---------------- .../viewfilter/tests/InstanceFilterTest.java | 5 ++--- 2 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/pluginnono.xml diff --git a/tests/tools.vitruv.applications.viewfilter.tests/pluginnono.xml b/tests/tools.vitruv.applications.viewfilter.tests/pluginnono.xml deleted file mode 100644 index 2bc642c49..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/pluginnono.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index a51f172a8..697d6dd2b 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -117,7 +117,6 @@ public void setup() { } - //--- Actual tests --- @Test public void testUmlView() throws NoSuchMethodException, InvocationTargetException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { View createUmlView = improvedViewTestFactory.createUmlView(); @@ -285,7 +284,7 @@ public void testCreateCountingView() { EObject eObject = root.eContents().get(0); assertTrue(eObject instanceof SingleInformation); SingleInformation singleInformation = (SingleInformation) eObject; - assertEquals("Anzahl Elemente", singleInformation.getTitle()); + assertEquals("Number of elements", singleInformation.getTitle()); assertEquals(1, singleInformation.getValue()); } @@ -301,7 +300,7 @@ public void testCreateCountingView() { EObject eObject = root.eContents().get(0); assertTrue(eObject instanceof SingleInformation); SingleInformation singleInformation = (SingleInformation) eObject; - assertEquals("Anzahl Elemente", singleInformation.getTitle()); + assertEquals("Number of elements", singleInformation.getTitle()); assertEquals(2, singleInformation.getValue()); } From c7899f9fb5334083f60bcfa7a37842eb05079b99 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 6 Mar 2024 20:54:17 +0100 Subject: [PATCH 35/62] - removed unnecessary if clause --- .../informationview/internal/CountElementsTransformator.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java index 1f2dc966b..42a9fce37 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java @@ -16,11 +16,6 @@ public abstract class CountElementsTransformator implements InformationViewTrans public SingleInformation transform(EObject root) { - if (!(root instanceof Model)) { - //not an Uml model - return null; - } - //TODO nbruening hier noch generischer machen SingleInformation createSingleInformation = NiklasdomainFactory.eINSTANCE.createSingleInformation(); createSingleInformation.setTitle(getTitle()); From 4be9d78cc429d2678e2b6526d3506d2e962ce55f Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Wed, 6 Mar 2024 21:27:55 +0100 Subject: [PATCH 36/62] Changed name of informationStructureModel package and added it to repo --- .../META-INF/MANIFEST.MF | 3 +- .../internal/CountElementsTransformator.java | 7 ++--- .../InformationViewTransformator.java | 2 +- .../views/BasicInformationFilterView.java | 8 ++--- .../META-INF/MANIFEST.MF | 3 +- .../viewfilter/tests/InstanceFilterTest.java | 4 +-- .../.project | 29 ++++++++++++++++++ .../META-INF/MANIFEST.MF | 16 ++++++++++ .../build.properties | 10 +++++++ .../model/infostructuremodel.aird | 30 +++++++++++++++++++ .../model/infostructuremodel.ecore | 13 ++++++++ .../model/infostructuremodel.genmodel | 23 ++++++++++++++ .../plugin.properties | 4 +++ .../plugin.xml | 17 +++++++++++ 14 files changed, 156 insertions(+), 13 deletions(-) create mode 100644 tools.vitruv.views.viewfilter.infostructure.model/.project create mode 100644 tools.vitruv.views.viewfilter.infostructure.model/META-INF/MANIFEST.MF create mode 100644 tools.vitruv.views.viewfilter.infostructure.model/build.properties create mode 100644 tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird create mode 100644 tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.ecore create mode 100644 tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.genmodel create mode 100644 tools.vitruv.views.viewfilter.infostructure.model/plugin.properties create mode 100644 tools.vitruv.views.viewfilter.infostructure.model/plugin.xml diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF index 1b8ac2de8..9fdfd1dd8 100644 --- a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF +++ b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF @@ -21,4 +21,5 @@ Bundle-Vendor: vitruv.tools Export-Package: tools.vitruv.applications.viewfilter.util.framework, tools.vitruv.applications.viewfilter.util.framework.impl, tools.vitruv.applications.viewfilter.util.framework.selectors -Import-Package: com.niklas.niklasproject.niklasdomain +Import-Package: com.niklas.niklasproject.niklasdomain, + tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java index 42a9fce37..9420f7f6c 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java @@ -1,10 +1,9 @@ package tools.vitruv.application.viewfilter.informationview.internal; -import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; -import com.niklas.niklasproject.niklasdomain.SingleInformation; import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; - +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InfostructuremodelFactory; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; import java.util.List; import java.util.function.Function; @@ -16,7 +15,7 @@ public abstract class CountElementsTransformator implements InformationViewTrans public SingleInformation transform(EObject root) { - SingleInformation createSingleInformation = NiklasdomainFactory.eINSTANCE.createSingleInformation(); + SingleInformation createSingleInformation = InfostructuremodelFactory.eINSTANCE.createSingleInformation(); createSingleInformation.setTitle(getTitle()); List allElements = ViewFilterHelper.convertTreeIterator2List(root.eAllContents()); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java index 105ba0c0b..df1e6fac9 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java @@ -2,7 +2,7 @@ import org.eclipse.emf.ecore.EObject; -import com.niklas.niklasproject.niklasdomain.SingleInformation; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; /** * Transforms a given model into a {@link SingleInformation}. A transformation could be diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java index a77d3baaf..ef0069627 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java @@ -12,9 +12,9 @@ import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import com.niklas.niklasproject.niklasdomain.InformationStructure; -import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; -import com.niklas.niklasproject.niklasdomain.SingleInformation; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InformationStructure; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InfostructuremodelFactory; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; import static com.google.common.base.Preconditions.checkArgument; @@ -56,7 +56,7 @@ protected void updateRootAndSelectedElements(ModifiableViewSelection selection) //method has been called as part of constructor and before the info transformator could be set return; } - InformationStructure informationStructure = NiklasdomainFactory.eINSTANCE.createInformationStructure(); + InformationStructure informationStructure = InfostructuremodelFactory.eINSTANCE.createInformationStructure(); EList singleinformationList = informationStructure.getSingleinformation(); for(EObject root : selection.getSelectableElements()) { diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index 9daafb961..56678de1b 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -10,7 +10,8 @@ Import-Package: com.niklas.niklasproject.niklasdomain, org.junit.jupiter.api.extension, tools.vitruv.applications.viewfilter.util.framework, tools.vitruv.applications.viewfilter.util.framework.impl, - tools.vitruv.applications.viewfilter.util.framework.selectors + tools.vitruv.applications.viewfilter.util.framework.selectors, + tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel Require-Bundle: tools.vitruv.testutils.vsum, org.eclipse.emf.compare, org.hamcrest.core, diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index 697d6dd2b..a4deb7223 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -52,8 +52,6 @@ import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.repository.RepositoryFactory; -import com.niklas.niklasproject.niklasdomain.InformationStructure; -import com.niklas.niklasproject.niklasdomain.SingleInformation; import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; @@ -69,6 +67,8 @@ import tools.vitruv.framework.vsum.VirtualModel; import tools.vitruv.testutils.RegisterMetamodelsInStandalone; import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InformationStructure; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; @ExtendWith(RegisterMetamodelsInStandalone.class) public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { diff --git a/tools.vitruv.views.viewfilter.infostructure.model/.project b/tools.vitruv.views.viewfilter.infostructure.model/.project new file mode 100644 index 000000000..f890a98d4 --- /dev/null +++ b/tools.vitruv.views.viewfilter.infostructure.model/.project @@ -0,0 +1,29 @@ + + + tools.vitruv.views.viewfilter.infostructure.model + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.sirius.nature.modelingproject + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/tools.vitruv.views.viewfilter.infostructure.model/META-INF/MANIFEST.MF b/tools.vitruv.views.viewfilter.infostructure.model/META-INF/MANIFEST.MF new file mode 100644 index 000000000..a397b7582 --- /dev/null +++ b/tools.vitruv.views.viewfilter.infostructure.model/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: tools.vitruv.views.viewfilter.infostructure.model;singleton:=true +Automatic-Module-Name: tools.vitruv.views.viewfilter.infostructure.model +Bundle-Version: 0.1.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Export-Package: tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel, + tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.impl, + tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.util +Require-Bundle: org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.core.runtime +Bundle-ActivationPolicy: lazy diff --git a/tools.vitruv.views.viewfilter.infostructure.model/build.properties b/tools.vitruv.views.viewfilter.infostructure.model/build.properties new file mode 100644 index 000000000..697ca9645 --- /dev/null +++ b/tools.vitruv.views.viewfilter.infostructure.model/build.properties @@ -0,0 +1,10 @@ +# + +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src-gen/ +output.. = bin/ diff --git a/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird b/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird new file mode 100644 index 000000000..c5ad78414 --- /dev/null +++ b/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird @@ -0,0 +1,30 @@ + + + + infostructuremodel.ecore + infostructuremodel.genmodel + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.ecore b/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.ecore new file mode 100644 index 000000000..194667bad --- /dev/null +++ b/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.ecore @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.genmodel b/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.genmodel new file mode 100644 index 000000000..e98c70323 --- /dev/null +++ b/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.genmodel @@ -0,0 +1,23 @@ + + + infostructuremodel.ecore + + + + + + + + + + + diff --git a/tools.vitruv.views.viewfilter.infostructure.model/plugin.properties b/tools.vitruv.views.viewfilter.infostructure.model/plugin.properties new file mode 100644 index 000000000..032dd38af --- /dev/null +++ b/tools.vitruv.views.viewfilter.infostructure.model/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = tools.vitruv.views.viewfilter.infostructure.model +providerName = www.example.org diff --git a/tools.vitruv.views.viewfilter.infostructure.model/plugin.xml b/tools.vitruv.views.viewfilter.infostructure.model/plugin.xml new file mode 100644 index 000000000..ad1b09d0d --- /dev/null +++ b/tools.vitruv.views.viewfilter.infostructure.model/plugin.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + From 906d43287a42cdc5003df94a152925bbad0492d7 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:20:06 +0100 Subject: [PATCH 37/62] minor code improvements, removed InformationView interface - InformationTransformator now expects a list of model-root-elements - Removed InformationView interface and did necessary refactorings - some small code quality improvements --- .../internal/CountElementsTransformator.java | 15 ++++++++------- .../internal/InformationViewTransformator.java | 18 ++++++++++-------- .../views/BasicInformationFilterView.java | 6 ++++-- .../views/CountUmlClassesView.java | 2 +- .../informationview/views/InformationView.java | 6 ------ ...ilterSupportingIdentityMappingViewType.java | 1 + .../viewfilter/views/BasicFilterView.java | 4 ++-- 7 files changed, 26 insertions(+), 26 deletions(-) delete mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/InformationView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java index 9420f7f6c..446e7d175 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java @@ -14,17 +14,18 @@ public abstract class CountElementsTransformator implements InformationViewTransformator { - public SingleInformation transform(EObject root) { + public SingleInformation transform(List roots) { SingleInformation createSingleInformation = InfostructuremodelFactory.eINSTANCE.createSingleInformation(); createSingleInformation.setTitle(getTitle()); - - List allElements = ViewFilterHelper.convertTreeIterator2List(root.eAllContents()); - int count = 0; - for (EObject element : allElements) { - if (takeElementIntoAccount(element)) { - count++; + for (EObject root : roots) { + List allElements = ViewFilterHelper.convertTreeIterator2List(root.eAllContents()); + + for (EObject element : allElements) { + if (takeElementIntoAccount(element)) { + count++; + } } } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java index df1e6fac9..b1d285e1d 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java @@ -1,26 +1,28 @@ package tools.vitruv.application.viewfilter.informationview.internal; +import java.util.List; + import org.eclipse.emf.ecore.EObject; import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; /** - * Transforms a given model into a {@link SingleInformation}. A transformation could be - * counting the elements of a certain type in the given model for instance. - * The actual transformation depends on the overwriting implementation.} + * Transforms given models into a {@link SingleInformation}. A transformation could be + * counting the elements of a certain type in a given model for instance. + * The actual transformation depends on the overwriting implementation. */ public interface InformationViewTransformator { /** - * Method transforms the given model (represented by its root) into a {@link SingleInformation}. + * Method transforms the given models (represented by their roots) into a {@link SingleInformation}. * The transformation corresponds to the calculation of the actual information, which will than * be represented by the {@link SingleInformation} instance which the method returns. - * A transformation could be counting the elements of a certain type in the given model for instance. + * A transformation could be counting the elements of a certain type in a given model for instance. * The actual transformation depends on the actual implementation of this method * - * @param root The root element of the model which is supposed to be transformed - * @return The information which has been extracted from the given model + * @param roots The list of root elements of the models which are supposed to be transformed + * @return The information which has been extracted from the given models */ - public abstract SingleInformation transform(EObject root); + public abstract SingleInformation transform(List roots); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java index ef0069627..587ad280e 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java @@ -32,7 +32,7 @@ import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; -public class BasicInformationFilterView extends BasicFilterView implements InformationView { +public class BasicInformationFilterView extends BasicFilterView { private final InformationViewTransformator infoTransformator; @@ -61,7 +61,9 @@ protected void updateRootAndSelectedElements(ModifiableViewSelection selection) for(EObject root : selection.getSelectableElements()) { if (selection.isSelected(root)) { - SingleInformation transformResult = infoTransformator.transform(root); + List rootList = new ArrayList(); + rootList.add(root); + SingleInformation transformResult = infoTransformator.transform(rootList); if (transformResult != null) { singleinformationList.add(transformResult); } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java index fd878b335..bf253439e 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java @@ -13,7 +13,7 @@ * in a model. Used a given {@link ViewFilter} object to filter the model for objects which are * supposed to be taken into account */ -public class CountUmlClassesView extends BasicInformationFilterView implements InformationView { +public class CountUmlClassesView extends BasicInformationFilterView { /** * Creates an {@link InformationView} object which counts all uml2.Class objects in a model diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/InformationView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/InformationView.java deleted file mode 100644 index 75044e604..000000000 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/InformationView.java +++ /dev/null @@ -1,6 +0,0 @@ -package tools.vitruv.applications.viewfilter.informationview.views; - -//TODO nbr: Add javadoc -public interface InformationView { - -} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index 319d0b57e..7e5c829ce 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -41,6 +41,7 @@ * selection mechanism and a filter-function. The filter-function can be used for * selecting single objects in a model. */ +//TODO nbr: Warum existiert AbstractFilterSupportingViewType interface?? public class FilterSupportingIdentityMappingViewType extends AbstractFilterSupportingViewType, HierarchicalId> { public FilterSupportingIdentityMappingViewType(String name) { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 9eaf0384a..39a975802 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -99,9 +99,9 @@ public void setViewChanged(boolean value) { protected ModifiableViewSelection filterElementsForSelection() { //TODO nbr: Hat das für Probleme gesorgt, dass ich hier nicht mehr überprüfe, ob alle Elemente auch in selection sind? // List rootsForSelection = findRootsForSelectionInViewSource(getViewSource().getViewSourceModels();); - Collection rootsForSelection = super.getRootObjects(); + Collection rootsForFiltering = super.getRootObjects(); - Set filteredElements = viewFilter.filterElements(rootsForSelection); + Set filteredElements = viewFilter.filterElements(rootsForFiltering); ModifiableViewSelection elementViewSelection = new ElementViewSelection(filteredElements); filteredElements.forEach(it -> elementViewSelection.setSelected(it, true)); return elementViewSelection; From 28254a7419f3fc6a734907b98a33c27d11becdea Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:47:36 +0100 Subject: [PATCH 38/62] Removed Marker-Interfaces: FilteredViewCreatingViewType AbstractFilterSupportingViewType --- .../views/BasicInformationFilterView.java | 4 ++-- .../views/CountUmlClassesView.java | 4 ++-- .../AbstractFilterSupportingViewType.java | 22 ------------------- ...lterSupportingIdentityMappingViewType.java | 2 +- .../impl/FilteredViewCreatingViewType.java | 11 ---------- ...lterSupportingViewElementSelectorImpl.java | 8 +++---- .../viewfilter/views/BasicFilterView.java | 4 ++-- 7 files changed, 11 insertions(+), 44 deletions(-) delete mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java delete mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java index 587ad280e..bbb6e1312 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java @@ -22,7 +22,7 @@ import tools.vitruv.application.viewfilter.informationview.internal.CountUmlClassesTransformator; import tools.vitruv.application.viewfilter.informationview.internal.InformationViewTransformator; import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; -import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; import tools.vitruv.applications.viewfilter.views.BasicFilterView; @@ -37,7 +37,7 @@ public class BasicInformationFilterView extends BasicFilterView { private final InformationViewTransformator infoTransformator; - public BasicInformationFilterView(FilteredViewCreatingViewType viewType, + public BasicInformationFilterView(ViewCreatingViewType viewType, ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter, InformationViewTransformator infoTransformator) { super(viewType, viewSource, selection, viewFilter); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java index bf253439e..f2e51f41f 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java @@ -1,7 +1,7 @@ package tools.vitruv.applications.viewfilter.informationview.views; import tools.vitruv.application.viewfilter.informationview.internal.CountUmlClassesTransformator; -import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.framework.views.ChangeableViewSource; @@ -24,7 +24,7 @@ public class CountUmlClassesView extends BasicInformationFilterView { * @param selection The selection for this {@link InformationView} object * @param viewFilter The viewFilter used to filter objects which are supposed to displayed in the view. */ - public CountUmlClassesView(FilteredViewCreatingViewType viewType, + public CountUmlClassesView(ViewCreatingViewType viewType, ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { super(viewType, viewSource, selection, viewFilter, new CountUmlClassesTransformator()); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java deleted file mode 100644 index cd6e595aa..000000000 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractFilterSupportingViewType.java +++ /dev/null @@ -1,22 +0,0 @@ -package tools.vitruv.applications.viewfilter.util.framework.impl; - -import tools.vitruv.framework.views.ViewSelector; - -/** - * Objects of this type support building {@link View} objects with a filter. Filters can be used to filter - * certain elements of one ore multiple models represented by the View. - * - * @param The Type of ViewSelector used to select the elements included in the {@link View} which will be constructed by instances of {@link AbstractFilterSupportingViewType} - * @param - */ -public abstract class AbstractFilterSupportingViewType extends AbstractViewType implements FilteredViewCreatingViewType { - - public AbstractFilterSupportingViewType(String name) { - super(name); - } - - - - - -} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index 7e5c829ce..9968b6f9a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -42,7 +42,7 @@ * selecting single objects in a model. */ //TODO nbr: Warum existiert AbstractFilterSupportingViewType interface?? -public class FilterSupportingIdentityMappingViewType extends AbstractFilterSupportingViewType, HierarchicalId> { +public class FilterSupportingIdentityMappingViewType extends AbstractViewType, HierarchicalId> { public FilterSupportingIdentityMappingViewType(String name) { super(name); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java deleted file mode 100644 index 3599e26e4..000000000 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilteredViewCreatingViewType.java +++ /dev/null @@ -1,11 +0,0 @@ -package tools.vitruv.applications.viewfilter.util.framework.impl; - -import tools.vitruv.framework.views.ViewSelector; -import tools.vitruv.framework.views.ViewType; - -public interface FilteredViewCreatingViewType extends ViewCreatingViewType { - - - - -} diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java index dccc4fcad..747c1d009 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java @@ -22,7 +22,7 @@ import com.google.common.base.Preconditions; -import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilterImpl; @@ -39,7 +39,7 @@ public class FilterSupportingViewElementSelectorImpl implemen private final ChangeableViewSource viewSource; - private final FilteredViewCreatingViewType, Id> viewType; + private final ViewCreatingViewType, Id> viewType; private ViewFilterBuilder viewFilterBuilder; @@ -48,7 +48,7 @@ public class FilterSupportingViewElementSelectorImpl implemen private View createdView; public FilterSupportingViewElementSelectorImpl( - FilteredViewCreatingViewType, Id> viewType, + ViewCreatingViewType, Id> viewType, ChangeableViewSource viewSource, Collection selectableElements) { Preconditions.checkArgument((selectableElements != null), "selectable elements must not be null"); Preconditions.checkArgument((viewType != null), "view type must not be null"); @@ -116,7 +116,7 @@ public ChangeableViewSource getViewSource() { return this.viewSource; } - public FilteredViewCreatingViewType, Id> getViewType() { + public ViewCreatingViewType, Id> getViewType() { return this.viewType; } diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 39a975802..913f711be 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -20,7 +20,7 @@ import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil; -import tools.vitruv.applications.viewfilter.util.framework.impl.FilteredViewCreatingViewType; +import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; import tools.vitruv.change.atomic.hid.HierarchicalId; @@ -42,7 +42,7 @@ public class BasicFilterView extends AbstractBasicView implements FilterableView private ResourceSet filteredModelsResSet = null; - public BasicFilterView(FilteredViewCreatingViewType viewType, + public BasicFilterView(ViewCreatingViewType viewType, ChangeableViewSource viewSource, ViewSelection selection, ViewFilter viewFilter) { super(viewType, viewSource, selection); this.viewFilter = viewFilter; From 9e5f9f8599d89bc5cc8d9e68a331aa5312aae780 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:50:39 +0100 Subject: [PATCH 39/62] Organized imports for tools.vitruv.applications.viewtest --- .../internal/CountElementsTransformator.java | 9 ++++----- .../views/BasicInformationFilterView.java | 20 +++++-------------- ...lterSupportingIdentityMappingViewType.java | 8 -------- .../selection/AbstractViewSelection.java | 6 +++--- ...lterSupportingViewElementSelectorImpl.java | 16 --------------- .../viewfilter/viewbuild/UmlViewBuilder.java | 2 -- .../viewfilter/viewbuild/ViewFilter.java | 1 - .../viewfilter/viewbuild/ViewFilterImpl.java | 5 ----- .../viewfilter/views/BasicFilterView.java | 6 ------ .../views/ChangesetDeterminableView.java | 3 --- .../views/FilterChangeDerivingView.java | 5 ----- .../views/FilterChangeRecordingView.java | 2 -- .../views/InformationDisplayView.java | 19 ------------------ 13 files changed, 12 insertions(+), 90 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java index 446e7d175..2f41ba4ea 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java @@ -1,14 +1,13 @@ package tools.vitruv.application.viewfilter.informationview.internal; -import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; -import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InfostructuremodelFactory; -import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; import java.util.List; -import java.util.function.Function; import org.eclipse.emf.ecore.EObject; -import org.eclipse.uml2.uml.Model; + +import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InfostructuremodelFactory; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; //TODO nbr add javadoc public abstract class CountElementsTransformator implements InformationViewTransformator { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java index bbb6e1312..d074186bc 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java @@ -1,27 +1,14 @@ package tools.vitruv.applications.viewfilter.informationview.views; +import static com.google.common.base.Preconditions.checkArgument; + import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; import java.util.List; -import java.util.Map; import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; - -import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InformationStructure; -import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InfostructuremodelFactory; -import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; -import static com.google.common.base.Preconditions.checkArgument; - -import tools.vitruv.application.viewfilter.informationview.internal.CountElementsTransformator; -import tools.vitruv.application.viewfilter.informationview.internal.CountUmlClassesTransformator; import tools.vitruv.application.viewfilter.informationview.internal.InformationViewTransformator; -import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; @@ -31,6 +18,9 @@ import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InformationStructure; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InfostructuremodelFactory; +import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; public class BasicInformationFilterView extends BasicFilterView { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index 9968b6f9a..c1c583629 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -9,17 +9,12 @@ import java.util.function.Function; import java.util.stream.Stream; -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.uml2.uml.internal.resource.UMLResourceImpl; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; -import tools.vitruv.applications.viewfilter.util.framework.selectors.DirectViewElementSelector; import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelectorImpl; import tools.vitruv.applications.viewfilter.views.BasicFilterView; import tools.vitruv.applications.viewfilter.views.FilterChangeRecordingView; @@ -27,13 +22,10 @@ import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.atomic.uuid.Uuid; import tools.vitruv.change.atomic.uuid.UuidResolver; -import tools.vitruv.change.composite.description.CompositeContainerChange; import tools.vitruv.change.composite.description.VitruviusChange; import tools.vitruv.change.composite.description.VitruviusChangeResolver; import tools.vitruv.framework.views.ChangeableViewSource; -import tools.vitruv.framework.views.View; import tools.vitruv.framework.views.ViewSelection; -import tools.vitruv.framework.views.ViewSource; /** diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java index 7142fae09..fb71c04d7 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java @@ -1,5 +1,8 @@ package tools.vitruv.applications.viewfilter.util.framework.selection; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -9,9 +12,6 @@ import tools.vitruv.framework.views.ModifiableViewSelection; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Preconditions.checkNotNull; - public abstract class AbstractViewSelection implements ModifiableViewSelection { final Map elementsSelection = new HashMap<>(); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java index 747c1d009..ba56a24ca 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java @@ -1,24 +1,9 @@ package tools.vitruv.applications.viewfilter.util.framework.selectors; import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; import java.util.function.Function; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.net4j.util.ImplementationError; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.Type; -import org.eclipse.uml2.uml.UMLFactory; import com.google.common.base.Preconditions; @@ -31,7 +16,6 @@ import tools.vitruv.framework.views.ModifiableViewSelection; import tools.vitruv.framework.views.View; import tools.vitruv.framework.views.ViewSelection; -import tools.vitruv.framework.views.ViewSelector; public class FilterSupportingViewElementSelectorImpl implements FilterSupportingViewElementSelector { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java index 319a3bea2..33a512206 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java @@ -10,10 +10,8 @@ import org.eclipse.uml2.uml.Model; import tools.vitruv.applications.viewfilter.util.framework.FilterSupportingViewTypeFactory; -import tools.vitruv.framework.views.View; import tools.vitruv.framework.views.ViewProvider; import tools.vitruv.framework.views.ViewSelector; -import tools.vitruv.framework.views.ViewTypeFactory; public class UmlViewBuilder { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java index 740e7bc3f..44148f411 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java @@ -5,7 +5,6 @@ import java.util.Set; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; /** * A ViewFilter filters the model objects contained in a {@link View}. What kind of diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index 07b7f3461..c0efa2d70 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -1,11 +1,9 @@ package tools.vitruv.applications.viewfilter.viewbuild; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; @@ -13,20 +11,17 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.net4j.util.ImplementationError; import org.eclipse.uml2.uml.Model; import org.eclipse.uml2.uml.Type; import org.eclipse.uml2.uml.UMLFactory; -import org.palladiosimulator.pcm.PcmFactory; import org.palladiosimulator.pcm.repository.DataType; import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.repository.RepositoryComponent; import org.palladiosimulator.pcm.repository.RepositoryFactory; import tools.vitruv.applications.viewfilter.helpers.ViewFilterHelper; -import tools.vitruv.framework.views.ViewSelection; public class ViewFilterImpl implements ViewFilter { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index 913f711be..baf343fbd 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -1,25 +1,19 @@ package tools.vitruv.applications.viewfilter.views; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceImpl; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.net4j.util.ImplementationError; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil; import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selection.ElementViewSelection; import tools.vitruv.applications.viewfilter.viewbuild.ViewFilter; diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java index 56fcc44ba..9c8ea39cf 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java @@ -5,10 +5,7 @@ import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.change.atomic.hid.HierarchicalId; -import tools.vitruv.change.composite.propagation.ChangePropagationListener; -import tools.vitruv.framework.views.View; import tools.vitruv.framework.views.ViewSelector; -import tools.vitruv.framework.views.ViewType; //TODO nbr: Add javadoc public interface ChangesetDeterminableView extends ModifiableView { diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java index 431648ec6..c95084cd0 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java @@ -1,8 +1,6 @@ package tools.vitruv.applications.viewfilter.views; -import java.net.URI; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -13,16 +11,13 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; -import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.change.composite.description.CompositeContainerChange; import tools.vitruv.change.composite.description.VitruviusChange; import tools.vitruv.change.composite.description.VitruviusChangeFactory; -import tools.vitruv.framework.views.View; import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java index d8593691e..ba4c0142a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -4,10 +4,8 @@ import java.util.Map; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; import tools.vitruv.change.atomic.EChange; diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java index ef7b3eb10..fc9e667a4 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java @@ -1,33 +1,14 @@ package tools.vitruv.applications.viewfilter.views; -import java.util.Collection; -import java.util.List; -import java.util.function.Function; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.xtext.xbase.lib.IterableExtensions; -import org.eclipse.xtext.xbase.lib.ListExtensions; - -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.change.atomic.hid.HierarchicalId; -import tools.vitruv.change.atomic.uuid.Uuid; -import tools.vitruv.change.composite.description.PropagatedChange; -import tools.vitruv.change.composite.description.VitruviusChange; import tools.vitruv.change.composite.propagation.ChangePropagationListener; import tools.vitruv.framework.views.ChangeableViewSource; -import tools.vitruv.framework.views.CommittableView; import tools.vitruv.framework.views.View; import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; -import tools.vitruv.framework.views.ViewType; -import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; //TODO nbr: Remove this class? public class InformationDisplayView extends AbstractBasicView implements View, ChangePropagationListener { From 1bcf17b2a0735a115c2176bacf2b8a98cd4daf70 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:52:08 +0100 Subject: [PATCH 40/62] Organized imports for tools.vitruv.applications.viewfilter.tests --- .../viewfilter/tests/BasicViewFilterTest.java | 12 +---------- .../viewfilter/tests/EmfTest.java | 10 ---------- .../viewfilter/tests/InstanceFilterTest.java | 15 -------------- .../viewfilter/tests/ViewTestFactory.java | 20 +++++++------------ .../utils/FluentUMLPackageBuilder.java | 3 +-- 5 files changed, 9 insertions(+), 51 deletions(-) diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java index 10e8c875e..9f85b1ffb 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java @@ -1,8 +1,5 @@ package tools.vitruv.applications.viewfilter.tests; -import com.niklas.niklasproject.niklasdomain.InformationStructure; -import com.niklas.niklasproject.niklasdomain.NiklasdomainFactory; - import java.nio.file.Path; import java.util.Collection; import java.util.Collections; @@ -13,7 +10,6 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Comment; @@ -26,30 +22,24 @@ import org.eclipse.xtend.lib.annotations.Accessors; import org.eclipse.xtext.xbase.lib.CollectionLiterals; import org.eclipse.xtext.xbase.lib.Exceptions; -import org.eclipse.xtext.xbase.lib.InputOutput; -import org.eclipse.xtext.xbase.lib.ObjectExtensions; -import org.eclipse.xtext.xbase.lib.Pure; import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import org.eclipse.xtext.xbase.lib.Pure; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.palladiosimulator.pcm.repository.BasicComponent; import org.palladiosimulator.pcm.repository.CompositeDataType; -import org.palladiosimulator.pcm.repository.DataType; import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.repository.RepositoryFactory; import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; import tools.vitruv.applications.testutility.uml.UmlQueryUtil; -import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; -import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; import tools.vitruv.applications.viewfilter.utils.PcmQueryUtil; import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper; import tools.vitruv.change.propagation.ChangePropagationSpecification; import tools.vitruv.framework.views.CommittableView; import tools.vitruv.framework.views.View; -import tools.vitruv.framework.vsum.VirtualModel; import tools.vitruv.testutils.RegisterMetamodelsInStandalone; import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java index 2e76ece89..a8340a21e 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java @@ -3,16 +3,12 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; -import java.util.function.Consumer; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.common.util.WrappedException; -import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EFactory; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; @@ -20,22 +16,16 @@ import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.PackageableElement; -import org.eclipse.uml2.uml.PrimitiveType; import org.eclipse.uml2.uml.UMLFactory; import org.eclipse.uml2.uml.UMLPackage; import org.eclipse.uml2.uml.resource.UMLResource; import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Exceptions; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; import tools.vitruv.change.propagation.ChangePropagationSpecification; -import tools.vitruv.framework.views.CommittableView; -import tools.vitruv.framework.views.View; import tools.vitruv.testutils.RegisterMetamodelsInStandalone; import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index a4deb7223..733db18ba 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -1,23 +1,13 @@ package tools.vitruv.applications.viewfilter.tests; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; -import java.util.List; import java.util.function.Consumer; import java.util.function.Function; @@ -25,7 +15,6 @@ import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.uml2.uml.Class; import org.eclipse.uml2.uml.Classifier; import org.eclipse.uml2.uml.Comment; @@ -52,19 +41,15 @@ import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.repository.RepositoryFactory; - import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; import tools.vitruv.applications.testutility.uml.UmlQueryUtil; -import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; import tools.vitruv.applications.viewfilter.utils.PcmQueryUtil; import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper; import tools.vitruv.change.propagation.ChangePropagationSpecification; import tools.vitruv.framework.views.CommittableView; import tools.vitruv.framework.views.View; import tools.vitruv.framework.views.ViewSelection; -import tools.vitruv.framework.views.ViewType; -import tools.vitruv.framework.vsum.VirtualModel; import tools.vitruv.testutils.RegisterMetamodelsInStandalone; import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InformationStructure; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 19604c4c7..628319276 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -3,34 +3,28 @@ import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.DynamicTest.stream; import java.util.Collection; import java.util.LinkedList; import java.util.function.Consumer; import java.util.function.Function; -import tools.vitruv.framework.views.View; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.NamedElement; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.repository.RepositoryComponent; + import tools.vitruv.applications.viewfilter.util.framework.FilterSupportingViewTypeFactory; -import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType; -import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; import tools.vitruv.applications.viewfilter.util.framework.selectors.FilterSupportingViewElementSelector; import tools.vitruv.framework.views.CommittableView; +import tools.vitruv.framework.views.View; import tools.vitruv.framework.views.ViewProvider; -import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.ViewSelector; import tools.vitruv.framework.views.ViewType; import tools.vitruv.framework.views.ViewTypeFactory; import tools.vitruv.testutils.TestViewFactory; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.NamedElement; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.pcm.repository.RepositoryComponent; - public class ViewTestFactory extends TestViewFactory { private ViewProvider viewProvider; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLPackageBuilder.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLPackageBuilder.java index 4b42d0530..eba0c86c4 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLPackageBuilder.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/utils/FluentUMLPackageBuilder.java @@ -1,12 +1,11 @@ package tools.vitruv.applications.viewfilter.utils; -import org.eclipse.uml2.uml.UMLFactory; - import java.util.ArrayList; import java.util.List; import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.PackageableElement; +import org.eclipse.uml2.uml.UMLFactory; public class FluentUMLPackageBuilder { From d525bc0688d1d6837a5644b52fee782b25f7dce1 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Thu, 7 Mar 2024 22:06:22 +0100 Subject: [PATCH 41/62] - Removed old class used for playground testing Class has been used for testing of Meta-Model-Filtering --- .../viewfilter/tests/EmfTest.java | 162 ------------------ 1 file changed, 162 deletions(-) delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java deleted file mode 100644 index a8340a21e..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/EmfTest.java +++ /dev/null @@ -1,162 +0,0 @@ -package tools.vitruv.applications.viewfilter.tests; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.common.util.WrappedException; -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; -import org.eclipse.uml2.uml.Class; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.UMLFactory; -import org.eclipse.uml2.uml.UMLPackage; -import org.eclipse.uml2.uml.resource.UMLResource; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; -import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; -import tools.vitruv.change.propagation.ChangePropagationSpecification; -import tools.vitruv.testutils.RegisterMetamodelsInStandalone; -import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; - -@ExtendWith(RegisterMetamodelsInStandalone.class) -public class EmfTest extends ViewBasedVitruvApplicationTest { - - - private static final ResourceSet RESOURCE_SET; - - static { - RESOURCE_SET = new ResourceSetImpl(); - } - - - @Test - public void testtest() { - - } - - - @Test - public void testCreateFilteredUmlView() { - Model model = UMLFactory.eINSTANCE.createModel(); - Model umlMetaModel = (Model) load(URI.createURI(UMLResource.UML_METAMODEL_URI)); - Class createClass = UMLFactory.eINSTANCE.createClass(); - System.out.println("Test"); - Model umlMetaModelCopy = EcoreUtil.copy(umlMetaModel); - (umlMetaModelCopy.eClass()).getEPackage().getEFactoryInstance(); - - //EFactory eFactoryInstance = ((EPackage) umlMetaModel).getEFactoryInstance(); - - //EcoreUtil.create(umlMetaModelCopy); - - EObject root = umlMetaModelCopy; - TreeIterator content = root.eAllContents(); - List contentList = convertTreeIterator2List(content); - for (EObject object : contentList) { - if (object instanceof org.eclipse.uml2.uml.Classifier) { - org.eclipse.uml2.uml.Class classifierObject = (org.eclipse.uml2.uml.Class) object; - classifierObject.getOwnedAttributes().removeAll(classifierObject.getOwnedAttributes()); - } - } - - EFactory eFactoryInstance = (umlMetaModelCopy.eClass()).getEPackage().getEFactoryInstance(); - - - - } - - private List convertTreeIterator2List(TreeIterator content) { - List list = new LinkedList(); - while(content.hasNext()) { - list.add(content.next()); - } - return list; - } - - - @Override - protected Iterable getChangePropagationSpecifications() { - CombinedPcmToUmlClassReactionsChangePropagationSpecification _combinedPcmToUmlClassReactionsChangePropagationSpecification = new CombinedPcmToUmlClassReactionsChangePropagationSpecification(); - CombinedUmlClassToPcmReactionsChangePropagationSpecification _combinedUmlClassToPcmReactionsChangePropagationSpecification = new CombinedUmlClassToPcmReactionsChangePropagationSpecification(); - return Collections.unmodifiableList( - CollectionLiterals.newArrayList( - _combinedPcmToUmlClassReactionsChangePropagationSpecification, - _combinedUmlClassToPcmReactionsChangePropagationSpecification)); - } - - - private static org.eclipse.uml2.uml.Package load(URI uri) { - //org.eclipse.uml2.uml.Package package_ = null; - org.eclipse.uml2.uml.Package package_ = null; - - try { - //Stackoverflow - RESOURCE_SET.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); - // Load the requested resource - Resource resource = RESOURCE_SET.getResource(uri, true); - - // Get the first (should be only) package from it (Stackoverflow should take the first Package for non uml) - package_ = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.PACKAGE); - //package_ = resource.getContents().get(0); - } catch (WrappedException we) { - System.out.println(we.getMessage()); - System.exit(1); - } - - return package_; - } - - -// protected void createBiggerUmlModel(final Procedure1 modelInitialization) { -// try { -// final Consumer firstChangeUmlFunction = (CommittableView it) -> { -// final Model umlModel = UMLFactory.eINSTANCE.createModel(); -// createAndRegisterRoot(it, umlModel, this.getUri(getProjectModelPath(UML_MODEL_NAME))); -// modelInitialization.apply(umlModel); -// }; -// improvedViewTestFactory.changeUmlView(firstChangeUmlFunction); -// -// getUserInteraction().addNextSingleSelection(1); -// getUserInteraction().addNextTextInput("model/System.system"); -// -// final Consumer secondChangeUmlFunction = (CommittableView it) -> { -// org.eclipse.uml2.uml.Package _createPackage = UMLFactory.eINSTANCE.createPackage(); -// Procedure1 setNameFunction = (org.eclipse.uml2.uml.Package it_1) -> { -// it_1.setName("niklasPackage"); -// }; -// -// org.eclipse.uml2.uml.Package package1 = UMLFactory.eINSTANCE.createPackage(); -// package1.setName("niklasPackage"); -// -// org.eclipse.uml2.uml.Class class1 = package1.createOwnedClass("niklasClass1", false); -// -// getUserInteraction().addNextSingleSelection(1); -// getUserInteraction().addNextTextInput("model/System.system"); -// org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage("niklasNestedPackage"); -// -// org.eclipse.uml2.uml.ClassClass class2 = package2.createOwnedClass("niklasClass2", false); -// EList _packagedElements = getDefaultUmlModel(it).getPackagedElements(); -// _packagedElements.add(package1); -// -// // create Attribute for class2 -// PrimitiveType stringPrimitiveType = package1.createOwnedPrimitiveType("niklasPrimitiveType1"); -// class2.createOwnedAttribute("niklasClass2Attribute", stringPrimitiveType, 0, 1); -// }; -// improvedViewTestFactory.changeUmlView(secondChangeUmlFunction); -// -// } catch (Throwable _e) { -// throw Exceptions.sneakyThrow(_e); -// } -// } - -} From 62889a523e26a507921afc6bac8f2657b2d53b73 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:27:23 +0100 Subject: [PATCH 42/62] - Fulfilled some TODOs, added JavaDoc --- .../internal/CountElementsTransformator.java | 25 +- .../CountUmlClassesTransformator.java | 4 + ...lterSupportingIdentityMappingViewType.java | 4 +- ...lterSupportingViewElementSelectorImpl.java | 3 +- .../viewfilter/tests/FirstTest.xtend | 277 ------------------ .../viewfilter/tests/FirstTestFactory.xtend | 77 ----- .../viewfilter/tests/ViewTestFactory.java | 9 - 7 files changed, 29 insertions(+), 370 deletions(-) delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java index 2f41ba4ea..03cf8722c 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java @@ -9,10 +9,17 @@ import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.InfostructuremodelFactory; import tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel.SingleInformation; -//TODO nbr add javadoc +/** + * Transforms models into an information. Instances of this class can be used to count elements of a certain + * type in a given set of models. Class uses {@link takeElementIntoAccount()} to determine whether a model-object is + * supposed to be counted (increase the counter by 1) or not. Class returns the determined information as + * an instance of {@link SingleInformation}. It therefor uses the {@link getTitle()} method to determine the title + * for the {@link SingleInformation}. Implementations of this abstract class therefor must implement those methods + * according to what is supposed to be counted. + */ public abstract class CountElementsTransformator implements InformationViewTransformator { - + @Override public SingleInformation transform(List roots) { SingleInformation createSingleInformation = InfostructuremodelFactory.eINSTANCE.createSingleInformation(); createSingleInformation.setTitle(getTitle()); @@ -33,8 +40,22 @@ public SingleInformation transform(List roots) { } + /** + * Method determines whether a model-object is supposed to be counted (if the counter is supposed + * to be increased for this object). If the given object is supposed to be counted, which means it is taken into + * account, this method returns true. If not, it returns false. + * + * @param object The object for which the method is supposed to determine whether it is supposed to be taken into account + * @return true if the object is supposed to be taken into account + */ protected abstract boolean takeElementIntoAccount(EObject object); + /** + * Method returns the title which the {@link SingleInformation} object which this {@link CountElementsTransformator} + * instance returns, is supposed to have. + * + * @return The title of {@link SingleInformation} objects which this {@link CountElementsTransformator} returns + */ protected abstract String getTitle(); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java index 174f5e2ee..54428ee8f 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java @@ -2,6 +2,10 @@ import org.eclipse.emf.ecore.EObject; +/** + * This transformator counts the {@link org.eclipse.uml2.Class} instances in the given models and + * returns the result in a {@link SingleInformation} object. + */ public class CountUmlClassesTransformator extends CountElementsTransformator { private static final String NUMBER_OF_ELEMENTS = "Number of elements"; diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index c1c583629..11216230a 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -33,7 +33,6 @@ * selection mechanism and a filter-function. The filter-function can be used for * selecting single objects in a model. */ -//TODO nbr: Warum existiert AbstractFilterSupportingViewType interface?? public class FilterSupportingIdentityMappingViewType extends AbstractViewType, HierarchicalId> { public FilterSupportingIdentityMappingViewType(String name) { @@ -41,7 +40,7 @@ public FilterSupportingIdentityMappingViewType(String name) { } - //TODO nbr replace by Interface + @Override public FilterSupportingViewElementSelectorImpl createSelector(ChangeableViewSource viewSource) { return new FilterSupportingViewElementSelectorImpl<>(this, viewSource, @@ -56,7 +55,6 @@ public FilterSupportingViewElementSelectorImpl createSelector(Ch } - //TODO nbr replace by interface @Override public ModifiableView createView(FilterSupportingViewElementSelectorImpl selector) { checkArgument(selector.getViewType() == this, "cannot create view with selector for different view type"); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java index ba56a24ca..ac17e9b8c 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java @@ -48,8 +48,7 @@ public FilterSupportingViewElementSelectorImpl( public View createView() { viewFilter = viewFilterBuilder.build(); Preconditions.checkState(this.isValid(), "the current selection is invalid, thus a view cannot be created"); - //TODO nbr do I need "this"? - createdView = this.viewType.createView(this); + createdView = viewType.createView(this); return createdView; } diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend deleted file mode 100644 index 8d6aefa5e..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTest.xtend +++ /dev/null @@ -1,277 +0,0 @@ -package tools.vitruv.applications.viewfilter.tests - -import java.nio.file.Path -import org.eclipse.emf.common.util.URI -import org.eclipse.emf.ecore.EObject -import org.emftext.language.java.containers.CompilationUnit -import org.eclipse.uml2.uml.Model -import org.eclipse.uml2.uml.UMLFactory -import org.eclipse.xtend.lib.annotations.Accessors -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification -import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification -import tools.vitruv.framework.views.View -import tools.vitruv.testutils.ViewBasedVitruvApplicationTest -//import tools.vitruv.applications.pcmumlclass.tests.helper.FluentUMLInterfaceBuilder -import org.eclipse.uml2.uml.PrimitiveType -import org.eclipse.uml2.uml.Type -import tools.vitruv.applications.viewfilter.utils.FluentUMLClassBuilder -import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper -import java.util.ArrayList -import tools.vitruv.framework.vsum.internal.VirtualModelImpl -import java.io.File -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl -import org.eclipse.emf.ecore.util.EcoreUtil - -import tools.vitruv.testutils.RegisterMetamodelsInStandalone -import org.junit.jupiter.api.^extension.ExtendWith -import tools.vitruv.applications.viewfilter.utils.FluentUMLPackageBuilder - -import static extension edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceUtil.getFirstRootEObject -import static extension tools.vitruv.applications.testutility.uml.UmlQueryUtil.* -import org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl -import tools.vitruv.applications.viewfilter.util.framework.impl.FilterSupportingIdentityMappingViewType -import tools.vitruv.framework.views.ViewSelector -import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView - -@ExtendWith(RegisterMetamodelsInStandalone) -class FirstTest extends ViewBasedVitruvApplicationTest { - - @Accessors(PROTECTED_GETTER) - static val UML_MODEL_FILE_EXTENSION = "uml" - @Accessors(PROTECTED_GETTER) - static val UML_MODEL_NAME = "model" - @Accessors(PROTECTED_GETTER) - static val UML_MODEL_FOLDER_NAME = "model" - @Accessors(PROTECTED_GETTER) - static val MODEL_FOLDER_NAME = "model" - @Accessors(PROTECTED_GETTER) - static val MODEL_FILE_EXTENSION = "uml" - - static val PROPERTY_NAME = "testAssemblyContextField" - - static val UML_MODEL_FILE_PATH = "resources/orhanobut/uml/model.uml" - - - protected var FirstTestFactory viewTestFactory - protected var extension ViewTestFactory improvedViewTestFactory - - @Accessors(PUBLIC_GETTER) - var org.eclipse.uml2.uml.Class class1 - @Accessors(PUBLIC_GETTER) - var org.eclipse.uml2.uml.Class class2 - - override protected getChangePropagationSpecifications() { - return #[ - new CombinedPcmToUmlClassReactionsChangePropagationSpecification, - new CombinedUmlClassToPcmReactionsChangePropagationSpecification - ] - } - - @BeforeEach - def void setup() { - //viewTestFactory = new FirstTestFactory(virtualModel) - improvedViewTestFactory = new ViewTestFactory(virtualModel) - createBiggerUmlModel[name = UML_MODEL_NAME] - } - - - @Test - def void testCreateSystemConcept_PCM() { - println("Hello world"); - } - - @Test - def void testView() { - createUmlView(); - } - - @Test - def void testCreateUmlPcmView() { - createUmlAndPcmClassesView(); - } - - @Test - def void testCreateFilteredUmlView() { - var view = createFilteredUmlView(); - //modifyModel() - - (viewType as FilterSupportingIdentityMappingViewType).updateView(view as ModifiableView); - - view.selection - view.viewType - } - - @Test - def void testFilterForName() { - createAdvancedUmlModel[name = UML_MODEL_NAME + "big"] - } - - - - - -// @Test -// def void testCreateAssemblyContextConcept_PCM() { -// createRepositoryWithTwoComponents() -// -// changePcmView[ -// val pcmComponent1 = PcmUmlClassApplicationTestHelper.getPcmComponent(defaultPcmRepository) -// val pcmComponent2 = PcmUmlClassApplicationTestHelper.getPcmComponent_2(defaultPcmRepository) -// -// var pcmAssemblyContext = CompositionFactory.eINSTANCE.createAssemblyContext -// pcmAssemblyContext.entityName = PROPERTY_NAME -// // TODO setting the same component as container and encapsulated doesn't seem to trigger change event -// pcmAssemblyContext.encapsulatedComponent__AssemblyContext = pcmComponent2 -// pcmComponent1.assemblyContexts__ComposedStructure += pcmAssemblyContext -// ] -// -// validateUmlView[ -// val component2Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_2_USC + -// PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.build -// val component1Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_USC + -// PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.addAttribute(PROPERTY_NAME, -// component2Class).build -// val component1Package = new FluentUMLPackageBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_LSC). -// addPackagedElement(component1Class).build -// assertEqualityAndContainmentOfUmlPackage(defaultUmlModel, -// String.join(".", PACKAGE_NAME, PcmUmlClassApplicationTestHelper.COMPONENT_NAME_LSC), component1Package) -// ] -// } - - - protected def void createAndRegisterRoot(View view, EObject rootObject, URI persistenceUri) { - view.registerRoot(rootObject, persistenceUri) - } - - protected def Path getUmlProjectModelPath(String modelName) { - Path.of(UML_MODEL_FOLDER_NAME).resolve(modelName + "." + UML_MODEL_FILE_EXTENSION) - } - - protected def Path getProjectModelPath(String modelName) { - Path.of(MODEL_FOLDER_NAME).resolve(modelName + "." + MODEL_FILE_EXTENSION) - } - -// /** -// * Changes the Java view containing all Java packages and classes as root elements -// * according to the given modification function. -// * Records the performed changes, commits the recorded changes, and closes the view afterwards. -// */ -// def void changeJavaView((View)=>void modelModification) { -// changeViewRecordingChanges(createJavaView, modelModification) -// } - -// private def View createJavaView() { -// createViewOfElements("Java packages and classes", #{Package, CompilationUnit}) -// } - -// protected def Path getProjectModelPath(String modelName) { -// Path.of(MODEL_FOLDER_NAME).resolve(modelName + "." + MODEL_FILE_EXTENSION) -// } - - - protected def void createUmlModel((Model)=>void modelInitialization) { - changeUmlView [ - val umlModel = UMLFactory.eINSTANCE.createModel - createAndRegisterRoot(umlModel, UML_MODEL_NAME.projectModelPath.uri) - modelInitialization.apply(umlModel) - ] - } - - protected def void createBiggerUmlModel((Model)=>void modelInitialization) { - changeUmlView [ - val umlModel = UMLFactory.eINSTANCE.createModel - createAndRegisterRoot(umlModel, UML_MODEL_NAME.projectModelPath.uri) - modelInitialization.apply(umlModel) - ] - - userInteraction.addNextSingleSelection(1) - userInteraction.addNextTextInput("model/System.system") - - changeUmlView[ - val package1 = UMLFactory.eINSTANCE.createPackage => [ - it.name = "niklasPackage" - ] - class1 = package1.createOwnedClass("niklasClass1", false) - - userInteraction.addNextSingleSelection(1) - userInteraction.addNextTextInput("model/System.system") - - val package2 = package1.createNestedPackage("niklasNestedPackage") - class2 = package2.createOwnedClass("niklasClass2", false) - defaultUmlModel.packagedElements += package1 - - val stringPrimitiveType = package1.createOwnedPrimitiveType("niklasPrimitiveType1"); - class2.createOwnedAttribute("niklasClass2Attribute", stringPrimitiveType, 0, 1) - -// val package = umlModel.createNestedPackage("test") -// package.createOwnedClass("test", false) -// -// val component2Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_2_USC + -// PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.build -// val component1Class = new FluentUMLClassBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_USC + -// PcmUmlClassApplicationTestHelper.IMPL_SUFFIX, true).addDefaultConstructor.addAttribute(PROPERTY_NAME, -// component2Class).build -// val component1Package = new FluentUMLPackageBuilder(PcmUmlClassApplicationTestHelper.COMPONENT_NAME_LSC). -// addPackagedElement(component1Class).build -// umlModel.packagedElements.add(component1Package) - ] - - } - - - private def void modifyModel() { - userInteraction.addNextSingleSelection(1) - userInteraction.addNextTextInput("model/System.system") - changeUmlView[ - val package3 = UMLFactory.eINSTANCE.createPackage => [ - it.name = "niklasPackage3" - ] - val class3 = package3.createOwnedClass("niklasClass3", false) - class2.addKeyword("subsequentlyAddedKeyword") - val comment = class2.createOwnedComment - comment.addKeyword("bla") - defaultUmlModel.packagedElements += package3 - ] - } - - - protected def void createAdvancedUmlModel((Model)=>void modelInitialization) { - - changeUmlView [ - val resourceSet = new ResourceSetImpl() - val model = resourceSet.getResource(URI.createFileURI(UML_MODEL_FILE_PATH), true).firstRootEObject as Model => [ - name = UML_MODEL_NAME - ] - - EcoreUtil.resolveAll(model) - // changeJavaView [ - // createAndRegisterRoot(model, UML_MODEL_NAME.projectModelPath.uri) - // ] - for (class : model.packagedElements.filter(org.eclipse.uml2.uml.Class).toList) { - //assertClassWithNameInRootPackage(class.name) - } - for (interface : model.packagedElements.filter(org.eclipse.uml2.uml.Interface).toList) { - //assertInterfaceWithNameInRootPackage(interface.name) - } - for (enum : model.packagedElements.filter(org.eclipse.uml2.uml.Enumeration).toList) { - //assertEnumWithNameInRootPackage(enum.name) - } - resourceSet.resources.forEach[unload()] - resourceSet.resources.clear() - - createAndRegisterRoot(model, UML_MODEL_NAME.umlProjectModelPath.uri) - modelInitialization.apply(model) - ] - } - - - //----------- UML Model queries ------ - protected def getDefaultUmlModel(View view) { - view.claimUmlModel(UML_MODEL_NAME) - } - - - -} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend deleted file mode 100644 index 5a64c811f..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FirstTestFactory.xtend +++ /dev/null @@ -1,77 +0,0 @@ -package tools.vitruv.applications.viewfilter.tests - -import tools.vitruv.testutils.TestViewFactory -import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor -import org.palladiosimulator.pcm.repository.RepositoryComponent -import org.eclipse.uml2.uml.Model -import tools.vitruv.framework.views.View -import tools.vitruv.framework.views.ViewSelector -import tools.vitruv.framework.views.ViewTypeFactory -import java.util.Collection -import static org.hamcrest.CoreMatchers.not -import static org.hamcrest.CoreMatchers.equalTo -import static org.hamcrest.MatcherAssert.assertThat -import tools.vitruv.framework.views.ViewProvider - - -class FirstTestFactory extends TestViewFactory { - - var ViewProvider viewProvider; - - - new(ViewProvider viewProvider) { - super(viewProvider) - this.viewProvider = viewProvider; - } - - - def View createUmlView() { - createViewOfElements("UML", #{Model}) - } - - - - - def View createUmlAndPcmClassesView() { - createViewOfElements("UML and PCM components", #{RepositoryComponent, Model}) - } - - - def View createFilteredUmlView() { - createFilteredViewOfElements("UML", #{Model}) - } - - - -//-------- Boilerplate code -----------// - - /** - * Changes the UML view containing all UML models as root elements - * according to the given modification function. - * Records the performed changes, commits the recorded changes, and closes the view afterwards. - */ - def void changeUmlView((View)=>void modelModification) { - changeViewRecordingChanges(createUmlView, modelModification) - } - - def View createFilteredViewOfElements(String viewName, Collection> rootTypes) { - val ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); - var filteredElements = selector.selectableElements.filter[ element | rootTypes.exists[it.isInstance(element)]] - filteredElements.forEach[element | selector.setSelected(element, true)] -// selector.selectableElements.forEach[element | selector.setSelected(element, true)] - var View view = selector.createView(); - assertThat("view must not be null", view, not(equalTo(null))); - return view; - } - - def View createNameFilteredViewOfElements(String viewName, Collection> rootTypes) { - val ViewSelector selector = viewProvider.createSelector(ViewTypeFactory.createIdentityMappingViewType(viewName)); -// var filteredElements = selector.selectableElements.filter[ element | rootTypes.exists[it.isInstance(element)]] -// filteredElements.forEach[element | selector.setSelected(element, true)] - selector.selectableElements.forEach[element | selector.setSelected(element, true)] - var View view = selector.createView(); - assertThat("view must not be null", view, not(equalTo(null))); - return view; - } - -} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java index 628319276..9b69ba748 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java @@ -53,15 +53,6 @@ public View createUmlAndPcmClassesView() { } - public View createFilteredUmlView(FirstTest test) { - Collection> rootTypes = createCollectionOfRootTypes(Model.class); - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); - View view = createFilteredForNoAttributesViewOfElements("UML", rootTypes, function); - view.getSelection().isViewObjectSelected(test.getClass1()); - view.getSelection().isViewObjectSelected(test.getClass2()); - return view; - } - public View createFilteredUmlView(BasicViewFilterTest test) { Collection> rootTypes = createCollectionOfRootTypes(Model.class); Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); From ff82f110617c2a7e41f07129ef14294b145c5e47 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:02:06 +0100 Subject: [PATCH 43/62] moved plugin to correct directory. Updated .gitignore - tools.vitruv.views.viewfilter.infostructure --- .gitignore | 3 ++- .../tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF | 3 +-- .../.project | 0 .../META-INF/MANIFEST.MF | 0 .../build.properties | 0 .../model/infostructuremodel.aird | 0 .../model/infostructuremodel.ecore | 0 .../model/infostructuremodel.genmodel | 0 .../plugin.properties | 0 .../plugin.xml | 0 .../META-INF/MANIFEST.MF | 3 +-- 11 files changed, 4 insertions(+), 5 deletions(-) rename {tools.vitruv.views.viewfilter.infostructure.model => bundles/tools.vitruv.views.viewfilter.infostructure.model}/.project (100%) rename {tools.vitruv.views.viewfilter.infostructure.model => bundles/tools.vitruv.views.viewfilter.infostructure.model}/META-INF/MANIFEST.MF (100%) rename {tools.vitruv.views.viewfilter.infostructure.model => bundles/tools.vitruv.views.viewfilter.infostructure.model}/build.properties (100%) rename {tools.vitruv.views.viewfilter.infostructure.model => bundles/tools.vitruv.views.viewfilter.infostructure.model}/model/infostructuremodel.aird (100%) rename {tools.vitruv.views.viewfilter.infostructure.model => bundles/tools.vitruv.views.viewfilter.infostructure.model}/model/infostructuremodel.ecore (100%) rename {tools.vitruv.views.viewfilter.infostructure.model => bundles/tools.vitruv.views.viewfilter.infostructure.model}/model/infostructuremodel.genmodel (100%) rename {tools.vitruv.views.viewfilter.infostructure.model => bundles/tools.vitruv.views.viewfilter.infostructure.model}/plugin.properties (100%) rename {tools.vitruv.views.viewfilter.infostructure.model => bundles/tools.vitruv.views.viewfilter.infostructure.model}/plugin.xml (100%) diff --git a/.gitignore b/.gitignore index 400ec69e6..f3a05e2fe 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ tmp/ # Genenerated Files src-gen/ +*.polyglot.META-INF # Xtend xtend-gen/ @@ -25,4 +26,4 @@ EvaluationData *.polyglot *.pom.tycho *.classpath -tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl.java +*.settings/ diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF index 9fdfd1dd8..44b193924 100644 --- a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF +++ b/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF @@ -21,5 +21,4 @@ Bundle-Vendor: vitruv.tools Export-Package: tools.vitruv.applications.viewfilter.util.framework, tools.vitruv.applications.viewfilter.util.framework.impl, tools.vitruv.applications.viewfilter.util.framework.selectors -Import-Package: com.niklas.niklasproject.niklasdomain, - tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel +Import-Package: tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel diff --git a/tools.vitruv.views.viewfilter.infostructure.model/.project b/bundles/tools.vitruv.views.viewfilter.infostructure.model/.project similarity index 100% rename from tools.vitruv.views.viewfilter.infostructure.model/.project rename to bundles/tools.vitruv.views.viewfilter.infostructure.model/.project diff --git a/tools.vitruv.views.viewfilter.infostructure.model/META-INF/MANIFEST.MF b/bundles/tools.vitruv.views.viewfilter.infostructure.model/META-INF/MANIFEST.MF similarity index 100% rename from tools.vitruv.views.viewfilter.infostructure.model/META-INF/MANIFEST.MF rename to bundles/tools.vitruv.views.viewfilter.infostructure.model/META-INF/MANIFEST.MF diff --git a/tools.vitruv.views.viewfilter.infostructure.model/build.properties b/bundles/tools.vitruv.views.viewfilter.infostructure.model/build.properties similarity index 100% rename from tools.vitruv.views.viewfilter.infostructure.model/build.properties rename to bundles/tools.vitruv.views.viewfilter.infostructure.model/build.properties diff --git a/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird b/bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird similarity index 100% rename from tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird rename to bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird diff --git a/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.ecore b/bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.ecore similarity index 100% rename from tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.ecore rename to bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.ecore diff --git a/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.genmodel b/bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.genmodel similarity index 100% rename from tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.genmodel rename to bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.genmodel diff --git a/tools.vitruv.views.viewfilter.infostructure.model/plugin.properties b/bundles/tools.vitruv.views.viewfilter.infostructure.model/plugin.properties similarity index 100% rename from tools.vitruv.views.viewfilter.infostructure.model/plugin.properties rename to bundles/tools.vitruv.views.viewfilter.infostructure.model/plugin.properties diff --git a/tools.vitruv.views.viewfilter.infostructure.model/plugin.xml b/bundles/tools.vitruv.views.viewfilter.infostructure.model/plugin.xml similarity index 100% rename from tools.vitruv.views.viewfilter.infostructure.model/plugin.xml rename to bundles/tools.vitruv.views.viewfilter.infostructure.model/plugin.xml diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index 56678de1b..49a403100 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -5,8 +5,7 @@ Bundle-SymbolicName: tools.vitruv.views.viewfilter.tests Bundle-Version: 3.0.1.qualifier Automatic-Module-Name: tools.vitruv.applications.viewfilter.tests Bundle-RequiredExecutionEnvironment: JavaSE-17 -Import-Package: com.niklas.niklasproject.niklasdomain, - org.junit.jupiter.api, +Import-Package: org.junit.jupiter.api, org.junit.jupiter.api.extension, tools.vitruv.applications.viewfilter.util.framework, tools.vitruv.applications.viewfilter.util.framework.impl, From 1f58dcb07fc8295e91e9035d1b7387b2e3cf7d85 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 9 Mar 2024 20:14:13 +0100 Subject: [PATCH 44/62] Resolved some TODOs. Added JavaDoc --- .../FilterSupportingIdentityMappingViewType.java | 2 +- .../viewfilter/viewbuild/ViewFilter.java | 8 +++++++- .../views/FilterChangeRecordingView.java | 14 ++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java index 11216230a..f91cda6b2 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java @@ -79,7 +79,7 @@ public void commitViewChanges(ModifiableView view, VitruviusChange viewResourceIdChangeResolver = VitruviusChangeResolver.forHierarchicalIdsAndFilteredModel(unfilteredResourceSet, filteredResourceSetInOriginalState, filterableView.getMapCopy2OriginalObject()); VitruviusChange viewResourceResolvedChange = viewResourceIdChangeResolver.resolveAndApply(viewChange); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java index 44148f411..968540132 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java @@ -30,7 +30,13 @@ public interface ViewFilter { Set filterElements(Collection roots); - //TODO nbr add javadoc + /** + * Returns a {@link Map} which can be used to map the copied {@link EObject} in a Filter-Model + * to its original {@link EObject}. The map can only be used to map {@link EObject}s which have + * been created by the same {@link ViewFilter} instance on which this method is then called. + * + * @return A map which maps the copied {@link EObject} on its original {@link EObject} in the unfiltered model + */ public Map getMapCopy2Original(); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java index ba4c0142a..40c8fd72f 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -97,12 +97,18 @@ public ResourceSet getViewResourceSet() { } - public ResourceSet getFilteredModelsInResourceSetWithBackwardExecution() { + /** + * Executes the current recorded changes backwards. May only be executed when the + * changes are currently really applied. This means that the method should not be + * executed twice without forward executing the changes in between. Returns the + * {@link ResourceSet} afterwards. + * + * @return The filtered {@link ResourceSet} in the state before the current recorded changes have been applied + */ + public ResourceSet backwardExecuteChangesAndReturnResourceSet() { ResourceSet resourceSet = getViewResourceSet(); if (recordedChange != null) { - //TODO nbr: What happens if changes have already been reverted? - VitruviusChangeBackwardsExecutionHelper changeResolver = new VitruviusChangeBackwardsExecutionHelper(resourceSet); - changeResolver.applyBackward(recordedChange); + VitruviusChangeBackwardsExecutionHelper.applyBackward(resourceSet, recordedChange); } return resourceSet; } From 5100b9ea443178a7932fdd736442cf7573a53851 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 9 Mar 2024 23:17:31 +0100 Subject: [PATCH 45/62] - Some minor code cleanups --- .../viewfilter/views/BasicFilterView.java | 2 - .../views/FilterChangeRecordingView.java | 16 +--- .../views/InformationDisplayView.java | 75 ------------------- 3 files changed, 1 insertion(+), 92 deletions(-) delete mode 100644 bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java index baf343fbd..d4e8cc4f8 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java @@ -91,8 +91,6 @@ public void setViewChanged(boolean value) { protected ModifiableViewSelection filterElementsForSelection() { - //TODO nbr: Hat das für Probleme gesorgt, dass ich hier nicht mehr überprüfe, ob alle Elemente auch in selection sind? -// List rootsForSelection = findRootsForSelectionInViewSource(getViewSource().getViewSourceModels();); Collection rootsForFiltering = super.getRootObjects(); Set filteredElements = viewFilter.filterElements(rootsForFiltering); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java index 40c8fd72f..cef45a778 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -23,7 +23,6 @@ public class FilterChangeRecordingView extends ChangeRecordingView implements Fi private Map mapCopy2OriginalObject; private TransactionalChange recordedChange = null; - //private ResourceSet resourceSetFromBeginningOfRecording; protected FilterChangeRecordingView(BasicFilterView view, Map mapCopy2OriginalObject) { super(view); @@ -38,8 +37,6 @@ public List> setupChangeRecorder() { changeRecorder = new ChangeRecorder(filteredModelsInResourceSet); changeRecorder.addToRecording(filteredModelsInResourceSet); ResourceSet resourceSetCopy = new ResourceSetImpl(); - //Map copyResourceMapping = ResourceCopier.copyViewResources(filteredModelsInResourceSet.getResources(), resourceSetCopy); - //resourceSetFromBeginningOfRecording = resourceSetCopy; return changeRecorder.beginRecording(); } @@ -52,23 +49,12 @@ private ResourceSet copyResourceSet(ResourceSet resourceSetToBeCopied) { } - //private Map - @Override public void commitChanges() { view.checkNotClosed(); recordedChange = changeRecorder.endRecording(); - - ResourceSet filteredModelsInResourceSet = getViewResourceSet(); - ResourceSet unfilteredResourceSet = getNonFilteredViewResourceSet(); -// EObject class2 = filteredModelsInResourceSet.getResources().get(0).getContents().get(0).eContents().get(0); -// EObject eObject = mapCopy2OriginalObject.get(class2); - - - //TODO nbr: ich muss hier irgendwie an das view resourceSet kommen - - //VitruviusChangeResolver.forMappingFilteredObjects(getView().getFilteredModelsInResourceSet(), getView().getNonFilteredViewResourceSet(), mapCopy2OriginalObject); + VitruviusChangeResolver changeResolver = VitruviusChangeResolver.forHierarchicalIds(view.getViewResourceSet()); VitruviusChange unresolvedChanges = changeResolver.assignIds(recordedChange); view.getViewType().commitViewChanges(this, unresolvedChanges); diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java deleted file mode 100644 index fc9e667a4..000000000 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/InformationDisplayView.java +++ /dev/null @@ -1,75 +0,0 @@ -package tools.vitruv.applications.viewfilter.views; - -import org.eclipse.emf.ecore.resource.ResourceSet; - -import tools.vitruv.applications.viewfilter.util.framework.impl.ViewCreatingViewType; -import tools.vitruv.change.atomic.hid.HierarchicalId; -import tools.vitruv.change.composite.propagation.ChangePropagationListener; -import tools.vitruv.framework.views.ChangeableViewSource; -import tools.vitruv.framework.views.View; -import tools.vitruv.framework.views.ViewSelection; -import tools.vitruv.framework.views.ViewSelector; - -//TODO nbr: Remove this class? -public class InformationDisplayView extends AbstractBasicView implements View, ChangePropagationListener { - - - private ResourceSet viewResourceSet; - - private boolean closed = false; - -// private ViewCreatingViewType viewType; -// -// private ChangeableViewSource viewSource; -// -// private ViewSelection viewSelection; - - - - - public InformationDisplayView(ViewCreatingViewType viewType, ChangeableViewSource viewSource, ViewSelection viewSelection) { - super(viewType, viewSource, viewSelection); -// this.viewType = viewType; -// this.viewSource = viewSource; -// this.viewSelection = viewSelection; - - } - - -// @Override -// public void close() throws Exception { -// if (!closed) { -// closed = true; -// viewResourceSet.getResources().forEach(it -> it.unload()); -// viewResourceSet.getResources().clear(); -// removeChangeListeners(viewResourceSet); -// } -// getViewSource().removeChangePropagationListener(this); -// } - - - @Override - public boolean isModified() { - return false; - } - - @Override - public boolean isOutdated() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void update() { - // TODO Auto-generated method stub - - } - -// @Override -// public boolean isClosed() { -// // TODO Auto-generated method stub -// return false; -// } - - -} From 45ec52e330540f3bd82e6b5e2b681ce8d4eb0461 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Sat, 9 Mar 2024 23:30:18 +0100 Subject: [PATCH 46/62] Replaced System.out.prints for errors by Exceptions --- .../viewfilter/viewbuild/ViewFilterImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java index c0efa2d70..711d03526 100644 --- a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java +++ b/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java @@ -95,7 +95,7 @@ private void attachElementToRoot(EObject root, EObject object) { } else if (root instanceof Repository) { attachElementToRootPcm((Repository) root, object); } else { - throw new ImplementationError("Not implemented yet! Undefined type: " + object.eClass()); + throw new RuntimeException("Not implemented yet! Undefined type: " + object.eClass()); } } @@ -104,7 +104,7 @@ private void attachElementToRootUml(Model root, EObject object) { if (object instanceof Type) { root.getOwnedTypes().add((Type) object); } else { - System.out.println("Warning: Undefined type: " + object.eClass()); + throw new RuntimeException("Warning: Undefined type: " + object.eClass()); } } @@ -122,7 +122,7 @@ private void attachElementToRootPcm(Repository root, EObject object) { } else if (object instanceof DataType) { root.getDataTypes__Repository().add((DataType) object); } else { - System.out.println("Warning: Undefined type: " + object.eClass()); + throw new RuntimeException("Warning: Undefined type: " + object.eClass()); } } @@ -138,8 +138,8 @@ private EObject createAndRegisterModelRootIfNotExistent(EObject filteredRoot, EO } } - - + + private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObject root) { if (root instanceof Model) { Model modelCopy = UMLFactory.eINSTANCE.createModel(); @@ -151,7 +151,7 @@ private EObject createFilteredModelRootIfNotExistent(EObject filteredRoot, EObje return repositoryCopy; } else { - throw new ImplementationError("nbruening: Not implemented yet"); + throw new RuntimeException("The type " + root.getClass() + " is not supported!"); } } From 3914d89e08f8a151f01ff4ac561fa7031bf769f0 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 08:30:08 +0100 Subject: [PATCH 47/62] added .classpath files to repo --- .gitignore | 1 - .../.classpath | 21 +++++++++++++++++++ .../.classpath | 9 ++++++++ .../.classpath | 8 +++++++ .../.classpath | 8 +++++++ .../.classpath | 9 ++++++++ .../.classpath | 8 +++++++ .../.classpath | 16 ++++++++++++++ 8 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 bundles/tools.vitruv.applications.SimuLinkAutoSAR/.classpath create mode 100644 bundles/tools.vitruv.applications.pcmumlclass/.classpath create mode 100644 bundles/tools.vitruv.applications.testutility/.classpath create mode 100644 bundles/tools.vitruv.applications.util.temporary/.classpath create mode 100644 bundles/tools.vitruv.applications.viewtest/.classpath create mode 100644 bundles/tools.vitruv.views.viewfilter.infostructure.model/.classpath create mode 100644 tests/tools.vitruv.applications.viewfilter.tests/.classpath diff --git a/.gitignore b/.gitignore index f3a05e2fe..b4c043ee1 100644 --- a/.gitignore +++ b/.gitignore @@ -25,5 +25,4 @@ EvaluationData *.DS_Store *.polyglot *.pom.tycho -*.classpath *.settings/ diff --git a/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.classpath b/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.classpath new file mode 100644 index 000000000..bd2afe379 --- /dev/null +++ b/bundles/tools.vitruv.applications.SimuLinkAutoSAR/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.classpath b/bundles/tools.vitruv.applications.pcmumlclass/.classpath new file mode 100644 index 000000000..b2bc4189e --- /dev/null +++ b/bundles/tools.vitruv.applications.pcmumlclass/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/bundles/tools.vitruv.applications.testutility/.classpath b/bundles/tools.vitruv.applications.testutility/.classpath new file mode 100644 index 000000000..5bfb3c399 --- /dev/null +++ b/bundles/tools.vitruv.applications.testutility/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/bundles/tools.vitruv.applications.util.temporary/.classpath b/bundles/tools.vitruv.applications.util.temporary/.classpath new file mode 100644 index 000000000..5bfb3c399 --- /dev/null +++ b/bundles/tools.vitruv.applications.util.temporary/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/bundles/tools.vitruv.applications.viewtest/.classpath b/bundles/tools.vitruv.applications.viewtest/.classpath new file mode 100644 index 000000000..b2bc4189e --- /dev/null +++ b/bundles/tools.vitruv.applications.viewtest/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/bundles/tools.vitruv.views.viewfilter.infostructure.model/.classpath b/bundles/tools.vitruv.views.viewfilter.infostructure.model/.classpath new file mode 100644 index 000000000..c3f9cf33e --- /dev/null +++ b/bundles/tools.vitruv.views.viewfilter.infostructure.model/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.classpath b/tests/tools.vitruv.applications.viewfilter.tests/.classpath new file mode 100644 index 000000000..9e313b577 --- /dev/null +++ b/tests/tools.vitruv.applications.viewfilter.tests/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + From 0ba7116f57b607c3b68fb1af72177f153ab57560 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:01:39 +0100 Subject: [PATCH 48/62] Added old classpath files --- .../.classpath | 41 +++++++++++++++++++ .../.classpath | 8 ++++ .../.classpath | 21 ++++++++++ .../.classpath | 20 +++++++-- .../.classpath | 14 +++++-- .../.classpath | 21 ++++++++++ .../.classpath | 16 ++++++-- .../.classpath | 2 +- .../.classpath | 8 +++- .../.classpath | 5 +++ .../.classpath | 16 ++++++++ .../.classpath | 17 ++++++++ .../.classpath | 16 ++++++++ .../.classpath | 16 ++++++++ .../.classpath | 12 ++++++ .../.classpath | 16 ++++++++ .../.classpath | 16 ++++++++ .../.classpath | 16 ++++++++ .../.classpath | 2 +- 19 files changed, 268 insertions(+), 15 deletions(-) create mode 100644 bundles/tools.vitruv.applications.cbs.commonalities/.classpath create mode 100644 bundles/tools.vitruv.applications.cbs.testutils/.classpath create mode 100644 bundles/tools.vitruv.applications.pcmjava/.classpath create mode 100644 bundles/tools.vitruv.applications.umljava/.classpath create mode 100644 releng/tools.vitruv.casestudies.dependencywrapper/.classpath create mode 100644 tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.classpath create mode 100644 tests/tools.vitruv.applications.cbs.commonalities.tests/.classpath create mode 100644 tests/tools.vitruv.applications.demo.insurancefamilies.tests/.classpath create mode 100644 tests/tools.vitruv.applications.demo.insurancepersons.tests/.classpath create mode 100644 tests/tools.vitruv.applications.pcmjava.tests/.classpath create mode 100644 tests/tools.vitruv.applications.pcmumlclass.tests/.classpath create mode 100644 tests/tools.vitruv.applications.transitivechange.tests/.classpath create mode 100644 tests/tools.vitruv.applications.umljava.tests/.classpath diff --git a/bundles/tools.vitruv.applications.cbs.commonalities/.classpath b/bundles/tools.vitruv.applications.cbs.commonalities/.classpath new file mode 100644 index 000000000..034a46731 --- /dev/null +++ b/bundles/tools.vitruv.applications.cbs.commonalities/.classpath @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.cbs.testutils/.classpath b/bundles/tools.vitruv.applications.cbs.testutils/.classpath new file mode 100644 index 000000000..00a29aef6 --- /dev/null +++ b/bundles/tools.vitruv.applications.cbs.testutils/.classpath @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.pcmjava/.classpath b/bundles/tools.vitruv.applications.pcmjava/.classpath new file mode 100644 index 000000000..fd023a9ad --- /dev/null +++ b/bundles/tools.vitruv.applications.pcmjava/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.pcmumlclass/.classpath b/bundles/tools.vitruv.applications.pcmumlclass/.classpath index b2bc4189e..412b338a8 100644 --- a/bundles/tools.vitruv.applications.pcmumlclass/.classpath +++ b/bundles/tools.vitruv.applications.pcmumlclass/.classpath @@ -1,9 +1,21 @@ - + + + + + - - - + + + + + + + + + + + diff --git a/bundles/tools.vitruv.applications.testutility/.classpath b/bundles/tools.vitruv.applications.testutility/.classpath index 5bfb3c399..ef548cb96 100644 --- a/bundles/tools.vitruv.applications.testutility/.classpath +++ b/bundles/tools.vitruv.applications.testutility/.classpath @@ -1,8 +1,16 @@ - + + + + + - - + + + + + + diff --git a/bundles/tools.vitruv.applications.umljava/.classpath b/bundles/tools.vitruv.applications.umljava/.classpath new file mode 100644 index 000000000..bd2afe379 --- /dev/null +++ b/bundles/tools.vitruv.applications.umljava/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.util.temporary/.classpath b/bundles/tools.vitruv.applications.util.temporary/.classpath index 5bfb3c399..30b0b3921 100644 --- a/bundles/tools.vitruv.applications.util.temporary/.classpath +++ b/bundles/tools.vitruv.applications.util.temporary/.classpath @@ -1,8 +1,16 @@ - + + + + + - - - + + + + + + + \ No newline at end of file diff --git a/bundles/tools.vitruv.applications.viewtest/.classpath b/bundles/tools.vitruv.applications.viewtest/.classpath index b2bc4189e..097ebb04e 100644 --- a/bundles/tools.vitruv.applications.viewtest/.classpath +++ b/bundles/tools.vitruv.applications.viewtest/.classpath @@ -5,5 +5,5 @@ - + diff --git a/bundles/tools.vitruv.views.viewfilter.infostructure.model/.classpath b/bundles/tools.vitruv.views.viewfilter.infostructure.model/.classpath index c3f9cf33e..c280941ad 100644 --- a/bundles/tools.vitruv.views.viewfilter.infostructure.model/.classpath +++ b/bundles/tools.vitruv.views.viewfilter.infostructure.model/.classpath @@ -2,7 +2,11 @@ - + + + + + - + diff --git a/releng/tools.vitruv.casestudies.dependencywrapper/.classpath b/releng/tools.vitruv.casestudies.dependencywrapper/.classpath new file mode 100644 index 000000000..4e5621a0d --- /dev/null +++ b/releng/tools.vitruv.casestudies.dependencywrapper/.classpath @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.classpath b/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.classpath new file mode 100644 index 000000000..e2f0d7065 --- /dev/null +++ b/tests/tools.vitruv.applications.SimuLinkAutoSAR.tests/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.cbs.commonalities.tests/.classpath b/tests/tools.vitruv.applications.cbs.commonalities.tests/.classpath new file mode 100644 index 000000000..1a7035e6e --- /dev/null +++ b/tests/tools.vitruv.applications.cbs.commonalities.tests/.classpath @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.classpath b/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.classpath new file mode 100644 index 000000000..c2f3215a6 --- /dev/null +++ b/tests/tools.vitruv.applications.demo.insurancefamilies.tests/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.demo.insurancepersons.tests/.classpath b/tests/tools.vitruv.applications.demo.insurancepersons.tests/.classpath new file mode 100644 index 000000000..c2f3215a6 --- /dev/null +++ b/tests/tools.vitruv.applications.demo.insurancepersons.tests/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.pcmjava.tests/.classpath b/tests/tools.vitruv.applications.pcmjava.tests/.classpath new file mode 100644 index 000000000..e31ed6fdd --- /dev/null +++ b/tests/tools.vitruv.applications.pcmjava.tests/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath b/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath new file mode 100644 index 000000000..30b0b3921 --- /dev/null +++ b/tests/tools.vitruv.applications.pcmumlclass.tests/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.transitivechange.tests/.classpath b/tests/tools.vitruv.applications.transitivechange.tests/.classpath new file mode 100644 index 000000000..30b0b3921 --- /dev/null +++ b/tests/tools.vitruv.applications.transitivechange.tests/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.umljava.tests/.classpath b/tests/tools.vitruv.applications.umljava.tests/.classpath new file mode 100644 index 000000000..30b0b3921 --- /dev/null +++ b/tests/tools.vitruv.applications.umljava.tests/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/.classpath b/tests/tools.vitruv.applications.viewfilter.tests/.classpath index 9e313b577..47de4eea1 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/.classpath +++ b/tests/tools.vitruv.applications.viewfilter.tests/.classpath @@ -12,5 +12,5 @@ - + From 63f173181484de8e803762a75d2b067e7f4291d9 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:06:41 +0100 Subject: [PATCH 49/62] added missing classpath files --- .../.classpath | 8 ++++++++ .../.classpath | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/tools.vitruv.applications.cbs.equivalence.tests/.classpath create mode 100644 tests/tools.vitruv.applications.demo.familiespersons.tests/.classpath diff --git a/tests/tools.vitruv.applications.cbs.equivalence.tests/.classpath b/tests/tools.vitruv.applications.cbs.equivalence.tests/.classpath new file mode 100644 index 000000000..199c20882 --- /dev/null +++ b/tests/tools.vitruv.applications.cbs.equivalence.tests/.classpath @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/tests/tools.vitruv.applications.demo.familiespersons.tests/.classpath b/tests/tools.vitruv.applications.demo.familiespersons.tests/.classpath new file mode 100644 index 000000000..47de4eea1 --- /dev/null +++ b/tests/tools.vitruv.applications.demo.familiespersons.tests/.classpath @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + From b6f956316c88fe3dba6cee400430c48421f849d5 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:17:36 +0100 Subject: [PATCH 50/62] Renamed viewtest plugin to viewfilter plugin tools.vitruv.applications.viewtest -> tools.vitruv.applications.viewfilter --- .../.classpath | 0 .../.maven_enable_dsls-compiler | 0 .../.project | 0 .../META-INF/MANIFEST.MF | 0 .../build.properties | 0 .../plugin.xml | 0 .../internal/CountElementsTransformator.java | 0 .../internal/CountUmlClassesTransformator.java | 0 .../internal/InformationViewTransformator.java | 0 .../applications/viewfilter/helpers/ViewFilterHelper.java | 0 .../informationview/views/BasicInformationFilterView.java | 0 .../informationview/views/CountUmlClassesView.java | 0 .../util/framework/FilterSupportingViewTypeFactory.java | 0 .../viewfilter/util/framework/FilteredViewSelector.java | 0 .../viewfilter/util/framework/impl/AbstractViewType.xtend | 0 .../impl/CountUmlClassesIdentityMappingViewType.java | 0 .../impl/FilterSupportingIdentityMappingViewType.java | 0 .../viewfilter/util/framework/impl/ModifiableView.xtend | 0 .../util/framework/impl/ViewCreatingViewType.java | 0 .../util/framework/selection/AbstractViewSelection.java | 0 .../util/framework/selection/ElementViewSelection.java | 0 .../framework/selectors/DirectViewElementSelector.xtend | 0 .../selectors/FilterSupportingViewElementSelector.java | 0 .../selectors/FilterSupportingViewElementSelectorImpl.java | 0 .../applications/viewfilter/viewbuild/UmlViewBuilder.java | 0 .../applications/viewfilter/viewbuild/ViewFilter.java | 0 .../applications/viewfilter/viewbuild/ViewFilterImpl.java | 0 .../applications/viewfilter/views/AbstractBasicView.xtend | 0 .../applications/viewfilter/views/BasicFilterView.java | 0 .../applications/viewfilter/views/ChangeDerivingView.xtend | 0 .../applications/viewfilter/views/ChangeRecordingView.xtend | 0 .../viewfilter/views/ChangesetDeterminableView.java | 0 .../viewfilter/views/FilterChangeDerivingView.java | 0 .../viewfilter/views/FilterChangeRecordingView.java | 0 .../applications/viewfilter/views/FilterChangeView.java | 0 .../applications/viewfilter/views/FilterableView.java | 0 .../META-INF/MANIFEST.MF | 6 ++---- 37 files changed, 2 insertions(+), 4 deletions(-) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/.classpath (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/.maven_enable_dsls-compiler (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/.project (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/META-INF/MANIFEST.MF (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/build.properties (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/plugin.xml (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/impl/CountUmlClassesIdentityMappingViewType.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/AbstractBasicView.xtend (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/ChangeDerivingView.xtend (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/ChangeRecordingView.xtend (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java (100%) rename bundles/{tools.vitruv.applications.viewtest => tools.vitruv.applications.viewfilter}/src/tools/vitruv/applications/viewfilter/views/FilterableView.java (100%) diff --git a/bundles/tools.vitruv.applications.viewtest/.classpath b/bundles/tools.vitruv.applications.viewfilter/.classpath similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/.classpath rename to bundles/tools.vitruv.applications.viewfilter/.classpath diff --git a/bundles/tools.vitruv.applications.viewtest/.maven_enable_dsls-compiler b/bundles/tools.vitruv.applications.viewfilter/.maven_enable_dsls-compiler similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/.maven_enable_dsls-compiler rename to bundles/tools.vitruv.applications.viewfilter/.maven_enable_dsls-compiler diff --git a/bundles/tools.vitruv.applications.viewtest/.project b/bundles/tools.vitruv.applications.viewfilter/.project similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/.project rename to bundles/tools.vitruv.applications.viewfilter/.project diff --git a/bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF b/bundles/tools.vitruv.applications.viewfilter/META-INF/MANIFEST.MF similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/META-INF/MANIFEST.MF rename to bundles/tools.vitruv.applications.viewfilter/META-INF/MANIFEST.MF diff --git a/bundles/tools.vitruv.applications.viewtest/build.properties b/bundles/tools.vitruv.applications.viewfilter/build.properties similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/build.properties rename to bundles/tools.vitruv.applications.viewfilter/build.properties diff --git a/bundles/tools.vitruv.applications.viewtest/plugin.xml b/bundles/tools.vitruv.applications.viewfilter/plugin.xml similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/plugin.xml rename to bundles/tools.vitruv.applications.viewfilter/plugin.xml diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/application/viewfilter/informationview/internal/CountElementsTransformator.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/application/viewfilter/informationview/internal/CountUmlClassesTransformator.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/application/viewfilter/informationview/internal/InformationViewTransformator.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/helpers/ViewFilterHelper.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/informationview/views/BasicInformationFilterView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/informationview/views/CountUmlClassesView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/FilterSupportingViewTypeFactory.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/AbstractViewType.xtend diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/CountUmlClassesIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/CountUmlClassesIdentityMappingViewType.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/CountUmlClassesIdentityMappingViewType.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/CountUmlClassesIdentityMappingViewType.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/FilterSupportingIdentityMappingViewType.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/ModifiableView.xtend diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/impl/ViewCreatingViewType.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selection/AbstractViewSelection.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selection/ElementViewSelection.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selectors/DirectViewElementSelector.xtend diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelector.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/selectors/FilterSupportingViewElementSelectorImpl.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilter.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/ViewFilterImpl.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/AbstractBasicView.xtend b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/AbstractBasicView.xtend similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/AbstractBasicView.xtend rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/AbstractBasicView.xtend diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/BasicFilterView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeDerivingView.xtend b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangeDerivingView.xtend similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeDerivingView.xtend rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangeDerivingView.xtend diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeRecordingView.xtend b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangeRecordingView.xtend similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangeRecordingView.xtend rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangeRecordingView.xtend diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java diff --git a/bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterableView.java similarity index 100% rename from bundles/tools.vitruv.applications.viewtest/src/tools/vitruv/applications/viewfilter/views/FilterableView.java rename to bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterableView.java diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index 49a403100..4a7f5c7fd 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -7,9 +7,6 @@ Automatic-Module-Name: tools.vitruv.applications.viewfilter.tests Bundle-RequiredExecutionEnvironment: JavaSE-17 Import-Package: org.junit.jupiter.api, org.junit.jupiter.api.extension, - tools.vitruv.applications.viewfilter.util.framework, - tools.vitruv.applications.viewfilter.util.framework.impl, - tools.vitruv.applications.viewfilter.util.framework.selectors, tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel Require-Bundle: tools.vitruv.testutils.vsum, org.eclipse.emf.compare, @@ -25,6 +22,7 @@ Require-Bundle: tools.vitruv.testutils.vsum, edu.kit.ipd.sdq.commons.util.emf, slf4j.api;bundle-version="2.0.9", org.emftext.language.java;bundle-version="1.4.1", - org.eclipse.emf.ecore + org.eclipse.emf.ecore, + tools.vitruv.views.viewfilter Export-Package: tools.vitruv.applications.viewfilter.tests Bundle-Vendor: vitruv.tools From ad3d0f49417eabcf48481fa9cd89b403ed101a09 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:20:12 +0100 Subject: [PATCH 51/62] Removed unnecessary export of test-project --- .../META-INF/MANIFEST.MF | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF index 4a7f5c7fd..4df5418a8 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.viewfilter.tests/META-INF/MANIFEST.MF @@ -24,5 +24,4 @@ Require-Bundle: tools.vitruv.testutils.vsum, org.emftext.language.java;bundle-version="1.4.1", org.eclipse.emf.ecore, tools.vitruv.views.viewfilter -Export-Package: tools.vitruv.applications.viewfilter.tests Bundle-Vendor: vitruv.tools From c9aa4a1c476e6a9199d18e911ec2e46f8c476bd6 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:25:58 +0100 Subject: [PATCH 52/62] Removed copied test resources --- .../resources/model/ms.repository | 915 ------------------ .../resources/model/ms_noSEFF.repository | 128 --- .../model/ms_repository_noSEFF_unedited.uml | 324 ------- .../java/com/orhanobut/logger/Helper.java | 105 -- .../java/com/orhanobut/logger/LogAdapter.java | 15 - .../java/com/orhanobut/logger/LogLevel.java | 14 - .../java/com/orhanobut/logger/Logger.java | 112 --- .../com/orhanobut/logger/LoggerPrinter.java | 401 -------- .../java/com/orhanobut/logger/Printer.java | 35 - .../java/com/orhanobut/logger/Settings.java | 69 -- .../com/orhanobut/logger/package-info.java | 1 - .../java/com/orhanobut/package-info.java | 1 - .../orhanobut/java/com/package-info.java | 1 - .../resources/orhanobut/uml/model.uml | 394 -------- 14 files changed, 2515 deletions(-) delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms.repository delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_noSEFF.repository delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_repository_noSEFF_unedited.uml delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Helper.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogAdapter.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogLevel.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Logger.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LoggerPrinter.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Printer.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Settings.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/package-info.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/package-info.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/package-info.java delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/uml/model.uml diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms.repository b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms.repository deleted file mode 100644 index 3e7a44690..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms.repository +++ /dev/null @@ -1,915 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_noSEFF.repository b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_noSEFF.repository deleted file mode 100644 index ecf01d195..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_noSEFF.repository +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_repository_noSEFF_unedited.uml b/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_repository_noSEFF_unedited.uml deleted file mode 100644 index efa5c6b9e..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/model/ms_repository_noSEFF_unedited.uml +++ /dev/null @@ -1,324 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Helper.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Helper.java deleted file mode 100644 index bc0c24d31..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Helper.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2015 Orhan Obut - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This software contains code derived from the following Android classes: - * android.util.Log, android.text.TextUtils. - */ -package com.orhanobut.logger; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.UnknownHostException; - -/** - * Helper util class to be used instead of Android methods to avoid direct dependency and enable - * unit testing on Android projects. - */ -final class Helper { - - private Helper() { - // Hidden constructor. - } - - /** - * Returns true if the string is null or 0-length. - * - * @param str the string to be examined - * - * @return true if str is null or zero length - */ - static boolean isEmpty(CharSequence str) { - return str == null || str.length() == 0; - } - - /** - * Returns true if a and b are equal, including if they are both null. - *

Note: In platform versions 1.1 and earlier, this method only worked well if - * both the arguments were instances of String.

- * - * @param a first CharSequence to check - * @param b second CharSequence to check - * - * @return true if a and b are equal - * - * NOTE: Logic slightly change due to strict policy on CI - - * "Inner assignments should be avoided" - */ - static boolean equals(CharSequence a, CharSequence b) { - if (a == b) return true; - if (a != null && b != null) { - int length = a.length(); - if (length == b.length()) { - if (a instanceof String && b instanceof String) { - return a.equals(b); - } else { - for (int i = 0; i < length; i++) { - if (a.charAt(i) != b.charAt(i)) return false; - } - return true; - } - } - } - return false; - } - - /** - * Copied from "android.util.Log.getStackTraceString()" in order to avoid usage of Android stack - * in unit tests. - * - * @return Stack trace in form of String - */ - static String getStackTraceString(Throwable tr) { - if (tr == null) { - return ""; - } - - // This is to reduce the amount of log spew that apps do in the non-error - // condition of the network being unavailable. - Throwable t = tr; - while (t != null) { - if (t instanceof UnknownHostException) { - return ""; - } - t = t.getCause(); - } - - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - tr.printStackTrace(pw); - pw.flush(); - return sw.toString(); - } - -} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogAdapter.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogAdapter.java deleted file mode 100644 index cab5d8ce7..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogAdapter.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.orhanobut.logger; - -public interface LogAdapter { - void d(String tag, String message); - - void e(String tag, String message); - - void w(String tag, String message); - - void i(String tag, String message); - - void v(String tag, String message); - - void wtf(String tag, String message); -} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogLevel.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogLevel.java deleted file mode 100644 index e3a33ed35..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LogLevel.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.orhanobut.logger; - -public enum LogLevel { - - /** - * Prints all logs - */ - FULL, - - /** - * No log will be printed - */ - NONE -} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Logger.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Logger.java deleted file mode 100644 index 4f6ba77bd..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Logger.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.orhanobut.logger; - -/** - * Logger is a wrapper of {@link android.util.Log} - * But more pretty, simple and powerful - */ -public final class Logger { - public static final int DEBUG = 3; - public static final int ERROR = 6; - public static final int ASSERT = 7; - public static final int INFO = 4; - public static final int VERBOSE = 2; - public static final int WARN = 5; - - private static final String DEFAULT_TAG = "PRETTYLOGGER"; - - private static Printer printer = new LoggerPrinter(); - - //no instance - private Logger() { - } - - /** - * It is used to get the settings object in order to change settings - * - * @return the settings object - */ - public static Settings init() { - return init(DEFAULT_TAG); - } - - /** - * It is used to change the tag - * - * @param tag is the given string which will be used in Logger as TAG - */ - public static Settings init(String tag) { - printer = new LoggerPrinter(); - return printer.init(tag); - } - - public static void resetSettings() { - printer.resetSettings(); - } - - public static Printer t(String tag) { - return printer.t(tag, printer.getSettings().getMethodCount()); - } - - public static Printer t(int methodCount) { - return printer.t(null, methodCount); - } - - public static Printer t(String tag, int methodCount) { - return printer.t(tag, methodCount); - } - - public static void log(int priority, String tag, String message, Throwable throwable) { - printer.log(priority, tag, message, throwable); - } - - public static void d(String message, Object... args) { - printer.d(message, args); - } - - public static void d(Object object) { - printer.d(object); - } - - public static void e(String message, Object... args) { - printer.e(null, message, args); - } - - public static void e(Throwable throwable, String message, Object... args) { - printer.e(throwable, message, args); - } - - public static void i(String message, Object... args) { - printer.i(message, args); - } - - public static void v(String message, Object... args) { - printer.v(message, args); - } - - public static void w(String message, Object... args) { - printer.w(message, args); - } - - public static void wtf(String message, Object... args) { - printer.wtf(message, args); - } - - /** - * Formats the json content and print it - * - * @param json the json content - */ - public static void json(String json) { - printer.json(json); - } - - /** - * Formats the json content and print it - * - * @param xml the xml content - */ - public static void xml(String xml) { - printer.xml(xml); - } - -} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LoggerPrinter.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LoggerPrinter.java deleted file mode 100644 index 6dfc57b7a..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/LoggerPrinter.java +++ /dev/null @@ -1,401 +0,0 @@ -package com.orhanobut.logger; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.StringReader; -import java.io.StringWriter; -import java.util.Arrays; - -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -final class LoggerPrinter implements Printer { - - private static final String DEFAULT_TAG = "PRETTYLOGGER"; - - private static final int DEBUG = 3; - private static final int ERROR = 6; - private static final int ASSERT = 7; - private static final int INFO = 4; - private static final int VERBOSE = 2; - private static final int WARN = 5; - - /** - * Android's max limit for a log entry is ~4076 bytes, - * so 4000 bytes is used as chunk size since default charset - * is UTF-8 - */ - private static final int CHUNK_SIZE = 4000; - - /** - * It is used for json pretty print - */ - private static final int JSON_INDENT = 2; - - /** - * The minimum stack trace index, starts at this class after two native calls. - */ - private static final int MIN_STACK_OFFSET = 3; - - /** - * Drawing toolbox - */ - private static final char TOP_LEFT_CORNER = '╔'; - private static final char BOTTOM_LEFT_CORNER = '╚'; - private static final char MIDDLE_CORNER = '╟'; - private static final char HORIZONTAL_DOUBLE_LINE = '║'; - private static final String DOUBLE_DIVIDER = "════════════════════════════════════════════"; - private static final String SINGLE_DIVIDER = "────────────────────────────────────────────"; - private static final String TOP_BORDER = TOP_LEFT_CORNER + DOUBLE_DIVIDER + DOUBLE_DIVIDER; - private static final String BOTTOM_BORDER = BOTTOM_LEFT_CORNER + DOUBLE_DIVIDER + DOUBLE_DIVIDER; - private static final String MIDDLE_BORDER = MIDDLE_CORNER + SINGLE_DIVIDER + SINGLE_DIVIDER; - - /** - * tag is used for the Log, the name is a little different - * in order to differentiate the logs easily with the filter - */ - private String tag; - - /** - * Localize single tag and method count for each thread - */ - private final ThreadLocal localTag = new ThreadLocal(); - private final ThreadLocal localMethodCount = new ThreadLocal(); - - /** - * It is used to determine log settings such as method count, thread info visibility - */ - private final Settings settings = new Settings(); - - public LoggerPrinter() { - init(DEFAULT_TAG); - } - - /** - * It is used to change the tag - * - * @param tag is the given string which will be used in Logger - */ - @Override public Settings init(String tag) { - if (tag == null) { - throw new NullPointerException("tag may not be null"); - } - if (tag.trim().length() == 0) { - throw new IllegalStateException("tag may not be empty"); - } - this.tag = tag; - return settings; - } - - @Override public Settings getSettings() { - return settings; - } - - @Override public Printer t(String tag, int methodCount) { - if (tag != null) { - localTag.set(tag); - } - localMethodCount.set(methodCount); - return this; - } - - @Override public void d(String message, Object... args) { - log(DEBUG, null, message, args); - } - - @Override public void d(Object object) { - String message; - if (object.getClass().isArray()) { - message = Arrays.deepToString((Object[]) object); - } else { - message = object.toString(); - } - log(DEBUG, null, message); - } - - @Override public void e(String message, Object... args) { - e(null, message, args); - } - - @Override public void e(Throwable throwable, String message, Object... args) { - log(ERROR, throwable, message, args); - } - - @Override public void w(String message, Object... args) { - log(WARN, null, message, args); - } - - @Override public void i(String message, Object... args) { - log(INFO, null, message, args); - } - - @Override public void v(String message, Object... args) { - log(VERBOSE, null, message, args); - } - - @Override public void wtf(String message, Object... args) { - log(ASSERT, null, message, args); - } - - /** - * Formats the json content and print it - * - * @param json the json content - */ - @Override public void json(String json) { - if (Helper.isEmpty(json)) { - d("Empty/Null json content"); - return; - } - try { - json = json.trim(); - if (json.startsWith("{")) { - JSONObject jsonObject = new JSONObject(json); - String message = jsonObject.toString(JSON_INDENT); - d(message); - return; - } - if (json.startsWith("[")) { - JSONArray jsonArray = new JSONArray(json); - String message = jsonArray.toString(JSON_INDENT); - d(message); - return; - } - e("Invalid Json"); - } catch (JSONException e) { - e("Invalid Json"); - } - } - - /** - * Formats the json content and print it - * - * @param xml the xml content - */ - @Override public void xml(String xml) { - if (Helper.isEmpty(xml)) { - d("Empty/Null xml content"); - return; - } - try { - Source xmlInput = new StreamSource(new StringReader(xml)); - StreamResult xmlOutput = new StreamResult(new StringWriter()); - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); - transformer.transform(xmlInput, xmlOutput); - d(xmlOutput.getWriter().toString().replaceFirst(">", ">\n")); - } catch (TransformerException e) { - e("Invalid xml"); - } - } - - @Override public synchronized void log(int priority, String tag, String message, Throwable throwable) { - if (settings.getLogLevel() == null) { - return; - } - if (throwable != null && message != null) { - message += " : " + Helper.getStackTraceString(throwable); - } - if (throwable != null && message == null) { - message = Helper.getStackTraceString(throwable); - } - if (message == null) { - message = "No message/exception is set"; - } - int methodCount = getMethodCount(); - if (Helper.isEmpty(message)) { - message = "Empty/NULL log message"; - } - - logTopBorder(priority, tag); - logHeaderContent(priority, tag, methodCount); - - //get bytes of message with system's default charset (which is UTF-8 for Android) - byte[] bytes = message.getBytes(); - int length = bytes.length; - if (length <= CHUNK_SIZE) { - if (methodCount > 0) { - logDivider(priority, tag); - } - logContent(priority, tag, message); - logBottomBorder(priority, tag); - return; - } - if (methodCount > 0) { - logDivider(priority, tag); - } - for (int i = 0; i < length; i += CHUNK_SIZE) { - int count = Math.min(length - i, CHUNK_SIZE); - //create a new String with system's default charset (which is UTF-8 for Android) - logContent(priority, tag, new String(bytes, i, count)); - } - logBottomBorder(priority, tag); - } - - @Override public void resetSettings() { - settings.reset(); - } - - /** - * This method is synchronized in order to avoid messy of logs' order. - */ - private synchronized void log(int priority, Throwable throwable, String msg, Object... args) { - if (settings.getLogLevel() == null) { - return; - } - String tag = getTag(); - String message = createMessage(msg, args); - log(priority, tag, message, throwable); - } - - private void logTopBorder(int logType, String tag) { - logChunk(logType, tag, TOP_BORDER); - } - - @SuppressWarnings("StringBufferReplaceableByString") - private void logHeaderContent(int logType, String tag, int methodCount) { - StackTraceElement[] trace = Thread.currentThread().getStackTrace(); - if (settings.isShowThreadInfo()) { - logChunk(logType, tag, HORIZONTAL_DOUBLE_LINE + " Thread: " + Thread.currentThread().getName()); - logDivider(logType, tag); - } - String level = ""; - - int stackOffset = getStackOffset(trace) + settings.getMethodOffset(); - - //corresponding method count with the current stack may exceeds the stack trace. Trims the count - if (methodCount + stackOffset > trace.length) { - methodCount = trace.length - stackOffset - 1; - } - - for (int i = methodCount; i > 0; i--) { - int stackIndex = i + stackOffset; - if (stackIndex >= trace.length) { - continue; - } - StringBuilder builder = new StringBuilder(); - builder.append("║ ") - .append(level) - .append(getSimpleClassName(trace[stackIndex].getClassName())) - .append(".") - .append(trace[stackIndex].getMethodName()) - .append(" ") - .append(" (") - .append(trace[stackIndex].getFileName()) - .append(":") - .append(trace[stackIndex].getLineNumber()) - .append(")"); - level += " "; - logChunk(logType, tag, builder.toString()); - } - } - - private void logBottomBorder(int logType, String tag) { - logChunk(logType, tag, BOTTOM_BORDER); - } - - private void logDivider(int logType, String tag) { - logChunk(logType, tag, MIDDLE_BORDER); - } - - private void logContent(int logType, String tag, String chunk) { - String[] lines = chunk.split(System.getProperty("line.separator")); - for (String line : lines) { - logChunk(logType, tag, HORIZONTAL_DOUBLE_LINE + " " + line); - } - } - - private void logChunk(int logType, String tag, String chunk) { - String finalTag = formatTag(tag); - switch (logType) { - case ERROR: - settings.getLogAdapter().e(finalTag, chunk); - break; - case INFO: - settings.getLogAdapter().i(finalTag, chunk); - break; - case VERBOSE: - settings.getLogAdapter().v(finalTag, chunk); - break; - case WARN: - settings.getLogAdapter().w(finalTag, chunk); - break; - case ASSERT: - settings.getLogAdapter().wtf(finalTag, chunk); - break; - case DEBUG: - // Fall through, log debug by default - default: - settings.getLogAdapter().d(finalTag, chunk); - break; - } - } - - private String getSimpleClassName(String name) { - int lastIndex = name.lastIndexOf("."); - return name.substring(lastIndex + 1); - } - - private String formatTag(String tag) { - if (!Helper.isEmpty(tag) && !Helper.equals(this.tag, tag)) { - return this.tag + "-" + tag; - } - return this.tag; - } - - /** - * @return the appropriate tag based on local or global - */ - private String getTag() { - String tag = localTag.get(); - if (tag != null) { - localTag.remove(); - return tag; - } - return this.tag; - } - - private String createMessage(String message, Object... args) { - return args == null || args.length == 0 ? message : String.format(message, args); - } - - private int getMethodCount() { - Integer count = localMethodCount.get(); - int result = settings.getMethodCount(); - if (count != null) { - localMethodCount.remove(); - result = count; - } - if (result < 0) { - throw new IllegalStateException("methodCount cannot be negative"); - } - return result; - } - - /** - * Determines the starting index of the stack trace, after method calls made by this class. - * - * @param trace the stack trace - * - * @return the stack offset - */ - private int getStackOffset(StackTraceElement[] trace) { - for (int i = MIN_STACK_OFFSET; i < trace.length; i++) { - StackTraceElement e = trace[i]; - String name = e.getClassName(); - if (!name.equals(LoggerPrinter.class.getName()) && !name.equals(Logger.class.getName())) { - return --i; - } - } - return -1; - } - -} \ No newline at end of file diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Printer.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Printer.java deleted file mode 100644 index a8dce3273..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Printer.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.orhanobut.logger; - -public interface Printer { - - Printer t(String tag, int methodCount); - - Settings init(String tag); - - Settings getSettings(); - - void d(String message, Object... args); - - void d(Object object); - - void e(String message, Object... args); - - void e(Throwable throwable, String message, Object... args); - - void w(String message, Object... args); - - void i(String message, Object... args); - - void v(String message, Object... args); - - void wtf(String message, Object... args); - - void json(String json); - - void xml(String xml); - - void log(int priority, String tag, String message, Throwable throwable); - - void resetSettings(); - -} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Settings.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Settings.java deleted file mode 100644 index 6ae6ea7b8..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/Settings.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.orhanobut.logger; - -public final class Settings { - - private int methodCount = 2; - private boolean showThreadInfo = true; - private int methodOffset = 0; - private LogAdapter logAdapter; - - /** - * Determines to how logs will be printed - */ - private LogLevel logLevel = LogLevel.FULL; - - public Settings hideThreadInfo() { - showThreadInfo = false; - return this; - } - - public Settings methodCount(int methodCount) { - if (methodCount < 0) { - methodCount = 0; - } - this.methodCount = methodCount; - return this; - } - - public Settings logLevel(LogLevel logLevel) { - this.logLevel = logLevel; - return this; - } - - public Settings methodOffset(int offset) { - this.methodOffset = offset; - return this; - } - - public Settings logAdapter(LogAdapter logAdapter) { - this.logAdapter = logAdapter; - return this; - } - - public int getMethodCount() { - return methodCount; - } - - public boolean isShowThreadInfo() { - return showThreadInfo; - } - - public LogLevel getLogLevel() { - return logLevel; - } - - public int getMethodOffset() { - return methodOffset; - } - - public LogAdapter getLogAdapter() { - return logAdapter; - } - - public void reset() { - methodCount = 2; - methodOffset = 0; - showThreadInfo = true; - logLevel = LogLevel.FULL; - } -} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/package-info.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/package-info.java deleted file mode 100644 index 312539fae..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/logger/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com.orhanobut.logger; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/package-info.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/package-info.java deleted file mode 100644 index 049674d03..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/orhanobut/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com.orhanobut; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/package-info.java b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/package-info.java deleted file mode 100644 index 86bcb18ba..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/java/com/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package com; diff --git a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/uml/model.uml b/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/uml/model.uml deleted file mode 100644 index 79f7f29bc..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/resources/orhanobut/uml/model.uml +++ /dev/null @@ -1,394 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 0fe57a379ee1208ef00555b0f7d4e6273c8a292b Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:28:34 +0100 Subject: [PATCH 53/62] Removed BasicViewFilterTest and renamed ViewTestFactory --- .../viewfilter/tests/BasicViewFilterTest.java | 408 ------------------ ...java => FilterAndInfoViewTestFactory.java} | 27 +- .../viewfilter/tests/InstanceFilterTest.java | 4 +- 3 files changed, 4 insertions(+), 435 deletions(-) delete mode 100644 tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java rename tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/{ViewTestFactory.java => FilterAndInfoViewTestFactory.java} (88%) diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java deleted file mode 100644 index 9f85b1ffb..000000000 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/BasicViewFilterTest.java +++ /dev/null @@ -1,408 +0,0 @@ -package tools.vitruv.applications.viewfilter.tests; - -import java.nio.file.Path; -import java.util.Collection; -import java.util.Collections; -import java.util.function.Consumer; -import java.util.function.Function; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.uml2.uml.Class; -import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.Comment; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.PackageableElement; -import org.eclipse.uml2.uml.PrimitiveType; -import org.eclipse.uml2.uml.UMLFactory; -import org.eclipse.xtend.lib.annotations.AccessorType; -import org.eclipse.xtend.lib.annotations.Accessors; -import org.eclipse.xtext.xbase.lib.CollectionLiterals; -import org.eclipse.xtext.xbase.lib.Exceptions; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import org.eclipse.xtext.xbase.lib.Pure; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.palladiosimulator.pcm.repository.BasicComponent; -import org.palladiosimulator.pcm.repository.CompositeDataType; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.pcm.repository.RepositoryFactory; - -import tools.vitruv.applications.pcmumlclass.CombinedPcmToUmlClassReactionsChangePropagationSpecification; -import tools.vitruv.applications.pcmumlclass.CombinedUmlClassToPcmReactionsChangePropagationSpecification; -import tools.vitruv.applications.testutility.uml.UmlQueryUtil; -import tools.vitruv.applications.viewfilter.utils.PcmQueryUtil; -import tools.vitruv.applications.viewfilter.utils.PcmUmlClassApplicationTestHelper; -import tools.vitruv.change.propagation.ChangePropagationSpecification; -import tools.vitruv.framework.views.CommittableView; -import tools.vitruv.framework.views.View; -import tools.vitruv.testutils.RegisterMetamodelsInStandalone; -import tools.vitruv.testutils.ViewBasedVitruvApplicationTest; - -@ExtendWith(RegisterMetamodelsInStandalone.class) -public class BasicViewFilterTest extends ViewBasedVitruvApplicationTest { - - private static final String NIKLAS_MODIFIED_CLASS_NAME = "niklasModifiedClass2"; - - private static final String NIKLAS_PACKAGE = "niklasPackage"; - - @Accessors(AccessorType.PROTECTED_GETTER) - private static final String UML_MODEL_NAME = "model"; - - @Accessors(AccessorType.PROTECTED_GETTER) - private static final String PCM_MODEL_NAME = "Repository"; - - - private static final String PCM_REPOSITORY_FILE_EXTENSION = "repository"; - - @Accessors(AccessorType.PROTECTED_GETTER) - private static final String MODEL_FOLDER_NAME = "model"; - - @Accessors(AccessorType.PROTECTED_GETTER) - private static final String MODEL_FILE_EXTENSION = "uml"; - - @Accessors(AccessorType.PUBLIC_GETTER) - private org.eclipse.uml2.uml.Class class1; - - @Accessors(AccessorType.PUBLIC_GETTER) - private org.eclipse.uml2.uml.Class class2; - - protected ViewTestFactory improvedViewTestFactory; - - @Test - public void testCreateSystemConcept_PCM() { - System.out.println("Hello world"); - } - - @Test - public void testView() { - improvedViewTestFactory.createUmlView(); - } - - @Test - public void testCreateUmlPcmView() { - improvedViewTestFactory.createUmlAndPcmClassesView(); - } - - @Test - public void testCreateFilteredUmlView() { - View view = improvedViewTestFactory.createFilteredUmlView(this); - // View view = improvedViewTestFactory.createFilteredPcmView(); -// ((FilterSupportingIdentityMappingViewType) improvedViewTestFactory.viewType) -// .updateView(((ModifiableView) view)); - view.update(); - view.update(); - Collection rootObjects = view.getRootObjects(); -// Object[] array = rootObjects.toArray(); -// EObject eobject = (EObject) array[0]; -// EObject copy = EcoreUtil.copy(eobject); -// EObject copy2 = EcoreUtil.copy(copy); -// EcoreUtil.equals(copy2, eobject); - - modifyModel(); - - view.update(); - - //view.getRootObjects(); - //Object object = view.withChangeDerivingTrait().getRootObjects().toArray()[0]; - view.getSelection(); - view.getRootObjects(); - view.getViewType(); - } - - @Test - public void testCreateCountingView() { - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); - View view = improvedViewTestFactory.createCountUmlElementsView(function); - view.getSelection(); - view.getRootObjects(); - - modifyModel(); - - view.update(); - view.update(); - - view.getSelection(); - } - - - @Test - public void testModifyView() { - View view = improvedViewTestFactory.createUmlView(); - CommittableView withChangeDerivingTrait = view.withChangeDerivingTrait(); - Collection rootObjects = withChangeDerivingTrait.getRootObjects(); - - for (EObject root : rootObjects) { - Model model = (Model) root; - for (EObject content : model.eContents()) { - if (content instanceof org.eclipse.uml2.uml.Package) { - org.eclipse.uml2.uml.Package umlPackage = (org.eclipse.uml2.uml.Package) content; - umlPackage.setName("test"); - } - } - - } - - withChangeDerivingTrait.commitChangesAndUpdate(); - view.getRootObjects(); - } - - - @Test - public void testModifyFilteredView() throws Exception { - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); - View view = improvedViewTestFactory.createFilteredUmlView(function); - //Change view function - Consumer modifyViewFunction = (CommittableView viewToBeModified) -> { - getDefaultUmlModel(viewToBeModified).getPackagedElement(NIKLAS_PACKAGE).setName("NiklasRenamedPackage"); - }; - //apply change - improvedViewTestFactory.changeViewDerivingChanges(view, modifyViewFunction); - view.getRootObjects(); - - -// CommittableView withChangeDerivingTrait = view.withChangeDerivingTrait(); -// Collection rootObjects = withChangeDerivingTrait.getRootObjects(); -// for (EObject root : rootObjects) { -// Model model = (Model) root; -// for (EObject content : model.eContents()) { -// if (content instanceof org.eclipse.uml2.uml.Class) { -// org.eclipse.uml2.uml.Class umlClass = (org.eclipse.uml2.uml.Class) content; -// umlClass.setName("modifiedNiklasClass2"); -// } -// } -// -// } - -// withChangeDerivingTrait.commitChangesAndUpdate(); - view.getRootObjects(); - } - - - @Test - public void testRenameClassInFilteredView() { - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); - View filterView = improvedViewTestFactory.createFilteredUmlView(function); - try { - improvedViewTestFactory.changeViewRecordingChanges(filterView, (CommittableView view) -> { - Model model = getDefaultUmlModel(view); - Class niklasClass2 = UmlQueryUtil.claimClass(model, "niklasClass2"); - niklasClass2.setName(NIKLAS_MODIFIED_CLASS_NAME); - }); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - filterView.getRootObjects(); - View secondView = improvedViewTestFactory.createUmlView(); - secondView.getRootObjects(); - } - - - - - @Override - protected Iterable getChangePropagationSpecifications() { - CombinedPcmToUmlClassReactionsChangePropagationSpecification _combinedPcmToUmlClassReactionsChangePropagationSpecification = new CombinedPcmToUmlClassReactionsChangePropagationSpecification(); - CombinedUmlClassToPcmReactionsChangePropagationSpecification _combinedUmlClassToPcmReactionsChangePropagationSpecification = new CombinedUmlClassToPcmReactionsChangePropagationSpecification(); - return Collections.unmodifiableList( - CollectionLiterals.newArrayList( - _combinedPcmToUmlClassReactionsChangePropagationSpecification, - _combinedUmlClassToPcmReactionsChangePropagationSpecification)); - } - - - @BeforeEach - public void setup() { - improvedViewTestFactory = new ViewTestFactory(getVirtualModel()); - final Procedure1 setNameFunction = (Model it) -> { - it.setName(UML_MODEL_NAME); - }; - createBiggerUmlModel(setNameFunction); - //createPcmModel(); - } - - protected void createUmlModel(final Procedure1 modelInitialization) { - try { - final Consumer firstChangeUmlFunction = (CommittableView it) -> { - final Model umlModel = UMLFactory.eINSTANCE.createModel(); - createAndRegisterRoot(it, umlModel, this.getUri(getProjectModelPath(UML_MODEL_NAME))); - modelInitialization.apply(umlModel); - }; - improvedViewTestFactory.changeUmlView(firstChangeUmlFunction); - - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); - } - } - - - protected void createBiggerUmlModel(final Procedure1 modelInitialization) { - try { - final Consumer firstChangeUmlFunction = (CommittableView it) -> { - final Model umlModel = UMLFactory.eINSTANCE.createModel(); - createAndRegisterRoot(it, umlModel, this.getUri(getProjectModelPath(UML_MODEL_NAME))); - modelInitialization.apply(umlModel); - }; - improvedViewTestFactory.changeUmlView(firstChangeUmlFunction); - - getUserInteraction().addNextSingleSelection(1); - getUserInteraction().addNextTextInput("model/System.system"); - - final Consumer secondChangeUmlFunction = (CommittableView it) -> { - org.eclipse.uml2.uml.Package _createPackage = UMLFactory.eINSTANCE.createPackage(); - Procedure1 setNameFunction = (org.eclipse.uml2.uml.Package it_1) -> { - it_1.setName(NIKLAS_PACKAGE); - }; - - org.eclipse.uml2.uml.Package package1 = UMLFactory.eINSTANCE.createPackage(); - package1.setName(NIKLAS_PACKAGE); - - class1 = package1.createOwnedClass("niklasClass1", false); - - getUserInteraction().addNextSingleSelection(1); - getUserInteraction().addNextTextInput("model/System.system"); - org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage("niklasNestedPackage"); - - class2 = package2.createOwnedClass("niklasClass2", false); - EList _packagedElements = getDefaultUmlModel(it).getPackagedElements(); - _packagedElements.add(package1); - - // create Attribute for class2 - PrimitiveType stringPrimitiveType = package1.createOwnedPrimitiveType("niklasPrimitiveType1"); - class2.createOwnedAttribute("niklasClass2Attribute", stringPrimitiveType, 0, 1); - }; - improvedViewTestFactory.changeUmlView(secondChangeUmlFunction); - - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); - } - } - - - private void modifyModel() { - try { - getUserInteraction().addNextSingleSelection(1); - getUserInteraction().addNextTextInput("model/System.system"); - - Consumer changeUmlFunction = (CommittableView it) -> { - org.eclipse.uml2.uml.Package package3 = UMLFactory.eINSTANCE.createPackage(); - package3.setName("niklasPackage3"); - - org.eclipse.uml2.uml.Class class3 = package3.createOwnedClass("niklasClass3", false); - org.eclipse.uml2.uml.Class class4 = package3.createOwnedClass("niklasClass2", false); - - class2.addKeyword("subsequentlyAddedKeyword"); - - final Comment comment = this.class2.createOwnedComment(); - comment.setBody("niklasCommentClass2"); - String searchedName = "niklasClass2"; - comment.addKeyword("bla"); - - TreeIterator umlIterator = getDefaultUmlModel(it).eAllContents(); - org.eclipse.uml2.uml.Class searchedClass = null; - while ((searchedClass == null) && (umlIterator.hasNext())) { - EObject next = umlIterator.next(); - if (next instanceof org.eclipse.uml2.uml.Class) { - if (searchedName.equals(((Classifier) next).getName())) { - searchedClass = (org.eclipse.uml2.uml.Class) next; - } - } - } - searchedClass.getOwnedComments().add(comment); - - getDefaultUmlModel(it).getPackagedElements().add(package3); - }; - - improvedViewTestFactory.changeUmlView(changeUmlFunction); - } catch (Throwable _e) { - throw Exceptions.sneakyThrow(_e); - } - } - - - protected void createPcmModel() { - - getUserInteraction().addNextTextInput(PcmUmlClassApplicationTestHelper.UML_MODEL_FILE); - Consumer createPcmRepoFunction = (CommittableView it) -> { - Repository repository = RepositoryFactory.eINSTANCE.createRepository(); - repository.setEntityName(PCM_MODEL_NAME); - it.registerRoot(repository, getUri(getPcmProjectModelPath(repository.getEntityName(), PCM_REPOSITORY_FILE_EXTENSION))); - //createAndRegisterRoot(it, repository, this.getUri(getProjectModelPath(PCM_MODEL_NAME))); - }; - - try { - improvedViewTestFactory.changePcmView(createPcmRepoFunction); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - Consumer changePcmFunction = (CommittableView it) -> { - Repository repository = getDefaultPcmRepository(it); - BasicComponent createBasicComponent = RepositoryFactory.eINSTANCE.createBasicComponent(); - createBasicComponent.setEntityName("Niklas Basic PCM component 1"); - repository.getComponents__Repository().add(createBasicComponent); - - CompositeDataType compositeDataType1 = RepositoryFactory.eINSTANCE.createCompositeDataType(); - compositeDataType1.setEntityName("niklasPcmCompositeDataType1"); - repository.getDataTypes__Repository().add(compositeDataType1); - - }; - - try { - improvedViewTestFactory.changePcmView(changePcmFunction); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - private Path getPcmProjectModelPath(String modelName, String modelFileExtension) { - return Path.of("pcm").resolve(modelName + "." + modelFileExtension); - } - - protected void createAndRegisterRoot(final View view, final EObject rootObject, final URI persistenceUri) { - view.registerRoot(rootObject, persistenceUri); - } - - protected Path getProjectModelPath(final String modelName) { - return Path.of(MODEL_FOLDER_NAME).resolve(((modelName + ".") + MODEL_FILE_EXTENSION)); - } - - protected Model getDefaultUmlModel(final View view) { - return UmlQueryUtil.claimUmlModel(view, UML_MODEL_NAME); - } - - private Repository getDefaultPcmRepository(View view) { - return PcmQueryUtil.claimPcmRepository(view, PCM_MODEL_NAME); - } - - @Pure - public org.eclipse.uml2.uml.Class getClass1() { - return this.class1; - } - - @Pure - public org.eclipse.uml2.uml.Class getClass2() { - return this.class2; - } - - private boolean hasNoAttribute(EObject object, String name) { - if (object instanceof org.eclipse.uml2.uml.Class) { - if (object instanceof NamedElement) { - if (name.equals(((NamedElement) object).getName())) { - return true; - } - } - - } - return false; - } - -} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FilterAndInfoViewTestFactory.java similarity index 88% rename from tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java rename to tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FilterAndInfoViewTestFactory.java index 9b69ba748..f2e5fe9e8 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/ViewTestFactory.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/FilterAndInfoViewTestFactory.java @@ -25,12 +25,12 @@ import tools.vitruv.framework.views.ViewTypeFactory; import tools.vitruv.testutils.TestViewFactory; -public class ViewTestFactory extends TestViewFactory { +public class FilterAndInfoViewTestFactory extends TestViewFactory { private ViewProvider viewProvider; ViewType viewType; - public ViewTestFactory(ViewProvider viewProvider) { + public FilterAndInfoViewTestFactory(ViewProvider viewProvider) { super(viewProvider); this.viewProvider = viewProvider; } @@ -53,15 +53,6 @@ public View createUmlAndPcmClassesView() { } - public View createFilteredUmlView(BasicViewFilterTest test) { - Collection> rootTypes = createCollectionOfRootTypes(Model.class); - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); - View view = createFilteredForNoAttributesViewOfElements("UML", rootTypes, function); - view.getSelection().isViewObjectSelected(test.getClass1()); - view.getSelection().isViewObjectSelected(test.getClass2()); - return view; - } - public View createFilteredUmlView(Function function) { Collection> rootTypes = createCollectionOfRootTypes(Model.class); return createFilteredForNoAttributesViewOfElements("UML", rootTypes, function); @@ -151,20 +142,6 @@ private View createFilteredViewOfElements(String viewName, Collection> assertThat("view must not be null", view, not(equalTo(null))); return view; } - - - - private boolean hasNoAttribute(EObject object, String name) { - if (object instanceof org.eclipse.uml2.uml.Class) { - if (object instanceof NamedElement) { - if (name.equals(((NamedElement) object).getName())) { - return true; - } - } - - } - return false; - } private Collection> createCollectionOfRootTypes(Collection> currentCollection, Class additionalRootType) { diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index 733db18ba..f75197eab 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -86,7 +86,7 @@ public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { @Accessors(AccessorType.PUBLIC_GETTER) private org.eclipse.uml2.uml.Class class2; - protected ViewTestFactory improvedViewTestFactory; + protected FilterAndInfoViewTestFactory improvedViewTestFactory; private Model umlModel; @@ -94,7 +94,7 @@ public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { @BeforeEach public void setup() { - improvedViewTestFactory = new ViewTestFactory(getVirtualModel()); + improvedViewTestFactory = new FilterAndInfoViewTestFactory(getVirtualModel()); final Procedure1 setNameFunction = (Model it) -> { it.setName(UML_MODEL_NAME); }; From 174c630bd358e89f616cca58eb4aa58ad3ce44ab Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:31:46 +0100 Subject: [PATCH 54/62] reverted some temporary changes --- .../JavaConstructionSimulationTest.xtend | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend index b44be0324..883fd6aee 100644 --- a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend +++ b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaConstructionSimulationTest.xtend @@ -92,9 +92,9 @@ class JavaConstructionSimulationTest extends AbstractJavaToUmlTest { */ @Test def void testOrhanobutLoggerProject() { - //registerStdLibraryModule("java.xml") - //registerLocalLibrary(Path.of(new File("target/dependency/json.jar").absolutePath)) - //transformJavaProjectAndValidateUmlModel("resources/orhanobut/java/") + registerStdLibraryModule("java.xml") + registerLocalLibrary(Path.of(new File("target/dependency/json.jar").absolutePath)) + transformJavaProjectAndValidateUmlModel("resources/orhanobut/java/") } private def Iterable collectJavaFilesInFolder(File folder) { From 097b8ed33a81ca83bd1bc1c9b0e41c720566aec7 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:34:52 +0100 Subject: [PATCH 55/62] added temporary deleted file --- ...OrClassFileResourceWithArraysDefaultFactoryImpl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl diff --git a/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl new file mode 100644 index 000000000..f28fb4034 --- /dev/null +++ b/tests/tools.vitruv.applications.umljava.tests/src/tools/vitruv/applications/umljava/tests/java2uml/constructionsimulationtest/JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl @@ -0,0 +1,14 @@ +package tools.vitruv.applications.umljava.tests.java2uml.constructionsimulationtest; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.emftext.language.java.resource.JavaSourceOrClassFileResourceFactoryImpl; + +public class JavaSourceOrClassFileResourceWithArraysDefaultFactoryImpl + extends JavaSourceOrClassFileResourceFactoryImpl { + + @Override + public Resource createResource(URI uri) { + return new JavaSourceOrClassFileResourceWithArraysDefault(uri); + } +} \ No newline at end of file From c1deeb4557fa962766774530420a0f9b6e76c238 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:43:03 +0100 Subject: [PATCH 56/62] Removed unnecessary interfaces --- .../util/framework/FilteredViewSelector.java | 9 --------- .../viewfilter/views/FilterChangeDerivingView.java | 3 +-- .../viewfilter/views/FilterChangeRecordingView.java | 4 +--- .../viewfilter/views/FilterChangeView.java | 12 ------------ 4 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java delete mode 100644 bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java deleted file mode 100644 index 524bd9cef..000000000 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/util/framework/FilteredViewSelector.java +++ /dev/null @@ -1,9 +0,0 @@ -package tools.vitruv.applications.viewfilter.util.framework; - -import tools.vitruv.framework.views.View; -import tools.vitruv.framework.views.ViewSelector; - -public interface FilteredViewSelector extends ViewSelector { - - View createFilteredView(); -} diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java index c95084cd0..82fc812da 100644 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java +++ b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java @@ -21,7 +21,7 @@ import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; -public class FilterChangeDerivingView extends ChangeDerivingView implements FilterableView, FilterChangeView { +public class FilterChangeDerivingView extends ChangeDerivingView implements FilterableView { // TODO nbr add javadoc private Map mapCopy2OriginalObject; @@ -95,7 +95,6 @@ private FilterableView getViewAsFilterableView() { return (FilterableView) view; } - @Override public ResourceSet getViewResourceSet() { return view.getViewResourceSet(); } diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java index cef45a778..ef8223ef6 100644 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java +++ b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -18,7 +18,7 @@ import tools.vitruv.framework.views.ViewSelection; //TODO nbr: Hier nicht ChangeRecordingView überschreiben, sondern eigen implementieren und Sichtbarkeiten in ChangeRecordingView zurücksetzen -public class FilterChangeRecordingView extends ChangeRecordingView implements FilterableView, FilterChangeView { +public class FilterChangeRecordingView extends ChangeRecordingView implements FilterableView { private Map mapCopy2OriginalObject; private TransactionalChange recordedChange = null; @@ -76,8 +76,6 @@ public ViewSelection getPreFilterSelection() { } - - @Override public ResourceSet getViewResourceSet() { return view.getViewResourceSet(); } diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java deleted file mode 100644 index 763676b9e..000000000 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeView.java +++ /dev/null @@ -1,12 +0,0 @@ -package tools.vitruv.applications.viewfilter.views; - -import org.eclipse.emf.ecore.resource.ResourceSet; - -public interface FilterChangeView { - - ResourceSet getViewResourceSet(); - - - - -} From b761b2a6d2118cb7875a90625c58ef775fd504dd Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:53:42 +0100 Subject: [PATCH 57/62] Removed "niklas" from code, removed unnecessary class --- .../viewfilter/viewbuild/UmlViewBuilder.java | 82 ------------------- .../viewfilter/tests/InstanceFilterTest.java | 74 ++++++++--------- 2 files changed, 37 insertions(+), 119 deletions(-) delete mode 100644 bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java deleted file mode 100644 index 33a512206..000000000 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/viewbuild/UmlViewBuilder.java +++ /dev/null @@ -1,82 +0,0 @@ -package tools.vitruv.applications.viewfilter.viewbuild; - - -import java.util.Collection; -import java.util.LinkedList; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.uml2.uml.Classifier; -import org.eclipse.uml2.uml.Model; - -import tools.vitruv.applications.viewfilter.util.framework.FilterSupportingViewTypeFactory; -import tools.vitruv.framework.views.ViewProvider; -import tools.vitruv.framework.views.ViewSelector; - -public class UmlViewBuilder { - - private ViewSelector selector; - - - private UmlViewBuilder(ViewProvider viewProvider) { - Collection> rootTypes = createCollectionOfRootTypes(Model.class); - createViewOfElements(viewProvider, "UML", rootTypes); - } - - public static UmlViewBuilder buildUmlView(ViewProvider viewProvider) { - return new UmlViewBuilder(viewProvider); - } - - - public UmlViewBuilder filterForTypeClass() { - selector.getSelectableElements().stream() - .filter(element -> element instanceof org.eclipse.uml2.uml.Class) - .forEach(element -> selector.setSelected(element, true)); - return this; - } - - - - - - - - - - - private void removeAttributes(EObject object) { - - if (object instanceof Classifier) { - Classifier currentClassifier = (Classifier) object; - - Classifier classifierCopy = EcoreUtil.copy(currentClassifier); - EcoreUtil.remove(object); - - //nbruening Hier weitermachen - currentClassifier.allAttributes(); - currentClassifier.getAttributes(); - - - selector.setSelected(object, true); - } - } - - /** - * Creates a view with the given name containing the provided root types (and - * its descendants). - */ - private void createViewOfElements(ViewProvider viewProvider, String viewName, Collection> rootTypes) { - ViewSelector selector = viewProvider.createSelector(FilterSupportingViewTypeFactory.createFilterSupportingIdentityMappingViewType(viewName)); - selector.getSelectableElements().stream() - .filter(element -> rootTypes.stream().anyMatch(it -> it.isInstance(element))) - .forEach(element -> selector.setSelected(element, true)); - } - - - private Collection> createCollectionOfRootTypes(Class additionalRootType) { - Collection> rootTypes = new LinkedList(); - rootTypes.add(additionalRootType); - return rootTypes; - } - -} diff --git a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java index f75197eab..11f77448b 100644 --- a/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java +++ b/tests/tools.vitruv.applications.viewfilter.tests/src/tools/vitruv/applications/viewfilter/tests/InstanceFilterTest.java @@ -58,7 +58,7 @@ @ExtendWith(RegisterMetamodelsInStandalone.class) public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { - private static final String NIKLAS_NESTED_PACKAGE = "niklasNestedPackage"; + private static final String NESTED_PACKAGE_TEST_NAME = "testNestedPackage"; @Accessors(AccessorType.PROTECTED_GETTER) private static final String UML_MODEL_NAME = "model"; @@ -66,7 +66,7 @@ public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { @Accessors(AccessorType.PROTECTED_GETTER) private static final String PCM_MODEL_NAME = "Repository"; - private static final String NIKLAS_MODIFIED_CLASS_NAME = "niklasModifiedClass2"; + private static final String TEST_MODIFIED_CLASS_NAME = "testModifiedClass2"; private static final String PCM_REPOSITORY_FILE_EXTENSION = "repository"; @@ -76,7 +76,7 @@ public class InstanceFilterTest extends ViewBasedVitruvApplicationTest { @Accessors(AccessorType.PROTECTED_GETTER) private static final String MODEL_FILE_EXTENSION = "uml"; - private static final String PCM_BASIC_COMPONENT_NAME = "Niklas Basic PCM component 1"; + private static final String PCM_BASIC_COMPONENT_NAME = "Test Basic PCM component 1"; private static final String UML_MODEL_URI = "1234uri1234"; @@ -119,7 +119,7 @@ public void testUmlView() throws NoSuchMethodException, InvocationTargetExceptio @Test public void testCreateFilteredUmlView() { - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + Function function = (EObject object) -> hasNoAttribute(object, "testClass2"); View view = improvedViewTestFactory.createFilteredUmlView(function); view.update(); @@ -127,7 +127,7 @@ public void testCreateFilteredUmlView() { Collection rootObjects = view.getRootObjects(); assertEquals(rootObjects.size(), 1); //Expected: - //Selection: Only ModelImpl with class "niklasClass2" as only PackagedElement + //Selection: Only ModelImpl with class "testClass2" as only PackagedElement //Root Objects: same structure as in selection for (EObject root : rootObjects) { assertTrue(root instanceof Model); @@ -136,13 +136,13 @@ public void testCreateFilteredUmlView() { EObject eObject = root.eContents().get(0); assertTrue(eObject instanceof org.eclipse.uml2.uml.Class); org.eclipse.uml2.uml.Class classObject = (Class) eObject; - assertEquals(classObject.getName(), "niklasClass2"); + assertEquals(classObject.getName(), "testClass2"); } modifyModel(); view.update(); view.getSelection(); - //Expected: Selection: Only ModelImpl with two Class Objects, both with the name niklasClass2 as packagedElements + //Expected: Selection: Only ModelImpl with two Class Objects, both with the name testClass2 as packagedElements //Root Objects: The same Collection modifiedRootObjects = view.getRootObjects(); assertEquals(modifiedRootObjects.size(), 1); @@ -153,7 +153,7 @@ public void testCreateFilteredUmlView() { for (EObject eObject : root.eContents()) { assertTrue(eObject instanceof org.eclipse.uml2.uml.Class); org.eclipse.uml2.uml.Class classObject = (Class) eObject; - assertEquals(classObject.getName(), "niklasClass2"); + assertEquals(classObject.getName(), "testClass2"); } } } @@ -162,12 +162,12 @@ public void testCreateFilteredUmlView() { @Test public void testCreateFilteredUmlViewWithAdditionalPcmElementsInVsum() { createPcmModel(); - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + Function function = (EObject object) -> hasNoAttribute(object, "testClass2"); View view = improvedViewTestFactory.createFilteredUmlView(function); view.update(); view.update(); - //Expected Selection: Only ModelImpl with class object "niklasClass2" as only PackagedElement + //Expected Selection: Only ModelImpl with class object "testClass2" as only PackagedElement //Root Objects: Same structure as selection Collection rootObjects = view.getRootObjects(); assertEquals(rootObjects.size(), 1); @@ -178,7 +178,7 @@ public void testCreateFilteredUmlViewWithAdditionalPcmElementsInVsum() { for (EObject eObject : root.eContents()) { assertTrue(eObject instanceof org.eclipse.uml2.uml.Class); org.eclipse.uml2.uml.Class classObject = (Class) eObject; - assertEquals(classObject.getName(), "niklasClass2"); + assertEquals(classObject.getName(), "testClass2"); } } @@ -194,7 +194,7 @@ public void testCreateFilteredUmlViewWithAdditionalPcmElementsInVsum() { for (EObject eObject : root.eContents()) { assertTrue(eObject instanceof org.eclipse.uml2.uml.Class); org.eclipse.uml2.uml.Class classObject = (Class) eObject; - assertEquals(classObject.getName(), "niklasClass2"); + assertEquals(classObject.getName(), "testClass2"); } } @@ -235,7 +235,7 @@ public void testCreateFilteredPcmView() { BasicComponent classObject = (BasicComponent) eObject; assertEquals(PCM_BASIC_COMPONENT_NAME, classObject.getEntityName()); } - //Expected: Selection: Only RepositoryImpl. Under eSettings is a list which contains "Niklas Basic PCM component 1" + //Expected: Selection: Only RepositoryImpl. Under eSettings is a list which contains the content of PCM_BASIC_COMPONENT_NAME //Root Objects: Identical to Selection but with less null values in irrelevant fields modifyModel(); view.update(); @@ -256,7 +256,7 @@ public void testCreateFilteredPcmView() { @Test public void testCreateCountingView() { - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + Function function = (EObject object) -> hasNoAttribute(object, "testClass2"); View view = improvedViewTestFactory.createCountUmlElementsView(function); Assertions.assertNotNull(view.getSelection(), "selection must not be null"); @@ -295,14 +295,14 @@ public void testCreateCountingView() { @Test public void testRenameClassInFilteredView() throws Exception { - Function function = (EObject object) -> hasNoAttribute(object, "niklasClass2"); + Function function = (EObject object) -> hasNoAttribute(object, "testClass2"); View baselineUnfilteredUmlView = improvedViewTestFactory.createUmlView(); View filterView = improvedViewTestFactory.createFilteredUmlView(function); improvedViewTestFactory.changeViewRecordingChanges(filterView, (CommittableView view) -> { Model model = getDefaultUmlModel(view); - Class niklasClass2 = UmlQueryUtil.claimClass(model, "niklasClass2"); - niklasClass2.setName(NIKLAS_MODIFIED_CLASS_NAME); + Class testClass2 = UmlQueryUtil.claimClass(model, "testClass2"); + testClass2.setName(TEST_MODIFIED_CLASS_NAME); }); @@ -313,7 +313,7 @@ public void testRenameClassInFilteredView() throws Exception { for (EObject filteredRoot : filteredRootObjects) { EObject classObject = filteredRoot.eContents().get(0); assertTrue(classObject instanceof Class); - assertEquals(NIKLAS_MODIFIED_CLASS_NAME, ((Class) classObject).getName()); + assertEquals(TEST_MODIFIED_CLASS_NAME, ((Class) classObject).getName()); } //Did the update of the vsum work? Is a newly created view in correct state? View secondView = improvedViewTestFactory.createUmlView(); @@ -322,14 +322,14 @@ public void testRenameClassInFilteredView() throws Exception { for (EObject viewRoot : newViewRootObjects) { assertTrue(viewRoot instanceof Model); if (viewRoot instanceof Model castedViewRoot) { - EObject classWithModifiedName = searchEObjectWithGivenNameInUmlModel(castedViewRoot, NIKLAS_MODIFIED_CLASS_NAME); + EObject classWithModifiedName = searchEObjectWithGivenNameInUmlModel(castedViewRoot, TEST_MODIFIED_CLASS_NAME); assertTrue(classWithModifiedName != null); assertTrue(classWithModifiedName instanceof Class); - EList niklasPackage = viewRoot.eContents().get(0).eContents(); - assertEquals(4, niklasPackage.size()); - assertEquals(1, niklasPackage.stream().filter(it -> {return (it instanceof PackageImpl);}).count()); - assertEquals(2, niklasPackage.stream().filter(it -> {return (it instanceof ClassImpl);}).count()); - assertEquals(1, niklasPackage.stream().filter(it -> {return (it instanceof PrimitiveTypeImpl);}).count()); + EList testPackage = viewRoot.eContents().get(0).eContents(); + assertEquals(4, testPackage.size()); + assertEquals(1, testPackage.stream().filter(it -> {return (it instanceof PackageImpl);}).count()); + assertEquals(2, testPackage.stream().filter(it -> {return (it instanceof ClassImpl);}).count()); + assertEquals(1, testPackage.stream().filter(it -> {return (it instanceof PrimitiveTypeImpl);}).count()); } } } @@ -353,25 +353,25 @@ protected void createBiggerUmlModel(final Procedure1 modelInitial final Consumer secondChangeUmlFunction = (CommittableView it) -> { org.eclipse.uml2.uml.Package _createPackage = UMLFactory.eINSTANCE.createPackage(); Procedure1 setNameFunction = (org.eclipse.uml2.uml.Package it_1) -> { - it_1.setName("niklasPackage"); + it_1.setName("testPackage"); }; org.eclipse.uml2.uml.Package package1 = UMLFactory.eINSTANCE.createPackage(); - package1.setName("niklasPackage"); + package1.setName("testPackage"); - class1 = package1.createOwnedClass("niklasClass1", false); + class1 = package1.createOwnedClass("testClass1", false); getUserInteraction().addNextSingleSelection(1); getUserInteraction().addNextTextInput("model/System.system"); - org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage(NIKLAS_NESTED_PACKAGE); + org.eclipse.uml2.uml.Package package2 = package1.createNestedPackage(NESTED_PACKAGE_TEST_NAME); - class2 = package2.createOwnedClass("niklasClass2", false); + class2 = package2.createOwnedClass("testClass2", false); EList _packagedElements = getDefaultUmlModel(it).getPackagedElements(); _packagedElements.add(package1); // create Attribute for class2 - PrimitiveType stringPrimitiveType = package1.createOwnedPrimitiveType("niklasPrimitiveType1"); - class2.createOwnedAttribute("niklasClass2Attribute", stringPrimitiveType, 0, 1); + PrimitiveType stringPrimitiveType = package1.createOwnedPrimitiveType("testPrimitiveType1"); + class2.createOwnedAttribute("testClass2Attribute", stringPrimitiveType, 0, 1); }; improvedViewTestFactory.changeUmlView(secondChangeUmlFunction); @@ -387,16 +387,16 @@ private void modifyModel() { Consumer changeUmlFunction = (CommittableView it) -> { org.eclipse.uml2.uml.Package package3 = UMLFactory.eINSTANCE.createPackage(); - package3.setName("niklasPackage3"); + package3.setName("testPackage3"); - org.eclipse.uml2.uml.Class class3 = package3.createOwnedClass("niklasClass3", false); - org.eclipse.uml2.uml.Class class4 = package3.createOwnedClass("niklasClass2", false); + org.eclipse.uml2.uml.Class class3 = package3.createOwnedClass("testClass3", false); + org.eclipse.uml2.uml.Class class4 = package3.createOwnedClass("testClass2", false); class2.addKeyword("subsequentlyAddedKeyword"); final Comment comment = this.class2.createOwnedComment(); - comment.setBody("niklasCommentClass2"); - String searchedName = "niklasClass2"; + comment.setBody("testCommentedClass2"); + String searchedName = "testClass2"; comment.addKeyword("bla"); TreeIterator umlIterator = getDefaultUmlModel(it).eAllContents(); @@ -443,7 +443,7 @@ protected void createPcmModel() { repository.getComponents__Repository().add(createBasicComponent); CompositeDataType compositeDataType1 = RepositoryFactory.eINSTANCE.createCompositeDataType(); - compositeDataType1.setEntityName("niklasPcmCompositeDataType1"); + compositeDataType1.setEntityName("testPcmCompositeDataType1"); repository.getDataTypes__Repository().add(compositeDataType1); }; From 7d940a450afdfe0982690a65ee344c9888c9fc75 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:03:24 +0100 Subject: [PATCH 58/62] Added javadoc, resolved todos --- .../views/FilterChangeDerivingView.java | 1 - .../viewfilter/views/FilterableView.java | 29 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java index 82fc812da..bbb6a83a7 100644 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java +++ b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java @@ -23,7 +23,6 @@ public class FilterChangeDerivingView extends ChangeDerivingView implements FilterableView { - // TODO nbr add javadoc private Map mapCopy2OriginalObject; private ResourceSet originalStateViewResourceSet; diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterableView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterableView.java index 97cf50e57..b1ec26f79 100644 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterableView.java +++ b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterableView.java @@ -8,12 +8,39 @@ import tools.vitruv.applications.viewfilter.util.framework.impl.ModifiableView; import tools.vitruv.framework.views.ViewSelection; -//TODO nbr: Add javadoc +/** + * {@link Views} which implement this interface provide filter functionality. This interface + * therefore allows access on the selection of unfiltered models as well as on the unfiltered + * {@link ResourceSet}. Notice: To access the filtered models, one should use the common {@link ModifiableView} + * or {@link View} interface. + * It also provides a mapping from an object in a filtered model to the object in the unfiltered + * model, as the objects in the filtered models might be copies of the original objects depending + * on the implementation. + */ public interface FilterableView extends ModifiableView { + /** + * Method returns the selection of models in this view before the first filtering. Can be used + * to access the unfiltered models which are sources for the actual filtering and need to be + * considered. + * + * @return A viewSelection of unfiltered models + */ ViewSelection getPreFilterSelection(); + /** + * Provides a mapping from an object in a filtered model to the object in the unfiltered + * model. The objects in the filtered models might be copies of the original objects depending + * on the implementation. + * + * @return The map containing the mapping + */ Map getMapCopy2OriginalObject(); + /** + * Method returns the {@link ResourceSet} containing all unfiltered models of this view. + * + * @return The {@link ResourceSet} containing all unfiltered models of this view + */ ResourceSet getNonFilteredViewResourceSet(); } From cc1bb803da7c47df077cf7863315689f5cbb1223 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:15:57 +0100 Subject: [PATCH 59/62] Some cleanups, some javadoc Some cleanups of FilterChangeRecording and FilterChangeDerivingView javadoc --- .../views/ChangesetDeterminableView.java | 24 +++++- .../views/FilterChangeDerivingView.java | 78 +------------------ .../views/FilterChangeRecordingView.java | 14 +--- 3 files changed, 29 insertions(+), 87 deletions(-) diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java index 9c8ea39cf..7bac01dbe 100644 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java +++ b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/ChangesetDeterminableView.java @@ -7,15 +7,37 @@ import tools.vitruv.change.atomic.hid.HierarchicalId; import tools.vitruv.framework.views.ViewSelector; -//TODO nbr: Add javadoc +/** + * Instances of this interface can be used to determine changes. These changes can then be used + * for further steps like commits. + */ public interface ChangesetDeterminableView extends ModifiableView { + /** + * Returns the {@link ResourceSet} of the {@link ChangesetDeterminableView} + * + * @return The {@link ResourceSet} object + */ public ResourceSet getViewResourceSet(); + /** + * Ensures that this {@link ChangesetDeterminableView} has not already been closed. + */ public void checkNotClosed(); + /** + * Method returns the {@link ViewType} of the {@link ChangesetDeterminableView} object. + * + * @return The {@link ViewType} + */ public ViewCreatingViewType getViewType(); + /** + * Method sets the marker for changes of this {@link ChangesetDeterminableView} on the + * given value. + * + * @param value The new value for the marker + */ public void setViewChanged(boolean value); } diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java index bbb6a83a7..9c3d13f2a 100644 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java +++ b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeDerivingView.java @@ -1,23 +1,10 @@ package tools.vitruv.applications.viewfilter.views; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; import java.util.Map; -import java.util.Set; import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.common.util.URIUtil; -import edu.kit.ipd.sdq.commons.util.org.eclipse.emf.ecore.resource.ResourceCopier; -import tools.vitruv.change.atomic.hid.HierarchicalId; -import tools.vitruv.change.composite.description.CompositeContainerChange; -import tools.vitruv.change.composite.description.VitruviusChange; -import tools.vitruv.change.composite.description.VitruviusChangeFactory; import tools.vitruv.framework.views.ViewSelection; import tools.vitruv.framework.views.changederivation.StateBasedChangeResolutionStrategy; @@ -25,9 +12,6 @@ public class FilterChangeDerivingView extends ChangeDerivingView implements Filt private Map mapCopy2OriginalObject; - private ResourceSet originalStateViewResourceSet; - - private HashMap originalStateResourceMapping; protected FilterChangeDerivingView(BasicFilterView view, StateBasedChangeResolutionStrategy changeResolutionStrategy, Map mapCopy2OriginalObject) { @@ -35,64 +19,6 @@ protected FilterChangeDerivingView(BasicFilterView view, this.mapCopy2OriginalObject = mapCopy2OriginalObject; } - @Override - protected void setupReferenceState() { - originalStateViewResourceSet = new ResourceSetImpl(); - ResourceCopier.copyViewResources(view.getViewResourceSet().getResources(), originalStateViewResourceSet); - originalStateResourceMapping = new HashMap(); - for (Resource resource : view.getViewResourceSet().getResources()) { - Resource searchedResource = null; - for (Resource originalStateResource : originalStateViewResourceSet.getResources()) { - if (originalStateResource.getURI() == resource.getURI()) { - searchedResource = originalStateResource; - break; - } - } - if (searchedResource != null) { - originalStateResourceMapping.put(resource, searchedResource); - } else { - throw new NullPointerException(); - } - } - } - - public void commitChanges() { - view.checkNotClosed(); - - ArrayList changes = new ArrayList(); - Set allResources = new HashSet(originalStateResourceMapping.keySet()); - allResources.addAll(view.getViewResourceSet().getResources()); // consider newly added resources - List pathmapResources = new ArrayList(); - for (Resource resource : allResources) { - if (URIUtil.isPathmap(resource.getURI())) { - pathmapResources.add(resource); - } - } - Resource[] array = (Resource[]) allResources.stream().filter((Resource it) -> { - return URIUtil.isPathmap(it.getURI()); - }).toArray(); - for (Resource changedResource : array) { - VitruviusChange change = generateChange(changedResource, - originalStateResourceMapping.get(changedResource)); - changes.add(change); - } - CompositeContainerChange change = VitruviusChangeFactory.getInstance().createCompositeChange(changes); - - view.getViewType().commitViewChanges(this, change); - view.setViewChanged(false); - - // super.getRootObjects(); - - // ViewSource auf Super.RootObjects mappen; Änderungen von FilterModell über - // Mapping auf ViewSource und - // Mapping auf Super.RootObjects auf Super.RootObjects übertragen, anschließend - // Super.CommitChanges() aufrufen. - // Oder reicht das Übertragen auf die ViewSource? - } - - private FilterableView getViewAsFilterableView() { - return (FilterableView) view; - } public ResourceSet getViewResourceSet() { return view.getViewResourceSet(); @@ -112,4 +38,8 @@ public Map getMapCopy2OriginalObject() { public ResourceSet getNonFilteredViewResourceSet() { return getViewAsFilterableView().getNonFilteredViewResourceSet(); } + + private FilterableView getViewAsFilterableView() { + return (FilterableView) view; + } } diff --git a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java index ef8223ef6..28b4d2c6a 100644 --- a/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java +++ b/bundles/tools.vitruv.applications.viewfilter/src/tools/vitruv/applications/viewfilter/views/FilterChangeRecordingView.java @@ -17,7 +17,7 @@ import tools.vitruv.change.composite.recording.ChangeRecorder; import tools.vitruv.framework.views.ViewSelection; -//TODO nbr: Hier nicht ChangeRecordingView überschreiben, sondern eigen implementieren und Sichtbarkeiten in ChangeRecordingView zurücksetzen + public class FilterChangeRecordingView extends ChangeRecordingView implements FilterableView { private Map mapCopy2OriginalObject; @@ -30,7 +30,6 @@ protected FilterChangeRecordingView(BasicFilterView view, Map } - @Override public List> setupChangeRecorder() { ResourceSet filteredModelsInResourceSet = view.getViewResourceSet(); @@ -41,15 +40,7 @@ public List> setupChangeRecorder() { return changeRecorder.beginRecording(); } - - private ResourceSet copyResourceSet(ResourceSet resourceSetToBeCopied) { - ResourceSet resourceSetCopy = new ResourceSetImpl(); - ResourceCopier.copyViewResources(resourceSetToBeCopied.getResources(), resourceSetCopy); - return resourceSetCopy; - } - - - + @Override public void commitChanges() { view.checkNotClosed(); @@ -63,7 +54,6 @@ public void commitChanges() { } - private FilterableView getViewAsFilterableView() { return (FilterableView) view; } From 52adcd5e135c4f34ecfd91628c8458ba42c5163a Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Mon, 18 Mar 2024 08:22:54 +0100 Subject: [PATCH 60/62] - Removed an unnecessary dependency in pcmumlclass.tests --- .../META-INF/MANIFEST.MF | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF index 16d0187e2..5fba5d43d 100644 --- a/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.pcmumlclass.tests/META-INF/MANIFEST.MF @@ -18,8 +18,6 @@ Require-Bundle: tools.vitruv.testutils.vsum, edu.kit.ipd.sdq.activextendannotations, tools.vitruv.applications.testutility, org.palladiosimulator.pcm, - edu.kit.ipd.sdq.commons.util.emf, - slf4j.api;bundle-version="2.0.9", - org.emftext.language.java;bundle-version="1.4.1" + edu.kit.ipd.sdq.commons.util.emf Export-Package: tools.vitruv.applications.pcmumlclass.tests Bundle-Vendor: vitruv.tools From 7a34582e593d53cf30abcc343a010ab903f43944 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Mon, 18 Mar 2024 08:23:34 +0100 Subject: [PATCH 61/62] - Some automatic change in generated files of infostructure meta-model --- .../model/infostructuremodel.aird | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird b/bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird index c5ad78414..960a43122 100644 --- a/bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird +++ b/bundles/tools.vitruv.views.viewfilter.infostructure.model/model/infostructuremodel.aird @@ -1,30 +1,59 @@ - - + + infostructuremodel.ecore infostructuremodel.genmodel - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 2988a878ca4e39d96d7fdd6495e262873c6edac8 Mon Sep 17 00:00:00 2001 From: niklas5810 <83550711+niklas5810@users.noreply.github.com> Date: Mon, 18 Mar 2024 08:36:45 +0100 Subject: [PATCH 62/62] - Removed slf4j dependency in umljava-test plugin --- .../META-INF/MANIFEST.MF | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/tools.vitruv.applications.umljava.tests/META-INF/MANIFEST.MF b/tests/tools.vitruv.applications.umljava.tests/META-INF/MANIFEST.MF index 73b8196f0..e6792176d 100644 --- a/tests/tools.vitruv.applications.umljava.tests/META-INF/MANIFEST.MF +++ b/tests/tools.vitruv.applications.umljava.tests/META-INF/MANIFEST.MF @@ -20,8 +20,7 @@ Require-Bundle: tools.vitruv.applications.umljava, org.apache.log4j, org.emftext.language.java.resource.java, org.emftext.language.java.resource, - tools.vitruv.applications.testutility, - slf4j.api;bundle-version="2.0.9" + tools.vitruv.applications.testutility Bundle-ClassPath: ., target/dependency/json.jar Bundle-Vendor: vitruv.tools