Skip to content
Snippets Groups Projects
Commit 40e36a93 authored by Sebastian Bergemann's avatar Sebastian Bergemann
Browse files

Finish correct default expansion behavior of Model Element Navigator

Issue-ref: 4352
Issue-URL: af3#4352



Signed-off-by: default avatarSebastian Bergemann <bergemann@fortiss.org>
parent 50787e05
Branches
Tags
1 merge request!223Categories in the Model Elements Navigator shall be collapsed by default
DoubleClick.java a94d27299814a93b0d8914050a5da7378a7eccd1 GREEN
GenericNewMenu.java 7e0dd435cb5ca6d4b486235ec17eef3e5c7aa5f6 GREEN
LinkWithEditorPartListener.java c5ab74424378e7b158a805c4dd14fc03c8abeded GREEN
ModelElementsView.java bc97ed1edbfa4473d23cbbb71d16f8eb0249bb73 GREEN
ModelElementsView.java ea9b92e2b538a71275a19561633ae53cc5b397a5 YELLOW
NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN
NavigatorTreeContentComparator.java d9f1354cfdff78b104b28887d2397e5ca0e9755b GREEN
NavigatorTreeContentProvider.java 8162138aab09b2cf833cf5f90ff6ab1fc3edc4d8 GREEN
......
......@@ -131,7 +131,7 @@ public final class ModelElementsView extends FXViewPart {
}
/**
* Expands the {@link TreeItem}s that should be expanded due to their prototype attribute (if
* Expands the {@link TreeItem}s that should be expanded due to their (prototype) attribute (if
* they should be expanded by default) or because they were already manually expanded by the
* user before. This method works on the currently contained items of the current viewer.
* Therefore, the method should only be called after the viewer was updated (when its items are
......@@ -139,38 +139,29 @@ public final class ModelElementsView extends FXViewPart {
*/
private void expandCorrectItems() {
TreeItem<Object> rootItem = treeViewer.getControl().getRoot();
for(TreeItem<Object> topLevelChildItem : rootItem.getChildren()) {
// All top level items should be shown to have the possibility to manually expand them.
treeViewer.expandItem(topLevelChildItem);
expandCorrectChildrenRecursively(topLevelChildItem);
for(TreeItem<Object> topLevelItem : rootItem.getChildren()) {
possiblyExpandItemAndChildrenRecursively(topLevelItem);
}
}
/** Expands the correct children (and their children, etc.) of the given {@link TreeItem}. */
private void expandCorrectChildrenRecursively(TreeItem<Object> parentItem) {
for(TreeItem<Object> childItem : parentItem.getChildren()) {
Object child = childItem.getValue();
boolean expansionWanted = false;
if(child instanceof PrototypeCategory) {
PrototypeCategory parentCategory = ((PrototypeCategory)child).getParentCategory();
if(parentCategory.getExpandedByDefaultStatus()) {
expansionWanted = true;
}
}
if(child instanceof Prototype) {
Prototype prototype = ((Prototype)child);
// TODO: get parentCategory
// if(parentCategory.getExpandedByDefaultStatus()) {
// expansionWanted = true;
// }
}
if(expansionWanted) {
/**
* Expands the given {@link TreeItem} if it represents a {@link PrototypeCategory} that should
* be expanded. In case of expansion, continues checking the same for all the children of this
* category (recursively).
*/
private void possiblyExpandItemAndChildrenRecursively(TreeItem<Object> item) {
Object itemObject = item.getValue();
if(itemObject instanceof PrototypeCategory) {
PrototypeCategory category = (PrototypeCategory)itemObject;
if(category.getExpandedByDefaultStatus()) {
// Expand this category (must also be set for all its direct children, otherwise the
// children will not show up in the expansion).
treeViewer.expandItem(item);
for(TreeItem<Object> childItem : item.getChildren()) {
treeViewer.expandItem(childItem);
possiblyExpandItemAndChildrenRecursively(childItem);
}
}
expandCorrectChildrenRecursively(childItem);
}
}
......
......@@ -3,6 +3,6 @@ ConstraintViolationBase.java ec66973ab2183623f0cd4a85c59c886dddad6cf6 GREEN
DialogMessage.java 8420640e999e4fb15fa644333e5d71e1d16c2559 GREEN
ElementCompositorBase.java 7a445e5adde11878fe0515baca8b915287149b28 GREEN
MultiViolationConstraintCheckerBase.java 30886a94c99cf8948f64401b1db821abe06e1e6c GREEN
PrototypeProviderBase.java 7418c494275bf75318504de65e82035535b9e9d8 GREEN
PrototypeProviderBase.java 5030720afa20243bf497a216187767537cd9117e YELLOW
TransformationContextChainBase.java 1ef37880ab275778c563928e80ba378fec964cb6 GREEN
TransformationProviderBase.java 9e91100cc1f2c8fbd8d41af55aedfea34e02ff71 GREEN
......@@ -166,7 +166,7 @@ public abstract class PrototypeProviderBase implements IPrototypeProvider {
/**
* Sets the status of the given prototype category whether it should be expanded (true) or not
* (false) by default in Model Elements Navigator. If the category does not exist, an
* (false) by default in the Model Elements Navigator. If the category does not exist, an
* {@link IllegalArgumentException} is thrown.
*/
protected void setPrototypeCategoryExpandedByDefaultStatus(String category,
......
......@@ -8,7 +8,7 @@ LogMessage.java 14204ed9d51b356f50be52362247cfbbe0cbd5c7 GREEN
ModelElementTransformationContext.java 5a41bd3a75ce434c3174d50d2fdfab28b66f09f2 GREEN
ModelStorageError.java 2aef480044047e960e64811111a7f27310011cc2 GREEN
Prototype.java f4b13f86b7511edacc138053ffb80cecbac70868 GREEN
PrototypeCategory.java 6aa849290948b1fd9608ad06d7cca2ec6ff76805 GREEN
PrototypeCategory.java ddbfe12adc5c428a25eebcf69e1f4772cfc164a0 YELLOW
TransformationProviderChain.java 67ec6d0b4c23d295323572649606d79f3b897437 GREEN
TutorialAtomicStep.java 09c0d6597d542b431b5bbdc790ee9e533d9f77fb GREEN
TutorialCompositeStep.java cc61c2e86eff310762acac4d023fd709507355c8 GREEN
......
......@@ -27,12 +27,6 @@ import java.util.Set;
*/
public class PrototypeCategory {
/** The default value of 'categoryPriority' attribute. */
public final static int CATEGORY_PRIORITY_DEFAULT_VALUE = 0;
/** The default value of 'expandedByDefault' attribute. */
public final static boolean EXPANDED_BY_DEFAULT_DEFAULT_VALUE = false;
/** Stores the name of the category. */
private final String categoryName;
......@@ -57,8 +51,8 @@ public class PrototypeCategory {
/** Constructor. */
public PrototypeCategory(String category) {
categoryName = category;
categoryPriority = CATEGORY_PRIORITY_DEFAULT_VALUE;
expandedByDefault = EXPANDED_BY_DEFAULT_DEFAULT_VALUE;
categoryPriority = 0;
expandedByDefault = false;
}
/** Returns the priority of the category. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment