Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Views for instance-filtering and information-abstracting views #289

Draft
wants to merge 64 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
1d660ec
Initial commit of half-working modified code
niklas5810 Dec 1, 2023
0256297
Added more complex UML model creation and first simple filter methods
niklas5810 Dec 6, 2023
4186195
forgot some files
niklas5810 Dec 6, 2023
ad150e8
Added large model to viewtest
niklas5810 Dec 15, 2023
e63f488
Merge branch 'main' of github.com:niklas5810/Vitruv-CaseStudies into …
niklas5810 Dec 15, 2023
da538ce
- some further approaches for filtering
niklas5810 Dec 25, 2023
d51f4ea
- Introduced functionality to FilterSupportingViewElementSelector to …
niklas5810 Dec 28, 2023
b082263
It is now possible to create a view with just the selected UML objects
niklas5810 Dec 29, 2023
2d8b646
Structural changes to make update of view possible
niklas5810 Dec 30, 2023
f828e70
- Translated FirstTest.xtend into BasicViewTest.java, minor fixes
niklas5810 Jan 4, 2024
eaa780a
improved selection of individual elements as preparation
niklas5810 Jan 4, 2024
1618324
Filtering View is now updated in case the underlying model is modified
niklas5810 Jan 4, 2024
270d94e
- First steps for pcm support
niklas5810 Jan 12, 2024
5f481f8
Save progress to make update and informationView work
niklas5810 Jan 20, 2024
7246f81
Fixed update-mechanism for BasicFilterView
niklas5810 Jan 26, 2024
941e31f
Some code clean ups
niklas5810 Jan 26, 2024
f4530c5
Added some infrastructure for testing
niklas5810 Jan 27, 2024
433ec21
Adjusted information view to fix of filtering views
niklas5810 Jan 29, 2024
4842901
Fixed getRoot() for BasicFilterView and BasicInformationFilterView
niklas5810 Feb 2, 2024
395431d
Added regression tests for instance filtering
niklas5810 Feb 2, 2024
1e7525c
Added test for correct informationView behaviour
niklas5810 Feb 2, 2024
cad4f2d
Added JavaDoc and some minor code quality improvements
niklas5810 Feb 2, 2024
e6064c0
Added tests for view modification
niklas5810 Feb 2, 2024
45bae4d
Made InformationView implementation more generic
niklas5810 Feb 2, 2024
1d83e1a
Current state
niklas5810 Feb 27, 2024
eed9f64
- Implemented transformation from FilterResourceSet to ViewResourceSet
niklas5810 Feb 28, 2024
7627175
Added new regression test for modification of filter view
niklas5810 Feb 28, 2024
c13eb53
Refactor: More distinctive names for methods of FilteredView
niklas5810 Mar 2, 2024
56da547
Introduced AbstractBasicView and corresponding interface
niklas5810 Mar 2, 2024
d2f21c4
Renamed modules
niklas5810 Mar 2, 2024
29e7bb5
Merge branch 'vitruv-tools:main' into main
niklas5810 Mar 2, 2024
5062b2e
Code quality improvements, refactor of informationView
niklas5810 Mar 2, 2024
342f5a3
- Renamed some methods to improve understandability
niklas5810 Mar 2, 2024
b4e7158
Some code cleanups, reverted accidental modification in cbs.testutils
niklas5810 Mar 6, 2024
3f6e0f0
- removed local files from git
niklas5810 Mar 6, 2024
8ac4574
- updated InstanceFilterTest to match new functionality removed file
niklas5810 Mar 6, 2024
c7899f9
- removed unnecessary if clause
niklas5810 Mar 6, 2024
4be9d78
Changed name of informationStructureModel package and added it to repo
niklas5810 Mar 6, 2024
906d432
minor code improvements, removed InformationView interface
niklas5810 Mar 7, 2024
28254a7
Removed Marker-Interfaces:
niklas5810 Mar 7, 2024
9e5f9f8
Organized imports for tools.vitruv.applications.viewtest
niklas5810 Mar 7, 2024
1bcf17b
Organized imports for tools.vitruv.applications.viewfilter.tests
niklas5810 Mar 7, 2024
d525bc0
- Removed old class used for playground testing
niklas5810 Mar 7, 2024
62889a5
- Fulfilled some TODOs, added JavaDoc
niklas5810 Mar 8, 2024
ff82f11
moved plugin to correct directory. Updated .gitignore
niklas5810 Mar 9, 2024
1f58dcb
Resolved some TODOs. Added JavaDoc
niklas5810 Mar 9, 2024
5100b9e
- Some minor code cleanups
niklas5810 Mar 9, 2024
45ec52e
Replaced System.out.prints for errors by Exceptions
niklas5810 Mar 9, 2024
3914d89
added .classpath files to repo
niklas5810 Mar 12, 2024
0ba7116
Added old classpath files
niklas5810 Mar 12, 2024
63f1731
added missing classpath files
niklas5810 Mar 12, 2024
b6f9563
Renamed viewtest plugin to viewfilter plugin
niklas5810 Mar 12, 2024
ad3d0f4
Removed unnecessary export of test-project
niklas5810 Mar 12, 2024
c9aa4a1
Removed copied test resources
niklas5810 Mar 12, 2024
0fe57a3
Removed BasicViewFilterTest and renamed ViewTestFactory
niklas5810 Mar 12, 2024
174c630
reverted some temporary changes
niklas5810 Mar 12, 2024
097b8ed
added temporary deleted file
niklas5810 Mar 12, 2024
c1deeb4
Removed unnecessary interfaces
niklas5810 Mar 12, 2024
b761b2a
Removed "niklas" from code, removed unnecessary class
niklas5810 Mar 12, 2024
7d940a4
Added javadoc, resolved todos
niklas5810 Mar 12, 2024
cc1bb80
Some cleanups, some javadoc
niklas5810 Mar 12, 2024
52adcd5
- Removed an unnecessary dependency in pcmumlclass.tests
niklas5810 Mar 18, 2024
7a34582
- Some automatic change in generated files of infostructure meta-model
niklas5810 Mar 18, 2024
2988a87
- Removed slf4j dependency in umljava-test plugin
niklas5810 Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tmp/

# Genenerated Files
src-gen/
*.polyglot.META-INF

# Xtend
xtend-gen/
Expand All @@ -23,4 +24,5 @@ target/
EvaluationData
*.DS_Store
*.polyglot
*.pom.tycho
*.pom.tycho
*.settings/
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</classpath>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</classpath>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</classpath>

This file was deleted.

2 changes: 1 addition & 1 deletion bundles/tools.vitruv.applications.pcmjava/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</classpath>

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion bundles/tools.vitruv.applications.umljava/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</classpath>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
</classpath>

This file was deleted.

9 changes: 9 additions & 0 deletions bundles/tools.vitruv.applications.viewfilter/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="xtend-gen"/>
<classpathentry kind="src" path="src-gen/"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
34 changes: 34 additions & 0 deletions bundles/tools.vitruv.applications.viewfilter/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tools.vitruv.views.viewfilter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Vitruv Viewfilter Application
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
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,
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,
tools.vitruv.applications.viewfilter.util.framework.selectors
Import-Package: tools.vitruv.views.viewfilter.infostructure.model.infostructuremodel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source.. = src/,\
src-gen/,\
xtend-gen/
output.. = target/classes/
bin.includes = META-INF/,\
plugin.xml,\
.
16 changes: 16 additions & 0 deletions bundles/tools.vitruv.applications.viewfilter/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>

<!--
-->

<plugin>
<extension
id="viewfilterApplication"
name="Viewfilter Application"
point="tools.vitruv.framework.applications.application">
<application
class="tools.vitruv.applications.viewfilter.viewfilterApplication"></application>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package tools.vitruv.application.viewfilter.informationview.internal;


import java.util.List;

import org.eclipse.emf.ecore.EObject;

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;

/**
* 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<EObject> roots) {
SingleInformation createSingleInformation = InfostructuremodelFactory.eINSTANCE.createSingleInformation();
createSingleInformation.setTitle(getTitle());
int count = 0;

for (EObject root : roots) {
List<EObject> allElements = ViewFilterHelper.convertTreeIterator2List(root.eAllContents());

for (EObject element : allElements) {
if (takeElementIntoAccount(element)) {
count++;
}
}
}

createSingleInformation.setValue(count);
return createSingleInformation;
}


/**
* 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();


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package tools.vitruv.application.viewfilter.informationview.internal;

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";

@Override
protected boolean takeElementIntoAccount(EObject object) {
if (object instanceof org.eclipse.uml2.uml.Class) {
return true;
} else {
return false;
}
}

@Override
protected String getTitle() {
return NUMBER_OF_ELEMENTS;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +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 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 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 a given model for instance.
* The actual transformation depends on the actual implementation of this method
*
* @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(List<EObject> roots);

}
Original file line number Diff line number Diff line change
@@ -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<EObject> convertTreeIterator2List(TreeIterator<EObject> content) {
List<EObject> list = new LinkedList<EObject>();
while(content.hasNext()) {
list.add(content.next());
}
return list;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package tools.vitruv.applications.viewfilter.informationview.views;

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 tools.vitruv.application.viewfilter.informationview.internal.InformationViewTransformator;
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;
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;
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 {

private final InformationViewTransformator infoTransformator;


public BasicInformationFilterView(ViewCreatingViewType<? extends ViewSelector, HierarchicalId> viewType,
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();
}


@Override
protected void updateRootAndSelectedElements(ModifiableViewSelection selection) {
if (selection == null) {
throw new NullPointerException("selection is null");
}
if (infoTransformator == null) {
//method has been called as part of constructor and before the info transformator could be set
return;
}
InformationStructure informationStructure = InfostructuremodelFactory.eINSTANCE.createInformationStructure();
EList<SingleInformation> singleinformationList = informationStructure.getSingleinformation();

for(EObject root : selection.getSelectableElements()) {
if (selection.isSelected(root)) {
List<EObject> rootList = new ArrayList();
rootList.add(root);
SingleInformation transformResult = infoTransformator.transform(rootList);
if (transformResult != null) {
singleinformationList.add(transformResult);
}
}
}

List<EObject> selectionList = new ArrayList();
selectionList.add(informationStructure);

setRootObjects(selectionList);

ElementViewSelection elementViewSelection = new ElementViewSelection(selectionList);
elementViewSelection.setSelected(informationStructure, true);
setSelection(elementViewSelection);
}

}
Loading