From e0656490adf10e4440e526b541fbffca20be369d Mon Sep 17 00:00:00 2001 From: Phillipus Date: Sat, 18 Jan 2025 17:32:08 +0000 Subject: [PATCH] 4 --- .../views/tree/search/SearchFilter.java | 60 ++++++++----------- .../views/tree/search/SearchWidget.java | 4 +- .../views/tree/search/messages.properties | 4 +- 3 files changed, 29 insertions(+), 39 deletions(-) diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/SearchFilter.java b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/SearchFilter.java index 22bb5c778..5816ea857 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/SearchFilter.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/SearchFilter.java @@ -129,8 +129,7 @@ public boolean matchesFilter(Object element) { if(isFilteringName() || isFilteringDocumentation() || isFilteringPropertyKeys() || isFilteringPropertyValues()) { show &= (isFilteringName() && shouldShowObjectWithName(element)) || (isFilteringDocumentation() && shouldShowObjectWithDocumentation(element)) - || (isFilteringPropertyValues() && shouldShowPropertyValue(element)) - || (isFilteringPropertyKeys() && shouldShowPropertyKey(element)); + || ((isFilteringPropertyKeys() || isFilteringPropertyValues()) && shouldShowObjectWithProperty(element)); } return show; @@ -140,6 +139,21 @@ private boolean shouldShowConcept(Object element) { return fConceptsFilter.contains(((EObject)element).eClass()); } + private boolean shouldShowSpecialization(Object element) { + if(element instanceof IArchimateConcept concept) { + for(IProfile profile : concept.getProfiles()) { + for(IProfile p : fSpecializationsFilter) { + // Could be matching Profile name/class in different models + if(ArchimateModelUtils.isMatchingProfile(p, profile)) { + return true; + } + } + } + } + + return false; + } + private boolean shouldShowObjectWithName(Object element) { if(element instanceof INameable nameable) { String name = StringUtils.safeString(nameable.getName()); @@ -164,43 +178,19 @@ private boolean shouldShowObjectWithDocumentation(Object element) { return false; } - private boolean shouldShowSpecialization(Object element) { - if(element instanceof IArchimateConcept concept) { - for(IProfile profile : concept.getProfiles()) { - for(IProfile p : fSpecializationsFilter) { - // Could be matching Profile name/class in different models - if(ArchimateModelUtils.isMatchingProfile(p, profile)) { - return true; - } - } - } - } - - return false; - } - - private boolean shouldShowPropertyKey(Object element) { - if(element instanceof IProperties properties) { - for(IProperty property : properties.getProperties()) { - if(fPropertyKeyFilter.contains(property.getKey())) { - // If there is search text filter on that, otherwise show the element if the property key is selected - return hasSearchText() && isFilteringPropertyValues() ? matchesString(property.getValue()) : true; - } - } - } - - return false; - } - - private boolean shouldShowPropertyValue(Object element) { + private boolean shouldShowObjectWithProperty(Object element) { if(element instanceof IProperties properties) { for(IProperty property : properties.getProperties()) { - // If we are filtering on property keys match on property key and value + // If filtering on property keys if(isFilteringPropertyKeys()) { - return fPropertyKeyFilter.contains(property.getKey()) && matchesString(property.getValue()); + // And this property has that filtered key + if(fPropertyKeyFilter.contains(property.getKey())) { + // If filtering on property value match on that else show the element + return isFilteringPropertyValues() ? matchesString(property.getValue()) : true; + } } - // If we are not filtering on property keys match on value (equivalent to all property kesy selected) - if(matchesString(property.getValue())) { + // Else match on property value + else if(matchesString(property.getValue())) { return true; } } diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/SearchWidget.java b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/SearchWidget.java index 7f135397a..b0393e221 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/SearchWidget.java +++ b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/SearchWidget.java @@ -259,7 +259,7 @@ public void run() { refreshTree(); }; }; - fActionFilterPropertyValues.setToolTipText("Search in Property Values"); + fActionFilterPropertyValues.setToolTipText("Filter on Property Values"); dropDownAction.add(fActionFilterPropertyValues); // Property Keys @@ -277,7 +277,7 @@ public void run() { } } }; - actionProperties.setToolTipText("Search in Property Keys"); + actionProperties.setToolTipText("Select Properties to filter"); dropDownAction.add(actionProperties); dropDownAction.add(new Separator()); diff --git a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/messages.properties b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/messages.properties index bcf253ce2..1f716725d 100644 --- a/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/messages.properties +++ b/com.archimatetool.editor/src/com/archimatetool/editor/views/tree/search/messages.properties @@ -1,5 +1,5 @@ SearchWidget_0=Name -SearchWidget_1=Search in Name +SearchWidget_1=Filter on Name SearchWidget_10=Implementation && Migration SearchWidget_11=Relations SearchWidget_12=Show All Folders @@ -12,7 +12,7 @@ SearchWidget_18=Match Case SearchWidget_19=Match Regular Expression SearchWidget_2=Documentation SearchWidget_20=Invalid Regular Expression -SearchWidget_3=Search in Documentation +SearchWidget_3=Filter on Documentation SearchWidget_4=Filter Options SearchWidget_5=Properties... SearchWidget_6=Business