Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-result.pngbin24462 -> 19417 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-search.pngbin52346 -> 64011 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/My-results.pngbin20837 -> 0 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/OCL.pngbin0 -> 48710 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/a-results.pngbin0 -> 21067 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/a-search.pngbin0 -> 65320 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/advanced_search.pngbin0 -> 85209 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_result.pngbin0 -> 15718 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_search.pngbin0 -> 74602 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-result.pngbin13045 -> 25234 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-search.pngbin51042 -> 62471 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/filter.pngbin15125 -> 20443 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/my-filtered.pngbin13533 -> 15365 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/query_kind.pngbin0 -> 22647 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_result.pngbin0 -> 13549 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_search.pngbin0 -> 80098 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model1.pngbin4884 -> 16150 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model2.pngbin5550 -> 0 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.html6
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.mediawiki76
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search_kind.pngbin0 -> 79102 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/simple_search.pngbin0 -> 76829 bytes
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java8
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java16
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java50
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java43
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java18
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java14
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java33
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java172
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java24
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java120
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java9
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java40
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/META-INF/MANIFEST.MF1
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AbstractResultEntry.java64
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AttributeMatch.java79
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ModelElementMatch.java33
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ResultEntry.java43
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ViewerMatch.java32
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java38
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/utils/MatchUtils.java29
42 files changed, 607 insertions, 341 deletions
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-result.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-result.png
index a7f04c43ce6..6b5e8b1d262 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-result.png
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-result.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-search.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-search.png
index 5551cecc3e9..bd99157a3c7 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-search.png
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/C-search.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/My-results.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/My-results.png
deleted file mode 100644
index 45f669effa7..00000000000
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/My-results.png
+++ /dev/null
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/OCL.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/OCL.png
new file mode 100644
index 00000000000..8aa959e3ea7
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/OCL.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/a-results.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/a-results.png
new file mode 100644
index 00000000000..9669ff43c22
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/a-results.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/a-search.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/a-search.png
new file mode 100644
index 00000000000..3e3b7542f8e
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/a-search.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/advanced_search.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/advanced_search.png
new file mode 100644
index 00000000000..074447082bd
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/advanced_search.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_result.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_result.png
new file mode 100644
index 00000000000..38b096c9671
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_result.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_search.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_search.png
new file mode 100644
index 00000000000..abf3be5c4a5
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_search.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-result.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-result.png
index bd270b12f26..0039b81f4fb 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-result.png
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-result.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-search.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-search.png
index 0bb2be2f5ae..fa6b2ef026d 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-search.png
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/comment-search.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/filter.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/filter.png
index 9e344223af6..87c456b6b46 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/filter.png
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/filter.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/my-filtered.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/my-filtered.png
index bb18238fda0..50a22cd3d3c 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/my-filtered.png
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/my-filtered.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/query_kind.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/query_kind.png
new file mode 100644
index 00000000000..2ec1ff8e877
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/query_kind.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_result.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_result.png
new file mode 100644
index 00000000000..93156cf8603
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_result.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_search.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_search.png
new file mode 100644
index 00000000000..0d767cf2bf7
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_search.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model1.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model1.png
index ae3d18ce947..6c540f51972 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model1.png
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model1.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model2.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model2.png
deleted file mode 100644
index 0696b6f728d..00000000000
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-model2.png
+++ /dev/null
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.html b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.html
index 17fdd2b183c..9d521d3272d 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.html
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.html
@@ -1,2 +1,6 @@
-<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body><p>In this documentation, we will use two different UML models to illustrate the search features. </p><p>Model 1:</p><p><img border="0" src="search-model1.png"/></p><p>Model 2 :</p><p><img border="0" src="search-model2.png"/></p><h1 id="Search_elements">Search elements</h1><p>The search feature of Papyrus helps the user to find elements in the models using a string pattern. It is able to search in string attributes of model elements. </p><p>The search dialog is illustrated in the following image: </p><p><img border="0" src="papyrus-search.png"/> </p><ul><li>The user can specify the string pattern he/she is looking for in the A area. <ul><li>Check the "Case sensitive" if case must be considered. </li><li>The user may also want to use regular expression to express the query. Then check "Regular expression" button. The regular expression must respect Java Regex</li></ul></li><li>The user can filter the types of elements to search the string pattern in by selecting the metaclasses in area B whose instances will be analyzed. </li><li>By default, the search feature will only search in the name attribute of instances of UML::NamedElement. By checking the button in area C, all string attributes will be analyzed</li><li>If button in area D is check, string attributes of stereotypes applied to model elements will be analyzed too. </li></ul><p>For instance, the following search: </p><p><img border="0" src="C-search.png"/></p><p>will provide the following results: </p><p><img border="0" src="C-result.png"/></p><p>Note that the comment is not returned because we were note looking for all string attributes. </p><p>However, this search:</p><p><img border="0" src="comment-search.png"/></p><p>will return : </p><p><img border="0" src="comment-result.png"/></p><h1 id="Replace_String">Replace String</h1><p>Should the user want to replace the matches of your search with another string, he/she may click on the "Replace" button in the search dialog. A new dialog will popup:</p><p><img border="0" src="replace.png"/></p><p>As mentioned on the dialog, the replace action is mostly undoable. Matches that are found in a resource that is not opened in an editor will be replaced and will be save so that the user cannot undo the modification. </p><h1 id="Filter">Filter</h1><p>The user can filter the results of the search by selecting the types of the elements he/she wants to show.</p><p>For instance, on the following search: </p><p><img border="0" src="my-search.png"/></p><p>the user may filter the results by clicking on the icon identified in a red rectangle in the following picture: </p><p><img border="0" src="My-results.png"/></p><p>this will open a new dialog where the user can select the metaclasses he/she want to show: </p><p><img border="0" src="filter.png"/></p><p>then, the result page will show only the matches of the selected type: </p><p><img border="0" src="my-filtered.png"/></p><p>If the user wants to remove this filtering, he/she may click on the Filters button as illustrated in previous picture. This will open the following dialog: </p><p><img border="0" src="select-filters.png"/></p><p><hr/>
+<?xml version='1.0' encoding='utf-8' ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body><p>In this documentation, we will use this UML model to illustrate the search features. </p><p><img border="0" src="search-model1.png"/></p><h1 id="Search_elements">Search elements</h1><p>The search feature of Papyrus helps the user to find elements in the models. The user can choose between a text search and an OCL search.</p><p>As it is shown in the following image the user chooses the query kind he wants to use: </p><p><img border="0" src="query_kind.png"/> </p><h1 id="Text_search">Text search</h1><p>The user can do a simple search or an advanced search.
+The user makes his choice in the A area of the following image which represents the text search dialog.</p><p><img border="0" src="search_kind.png"/> </p><h2 id="Simple_search">Simple search</h2><p>The following image illustrates a simple text search dialog:</p><p><img border="0" src="simple_search.png"/> </p><ul><li>The user can specify the string pattern he/she is looking for in the A area. <ul><li>Check the "Case sensitive" if case must be considered. </li><li>The user may also want to use regular expression to express the query. Then check "Regular expression" button. The regular expression must respect Java Regex.</li></ul></li><li>The user chooses whether he wants to search only in the name attribute of instances of UML::NamedElement or in all string attributes of instances of UML metaClasses, in B area.</li></ul><p>For instance, the following search: </p><p><img border="0" src="C-search.png"/></p><p>will provide the following results: </p><p><img border="0" src="C-result.png"/></p><p>The comment is not returned because we were note looking for all string attributes. </p><p>However, this search:</p><p><img border="0" src="comment-search.png"/></p><p>will return : </p><p><img border="0" src="comment-result.png"/></p><h2 id="Advanced_search">Advanced search</h2><p>The following image shows the advanced text search dialog.</p><p><img border="0" src="advanced_search.png"/></p><ul><li>As in the simple search the user can specify the string pattern he/she is looking for, and may indicate if he uses regular expression or if he wants to consider case, in the A area. </li><li>The user can filter the types of elements to search the string pattern in by selecting the UML metaClasses or applied stereotypes in area B . He can also choose in which attributes he wants to do the research.</li><li>In the C area, the user can select all subelements of the actual selected element. For example, if the user selects "NamedElement" and clicks on "Select subelements",all metaClasses which inherit of UML::NamedElement will be checked. If the name attribute of "NamedElement" is checked and the user selects "NamedElement" and then clicks on "Select subelements",all instances of UML::NamedElement and their name attribute will be checked.</li></ul><p>In the following image we search the pattern "my" in the attribute body of the metaClass "Comment". The research will give us all the instances of "Comment" having an attribute body matching with the string pattern. </p><p><img border="0" src="body_search.png"/></p><p>The result will be</p><p><img border="0" src="body_result.png"/></p><p>If the user select a stereotype or an UML metaClass without indicating a string pattern, the research will give him all the instances of the metaClasses he checked and all the elements having the applied stereotypes he checked.</p><p>For example the result of this research:</p><pre><img border="0" src="requirement_search.png"/>
+</pre><p>will be</p><pre><img border="0" src="requirement_result.png"/>
+</pre><h1 id="OCL_search">OCL search</h1><p>The following image shows an OCL search dialog</p><p><img border="0" src="OCL.png"/></p><p>The user writes his OCL query in the A area.
+The scope must be "Selected resources" if the user wants to do this kind of query.</p><h1 id="Replace_String">Replace String</h1><p>Should the user want to replace the matches of your search with another string, he/she may click on the "Replace" button in the search dialog. A new dialog will popup:</p><p><img border="0" src="replace.png"/></p><p>As mentioned on the dialog, the replace action is mostly undoable. Matches that are found in a resource that is not opened in an editor will be replaced and will be save so that the user cannot undo the modification. </p><h1 id="Filter">Filter</h1><p>The user can filter the results of the search by selecting the types of the elements he/she wants to show.</p><p>For instance, on the following search (we use the model 1): </p><p><img border="0" src="a-search.png"/></p><p>the user may filter the results by clicking on the icon identified in a red rectangle in the following picture: </p><p><img border="0" src="a-results.png"/></p><p>this will open a new dialog where the user can select the metaclasses he/she want to show: </p><p><img border="0" src="filter.png"/></p><p>then, the result page will show only the matches of the selected type: </p><p><img border="0" src="my-filtered.png"/></p><p>If the user wants to remove this filtering, he/she may click on the Filters button as illustrated in previous picture. This will open the following dialog: </p><p><img border="0" src="select-filters.png"/></p><p><hr/>
This work is developed by <a href="http://www-list.cea.fr">CEA LIST</a> and sponsored by <a href="http://www.ericsson.com">Ericsson</a> in the context of Polarsys <a href="http://wiki.eclipse.org/Polarsys">http://wiki.eclipse.org/Polarsys</a></p></body></html> \ No newline at end of file
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.mediawiki b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.mediawiki
index bfe8d54c50c..2c1b8aa202a 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.mediawiki
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.mediawiki
@@ -1,26 +1,30 @@
-In this documentation, we will use two different UML models to illustrate the search features.
-
-Model 1:
+In this documentation, we will use this UML model to illustrate the search features.
[[image:search-model1.png]]
-Model 2 :
+=Search elements=
+The search feature of Papyrus helps the user to find elements in the models. The user can choose between a text search and an OCL search.
-[[image:search-model2.png]]
+As it is shown in the following image the user chooses the query kind he wants to use:
-=Search elements=
-The search feature of Papyrus helps the user to find elements in the models using a string pattern. It is able to search in string attributes of model elements.
+[[image:query_kind.png]]
+
+=Text search=
+
+The user can do a simple search or an advanced search.
+The user makes his choice in the A area of the following image which represents the text search dialog.
-The search dialog is illustrated in the following image:
+[[image:search_kind.png]]
-[[image:papyrus-search.png]]
+==Simple search==
+The following image illustrates a simple text search dialog:
+
+[[image:simple_search.png]]
* The user can specify the string pattern he/she is looking for in the A area.
** Check the "Case sensitive" if case must be considered.
-** The user may also want to use regular expression to express the query. Then check "Regular expression" button. The regular expression must respect Java Regex
-* The user can filter the types of elements to search the string pattern in by selecting the metaclasses in area B whose instances will be analyzed.
-* By default, the search feature will only search in the name attribute of instances of UML::NamedElement. By checking the button in area C, all string attributes will be analyzed
-* If button in area D is check, string attributes of stereotypes applied to model elements will be analyzed too.
+** The user may also want to use regular expression to express the query. Then check "Regular expression" button. The regular expression must respect Java Regex.
+*The user chooses whether he wants to search only in the name attribute of instances of UML::NamedElement or in all string attributes of instances of UML metaClasses, in B area.
For instance, the following search:
@@ -30,7 +34,7 @@ will provide the following results:
[[image:C-result.png]]
-Note that the comment is not returned because we were note looking for all string attributes.
+The comment is not returned because we were note looking for all string attributes.
However, this search:
@@ -40,6 +44,44 @@ will return :
[[image:comment-result.png]]
+==Advanced search==
+The following image shows the advanced text search dialog.
+
+[[image:advanced_search.png]]
+
+* As in the simple search the user can specify the string pattern he/she is looking for, and may indicate if he uses regular expression or if he wants to consider case, in the A area.
+* The user can filter the types of elements to search the string pattern in by selecting the UML metaClasses or applied stereotypes in area B . He can also choose in which attributes he wants to do the research.
+* In the C area, the user can select all subelements of the actual selected element. For example, if the user selects "NamedElement" and clicks on "Select subelements",all metaClasses which inherit of UML::NamedElement will be checked. If the name attribute of "NamedElement" is checked and the user selects "NamedElement" and then clicks on "Select subelements",all instances of UML::NamedElement and their name attribute will be checked.
+
+
+In the following image we search the pattern "my" in the attribute body of the metaClass "Comment". The research will give us all the instances of "Comment" having an attribute body matching with the string pattern.
+
+[[Image:body_search.png]]
+
+The result will be
+
+[[Image:body_result.png]]
+
+
+If the user select a stereotype or an UML metaClass without indicating a string pattern, the research will give him all the instances of the metaClasses he checked and all the elements having the applied stereotypes he checked.
+
+For example the result of this research:
+
+ [[Image:requirement_search.png]]
+
+will be
+
+ [[Image:requirement_result.png]]
+
+=OCL search=
+
+The following image shows an OCL search dialog
+
+[[Image:OCL.png]]
+
+The user writes his OCL query in the A area.
+The scope must be "Selected resources" if the user wants to do this kind of query.
+
=Replace String=
Should the user want to replace the matches of your search with another string, he/she may click on the "Replace" button in the search dialog. A new dialog will popup:
@@ -51,13 +93,13 @@ As mentioned on the dialog, the replace action is mostly undoable. Matches that
=Filter=
The user can filter the results of the search by selecting the types of the elements he/she wants to show.
-For instance, on the following search:
+For instance, on the following search (we use the model 1):
-[[image:my-search.png]]
+[[image:a-search.png]]
the user may filter the results by clicking on the icon identified in a red rectangle in the following picture:
-[[image:My-results.png]]
+[[image:a-results.png]]
this will open a new dialog where the user can select the metaclasses he/she want to show:
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search_kind.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search_kind.png
new file mode 100644
index 00000000000..ebb7fb584bc
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search_kind.png
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/simple_search.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/simple_search.png
new file mode 100644
index 00000000000..8ab34b99fdd
--- /dev/null
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/simple_search.png
Binary files differ
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java
index c524bf201a9..a429c3d292e 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java
@@ -190,13 +190,19 @@ public class Messages extends NLS {
public static String TypesMatchFilter_2;
public static String TypesMatchFilter_3;
+
public static String PapyrusSearchPage_lblResearchKind_text;
+
public static String PapyrusSearchPage_txtSearchKind_text;
- public static String PapyrusSearchPage_group_text;
+
public static String PapyrusSearchPage_btnCheckButton_text;
+
public static String PapyrusSearchPage_btnGg_text;
+
public static String PapyrusSearchPage_btnRefreshTypes_text;
+
public static String PapyrusSearchPage_btnRefreshTypes_text_1;
+
public static String PapyrusSearchPage_btnNewButton_text;
static {
// initialize resource bundle
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java
index 443b15ecd27..1904b7e52fc 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java
@@ -147,12 +147,12 @@ public class ReplaceDialog extends Dialog {
}
private void change(AttributeMatch match) {
- if(match.getTarget() instanceof EObject) {
+ if(match.getSource() instanceof EObject) {
- EObject target = (EObject)match.getTarget();
+ EObject target = (EObject)match.getSource();
- if(match.getSource() instanceof EAttribute) {
- Object value = target.eGet((EAttribute)match.getSource());
+ if(match.getMetaAttribute() instanceof EAttribute) {
+ Object value = target.eGet((EAttribute)match.getMetaAttribute());
if(value != null) {
if(value instanceof String) {
String originalvalue = (String)value;
@@ -160,12 +160,12 @@ public class ReplaceDialog extends Dialog {
String newValue = computeReplacementString(pattern, originalvalue, replaceText.getText());
- target.eSet((EAttribute)match.getSource(), newValue);
+ target.eSet((EAttribute)match.getMetaAttribute(), newValue);
}
}
- } else if(match.getSource() instanceof Property) {
- Property source = (Property)match.getSource();
+ } else if(match.getMetaAttribute() instanceof Property) {
+ Property source = (Property)match.getMetaAttribute();
Class containingClass = source.getClass_();
if(containingClass instanceof Stereotype) {
if(target instanceof Element) {
@@ -216,7 +216,7 @@ public class ReplaceDialog extends Dialog {
if(match instanceof AttributeMatch) {
final AttributeMatch attributeMatch = (AttributeMatch)match;
- EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(attributeMatch.getTarget());
+ EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(attributeMatch.getSource());
Object element = match.getElement();
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java
index 71b73a18e19..a8a1b2b84e3 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java
@@ -363,7 +363,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
}
- boolean test = ((Stereotype)parentElement.getElement()).isAbstract();
+
participantsList.put(parentElement, attributeList);
@@ -388,9 +388,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
protected void createAdvancedSearch() {
-
-
-
participantTypesTree = new CheckBoxFilteredTree(advancedSearchComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE, new PatternFilter(), true);
participantTypesTree.setLayout(new GridLayout());
GridData chechboxTreeViewerGridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
@@ -420,9 +417,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
participantManipualtionComposite.setLayout(new GridLayout(1, false));
participantManipualtionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
-
-
-
Button btnSelectSub = new Button(participantManipualtionComposite, SWT.PUSH);
btnSelectSub.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnSelectSub.setText(Messages.PapyrusSearchPage_14);
@@ -520,7 +514,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
});
-
participantTypesTreeViewer.setInput(participantsList);
// participantTypesTreeViewer.setAllChecked(true);
@@ -679,37 +672,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
// TODO Auto-generated catch block
e1.printStackTrace();
}
-
-
-
-
-
- // for(Object element : participantsList.keySet()) {
- // if(element instanceof ParticipantTypeElement) {
- // if(((ParticipantTypeElement)element).getElement() instanceof EClass) {
- // List<EClass> superTypes = ((EClass)((ParticipantTypeElement)element).getElement()).getEAllSuperTypes();
- //
- // if(superTypes.contains(elementParent.getElement())) {
- // // participantTypesTreeViewer.setChecked(element, true);
- // ((ParticipantTypeElement)element).setChecked(true);
- //
- // //Proceed with attributes
- // for(ParticipantTypeAttribute attributeParent : attributeParentList) {
- // for(ParticipantTypeAttribute attributeToEvaluate : participantsList.get(element)) {
- // if(attributeParent.getElement() == attributeToEvaluate.getElement()) {
- //
- // attributeToEvaluate.setChecked(true);
- //
- //
- // }
- //
- // }
- // }
- // }
- // }
- // }
- // }
- //
}
@@ -809,7 +771,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
oclEditor.getViewer().getTextWidget().addVerifyKeyListener(new VerifyKeyListener() {
public void verifyKey(VerifyEvent e) {
- // System.out.println("verifyKey: " + e.keyCode);
if(e.keyCode == SWT.KEYPAD_CR || e.keyCode == SWT.CR) {
if((e.stateMask & (SWT.CTRL | SWT.SHIFT)) == 0) {
e.doit = false;
@@ -1028,15 +989,15 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) {
if(validateRegex()) {
Collection<IResource> scope = ScopeCollector.getInstance().computeSearchScope(container);
-
Collection<ScopeEntry> scopeEntries = createScopeEntries(scope);
ISearchQuery query;
if(searchKind.getSelectionIndex() == SIMPLE_SEARCH) {
- if(searchQueryText.getText().length() == 0) {
+ if(searchQueryText.getText().isEmpty()) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_29, Messages.PapyrusSearchPage_30);
return false;
} else {
initMetaClasses();
+
query = new PapyrusQuery(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), scopeEntries, umlMetaClasses.toArray(), btnSearchAllStringAttributes.getSelection());
}
} else {
@@ -1058,7 +1019,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_31, Messages.PapyrusSearchPage_32);
return false;
} else {
- if(searchQueryText.getText().length() == 0) {
+ if(searchQueryText.getText().isEmpty()) {
for(Object participantChecked : participantTypesTreeViewer.getCheckedElements()) {
if(participantChecked instanceof ParticipantTypeAttribute) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_33, Messages.PapyrusSearchPage_34);
@@ -1118,7 +1079,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
public boolean performReplace() {
if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) {
if(validateRegex()) {
- if(searchQueryText.getText().length() == 0) {
+ if(searchQueryText.getText().isEmpty()) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_36, Messages.PapyrusSearchPage_37);
return false;
}
@@ -1157,6 +1118,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
query = new PapyrusAdvancedQuery(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), scopeEntries, participantsToEvaluate.toArray());
}
+
NewSearchUI.runQueryInForeground(container.getRunnableContext(), query);
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java
index dac2e439797..68385a536be 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java
@@ -15,6 +15,9 @@ package org.eclipse.papyrus.uml.search.ui.pages;
import java.util.Set;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.ISelection;
@@ -35,6 +38,8 @@ import org.eclipse.papyrus.views.search.utils.MatchUtils;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
import org.eclipse.search.ui.text.Match;
+import org.eclipse.search2.internal.ui.SearchView;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
/**
@@ -42,7 +47,7 @@ import org.eclipse.ui.PartInitException;
* Papyrus specific search results page
*
*/
-public class PapyrusSearchResultPage extends AbstractTextSearchViewPage {
+public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implements IResourceChangeListener {
ResultContentProvider fContentProvider = null;
@@ -51,11 +56,16 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage {
private static final int DEFAULT_ELEMENT_LIMIT = 1000;
public PapyrusSearchResultPage() {
+
super(FLAG_LAYOUT_TREE);
setElementLimit(new Integer(DEFAULT_ELEMENT_LIMIT));
fFiltertypesAction = new FilterTypesAction(this);
+
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
}
+
+
@Override
public Match[] getDisplayedMatches(Object element) {
@@ -157,6 +167,7 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage {
viewer.setContentProvider(new ResultContentProvider(this, viewer));
viewer.setLabelProvider(new ResultLabelProvider());
fContentProvider = (ResultContentProvider)viewer.getContentProvider();
+
}
@Override
@@ -164,4 +175,34 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage {
}
+ public void resourceChanged(IResourceChangeEvent event) {
+
+ if(event.getType() == IResourceChangeEvent.POST_CHANGE) {
+
+ if(this.getInput() != null && this.getViewer().getInput() != null && this.getViewPart() != null) {
+
+
+
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ ((SearchView)getViewPart()).showSearchResult(getInput());
+ getViewer().refresh();
+ }
+ });
+ }
+ }
+
+
+
+
+
+ }
+
+ @Override
+ public void dispose() {
+
+ super.dispose();
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ }
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
index e63ba98135b..83cac65d9fd 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
@@ -36,9 +36,9 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
LabelProviderService service = new LabelProviderServiceImpl();
try {
service.startService();
- return service.getLabelProvider().getImage(((AttributeMatch)element).getSource());
+ return service.getLabelProvider().getImage(((AttributeMatch)element).getMetaAttribute());
} catch (ServiceException e) {
- Activator.log.warn(Messages.AttributeMatchLabelProvider_0 + ((AttributeMatch)element).getSource());
+ Activator.log.warn(Messages.AttributeMatchLabelProvider_0 + ((AttributeMatch)element).getMetaAttribute());
}
}
return null;
@@ -52,10 +52,10 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
if(element instanceof AttributeMatch) {
AttributeMatch attributeMatch = ((AttributeMatch)element);
- if((attributeMatch).getTarget() instanceof EObject) {
- EObject target = (EObject)attributeMatch.getTarget();
- if(attributeMatch.getSource() instanceof EAttribute) {
- EAttribute source = (EAttribute)attributeMatch.getSource();
+ if((attributeMatch).getSource() instanceof EObject) {
+ EObject target = (EObject)attributeMatch.getSource();
+ if(attributeMatch.getMetaAttribute() instanceof EAttribute) {
+ EAttribute source = (EAttribute)attributeMatch.getMetaAttribute();
if(target.eGet(source) instanceof String) {
String value = (String)target.eGet(source);
return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
@@ -64,14 +64,14 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
String value = String.valueOf(target.eGet(source));
return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
}
- } else if(attributeMatch.getSource() instanceof Property) {
+ } else if(attributeMatch.getMetaAttribute() instanceof Property) {
- Property source = (Property)attributeMatch.getSource();
+ Property source = (Property)attributeMatch.getMetaAttribute();
Class containingClass = source.getClass_();
if(containingClass instanceof Stereotype) {
if(target instanceof Element) {
- Object tagValue = ((Element)target).getValue((Stereotype)containingClass, ((Property)attributeMatch.getSource()).getName());
+ Object tagValue = ((Element)target).getValue((Stereotype)containingClass, ((Property)attributeMatch.getMetaAttribute()).getName());
if(tagValue instanceof String) {
String value = (String)tagValue;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
index c126e5f42ef..1486b31b7a8 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
@@ -43,6 +43,16 @@ public class ResultContentProvider implements ITreeContentProvider {
private AbstractTreeViewer fViewer;
+
+ public AbstractTreeViewer getfViewer() {
+ return fViewer;
+ }
+
+
+ public void setfViewer(AbstractTreeViewer fViewer) {
+ this.fViewer = fViewer;
+ }
+
private Map<Object, Set<Object>> fChildrenMap;
public ResultContentProvider(PapyrusSearchResultPage page, AbstractTreeViewer viewer) {
@@ -87,7 +97,7 @@ public class ResultContentProvider implements ITreeContentProvider {
fViewer.refresh();
}
- private void initialize() {
+ public void initialize() {
fChildrenMap = new HashMap<Object, Set<Object>>();
@@ -253,7 +263,7 @@ public class ResultContentProvider implements ITreeContentProvider {
}
}
- protected void remove(Object element, boolean refreshViewer) {
+ public void remove(Object element, boolean refreshViewer) {
if(hasChildren(element)) {
if(refreshViewer) {
fViewer.refresh(element);
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java
index 4f2881c69f5..a0309c2fd13 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.resource.NotFoundException;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.viewersearch.impl.ViewerSearchService;
@@ -187,7 +188,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
* @param scopeEntry
* the scopeEntry that contains the participant
*/
- protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry) {
+ protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry, Stereotype stereotype) {
value = value != null ? value : ""; //$NON-NLS-1$
@@ -197,7 +198,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
if(m.matches()) {
int start = m.start();
int end = m.end();
- ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
fResults.add(match);
}
@@ -205,7 +206,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
while(m.find()) {
int start = m.start();
int end = m.end();
- AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
fResults.add(match);
}
}
@@ -263,10 +264,10 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
if(value instanceof String) {
String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry, null);
} else {
String stringValue = String.valueOf(value);
- evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry, null);
}
}
}
@@ -274,7 +275,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
}
}
- findAndShow(scopeEntry);
+ findInDiagram(scopeEntry);
}
@@ -298,7 +299,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
EList<Stereotype> stereotypesApplied = ((Element)participant).getAppliedStereotypes();
for(Stereotype stereotype : stereotypesApplied) {
for(Stereotype stereotypeSelected : stereotypeList.keySet()) {
- if(stereotype.getName().equals(stereotypeSelected.getName())) {
+ if(EcoreUtil.equals(stereotype, stereotypeSelected)) {
if(stereotypeList.get(stereotypeSelected).size() == 0) {
propertyList = this.getStereotypesAttributes(stereotype);
@@ -308,10 +309,10 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
if(value != null) {
if(value instanceof String) {
String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
} else {
String stringValue = String.valueOf(value);
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
}
}
}
@@ -319,15 +320,15 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
propertyList = this.getStereotypesAttributes(stereotype);
for(Property property : propertyList) {
for(Property property2 : (stereotypeList.get(stereotypeSelected))) {
- if(property.getName().equals(property2.getName())) {
+ if(EcoreUtil.equals(property, property2)) {
Object value = ((Element)participant).getValue(stereotype, property.getName());
if(value != null) {
if(value instanceof String) {
String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
} else {
String stringValue = String.valueOf(value);
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
}
}
}
@@ -342,7 +343,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
}
- findAndShow(scopeEntry);
+ findInDiagram(scopeEntry);
}
@@ -371,7 +372,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
return result;
}
- protected void findAndShow(ScopeEntry scopeEntry) {
+ protected void findInDiagram(ScopeEntry scopeEntry) {
//Now, find in diagram and others the elements we found
ViewerSearchService viewerSearcherService = new ViewerSearchService();
try {
@@ -381,7 +382,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
for(AbstractResultEntry match : fResults) {
if(match instanceof AttributeMatch) {
- sources.add(((AttributeMatch)match).getTarget());
+ sources.add(((AttributeMatch)match).getSource());
} else {
sources.add(match.getSource());
}
@@ -409,7 +410,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
}
public boolean canRerun() {
- return false;
+ return true;
}
public boolean canRunInBackground() {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java
index d4f7adf459c..c94f09d3674 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java
@@ -13,11 +13,10 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.search.ui.query;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -52,6 +51,7 @@ import org.eclipse.ocl.examples.pivot.utilities.PivotUtil;
import org.eclipse.ocl.examples.xtext.console.messages.ConsoleMessages;
import org.eclipse.ocl.examples.xtext.essentialocl.ui.model.BaseDocument;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.uml.search.ui.Activator;
import org.eclipse.papyrus.uml.search.ui.Messages;
import org.eclipse.papyrus.uml.search.ui.results.PapyrusSearchResult;
import org.eclipse.papyrus.views.search.results.AbstractResultEntry;
@@ -96,6 +96,9 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
this.parserContext = parserContext;
this.metaModelManager = metaModelManager;
this.modelManager = modelManager;
+
+ Collection<ScopeEntry> scopeEntries = new ArrayList<ScopeEntry>();
+ scopeEntries.add(scopeEntry);
results = new PapyrusSearchResult(this);
fResults = new HashSet<AbstractResultEntry>();
}
@@ -125,19 +128,16 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
EvaluationRunnable runnable = new EvaluationRunnable((BaseResource)state, expression);
runnable.run(new NullProgressMonitor());
- // progressService.busyCursorWhile(runnable);
return runnable.getValue();
}
});
} catch (Exception e) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getMessage());
+ Activator.log.error(e);
}
if(value instanceof InvalidValueException) {
InvalidValueException exception = (InvalidValueException)value;
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", exception.getMessage());
Throwable cause = exception.getCause();
if((cause != null) && (cause != exception)) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", cause.getMessage());
}
} else if(value != null) {
CollectionValue collectionValue = ValuesUtil.isCollectionValue(value);
@@ -147,28 +147,25 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
ModelMatch match = new ModelElementMatch(elementValue, scopeEntry);
fResults.add(match);
}
- // System.err.println("Found : " + ValuesUtil.stringValueOf(elementValue));
}
} else {
if(value instanceof EObject) {
ModelMatch match = new ModelElementMatch(value, scopeEntry);
fResults.add(match);
}
- // System.err.println("Found : " + ValuesUtil.stringValueOf(value));
}
- } else {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", ValuesUtil.stringValueOf(value));
-
}
} catch (Exception e) {
result = false;
- if(e.getLocalizedMessage() == null) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getClass().getName());
- } else {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getLocalizedMessage());
- }
+ Activator.log.error(e);
+
+ // if(e.getLocalizedMessage() == null) {
+ // // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getClass().getName());
+ // } else {
+ // // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getLocalizedMessage());
+ // }
}
return result;
@@ -225,17 +222,6 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
try {
// metaModelManager.setMonitor(monitor);
CancelableEvaluationVisitor evaluationVisitor = new CancelableEvaluationVisitor(monitor, environment, evaluationEnvironment, modelManager2);
- // evaluationVisitor.setLogger(new DomainLogger() {
- //
- // public void append(final @NonNull String message) {
- // OCLConsolePage.this.getControl().getDisplay().asyncExec(new Runnable() {
- //
- // public void run() {
- // OCLConsolePage.this.append(message, ColorManager.DEFAULT, false);
- // }
- // });
- // }
- // });
value = evaluationVisitor.visitExpressionInOCL(expressionInOCL);
} catch (InvalidValueException e) {
value = e;
@@ -288,138 +274,6 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
return Status.OK_STATUS;
}
- /**
- * Evaluate if the value matches the pattern
- *
- * @param value
- * the value to evaluate
- * @param attribute
- * the attribute has the value
- * @param pattern
- * the pattern that is searched
- * @param participant
- * the element that contains the value
- * @param scopeEntry
- * the scopeEntry that contains the participant
- */
- protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry) {
-
- value = value != null ? value : ""; //$NON-NLS-1$
-
- Matcher m = pattern.matcher(value);
-
- // if(isRegularExpression) {
- // if(m.matches()) {
- // int start = m.start();
- // int end = m.end();
- // ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
- //
- // fResults.add(match);
- // }
- // } else {
- // while(m.find()) {
- // int start = m.start();
- // int end = m.end();
- // AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
- // fResults.add(match);
- // }
- // }
-
-
- }
-
- /**
- * Try to find elements that match in the participants
- *
- * @param participants
- * @param scopeEntry
- */
- protected void evaluate(Collection<EObject> participants, ScopeEntry scopeEntry) {
-
- // for(EObject participant : participants) {
- //
- // String query = searchQueryText;
- // if(searchQueryText.equals("")) { //$NON-NLS-1$
- // query = ".*"; //$NON-NLS-1$
- // }
- //
- // Pattern pattern = PatternHelper.getInstance().createPattern(query, isCaseSensitive, isRegularExpression);
- //
- // if(pattern != null) {
- // if(searchAllStringAttributes) {
- //
- // for(EAttribute attribute : participant.eClass().getEAllAttributes()) {
- // Object value = participant.eGet(attribute);
- //
- // if(value instanceof String) {
- // String stringValue = (String)value;
- // evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
- // }
- // }
- //
- // } else {
- // if(participant instanceof NamedElement) {
- // String umlElementName = ((NamedElement)participant).getName();
- // umlElementName = umlElementName != null ? umlElementName : ""; //$NON-NLS-1$
- //
- // evaluateAndAddToResult(umlElementName, UMLPackage.eINSTANCE.getNamedElement_Name(), pattern, participant, scopeEntry);
- // }
- // }
- // if(searchStereotypeAttributes) {
- // if(participant instanceof Element) {
- // EList<Stereotype> stereotypes = ((Element)participant).getAppliedStereotypes();
- // for(Stereotype stereotype : stereotypes) {
- // for(Property stereotypeProperty : stereotype.getAllAttributes()) {
- // if(!stereotypeProperty.getName().startsWith("base_")) {
- // Object value = ((Element)participant).getValue(stereotype, stereotypeProperty.getName());
- // if(value != null) {
- //
- // if(value instanceof String) {
- // String stringValue = (String)value;
- // evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
- // }
- // }
- // }
- // }
- //
- // }
- // }
- // }
- //
- // }
- // }
- //
- // //Now, find in diagram and others the elements we found
- // ViewerSearchService viewerSearcherService = new ViewerSearchService();
- // try {
- // viewerSearcherService.startService();
- //
- // //Get sources elements that matched
- // Set<Object> sources = new HashSet<Object>();
- // for(AbstractResultEntry match : fResults) {
- // if(match instanceof AttributeMatch) {
- // sources.add(((AttributeMatch)match).getTarget());
- // } else {
- // sources.add(match.getSource());
- // }
- // }
- //
- // //Get viewer of these sources
- // Map<Object, Map<Object, Object>> viewersMappings = viewerSearcherService.getViewers(sources, scopeEntry.getModelSet());
- //
- // //Add viewers to results
- // for(Object containingModelSet : viewersMappings.keySet()) {
- // for(Object view : viewersMappings.get(containingModelSet).keySet()) {
- // Object semanticElement = viewersMappings.get(containingModelSet).get(view);
- // ViewerMatch viewMatch = new ViewerMatch(view, scopeEntry, semanticElement);
- // fResults.add(viewMatch);
- // }
- // }
- //
- // } catch (ServiceException e) {
- // Activator.log.error(Messages.PapyrusQuery_5 + scopeEntry.getModelSet(), e);
- // }
- }
public String getLabel() {
return Messages.PapyrusQuery_6;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java
index a2605a7a347..d65a2827e10 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -79,7 +79,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
protected Set<AbstractResultEntry> fResults = null;
- private boolean searchStereotypeAttributes;
+
public PapyrusQuery(String searchQueryText, boolean isCaseSensitive, boolean isRegularExpression, Collection<ScopeEntry> scopeEntries, Object[] participantsTypes, boolean searchAllStringAttributes) {
this.searchQueryText = searchQueryText;
@@ -143,7 +143,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
if(m.matches()) {
int start = m.start();
int end = m.end();
- ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, null);
fResults.add(match);
}
@@ -151,7 +151,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
while(m.find()) {
int start = m.start();
int end = m.end();
- AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, null);
fResults.add(match);
}
}
@@ -200,16 +200,12 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
for(Property stereotypeProperty : stereotype.getAllAttributes()) {
if(!stereotypeProperty.getName().startsWith("base_")) { //$NON-NLS-1$
Object value = ((Element)participant).getValue(stereotype, stereotypeProperty.getName());
- if(value != null) {
- if(value instanceof String) {
- String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
- }
+ if(value instanceof String) {
+ String stringValue = (String)value;
+ evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
}
-
}
-
}
}
}
@@ -227,7 +223,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
}
}
- //Now, find in diagram and others the elements we found
+ // Now, find in diagram and others the elements we found
ViewerSearchService viewerSearcherService = new ViewerSearchService();
try {
viewerSearcherService.startService();
@@ -236,7 +232,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
Set<Object> sources = new HashSet<Object>();
for(AbstractResultEntry match : fResults) {
if(match instanceof AttributeMatch) {
- sources.add(((AttributeMatch)match).getTarget());
+ sources.add(((AttributeMatch)match).getSource());
} else {
sources.add(match.getSource());
}
@@ -264,7 +260,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
}
public boolean canRerun() {
- return false;
+ return true;
}
public boolean canRunInBackground() {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
index 6dd1ef67b0e..5b07cce5762 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
@@ -13,15 +13,27 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.search.ui.results;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.uml.search.ui.Activator;
import org.eclipse.papyrus.uml.search.ui.Messages;
import org.eclipse.papyrus.uml.search.ui.query.AbstractPapyrusQuery;
+import org.eclipse.papyrus.views.search.regex.PatternHelper;
import org.eclipse.papyrus.views.search.results.AbstractResultEntry;
+import org.eclipse.papyrus.views.search.results.AttributeMatch;
+import org.eclipse.papyrus.views.search.results.ModelElementMatch;
+import org.eclipse.papyrus.views.search.results.ModelMatch;
+import org.eclipse.papyrus.views.search.results.ViewerMatch;
import org.eclipse.papyrus.views.search.scope.ScopeEntry;
import org.eclipse.papyrus.views.search.utils.MatchUtils;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
@@ -31,6 +43,8 @@ import org.eclipse.search.ui.text.Match;
import org.eclipse.search.ui.text.MatchFilter;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Property;
import com.swtdesigner.ResourceManager;
@@ -38,8 +52,6 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
MatchFilter[] possibleMatchFilter;
-
-
private AbstractPapyrusQuery searchQuery;
public PapyrusSearchResult(AbstractPapyrusQuery query) {
@@ -88,6 +100,7 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
Set<Match> results = new HashSet<Match>();
+
Set<AbstractResultEntry> allMatches = MatchUtils.getMatches(result, true);
for(AbstractResultEntry modelMatch : allMatches) {
Object element = modelMatch.getElement();
@@ -126,9 +139,92 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
return false;
}
+ @Override
+ public Match[] getMatches(Object element) {
+
+ Match[] matchList = super.getMatches(element);
+ Set<Match> matchToKeep = new HashSet<Match>();
+ List<Object> sourceList = new ArrayList<Object>();
+ // Get matches which are still true
+ for(Match match : matchList) {
+ if(match instanceof AbstractResultEntry) {
+ if(((AbstractResultEntry)match).getSource() != null) {
+ if(match instanceof AttributeMatch) {
+
+ String value = null;
+ EObject target = (EObject)((AbstractResultEntry)match).getSource();
+ if(((AttributeMatch)match).getMetaAttribute() instanceof EAttribute) {
+
+ EAttribute attribute = (EAttribute)((AttributeMatch)match).getMetaAttribute();
+ value = String.valueOf(target.eGet(attribute));
+ } else if(((AttributeMatch)match).getMetaAttribute() instanceof Property) {
+
+ Property attribute = (Property)((AttributeMatch)match).getMetaAttribute();
+ value = (String)((Element)((AbstractResultEntry)match).getSource()).getValue(((AttributeMatch)match).getStereotype(), attribute.getName());
+
+
+ }
+ if(value != null && !this.getQuery().isRegularExpression()) {
+ if(value.length() >= match.getOffset() + match.getLength()) {
+ value = value.substring(match.getOffset(), match.getLength());
+ if(this.searchQuery.isCaseSensitive()) {
+ if(value.equals(this.searchQuery.getSearchQueryText())) {
+ ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)((AbstractResultEntry)match).getParent());
+ matchToKeep.add(match);
+ sourceList.add(((AbstractResultEntry)match).getSource());
+ }
+ } else {
+ if(value.equalsIgnoreCase(this.searchQuery.getSearchQueryText())) {
+
+ ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)((AbstractResultEntry)match).getParent());
+
+ matchToKeep.add(match);
+ sourceList.add(((AbstractResultEntry)match).getSource());
+ }
+ }
+ }
+ } else if(this.getQuery().isRegularExpression()) {
+ if(this.getQuery().getSearchQueryText() != null) {
+
+
+ Pattern pattern = PatternHelper.getInstance().createPattern(this.getQuery().getSearchQueryText(), false, true);
+ Matcher m = pattern.matcher(value);
+ if(m.matches()) {
+ int start = m.start();
+ int end = m.end();
+ if(start == match.getOffset() && end == match.getOffset() + match.getLength()) {
+ matchToKeep.add(match);
+ sourceList.add(((AbstractResultEntry)match).getSource());
+ }
+ }
+ }
+ }
+ } else if(match instanceof ModelElementMatch) {
+ ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)match);
+
+ matchToKeep.add(match);
+ sourceList.add(((AbstractResultEntry)match).getSource());
+ }
+ }
+ }
+ }
+ // Now get Viewers
+ for(Match match : matchList) {
+ if(match instanceof ViewerMatch) {
+ Object source = ((ViewerMatch)match).getSemanticElement();
+ if(sourceList.contains(source)) {
+ matchToKeep.add(match);
+ }
+ }
+
+ }
+
+ return (Match[])matchToKeep.toArray(new Match[matchToKeep.size()]);
+
+ }
+
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
Set<Object> results = new HashSet<Object>();
-
Set<AbstractResultEntry> allMatches = MatchUtils.getMatches(result, true);
for(AbstractResultEntry modelMatch : allMatches) {
Object element = modelMatch.getElement();
@@ -144,4 +240,22 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
return results.toArray(arrayResult);
}
+ @Override
+ public int getMatchCount() {
+
+ List<Object> elementList = Arrays.asList(this.getElements());
+ int count = 0;
+ for(Object element : elementList) {
+
+ for(Match match : this.getMatches(element)) {
+ if(match instanceof ModelMatch || match instanceof ViewerMatch)
+ count++;
+ }
+
+ }
+ return count;
+ }
+
+
+
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java
index 177ff26c248..38eb000b851 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java
@@ -19,7 +19,9 @@ import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
@@ -59,8 +61,9 @@ public class ParticipantValidator implements IParticipantValidator {
TreeIterator<EObject> it = root.eAllContents();
while(it.hasNext()) {
EObject modelElement = (EObject)it.next();
- //Check that metaclass of this element is a supported metaclass
+ //Check that metaclass of this element is a supported metaclass
+ EClass e = modelElement.eClass();
if(participantsTypesList.contains(modelElement.eClass())) {
results.add(modelElement);
}
@@ -85,10 +88,10 @@ public class ParticipantValidator implements IParticipantValidator {
while(it.hasNext()) {
EObject modelElement = (EObject)it.next();
if(modelElement instanceof Element) {
- for(Stereotype element : ((Element)modelElement).getAppliedStereotypes()) {
+ for(Stereotype appliedStereotype : ((Element)modelElement).getAppliedStereotypes()) {
//Check that metaclass of this element is a supported metaclass
for(Object stereotypeToGet : participantsTypesList) {
- if(element.getName().equals(((Stereotype)stereotypeToGet).getName())) {
+ if(EcoreUtil.equals(appliedStereotype, (EObject)stereotypeToGet)) {
results.add(modelElement);
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java
index bf8d15d39bb..329e278692a 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java
@@ -32,6 +32,7 @@ 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.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.emf.utils.BusinessModelResolver;
@@ -129,7 +130,17 @@ public class StereotypeCollector implements IStereotypeCollector {
EObject umlElement = (EObject)UMLResourceContentIterator.next();
if(umlElement instanceof ProfileApplication) {
- profiles.add(((ProfileApplication)umlElement).getAppliedProfile());
+ boolean found = false;
+ Profile profileToProcess = ((ProfileApplication)umlElement).getAppliedProfile();
+ for(Profile alreadyAddedProfile : profiles) {
+
+ if(EcoreUtil.equals(alreadyAddedProfile, profileToProcess)) {
+ found = true;
+ }
+ }
+ if(!found) {
+ profiles.add(profileToProcess);
+ }
}
}
@@ -141,7 +152,18 @@ public class StereotypeCollector implements IStereotypeCollector {
while(profileContentIterator.hasNext()) {
EObject profileContent = (EObject)profileContentIterator.next();
if(profileContent instanceof Stereotype) {
- preResult.add((Stereotype)profileContent);
+ boolean found = false;
+ Stereotype stereotypeToProcess = (Stereotype)profileContent;
+ for(Stereotype alreadyAddedStereotype : preResult) {
+
+ if(EcoreUtil.equals(alreadyAddedStereotype, stereotypeToProcess)) {
+ found = true;
+ }
+ }
+
+ if(!found) {
+ preResult.add(stereotypeToProcess);
+ }
}
}
@@ -153,6 +175,20 @@ public class StereotypeCollector implements IStereotypeCollector {
for(Classifier parent : stereo.getGenerals()) {
if(parent instanceof Stereotype) {
result.add((Stereotype)parent);
+
+ boolean found = false;
+ Stereotype stereotypeToProcess = (Stereotype)parent;
+ for(Stereotype alreadyAddedStereotype : result) {
+
+ if(EcoreUtil.equals(alreadyAddedStereotype, stereotypeToProcess)) {
+ found = true;
+ }
+ }
+
+ if(!found) {
+ result.add(stereotypeToProcess);
+ }
+
}
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/META-INF/MANIFEST.MF b/plugins/views/org.eclipse.papyrus.views.search/META-INF/MANIFEST.MF
index 97d89a96591..a2d393046bf 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/META-INF/MANIFEST.MF
+++ b/plugins/views/org.eclipse.papyrus.views.search/META-INF/MANIFEST.MF
@@ -26,4 +26,5 @@ Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.views.search.Activator
Bundle-SymbolicName: org.eclipse.papyrus.views.search;singleton:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.eclipse.uml2.uml
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AbstractResultEntry.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AbstractResultEntry.java
index 0f15437900a..17f561a69ca 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AbstractResultEntry.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AbstractResultEntry.java
@@ -13,7 +13,15 @@
*****************************************************************************/
package org.eclipse.papyrus.views.search.results;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.openelement.service.OpenElementService;
import org.eclipse.papyrus.views.search.scope.ScopeEntry;
@@ -39,6 +47,10 @@ public abstract class AbstractResultEntry extends Match {
*/
protected Object parent;
+ protected URI uriSource;
+
+ protected java.net.URI uriResource;
+
/**
* Used to specify offset and length of {@link Match} when these attributes are not meaningful
*/
@@ -76,16 +88,16 @@ public abstract class AbstractResultEntry extends Match {
* @param scopeEntry
* the {@link ScopeEntry} corresponding to the resource that contains the element that matches
*/
- protected void recursiveHierarchy(AbstractResultEntry child, ScopeEntry scopeEntry) {
+ public void recursiveHierarchy(AbstractResultEntry child) {
if(child.getSource() instanceof EObject) {
EObject potentialParent = ((EObject)child.getSource()).eContainer();
if(potentialParent != null) {
- ResultEntry theParent = new ResultEntry(potentialParent, scopeEntry);
+ ResultEntry theParent = new ResultEntry(potentialParent, (ScopeEntry)this.getElement());
child.setParent(theParent);
- recursiveHierarchy(theParent, scopeEntry);
+ recursiveHierarchy(theParent);
} else {
- ResultEntry theParent = new ResultEntry(scopeEntry.getResource(), scopeEntry);
+ ResultEntry theParent = new ResultEntry(((ScopeEntry)this.getElement()).getResource(), (ScopeEntry)this.getElement());
child.setParent(theParent);
}
}
@@ -130,10 +142,23 @@ public abstract class AbstractResultEntry extends Match {
@Override
public boolean equals(Object obj) {
if(obj instanceof AbstractResultEntry) {
- if(((AbstractResultEntry)obj).getSource().equals(this.source)) {
- if(((AbstractResultEntry)obj).getOffset() == this.getOffset()) {
- if(((AbstractResultEntry)obj).getLength() == this.getLength()) {
- return true;
+ if(obj instanceof EObject && this.getSource() instanceof EObject) {
+ if(EcoreUtil.equals((EObject)this.getSource(), (EObject)obj)) {
+ if(((AbstractResultEntry)obj).getOffset() == this.getOffset()) {
+ if(((AbstractResultEntry)obj).getLength() == this.getLength()) {
+ return true;
+ }
+ }
+ }
+ } else {
+ if(((AbstractResultEntry)obj).getSource() != null) {
+ if(((AbstractResultEntry)obj).getSource().equals(this.getSource())) {
+ if(((AbstractResultEntry)obj).getOffset() == this.getOffset()) {
+ if(((AbstractResultEntry)obj).getLength() == this.getLength()) {
+ return true;
+ }
+ }
+
}
}
}
@@ -157,11 +182,29 @@ public abstract class AbstractResultEntry extends Match {
*/
public AbstractResultEntry(int offset, int lenght, Object source, ScopeEntry scopeEntry) {
super(scopeEntry, offset, lenght);
- this.source = source;
+ // this.source = source;
+ if(source instanceof EObject) {
+
+ this.uriSource = EcoreUtil.getURI((EObject)source);
+ } else if(source instanceof IResource) {
+ this.uriResource = ((IResource)source).getLocationURI();
+ }
}
public Object getSource() {
- return source;
+ if(this.uriSource != null) {
+ ResourceSet resSet = ((ScopeEntry)this.getElement()).getModelSet();
+ return resSet.getEObject(this.uriSource, true);
+ } else if(this.uriResource != null) {
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+
+
+ IPath path = new Path(this.uriResource.getPath());
+ return root.getFile(path);
+ }
+
+ return null;
}
public void setSource(Object source) {
@@ -182,5 +225,4 @@ public abstract class AbstractResultEntry extends Match {
}
-
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AttributeMatch.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AttributeMatch.java
index e2825b6ade9..4932a486b14 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AttributeMatch.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AttributeMatch.java
@@ -13,11 +13,14 @@
*****************************************************************************/
package org.eclipse.papyrus.views.search.results;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.openelement.service.OpenElementService;
import org.eclipse.papyrus.views.search.scope.ScopeEntry;
import org.eclipse.ui.PartInitException;
+import org.eclipse.uml2.uml.Stereotype;
/**
*
@@ -29,7 +32,14 @@ public class AttributeMatch extends ModelMatch {
/**
* The element containing the value of the attribute that matches
*/
- protected Object target;
+
+ protected URI uriSource;
+
+ protected Object attribute;
+
+ private Stereotype stereotype;
+
+
/**
* Similar to {@link AbstractResultEntry} but adds an information about which attribute raised the match and which element contains the value of
@@ -43,11 +53,16 @@ public class AttributeMatch extends ModelMatch {
* @param attribute
* the attribute that raised the match
*/
- public AttributeMatch(int offset, int lenght, Object target, ScopeEntry scopeEntry, Object attribute) {
- super(offset, lenght, attribute, scopeEntry);
- this.target = target;
+ public AttributeMatch(int offset, int lenght, Object target, ScopeEntry scopeEntry, Object attribute, Stereotype stereotype) {
+ super(offset, lenght, target, scopeEntry);
+ this.attribute = attribute;
+ this.stereotype = stereotype;
+
+ // if(target instanceof EObject) {
+ // this.uriSource = EcoreUtil.getURI((EObject)target);
+ // }
this.parent = new ResultEntry(target, scopeEntry);
- recursiveHierarchy((AbstractResultEntry)parent, scopeEntry);
+ recursiveHierarchy((AbstractResultEntry)parent);
}
/**
@@ -62,8 +77,14 @@ public class AttributeMatch extends ModelMatch {
public boolean equals(Object obj) {
if(obj instanceof AttributeMatch) {
if(super.equals(obj)) {
- if(((AttributeMatch)obj).getTarget().equals(this.target)) {
- return true;
+ if(((AttributeMatch)obj).getSource() instanceof EObject && this.getSource() instanceof EObject) {
+ if(EcoreUtil.equals((EObject)((AttributeMatch)obj).getSource(), (EObject)this.getSource())) {
+ return true;
+ }
+ } else {
+ if(((AttributeMatch)obj).getSource().equals(this.getSource())) {
+ return true;
+ }
}
}
return false;
@@ -73,13 +94,22 @@ public class AttributeMatch extends ModelMatch {
}
}
- public Object getTarget() {
- return target;
- }
-
- public void setTarget(Object target) {
- this.target = target;
- }
+ // public Object getTarget() {
+ // // ResourceSet resSet = new ResourceSetImpl();
+ // if(this.uriSource != null) {
+ // ResourceSet resSet = ((ScopeEntry)this.getElement()).getModelSet();
+ // return resSet.getEObject(this.uriSource, true);
+ // }
+ // return null;
+ //
+ // }
+ //
+ // public void setTarget(Object target) {
+ // if(target instanceof EObject) {
+ // this.uriSource = EcoreUtil.getURI((EObject)target);
+ // }
+ //
+ // }
/**
*
@@ -101,7 +131,7 @@ public class AttributeMatch extends ModelMatch {
*/
@Override
public Object elementToCheckFilterFor() {
- return target;
+ return this.getSource();
}
/**
@@ -112,9 +142,24 @@ public class AttributeMatch extends ModelMatch {
*/
@Override
public Object openElement(OpenElementService service) throws ServiceException, PartInitException {
- if(target instanceof EObject) {
- return service.openSemanticElement((EObject)target);
+ if(this.getSource() instanceof EObject) {
+ return service.openSemanticElement((EObject)this.getSource());
}
return null;
}
+
+ public Object getMetaAttribute() {
+ // TODO Auto-generated method stub
+ return this.attribute;
+ }
+
+ public Stereotype getStereotype() {
+ return stereotype;
+ }
+
+
+ public void setStereotype(Stereotype stereotype) {
+ this.stereotype = stereotype;
+ }
+
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ModelElementMatch.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ModelElementMatch.java
index 61b7bfa94e4..122f40dd1a0 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ModelElementMatch.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ModelElementMatch.java
@@ -14,6 +14,7 @@
package org.eclipse.papyrus.views.search.results;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.openelement.service.OpenElementService;
import org.eclipse.papyrus.views.search.scope.ScopeEntry;
@@ -26,9 +27,13 @@ import org.eclipse.ui.PartInitException;
*/
public class ModelElementMatch extends ModelMatch {
+
+
public ModelElementMatch(Object source, ScopeEntry scopeEntry) {
super(UNSPECIFIED, UNSPECIFIED, source, scopeEntry);
- recursiveHierarchy(this, scopeEntry);
+ recursiveHierarchy(this);
+
+
// this.parent = new ResultEntry(scopeEntry.getResource(), scopeEntry);
}
@@ -56,7 +61,12 @@ public class ModelElementMatch extends ModelMatch {
*/
@Override
public Object elementToDisplay() {
- return source;
+ // return this.getSource();
+ if(this.uriSource != null) {
+ ResourceSet resSet = ((ScopeEntry)this.getElement()).getModelSet();
+ return resSet.getEObject(this.uriSource, true);
+ }
+ return null;
}
/**
@@ -67,9 +77,21 @@ public class ModelElementMatch extends ModelMatch {
*/
@Override
public Object elementToCheckFilterFor() {
- return source;
+ return this.getSource();
}
+ // @Override
+ // public Object getSource() {
+ //
+ // if(this.uriSource != null) {
+ // ResourceSet resSet = ((ScopeEntry)this.getElement()).getModelSet();
+ // return resSet.getEObject(this.uriSource, true);
+ // }
+ // return null;
+ //
+ //
+ // }
+
/**
*
* @see org.eclipse.papyrus.views.search.results.AbstractResultEntry#openElement()
@@ -78,8 +100,9 @@ public class ModelElementMatch extends ModelMatch {
*/
@Override
public Object openElement(OpenElementService service) throws ServiceException, PartInitException {
- if(source instanceof EObject) {
- return service.openSemanticElement((EObject)source);
+ if(this.getSource() instanceof EObject) {
+
+ return service.openSemanticElement((EObject)this.getSource());
}
return null;
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ResultEntry.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ResultEntry.java
index cd93a65c61d..9c917f531f9 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ResultEntry.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ResultEntry.java
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.views.search.results;
+
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.openelement.service.OpenElementService;
@@ -26,8 +27,12 @@ import org.eclipse.ui.PartInitException;
*/
public class ResultEntry extends AbstractResultEntry {
+
+
public ResultEntry(Object source, ScopeEntry scopeEntry) {
super(UNSPECIFIED, UNSPECIFIED, source, scopeEntry);
+
+
}
/**
@@ -38,9 +43,30 @@ public class ResultEntry extends AbstractResultEntry {
*/
@Override
public Object elementToDisplay() {
- return source;
+ return this.getSource();
+
+
+
}
+ // @Override
+ // public Object getSource() {
+ // if(this.uriSource != null) {
+ // ResourceSet resSet = ((ScopeEntry)this.getElement()).getModelSet();
+ // return resSet.getEObject(this.uriSource, true);
+ // } else if(this.uriResource != null) {
+ //
+ // IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ //
+ //
+ // IPath path = new Path(this.uriResource.getPath());
+ // return root.getFile(path);
+ // }
+ // return null;
+ //
+ //
+ // }
+
/**
*
* @see org.eclipse.papyrus.views.search.results.AbstractResultEntry#elementToCheckFilterFor()
@@ -49,9 +75,14 @@ public class ResultEntry extends AbstractResultEntry {
*/
@Override
public Object elementToCheckFilterFor() {
- return source;
+ // ResourceSet resSet = new ResourceSetImpl();
+ // if(this.uriSource != null) {
+ // return resSet.getEObject(uriSource, true);
+ // }
+ return this.getSource();
}
+
/**
*
* @see org.eclipse.papyrus.views.search.results.AbstractResultEntry#openElement()
@@ -60,9 +91,13 @@ public class ResultEntry extends AbstractResultEntry {
*/
@Override
public Object openElement(OpenElementService service) throws ServiceException, PartInitException {
- if(source instanceof EObject) {
- return service.openElement((EObject)source);
+ if(this.getSource() instanceof EObject) {
+
+ return service.openSemanticElement((EObject)this.getSource());
}
return null;
}
+
+
+
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ViewerMatch.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ViewerMatch.java
index 06c152c236d..b552426b712 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ViewerMatch.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ViewerMatch.java
@@ -13,7 +13,10 @@
*****************************************************************************/
package org.eclipse.papyrus.views.search.results;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.openelement.service.OpenElementService;
import org.eclipse.papyrus.views.search.scope.ScopeEntry;
@@ -29,11 +32,14 @@ public class ViewerMatch extends AbstractResultEntry {
/**
* The model element that is represented by the viewer
*/
- protected Object semanticElement;
+ protected URI URIsemanticElement;
public ViewerMatch(Object source, ScopeEntry scopeEntry, Object semanticElement) {
super(UNSPECIFIED, UNSPECIFIED, source, scopeEntry);
- this.semanticElement = semanticElement;
+ if(semanticElement instanceof EObject) {
+ this.URIsemanticElement = EcoreUtil.getURI((EObject)semanticElement);
+ }
+
this.parent = getLastParent(this, scopeEntry);
// this.parent = new ResultEntry(scopeEntry.getResource(), scopeEntry);
@@ -41,11 +47,17 @@ public class ViewerMatch extends AbstractResultEntry {
}
public Object getSemanticElement() {
- return semanticElement;
+ if(this.URIsemanticElement != null) {
+ ResourceSet resSet = ((ScopeEntry)this.getElement()).getModelSet();
+ return resSet.getEObject(this.URIsemanticElement, true);
+ }
+ return null;
}
public void setSemanticElement(Object semanticElement) {
- this.semanticElement = semanticElement;
+ if(semanticElement instanceof EObject) {
+ this.URIsemanticElement = EcoreUtil.getURI((EObject)semanticElement);
+ }
}
/**
@@ -56,7 +68,7 @@ public class ViewerMatch extends AbstractResultEntry {
*/
@Override
public Object elementToDisplay() {
- return source;
+ return this.getSource();
}
/**
@@ -67,7 +79,11 @@ public class ViewerMatch extends AbstractResultEntry {
*/
@Override
public Object elementToCheckFilterFor() {
- return semanticElement;
+ if(this.URIsemanticElement != null) {
+ ResourceSet resSet = ((ScopeEntry)this.getElement()).getModelSet();
+ return resSet.getEObject(this.URIsemanticElement, true);
+ }
+ return null;
}
/**
@@ -78,8 +94,8 @@ public class ViewerMatch extends AbstractResultEntry {
*/
@Override
public Object openElement(OpenElementService service) throws ServiceException, PartInitException {
- if(source instanceof EObject) {
- return service.openElement((EObject)source);
+ if(this.getSource() instanceof EObject) {
+ return service.openElement((EObject)this.getSource());
}
return null;
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java
index b1a76dd602b..6c81f513b19 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java
@@ -16,7 +16,11 @@ package org.eclipse.papyrus.views.search.scope;
import java.util.Collection;
import java.util.HashSet;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.papyrus.infra.core.resource.ModelMultiException;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.services.ServiceException;
@@ -59,12 +63,16 @@ public class ScopeEntry {
/**
* The resource that contains the element that raised a match
*/
- private IResource resource;
+ // private IResource resource;
+
+ private IPath pathResource;
public ScopeEntry(IResource resource) {
super();
- this.resource = resource;
+ // this.resource = resource;
+
+ this.pathResource = resource.getFullPath();
this.modelSet = getModelSet();
this.servicesRegistry = getServicesRegistry();
}
@@ -122,12 +130,13 @@ public class ScopeEntry {
} catch (ServiceException e) {
//Create one
try {
- modelSet = ModelUtils.openFile(resource);
+
+ modelSet = ModelUtils.openFile(this.getResource());
getServicesRegistry().add(ModelSet.class, 10, modelSet);
getServicesRegistry().add(ServiceUtilsForResourceInitializerService.class, 10, new ServiceUtilsForResourceInitializerService());
getServicesRegistry().startServicesByClassKeys(ModelSet.class, ServiceUtilsForResourceInitializerService.class);
} catch (ModelMultiException modelMultiException) {
- Activator.log.error(Messages.ScopeEntry_1 + resource, modelMultiException);
+ Activator.log.error(Messages.ScopeEntry_1 + this.getResource(), modelMultiException);
} catch (ServiceMultiException e1) {
Activator.log.error(e1);
} catch (ServiceNotFoundException e1) {
@@ -148,7 +157,7 @@ public class ScopeEntry {
for(IEditorPart editor : editors) {
if(editor != null) {
- if(ResourceUtil.getResource(editor.getEditorInput()).equals(resource)) {
+ if(ResourceUtil.getResource(editor.getEditorInput()).equals(this.getResource())) {
return editor;
}
}
@@ -200,11 +209,26 @@ public class ScopeEntry {
}
public IResource getResource() {
- return resource;
+
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IFile file = root.getFile(pathResource);
+
+ return (IResource)file;
+ // if(this.uriResource != null) {
+ //
+ // IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ //
+ //
+ // IPath path = new Path(this.uriResource.getPath());
+ // return root.getFile(path);
+ // } else {
+ // return null;
+ // }
}
public void setResource(IResource resource) {
- this.resource = resource;
+ this.pathResource = resource.getFullPath();
}
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/utils/MatchUtils.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/utils/MatchUtils.java
index 5a52dfaab2e..2c3081ee678 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/utils/MatchUtils.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/utils/MatchUtils.java
@@ -19,6 +19,7 @@ import java.util.List;
import java.util.Set;
import org.eclipse.papyrus.views.search.results.AbstractResultEntry;
+import org.eclipse.papyrus.views.search.scope.ScopeEntry;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.Match;
@@ -46,21 +47,31 @@ public class MatchUtils {
for(Object element : elementList) {
for(Match match : searchResult.getMatches(element)) {
+
if(match instanceof AbstractResultEntry) {
- boolean toAdd = false;
- if(checkFiltered) {
- if(!match.isFiltered()) {
+
+ if(match.getElement() instanceof ScopeEntry) {
+ // ScopeEntry scope = (ScopeEntry)match.getElement();
+ // ((AbstractResultEntry)element).recursiveHierarchy((AbstractResultEntry)element, scope);
+
+ boolean toAdd = false;
+ if(checkFiltered) {
+ if(!match.isFiltered()) {
+ toAdd = true;
+ }
+ } else {
toAdd = true;
}
- } else {
- toAdd = true;
- }
- if(toAdd) {
- if(type.isAssignableFrom(((AbstractResultEntry)match).elementToCheckFilterFor().getClass())) {
- results.add((AbstractResultEntry)match);
+ if(toAdd) {
+ if(type.isAssignableFrom(((AbstractResultEntry)match).elementToCheckFilterFor().getClass())) {
+ results.add((AbstractResultEntry)match);
+ }
}
}
+
+
+
}
}
}

Back to the top