Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/advanced_search.pngbin85209 -> 117416 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/body_search.pngbin74602 -> 119478 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/replace.pngbin22475 -> 25595 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/requirement_search.pngbin80098 -> 118393 bytes
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-main-toc.xml2
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.html4
-rw-r--r--plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search.mediawiki8
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/META-INF/MANIFEST.MF30
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java12
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java11
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceTransformationOnElement.java141
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceRefactoring.java151
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/manager/PapyrusSearchTextManager.java101
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/messages.properties6
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java185
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java26
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java43
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java1
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java71
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java168
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java19
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java14
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java2
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java32
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java3
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/regex/PatternHelper.java5
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AbstractResultEntry.java3
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/AttributeMatch.java7
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/results/ModelElementMatch.java12
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java13
-rw-r--r--plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/validator/ParticipantValidator.java8
31 files changed, 868 insertions, 210 deletions
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
index 074447082bd..5d8932cfe9a 100644
--- 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
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
index abf3be5c4a5..7a88be13b15 100644
--- 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
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/replace.png b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/replace.png
index 61656494e41..32e0df131ea 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/replace.png
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/replace.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
index 0d767cf2bf7..c7fa4152bc1 100644
--- 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
Binary files differ
diff --git a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-main-toc.xml b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-main-toc.xml
index 48267f8e8ba..14ecc4b1eb5 100644
--- a/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-main-toc.xml
+++ b/plugins/doc/org.eclipse.papyrus.uml.search.ui.doc/resource/search-main-toc.xml
@@ -2,7 +2,7 @@
<toc label="Search" link_to="../org.eclipse.papyrus.infra.doc/toc.xml#PapyrusDocUser">
<topic href="resource/search.html" label="Search in Models">
<link toc="resource/search-toc.xml"/>
- <anchor id="searchInModel"/>
+ <anchor id="SearchID"/>
</topic>
</toc>
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 9d521d3272d..978df0a3cd5 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,6 +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 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"/>
+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. The stereotypes displayed in the B area are the stereotypes which can be applied on elements from the model(s) corresponding to the selected scope, for example if the selected scope is "Selected resources" only the stereotypes defined in the profiles applied on the current model will be displayed, but if the selected scope is "Workspace" the stereotypes defined in all the profiles applied on models from the current workspace will be displayed.</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. If the user changes the selected scope he should click on the refresh types button, this will update the list of stereotypes displayed.</li><li>The user can specify, in the D area, if he wants to search for model elements with all the specified stereotype (the ones checked in the B area).</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/>
+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>More details about the refactoring tool in the Model Refactor Wizard page.</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 2c1b8aa202a..444807ed899 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
@@ -50,8 +50,10 @@ 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.
+* 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. The stereotypes displayed in the B area are the stereotypes which can be applied on elements from the model(s) corresponding to the selected scope, for example if the selected scope is "Selected resources" only the stereotypes defined in the profiles applied on the current model will be displayed, but if the selected scope is "Workspace" the stereotypes defined in all the profiles applied on models from the current workspace will be displayed.
+* 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 metaClasses which inherit UML::NamedElement and their name attribute will be checked. If the user changes the selected scope he should click on the refresh types button, this will update the list of stereotypes displayed.
+*The user can specify, in the D area, if he wants to search for model elements with all the specified stereotype (the ones checked in the B area).
+
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.
@@ -88,7 +90,7 @@ Should the user want to replace the matches of your search with another string,
[[Image:replace.png]]
-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.
+More details about the refactoring tool in the Model Refactor Wizard page.
=Filter=
The user can filter the results of the search by selecting the types of the elements he/she wants to show.
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.search.ui/META-INF/MANIFEST.MF
index 706e0a3795c..e8ffabe1ce2 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/META-INF/MANIFEST.MF
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/META-INF/MANIFEST.MF
@@ -2,33 +2,35 @@ Manifest-Version: 1.0
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.search;bundle-version="3.8.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.core;bundle-version="0.10.1",
org.eclipse.core.resources;bundle-version="3.8.1",
- org.eclipse.papyrus.editor;bundle-version="1.0.0",
- org.eclipse.papyrus.views.search;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.onefile;bundle-version="1.0.0",
+ org.eclipse.papyrus.editor;bundle-version="0.10.1",
+ org.eclipse.papyrus.views.search;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.onefile;bundle-version="0.10.1",
org.eclipse.emf;bundle-version="2.6.0",
org.eclipse.ui.ide;bundle-version="3.8.100",
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="0.10.1",
org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.3.0",
- org.eclipse.papyrus.uml.tools;bundle-version="1.0.0",
+ org.eclipse.papyrus.uml.tools;bundle-version="0.10.1",
org.eclipse.uml2.uml;bundle-version="4.0.100",
- org.eclipse.papyrus.infra.services.viewersearch;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.services.openelement;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.services.viewersearch;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.services.openelement;bundle-version="0.10.1",
+ org.eclipse.papyrus.infra.core.log;bundle-version="0.10.1",
org.eclipse.jface,
org.eclipse.emf.transaction,
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.1",
org.eclipse.ocl.examples.xtext.essentialocl;bundle-version="3.3.0",
org.eclipse.ocl.examples.xtext.essentialocl.ui;bundle-version="3.3.0",
- org.eclipse.ocl.examples.xtext.console
-Export-Package: org.eclipse.papyrus.uml.search.ui.providers,
+ org.eclipse.ocl.examples.xtext.console,
+ org.eclipse.ltk.ui.refactoring;bundle-version="3.7.100",
+ org.eclipse.papyrus.infra.refactoring;bundle-version="1.0.0"
+Export-Package: org.eclipse.papyrus.uml.search.ui.actions,
+ org.eclipse.papyrus.uml.search.ui.providers,
org.eclipse.papyrus.uml.search.ui.query,
- org.eclipse.papyrus.uml.search.ui.results,
org.eclipse.papyrus.uml.search.ui.validator
Bundle-Vendor: %vendorName
Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 0.10.1.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-ManifestVersion: 2
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 a429c3d292e..9a1cd027295 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
@@ -51,6 +51,8 @@ public class Messages extends NLS {
public static String PapyrusSearchPage_12;
+ public static String PapyrusSearchPage_13;
+
public static String PapyrusSearchPage_14;
public static String PapyrusSearchPage_15;
@@ -151,6 +153,16 @@ public class Messages extends NLS {
public static String ReplaceDialog_4;
+ public static String ReplaceRefactoring_0;
+
+ public static String ReplaceRefactoring_1;
+
+ public static String ReplaceRefactoring_2;
+
+ public static String ReplaceRefactoring_3;
+
+ public static String ReplaceRefactoring_4;
+
public static String ResultContentProvider_0;
public static String ResultContentProvider_10;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java
index 5cde7e08c7f..acc8bd97fc8 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceAction.java
@@ -14,7 +14,8 @@
package org.eclipse.papyrus.uml.search.ui.actions;
import org.eclipse.jface.action.Action;
-import org.eclipse.papyrus.uml.search.ui.dialogs.ReplaceDialog;
+import org.eclipse.papyrus.infra.refactoring.core.PapyrusRefactoringOperation;
+import org.eclipse.papyrus.uml.search.ui.dialogs.ReplaceRefactoring;
import org.eclipse.papyrus.uml.search.ui.pages.PapyrusSearchResultPage;
import org.eclipse.swt.widgets.Shell;
@@ -24,8 +25,6 @@ public class ReplaceAction extends Action {
private final Object[] fSelection;
- private final Shell fShell;
-
/**
* Creates the replace action to be
*
@@ -38,7 +37,6 @@ public class ReplaceAction extends Action {
* the selected entries or <code>null</code> to replace all
*/
public ReplaceAction(Shell shell, PapyrusSearchResultPage resultPage, Object[] selection) {
- fShell = shell;
fResultPage = resultPage;
fSelection = selection;
}
@@ -51,9 +49,10 @@ public class ReplaceAction extends Action {
@Override
public void run() {
- ReplaceDialog replaceDialog = new ReplaceDialog(fShell, fResultPage, fSelection);
- replaceDialog.open();
+ ReplaceRefactoring replaceRef = new ReplaceRefactoring(fResultPage, fSelection);
+ PapyrusRefactoringOperation refactoringOperation = new PapyrusRefactoringOperation(replaceRef);
+ refactoringOperation.run();
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceTransformationOnElement.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceTransformationOnElement.java
new file mode 100644
index 00000000000..c38b44f5a59
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/actions/ReplaceTransformationOnElement.java
@@ -0,0 +1,141 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.search.ui.actions;
+
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.infra.refactoring.refactoringOnElement.ITransformationOnElement;
+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.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
+
+
+public class ReplaceTransformationOnElement implements ITransformationOnElement {
+
+ /**
+ * The {@link AbstractResultEntry} list representing textual matches with the String pattern to be replaced.
+ */
+ private Set<AbstractResultEntry> fAttributeMatchList;
+
+ /**
+ * The {@link AbstractPapyrusQuery} representing the search of matches.
+ */
+ private AbstractPapyrusQuery fQuery;
+
+ /**
+ * The string that should replace the String pattern to be replaced.
+ */
+ private String fNewString;
+
+
+ public ReplaceTransformationOnElement(Set<AbstractResultEntry> toProcess, AbstractPapyrusQuery query, String newString) {
+ fAttributeMatchList = toProcess;
+ fQuery = query;
+ fNewString = newString;
+ }
+
+
+ public void transformationToExecute(EObject element) {
+ for(AbstractResultEntry match : fAttributeMatchList) {
+ if(match.getSource() instanceof EObject && match instanceof AttributeMatch){
+ AttributeMatch attributeMatch=(AttributeMatch) match;
+ if(EcoreUtil.equals(element, (EObject)match.getSource())) {
+
+ if(attributeMatch.getMetaAttribute() instanceof EAttribute) {
+ Object value = element.eGet((EAttribute)attributeMatch.getMetaAttribute());
+ if(value != null) {
+ if(value instanceof String) {
+ String originalvalue = (String)value;
+ Pattern pattern = PatternHelper.getInstance().createPattern(fQuery.getSearchQueryText(), fQuery.isCaseSensitive(), fQuery.isRegularExpression());
+
+ String newValue = computeReplacementString(pattern, originalvalue, fNewString);
+
+ element.eSet((EAttribute)attributeMatch.getMetaAttribute(), newValue);
+
+ }
+ }
+ }
+
+ else if(attributeMatch.getMetaAttribute() instanceof Property) {
+ Property source = (Property)attributeMatch.getMetaAttribute();
+ Class containingClass = source.getClass_();
+ if(containingClass instanceof Stereotype) {
+ if(element instanceof Element) {
+ Stereotype stereotype = ((Element)element).getAppliedStereotype(containingClass.getQualifiedName());
+ Object tagValue = ((Element)element).getValue(stereotype, source.getName());
+ if(tagValue instanceof String) {
+ Object value = tagValue;
+
+ if(value != null) {
+ if(value instanceof String) {
+ String originalvalue = (String)value;
+ Pattern pattern = PatternHelper.getInstance().createPattern(fQuery.getSearchQueryText(), fQuery.isCaseSensitive(), fQuery.isRegularExpression());
+
+ String newValue = computeReplacementString(pattern, originalvalue, fNewString);
+
+ ((Element)element).setValue(stereotype, source.getName(), newValue);
+
+ }
+ }
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ /**
+ * Compute the replacement.
+ * @param pattern The pattern that we will us to compute the replacement.
+ * @param originalText The String to be modified.
+ * @param replacementText The String to append.
+ * @return The new String.
+ */
+ private String computeReplacementString(Pattern pattern, String originalText, String replacementText) throws PatternSyntaxException {
+ if(pattern != null) {
+ try {
+
+ Matcher matcher = pattern.matcher(originalText);
+ StringBuffer sb = new StringBuffer();
+ matcher.reset();
+ if(matcher.find()) {
+ matcher.appendReplacement(sb, replacementText);
+ } else {
+ return null;
+ }
+ matcher.appendTail(sb);
+ return sb.toString();
+ } catch (IndexOutOfBoundsException ex) {
+ throw new PatternSyntaxException(ex.getLocalizedMessage(), replacementText, -1);
+ }
+ }
+ return replacementText;
+ }
+
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceRefactoring.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceRefactoring.java
new file mode 100644
index 00000000000..51a8d4f79b6
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceRefactoring.java
@@ -0,0 +1,151 @@
+package org.eclipse.papyrus.uml.search.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.papyrus.infra.refactoring.refactoringOnElement.AbstractTransformationOnElement;
+import org.eclipse.papyrus.infra.refactoring.refactoringOnElement.ITransformationOnElement;
+import org.eclipse.papyrus.uml.search.ui.Messages;
+import org.eclipse.papyrus.uml.search.ui.actions.ReplaceTransformationOnElement;
+import org.eclipse.papyrus.uml.search.ui.pages.PapyrusSearchResultPage;
+import org.eclipse.papyrus.uml.search.ui.query.AbstractPapyrusQuery;
+import org.eclipse.papyrus.views.search.results.AbstractResultEntry;
+import org.eclipse.papyrus.views.search.results.AttributeMatch;
+import org.eclipse.papyrus.views.search.utils.MatchUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+public class ReplaceRefactoring extends AbstractTransformationOnElement {
+
+ private Text fNewValueText;
+
+ private Text fOldValueText;
+
+ private PapyrusSearchResultPage fResultPage;
+
+ private AbstractPapyrusQuery fQuery;
+
+ private Object[] fSelection;
+
+ private Set<AbstractResultEntry> fListMatch;
+
+
+
+ public ReplaceRefactoring(PapyrusSearchResultPage resultPage, Object[] selection) {
+ super(Messages.ReplaceRefactoring_0);
+ fResultPage = resultPage;
+ fSelection = selection;
+ fQuery = (AbstractPapyrusQuery)fResultPage.getInput().getQuery();
+ initListMatches();
+
+
+ }
+
+
+ private Text createNameField(Composite result) {
+ Text field = new Text(result, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+ field.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ return field;
+ }
+
+
+
+ @Override
+ public RefactoringStatus checkFinalConditions() {
+ RefactoringStatus status = new RefactoringStatus();
+ if(fNewValueText.getText().isEmpty()) {
+ status.merge(RefactoringStatus.createFatalErrorStatus(Messages.ReplaceRefactoring_1));
+ } else if(fNewValueText.getText().equals(fQuery.getSearchQueryText())) {
+ status.merge(RefactoringStatus.createFatalErrorStatus(Messages.ReplaceRefactoring_2));
+
+ }
+ return status;
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+
+
+ GridLayout layout = new GridLayout();
+
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+
+ setControl(composite);
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(Messages.ReplaceRefactoring_3);
+ fOldValueText = createNameField(composite);
+ fOldValueText.setFocus();
+ fOldValueText.setText(fQuery.getSearchQueryText());
+ fOldValueText.setEnabled(false);
+
+
+ label = new Label(composite, SWT.NONE);
+ label.setText(Messages.ReplaceRefactoring_4);
+
+ fNewValueText = createNameField(composite);
+
+ GridData data = new GridData();
+ data.horizontalAlignment = SWT.END;
+
+ }
+
+
+
+ private void initListMatches() {
+ fListMatch = new HashSet<AbstractResultEntry>();
+ if(fSelection == null) {
+ for(AbstractResultEntry resultEntry : MatchUtils.getMatches(fResultPage.getInput(), false)) {
+ if(resultEntry instanceof AttributeMatch) {
+ fListMatch.add((AttributeMatch)resultEntry);
+ }
+ }
+ } else {
+ for(Object selected : Arrays.asList(fSelection)) {
+ if(selected instanceof AttributeMatch) {
+ fListMatch.add((AttributeMatch)selected);
+ }
+ }
+
+ }
+
+ }
+
+ @Override
+ public Collection<EObject> getElementsListToTransform() {
+ List<EObject> toProcess = new ArrayList<EObject>();
+ for(AbstractResultEntry match : fListMatch) {
+ if(match.getSource() instanceof EObject) {
+ if(!toProcess.contains(match.getSource())) {
+ toProcess.add((EObject)match.getSource());
+ }
+
+ }
+ }
+ return toProcess;
+ }
+
+ @Override
+ public ITransformationOnElement getTransformationOnElement() {
+
+ return new ReplaceTransformationOnElement(fListMatch, fQuery, fNewValueText.getText());
+
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/manager/PapyrusSearchTextManager.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/manager/PapyrusSearchTextManager.java
new file mode 100644
index 00000000000..de6b4f62df3
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/manager/PapyrusSearchTextManager.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.search.ui.manager;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.uml.search.ui.Messages;
+import org.eclipse.papyrus.uml.search.ui.providers.ParticipantTypeAttribute;
+import org.eclipse.papyrus.uml.search.ui.providers.ParticipantTypeElement;
+import org.eclipse.papyrus.uml.search.ui.query.PapyrusAdvancedQuery;
+import org.eclipse.papyrus.uml.search.ui.query.PapyrusQuery;
+import org.eclipse.papyrus.views.search.scope.ScopeEntry;
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ *Manage the search depending on user choices.
+ *
+ */
+public class PapyrusSearchTextManager {
+
+ private Collection<ScopeEntry> fScopeEntries;
+
+ private boolean fIsCaseSensitive;
+
+ private boolean fIsRegularExpression;
+
+ private String fQueryText;
+
+ public PapyrusSearchTextManager(Collection<ScopeEntry> scopeEntries, boolean isCaseSensitive, boolean isRegularExpression, String queryText) {
+ fScopeEntries = scopeEntries;
+ fIsCaseSensitive = isCaseSensitive;
+ fIsRegularExpression = isRegularExpression;
+ fQueryText = queryText;
+ }
+
+ public ISearchQuery manageSimpleSearch(boolean searchAllStrings, Object[] umlMetaClassesArray) {
+ if(fQueryText.isEmpty()) {
+ MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_29, Messages.PapyrusSearchPage_30);
+ return null;
+ } else {
+ PapyrusQuery query = new PapyrusQuery(fQueryText, fIsCaseSensitive, fIsRegularExpression, fScopeEntries, umlMetaClassesArray, searchAllStrings);
+ return query;
+ }
+
+ }
+
+ public ISearchQuery manageAdvancedSearch(HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>> participantsList, Object[] checkedElements, boolean searchForAllSter) {
+ List<ParticipantTypeElement> participantsToEvaluate = getParticipantsToEvaluate(participantsList);
+
+
+ if(participantsToEvaluate.size() == 0) {
+
+ MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_31, Messages.PapyrusSearchPage_32);
+ return null;
+ } else {
+ if(fQueryText.isEmpty()) {
+ for(Object participantChecked : checkedElements) {
+ if(participantChecked instanceof ParticipantTypeAttribute) {
+ MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_33, Messages.PapyrusSearchPage_34);
+ return null;
+ }
+ }
+ }
+
+ PapyrusAdvancedQuery query = new PapyrusAdvancedQuery(fQueryText, fIsCaseSensitive, fIsRegularExpression, fScopeEntries, participantsToEvaluate.toArray(), searchForAllSter);
+ return query;
+ }
+ }
+
+ private List<ParticipantTypeElement> getParticipantsToEvaluate(HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>> participantsList) {
+ List<ParticipantTypeElement> participantsToEvaluate = new ArrayList<ParticipantTypeElement>();
+
+ for(ParticipantTypeElement element : participantsList.keySet()) {
+ if(element.isChecked()) {
+ participantsToEvaluate.add(element);
+ for(ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) {
+ if(attributesToEvaluate.isChecked()) {
+ participantsToEvaluate.add(attributesToEvaluate);
+ }
+ }
+ }
+ }
+ return participantsToEvaluate;
+ }
+}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/messages.properties b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/messages.properties
index 2f19d527713..3fcc2a68c0d 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/messages.properties
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/messages.properties
@@ -16,6 +16,7 @@ PapyrusSearchPage_1=Query issue
PapyrusSearchPage_10=Deselect All
PapyrusSearchPage_11=Simple search
PapyrusSearchPage_12=Advanced search
+PapyrusSearchPage_13=Search for elements with exactly all the specified stereotypes
PapyrusSearchPage_14=Select subelements
PapyrusSearchPage_15=Refresh types
PapyrusSearchPage_16=Search only in name attribute
@@ -73,6 +74,11 @@ ReplaceDialog_1=Replace\:
ReplaceDialog_2=With\:
ReplaceDialog_3=WARNING\: replace action is not undoable if resource containing the match is not already open in an editor.
ReplaceDialog_4=Failed to save resource\:
+ReplaceRefactoring_0=Replace
+ReplaceRefactoring_1=Please indicate the new value which should replace the original.
+ReplaceRefactoring_2=Original and new strings are same.
+ReplaceRefactoring_3=&Replace:
+ReplaceRefactoring_4=&With:
ResultContentProvider_0=The plug-in
ResultContentProvider_10=The plug-in
ResultContentProvider_11=\ contributed an invalid extension for
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 044a4a815e7..46e7cfc58f2 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
@@ -19,7 +19,9 @@ import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import java.util.regex.PatternSyntaxException;
import org.eclipse.core.runtime.IAdaptable;
@@ -140,10 +142,6 @@ import com.google.inject.Injector;
*/
public class PapyrusSearchPage extends DialogPage implements ISearchPage, IReplacePage, MetaModelManagerListener {
- public PapyrusSearchPage() {
- }
-
-
private HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>> participantsList = new HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>>();
private Collection<Stereotype> availableStereotypes;
@@ -154,10 +152,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
private static final String SEARCH_ISSUE = Messages.PapyrusSearchPage_1;
- private static final String SEARCH_IN_ALL_STRINGS = Messages.PapyrusSearchPage_2;
-
- private static final String SEARCH_IN_STEREOTYPE_ATTRIBUTES = Messages.PapyrusSearchPage_3;
-
private Text searchQueryText;
private Text oclContext;
@@ -191,8 +185,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
private static final int TEXT_QUERY_KIND = 0;
- private static final int OCL_QUERY_KIND = 1;
-
private static final int SIMPLE_SEARCH = 0;
private static final int ADVANCED_SEARCH = 1;
@@ -205,17 +197,13 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
protected Composite textQueryComposite;
- protected Composite textQueryComposite2;
-
-
-
private Composite advancedSearchComposite;
- protected Group grpSearchFor;
-
private Composite textQueryFieldsComposite;
- protected ParticipantTypeContentProvider participantTypeContentProvider = new ParticipantTypeContentProvider();
+
+ private Button fBtnSearchForAllSelected;
+
@@ -270,7 +258,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
- grpSearchFor = new Group(textQueryComposite, SWT.NONE);
+ Group grpSearchFor = new Group(textQueryComposite, SWT.NONE);
grpSearchFor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
grpSearchFor.setLayout(new GridLayout(1, false));
grpSearchFor.setText(Messages.PapyrusSearchPage_8);
@@ -296,9 +284,9 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
if(searchKind.getSelectionIndex() == ADVANCED_SEARCH) {
- if(participantsList.size() == 0) {
+ participantsList.clear();
createResultList();
- }
+
createAdvancedSearch();
} else {
simpleSearch();
@@ -391,7 +379,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
participantTypesTree.setLayoutData(chechboxTreeViewerGridData);
participantTypesTreeViewer = (CheckboxTreeViewer)participantTypesTree.getViewer();
- participantTypesTreeViewer.setContentProvider(participantTypeContentProvider);
+ participantTypesTreeViewer.setContentProvider(new ParticipantTypeContentProvider());
participantTypesTreeViewer.setLabelProvider(new ParticipantTypeLabelProvider());
participantTypesTreeViewer.setSorter(new ViewerSorter());
participantTypesTreeViewer.setCheckStateProvider(new ICheckStateProvider() {
@@ -504,6 +492,8 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
@Override
public void mouseUp(MouseEvent e) {
+ participantsList.clear();
+ createResultList();
createAdvancedSearch();
@@ -557,33 +547,47 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
});
+
+ fBtnSearchForAllSelected = new Button(advancedSearchComposite, SWT.CHECK);
+ fBtnSearchForAllSelected.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+ fBtnSearchForAllSelected.setText(Messages.PapyrusSearchPage_13);
}
protected void selectAllSubSter(final ParticipantTypeElement elementParent, final List<ParticipantTypeAttribute> attributeParentList) {
- // for(Object element : result) {
- // if(element instanceof Stereotype) {
- // List<Class> superTypes = ((Stereotype)element).getSuperClasses();
- // for(Class type : superTypes) {
- // ((Stereotype)elementParent).getName();
- //
- // if(((Class)type).getName().equals(((Stereotype)elementParent).getName())) {
- // participantTypesTreeViewer.setChecked(element, true);
- //
- // }
- // }
- // }
- // }
+
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
IRunnableWithProgress computeAvailableTypes = new IRunnableWithProgress() {
public void run(IProgressMonitor thePM) throws InterruptedException {
for(Object element : participantsList.keySet()) {
if(element instanceof ParticipantTypeElement) {
+ checkAllSubSter((ParticipantTypeElement)element, elementParent, attributeParentList);
+
+ }
+ }
+
+
+ }
+
+ };
+
+
+ try {
+ dialog.run(true, true, computeAvailableTypes);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
+ protected void checkAllSubSter(ParticipantTypeElement element, ParticipantTypeElement elementParent, List<ParticipantTypeAttribute> attributeParentList) {
if(((ParticipantTypeElement)element).getElement() instanceof Stereotype) {
List<Class> superTypes = ((Class)((ParticipantTypeElement)element).getElement()).getSuperClasses();
if(superTypes.contains(elementParent.getElement())) {
- // participantTypesTreeViewer.setChecked(element, true);
((ParticipantTypeElement)element).setChecked(true);
@@ -602,10 +606,20 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
}
}
- }
+ protected void selectAllSubUML(final ParticipantTypeElement elementParent, final List<ParticipantTypeAttribute> attributeParentList) {
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
+ IRunnableWithProgress computeAvailableTypes = new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor thePM) throws InterruptedException {
+ for(Object element : participantsList.keySet()) {
+ if(element instanceof ParticipantTypeElement) {
+ checkAllSubUML((ParticipantTypeElement)element, elementParent, attributeParentList);
}
+ }
+ }
};
@@ -621,14 +635,8 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
- protected void selectAllSubUML(final ParticipantTypeElement elementParent, final List<ParticipantTypeAttribute> attributeParentList) {
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
- IRunnableWithProgress computeAvailableTypes = new IRunnableWithProgress() {
- public void run(IProgressMonitor thePM) throws InterruptedException {
- for(Object element : participantsList.keySet()) {
- if(element instanceof ParticipantTypeElement) {
+ protected void checkAllSubUML(ParticipantTypeElement element, ParticipantTypeElement elementParent, List<ParticipantTypeAttribute> attributeParentList) {
if(((ParticipantTypeElement)element).getElement() instanceof EClass) {
List<EClass> superTypes = ((EClass)((ParticipantTypeElement)element).getElement()).getEAllSuperTypes();
@@ -651,23 +659,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
}
}
- }
- }
-
-
- }
-
- };
- try {
- dialog.run(true, true, computeAvailableTypes);
- } catch (InvocationTargetException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (InterruptedException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
}
@@ -691,6 +683,19 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
+ public Object[] getMetaClassesList() {
+ Set<EObject> umlMetaClasses= new HashSet<EObject>();
+
+ for(EClassifier eClassifier : UMLPackage.eINSTANCE.getEClassifiers()) {
+ if(eClassifier instanceof EClass) {
+ umlMetaClasses.add(eClassifier);
+ }
+ }
+ return umlMetaClasses.toArray();
+
+ }
+
+
protected void createOCLSearchQueryField(EObject root) {
Composite client = queryComposite;
@@ -719,7 +724,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
if(currentScope != null) {
try {
- EObject root = ((UmlModel)currentScope.getModelSet().getModel(UmlModel.MODEL_ID)).lookupRoot();
+ ((UmlModel)currentScope.getModelSet().getModel(UmlModel.MODEL_ID)).lookupRoot();
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(Display.getCurrent().getActiveShell(), labelProvider, new OCLContextContentProvider());
dialog.setTitle(Messages.PapyrusSearchPage_19);
@@ -757,6 +762,7 @@ 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;
@@ -913,8 +919,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
if(selectedObject instanceof IOutlineNode) {
if(selectedObject instanceof EObjectNode) {
EObjectNode selectedObjectNode = (EObjectNode)selectedObject;
- @SuppressWarnings("unused")
- URI eObjectURI = selectedObjectNode.getEObjectURI();
+ selectedObjectNode.getEObjectURI();
contextObject = null; // FIXME
// metaModelManager.loadResource(eObjectURI,
// null, null);
@@ -952,6 +957,37 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
});
}
+
+ private Collection<ScopeEntry> createScopeEntries(Collection<URI> scope) {
+ Collection<ScopeEntry> results = new HashSet<ScopeEntry>();
+
+ for(URI resource : scope) {
+
+ ScopeEntry scopeEntry = new ScopeEntry(resource);
+
+ results.add(scopeEntry);
+
+ }
+
+ return results;
+ }
+
+ private List<ParticipantTypeElement> getParticipantsToEvaluate(HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>> participantsList) {
+ List<ParticipantTypeElement> participantsToEvaluate = new ArrayList<ParticipantTypeElement>();
+
+ for(ParticipantTypeElement element : participantsList.keySet()) {
+ if(element.isChecked()) {
+ participantsToEvaluate.add(element);
+ for(ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) {
+ if(attributesToEvaluate.isChecked()) {
+ participantsToEvaluate.add(attributesToEvaluate);
+ }
+ }
+ }
+ }
+ return participantsToEvaluate;
+ }
+
public boolean performAction() {
if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) {
@@ -994,7 +1030,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
}
- QueryInfo info = new QueryInfo(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), participantsToEvaluate, scope);
+ QueryInfo info = new QueryInfo(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), participantsToEvaluate, scope, fBtnSearchForAllSelected.getSelection());
query = CompositePapyrusQueryProvider.getInstance().createAdvancedSearchQuery(info);
}
@@ -1045,6 +1081,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
public boolean performReplace() {
if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) {
+ if(container.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) {
if(validateRegex()) {
if(searchQueryText.getText().length() == 0) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_36, Messages.PapyrusSearchPage_37);
@@ -1070,8 +1107,19 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
for(ParticipantTypeAttribute attributesToEvaluate : participantsList.get(element)) {
if(attributesToEvaluate.isChecked()) {
participantsToEvaluate.add(attributesToEvaluate);
+ boolean canDoReplace = false;
+ if(attributesToEvaluate.getElement() instanceof EAttribute) {
Object value = element.getElement().eGet((EAttribute)attributesToEvaluate.getElement());
- if(!(value instanceof String)) {
+ if(value instanceof String) {
+ canDoReplace = true;
+ }
+ } else if(attributesToEvaluate.getElement() instanceof Property) {
+ Property property = (Property)attributesToEvaluate.getElement();
+ if(UMLUtil.isString(property.getType())) {
+ canDoReplace = true;
+ }
+ }
+ if(!canDoReplace) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_40, Messages.PapyrusSearchPage_41);
return false;
}
@@ -1080,7 +1128,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
}
}
- QueryInfo info = new QueryInfo(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), participantsToEvaluate, scope);
+ QueryInfo info = new QueryInfo(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), participantsToEvaluate, scope, fBtnSearchForAllSelected.getSelection());
query = CompositePapyrusQueryProvider.getInstance().createAdvancedSearchQuery(info);
}
@@ -1104,14 +1152,17 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
});
- NewSearchUI.runQueryInForeground(container.getRunnableContext(), query);
-
+ NewSearchUI.removeQuery(query);
return true;
} else {
MessageDialog.openError(Display.getCurrent().getActiveShell(), SEARCH_ISSUE, REGULAR_EXPRESSION_ILLFORMED);
return false;
}
} else {
+ MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_27, Messages.PapyrusSearchPage_28);
+ return false;
+ }
+ } else {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_42, Messages.PapyrusSearchPage_43);
return false;
}
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 d133e3adf43..2182ad93585 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
@@ -26,6 +26,7 @@ import org.eclipse.papyrus.views.search.results.AttributeMatch;
import org.eclipse.swt.graphics.Image;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.EnumerationLiteral;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Stereotype;
@@ -72,18 +73,8 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
Class containingClass = source.getClass_();
if(containingClass instanceof Stereotype) {
if(target instanceof Element) {
-
- Object tagValue = ((Element)target).getValue((Stereotype)containingClass, ((Property)attributeMatch.getMetaAttribute()).getName());
-
- if(tagValue instanceof String) {
- String value = (String)tagValue;
- int end = attributeMatch.getOffset() + attributeMatch.getLength();
- return printResult(value.substring(attributeMatch.getOffset(), end), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
- } else {
- String value = String.valueOf(tagValue);
- int end = attributeMatch.getOffset() + attributeMatch.getLength();
- return printResult(value.substring(attributeMatch.getOffset(), end), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
- }
+ String value = getStringValueOfProperty(((Element)target), (Stereotype)containingClass, (Property)attributeMatch.getMetaAttribute());
+ return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
}
}
@@ -120,4 +111,15 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
return false;
}
+ private String getStringValueOfProperty(Element element, Stereotype stereotype, Property property) {
+ Object value = element.getValue(stereotype, property.getName());
+ if(value instanceof String) {
+ return (String)value;
+ } else if(value instanceof EnumerationLiteral) {
+ return ((EnumerationLiteral)value).getName();
+ } else {
+ return String.valueOf(value);
+ }
+ }
+
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java
index 07b4ea93a44..90747d62b36 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ParticipantTypeContentProvider.java
@@ -31,9 +31,6 @@ public class ParticipantTypeContentProvider implements ITreeContentProvider {
- private EPackage ePackage = null;
-
-
private HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>> participantsList = new HashMap<ParticipantTypeElement, List<ParticipantTypeAttribute>>();
@@ -59,11 +56,7 @@ public class ParticipantTypeContentProvider implements ITreeContentProvider {
return ((HashMap)inputElement).keySet().toArray();
}
- // for(Object obj : (Collection<Object>)inputElement) {
- // result.add(obj);
- // }
-
-
+
return result.toArray();
}
@@ -75,40 +68,6 @@ public class ParticipantTypeContentProvider implements ITreeContentProvider {
}
return null;
- // List<ParticipantTypeAttribute> result = new ArrayList<ParticipantTypeAttribute>();
- // if(parentElement instanceof ParticipantTypeElement) {
- //
- // if(((ParticipantTypeElement)parentElement).getElement() instanceof EClass) {
- // // result.addAll(((EClass)parentElement).getEAllAttributes());
- // for(EObject eAttribute : ((EClass)((ParticipantTypeElement)parentElement).getElement()).getEAllAttributes()) {
- // ParticipantTypeAttribute attribute = new ParticipantTypeAttribute(eAttribute, ((ParticipantTypeElement)parentElement));
- //
- // result.add(attribute);
- //
- // }
- //
- //
- // } else if(((ParticipantTypeElement)parentElement).getElement() instanceof Stereotype) {
- //
- // for(Property property : ((Stereotype)((ParticipantTypeElement)parentElement).getElement()).getAllAttributes()) {
- // if(!property.getName().startsWith("base_")) {
- // if(property.getType() instanceof Element) {
- //
- // if(UMLUtil.isBoolean(property.getType()) || UMLUtil.isString(property.getType()) || UMLUtil.isInteger(property.getType()) || UMLUtil.isReal(property.getType()) || UMLUtil.isUnlimitedNatural(property.getType()) || property.getType() instanceof Enumeration) {
- // // result.add(property);
- // ParticipantTypeAttribute attribute = new ParticipantTypeAttribute(property, (ParticipantTypeElement)parentElement);
- //
- // result.add(attribute);
- //
- //
- // }
- // }
- // }
- // }
- // }
- // }
- //
- // return result.toArray();
}
public Object getParent(Object element) {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java
index 989ede3387c..1ceb4662045 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java
@@ -42,7 +42,6 @@ public class ResultLabelProvider extends LabelProvider {
if(element instanceof AbstractResultEntry) {
return labelProviderService.getLabelProvider().getText(((AbstractResultEntry)element).elementToDisplay());
}
-
return ""; //$NON-NLS-1$
}
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 a0309c2fd13..32fcbbcd602 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
@@ -52,6 +52,7 @@ import org.eclipse.papyrus.views.search.scope.ScopeEntry;
import org.eclipse.search.ui.ISearchResult;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Enumeration;
+import org.eclipse.uml2.uml.EnumerationLiteral;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.util.UMLUtil;
@@ -97,11 +98,13 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
private List<Property> propertyList;
+ private boolean searchForAllSter;
- public PapyrusAdvancedQuery(String searchQueryText, boolean isCaseSensitive, boolean isRegularExpression, Collection<ScopeEntry> scopeEntries, Object[] participantsChecked) {
+
+ public PapyrusAdvancedQuery(String searchQueryText, boolean isCaseSensitive, boolean isRegularExpression, Collection<ScopeEntry> scopeEntries, Object[] participantsChecked, boolean searchForAllSter) {
this.propertyList = new ArrayList<Property>();
this.sources = new HashSet<Object>();
this.searchQueryText = searchQueryText;
@@ -109,6 +112,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
this.isRegularExpression = isRegularExpression;
this.scopeEntries = scopeEntries;
this.participantsChecked = participantsChecked;
+ this.searchForAllSter = searchForAllSter;
results = new PapyrusSearchResult(this);
participantsList = new HashMap<EObject, List<EAttribute>>();
@@ -156,14 +160,26 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
EObject root = umlModel.lookupRoot();
Collection<EObject> participants = ParticipantValidator.getInstance().getParticipants(root, participantsList.keySet().toArray());
+ Collection<EObject> stereotypesParticipants = ParticipantValidator.getInstance().getParticipantsStereotype(root, stereotypeList.keySet().toArray());
+ if(searchForAllSter) {
+
+ if(participantsList.keySet().size() == 0) {
+ stereotypesParticipants = getElementsWithAllSter(stereotypesParticipants);
+ evaluateStereotypes(stereotypesParticipants, scopeEntry);
+ } else {
+ participants = getElementsWithAllSter(participants);
+ evaluate(participants, scopeEntry);
+ }
+
+ } else {
+ evaluate(participants, scopeEntry);
+ evaluateStereotypes(stereotypesParticipants, scopeEntry);
+ }
- evaluate(participants, scopeEntry);
- Collection<EObject> stereotypesParticipants = ParticipantValidator.getInstance().getParticipantsStereotype(root, stereotypeList.keySet().toArray());
- evaluateStereotypes(stereotypesParticipants, scopeEntry);
}
} catch (NotFoundException e) {
Activator.log.error(Messages.PapyrusQuery_0 + scopeEntry.getModelSet(), e);
@@ -174,6 +190,29 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
return Status.OK_STATUS;
}
+ private Collection<EObject> getElementsWithAllSter(Collection<EObject> initialParticipants) {
+ Collection<EObject> participantsToKeep = new ArrayList<EObject>();
+ for(EObject participants : initialParticipants) {
+ if(participants instanceof Element) {
+ int numberOfStereotypeToBeApplied = stereotypeList.size();
+ int numberOfStereotypeMatching = 0;
+ if(numberOfStereotypeToBeApplied == ((Element)participants).getAppliedStereotypes().size()) {
+ for(Stereotype stereotypeToBeApplied : stereotypeList.keySet()) {
+ for(Stereotype stereotypeApplied : ((Element)participants).getAppliedStereotypes()) {
+ if(EcoreUtil.equals(stereotypeToBeApplied, stereotypeApplied)) {
+ numberOfStereotypeMatching++;
+ }
+ }
+ }
+ if(numberOfStereotypeMatching == numberOfStereotypeToBeApplied) {
+ participantsToKeep.add(participants);
+ }
+ }
+ }
+ }
+ return participantsToKeep;
+ }
+
/**
* Evaluate if the value matches the pattern
*
@@ -321,15 +360,11 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
for(Property property : propertyList) {
for(Property property2 : (stereotypeList.get(stereotypeSelected))) {
if(EcoreUtil.equals(property, property2)) {
- Object value = ((Element)participant).getValue(stereotype, property.getName());
+
+ String value = getStringValueOfProperty((Element)participant, stereotype, property);
+
if(value != null) {
- if(value instanceof String) {
- String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
- } else {
- String stringValue = String.valueOf(value);
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
- }
+ evaluateAndAddToResult(value, property, pattern, participant, scopeEntry, stereotype);
}
}
}
@@ -343,10 +378,22 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
}
+
findInDiagram(scopeEntry);
}
+ private String getStringValueOfProperty(Element element, Stereotype stereotype, Property property) {
+ Object value = element.getValue(stereotype, property.getName());
+ if(value instanceof String) {
+ return (String)value;
+ } else if(value instanceof EnumerationLiteral) {
+ return ((EnumerationLiteral)value).getName();
+ } else {
+ return String.valueOf(value);
+ }
+ }
+
public List<Property> getStereotypesAttributes(Object parentElement) {
List<Property> result = new ArrayList<Property>();
if(parentElement instanceof Stereotype) {
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 3dd729e5aac..6e9a377efed 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
@@ -17,6 +17,8 @@ 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;
@@ -51,7 +53,6 @@ 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;
@@ -128,16 +129,19 @@ 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) {
- Activator.log.error(e);
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getMessage());
}
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,25 +151,28 @@ 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;
- 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());
- // }
+ if(e.getLocalizedMessage() == null) {
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getClass().getName());
+ } else {
+ // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getLocalizedMessage());
+ }
}
return result;
@@ -222,6 +229,17 @@ 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;
@@ -274,6 +292,138 @@ 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 d65a2827e10..ec6dfd20d77 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
@@ -133,7 +133,7 @@ public class PapyrusQuery 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$
@@ -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, null);
+ ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
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, null);
+ AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
fResults.add(match);
}
}
@@ -190,7 +190,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
if(value instanceof String) {
String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry, null);
}
}
@@ -203,7 +203,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
if(value instanceof String) {
String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry, stereotype);
}
}
}
@@ -215,7 +215,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
String umlElementName = ((NamedElement)participant).getName();
umlElementName = umlElementName != null ? umlElementName : ""; //$NON-NLS-1$
- evaluateAndAddToResult(umlElementName, UMLPackage.eINSTANCE.getNamedElement_Name(), pattern, participant, scopeEntry);
+ evaluateAndAddToResult(umlElementName, UMLPackage.eINSTANCE.getNamedElement_Name(), pattern, participant, scopeEntry, null);
}
}
@@ -255,12 +255,17 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
}
}
+
+ public Set<AbstractResultEntry> getResults() {
+ return fResults;
+ }
+
public String getLabel() {
return Messages.PapyrusQuery_6;
}
public boolean canRerun() {
- return true;
+ return false;
}
public boolean canRunInBackground() {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java
index 1f0251bcec8..9f1d79c69d5 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/QueryInfo.java
@@ -32,6 +32,8 @@ public class QueryInfo {
private boolean searchAllStringAttributes;
private Collection<? extends ParticipantTypeElement> participantTypes;
+
+ private boolean searchForAllSter;
private Collection<URI> scope;
@@ -53,6 +55,7 @@ public class QueryInfo {
public QueryInfo(String queryText, boolean caseSensitive, boolean regularExpression, boolean searchAllStringAttributes, Collection<URI> scope) {
super();
+
this.queryText = queryText;
this.caseSensitive = caseSensitive;
this.regularExpression = regularExpression;
@@ -72,10 +75,12 @@ public class QueryInfo {
* whether the {@code queryText} is to be taken as a regular expression
* @param participantTypes
* the participant types (identifying specific metaclasses and/or attributes) to include in the search
+ * @param searchForAllSter
+ * stereotype application must all applied or not
* @param scope
* the domain-specific search scope
*/
- public QueryInfo(String queryText, boolean caseSensitive, boolean regularExpression, Collection<? extends ParticipantTypeElement> participantTypes, Collection<URI> scope) {
+ public QueryInfo(String queryText, boolean caseSensitive, boolean regularExpression, Collection<? extends ParticipantTypeElement> participantTypes, Collection<URI> scope,boolean searchForAllSter) {
super();
this.queryText = queryText;
@@ -84,6 +89,7 @@ public class QueryInfo {
this.searchAllStringAttributes = false;
this.participantTypes = participantTypes;
this.scope = scope;
+ this.searchForAllSter = searchForAllSter;
}
/**
@@ -97,6 +103,7 @@ public class QueryInfo {
this.regularExpression = original.regularExpression;
this.searchAllStringAttributes = original.searchAllStringAttributes;
this.participantTypes = original.participantTypes;
+ this.searchForAllSter = original.searchForAllSter;
this.scope = scope;
}
@@ -123,6 +130,11 @@ public class QueryInfo {
public Collection<URI> getScope() {
return scope;
}
+
+ public boolean isSearchForAllSter() {
+ return searchForAllSter;
+ }
+
/**
* Creates a new instance encapsulating query parameters for the specified partition (strict subset) of my {@linkplain #getScope() scope}.
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java
index 18318084408..5296eec748d 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/WorkspaceQueryProvider.java
@@ -51,7 +51,7 @@ public class WorkspaceQueryProvider implements IPapyrusQueryProvider {
public AbstractPapyrusQuery createAdvancedSearchQuery(QueryInfo queryInfo) {
Collection<ScopeEntry> scopeEntries = createScopeEntries(queryInfo.getScope());
- return new PapyrusAdvancedQuery(queryInfo.getQueryText(), queryInfo.isCaseSensitive(), queryInfo.isRegularExpression(), scopeEntries, queryInfo.getParticipantTypes().toArray());
+ return new PapyrusAdvancedQuery(queryInfo.getQueryText(), queryInfo.isCaseSensitive(), queryInfo.isRegularExpression(), scopeEntries, queryInfo.getParticipantTypes().toArray(),queryInfo.isSearchForAllSter());
}
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 b64c82da64c..0afcb88d95d 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
@@ -28,6 +28,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
import org.eclipse.papyrus.uml.search.ui.Activator;
@@ -49,7 +50,9 @@ 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.EnumerationLiteral;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Stereotype;
import com.google.common.base.Objects;
import com.swtdesigner.ResourceManager;
@@ -167,22 +170,20 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
if(match instanceof AbstractResultEntry) {
if(((AbstractResultEntry)match).getSource() != null) {
if(match instanceof AttributeMatch) {
-
+ Object attribute = ((AttributeMatch)match).getMetaAttribute();
String value = null;
EObject target = (EObject)((AbstractResultEntry)match).getSource();
- if(((AttributeMatch)match).getMetaAttribute() instanceof EAttribute) {
+ if(attribute instanceof EAttribute) {
- EAttribute attribute = (EAttribute)((AttributeMatch)match).getMetaAttribute();
- value = String.valueOf(target.eGet(attribute));
- } else if(((AttributeMatch)match).getMetaAttribute() instanceof Property) {
+ value = String.valueOf(target.eGet((EStructuralFeature)attribute));
+ } else if(attribute instanceof Property) {
- Property attribute = (Property)((AttributeMatch)match).getMetaAttribute();
- value = (String)((Element)((AbstractResultEntry)match).getSource()).getValue(((AttributeMatch)match).getStereotype(), attribute.getName());
+ value = getStringValueOfProperty((Element)((AbstractResultEntry)match).getSource(), ((AttributeMatch)match).getStereotype(), ((Property)attribute));
}
if(value != null && !this.getQuery().isRegularExpression()) {
- if(value.length() >= match.getOffset() + match.getLength()) {
+ if(value.length() >= match.getLength() - match.getOffset()) {
int end = match.getOffset() + match.getLength();
value = value.substring(match.getOffset(), end);
if(this.searchQuery.isCaseSensitive()) {
@@ -226,7 +227,7 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
}
}
}
- // Now get Viewers
+ // Now get Viewer
for(Match match : matchList) {
if(match instanceof ViewerMatch) {
Object source = ((ViewerMatch)match).getSemanticElement();
@@ -238,7 +239,8 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
}
return (Match[])matchToKeep.toArray(new Match[matchToKeep.size()]);
-
+ // return ((PapyrusQuery)searchQuery).getfResults().toArray(new Match[matchToKeep.size()]);
+ //
}
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
@@ -274,6 +276,16 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
return count;
}
+ private String getStringValueOfProperty(Element element, Stereotype stereotype, Property property) {
+ Object value = element.getValue(stereotype, property.getName());
+ if(value instanceof String) {
+ return (String)value;
+ } else if(value instanceof EnumerationLiteral) {
+ return ((EnumerationLiteral)value).getName();
+ } else {
+ return String.valueOf(value);
+ }
+ }
}
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 09e2def3e46..ab63bc3a987 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
@@ -35,6 +35,7 @@ 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.core.resource.ModelSet;
import org.eclipse.papyrus.infra.emf.utils.BusinessModelResolver;
import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile;
import org.eclipse.search.ui.ISearchPageContainer;
@@ -111,7 +112,7 @@ public class StereotypeCollector implements IStereotypeCollector {
}
for(URI uri : umlResources) {
- ResourceSet resourceSet = new ResourceSetImpl();
+ ModelSet resourceSet = new ModelSet();
Resource resource = resourceSet.getResource(uri, true);
TreeIterator<EObject> UMLResourceContentIterator = resource.getAllContents();
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/regex/PatternHelper.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/regex/PatternHelper.java
index 2ad1497849b..96495a60fed 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/regex/PatternHelper.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/regex/PatternHelper.java
@@ -35,14 +35,13 @@ public class PatternHelper {
* @return the helper
*/
public final static PatternHelper getInstance() {
-
- if(PatternHelper.instance == null) {
+
synchronized(PatternHelper.class) {
if(PatternHelper.instance == null) {
PatternHelper.instance = new PatternHelper();
}
}
- }
+
return PatternHelper.instance;
}
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 fc5ca9fb494..5fdc926872d 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
@@ -266,5 +266,8 @@ public abstract class AbstractResultEntry extends Match {
return this.getClass().getSimpleName() + "(" + super.hashCode() + ") : source -> " + source; //$NON-NLS-1$ //$NON-NLS-2$
}
+ public URI getURI() {
+ return uriSource;
+ }
}
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 0a7996d6c0b..6434bc83e45 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
@@ -33,7 +33,7 @@ public class AttributeMatch extends ModelMatch {
* The element containing the value of the attribute that matches
*/
- protected URI uriSource;
+
protected Object attribute;
@@ -182,4 +182,9 @@ public class AttributeMatch extends ModelMatch {
this.stereotype = stereotype;
}
+ public URI getURISource() {
+
+ return uriSource;
+ }
+
}
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 122f40dd1a0..c560deb82dc 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
@@ -39,17 +39,7 @@ public class ModelElementMatch extends ModelMatch {
@Override
public boolean equals(Object obj) {
- // if(obj instanceof ModelElementMatch) {
- // if(super.equals(obj)) {
- //
- // return true;
- //
- // }
- // return false;
- //
- // } else {
- // return false;
- // }
+
return super.equals(obj);
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java
index 74f22d98d04..091fa55d35c 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeCollector.java
@@ -38,10 +38,10 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.views.search.Activator;
import org.eclipse.search.ui.ISearchPageContainer;
import org.eclipse.ui.IWorkingSet;
-
+
public class ScopeCollector implements IScopeCollector {
- private static final ScopeCollector instance = new ScopeCollector();
+ private static ScopeCollector instance = new ScopeCollector();
private final Iterable<? extends IScopeProvider> scopeProviders;
@@ -52,6 +52,15 @@ public class ScopeCollector implements IScopeCollector {
}
public final static ScopeCollector getInstance() {
+
+
+
+ synchronized(ScopeCollector.class) {
+ if(ScopeCollector.instance == null) {
+ ScopeCollector.instance = new ScopeCollector();
+
+ }
+ }
return ScopeCollector.instance;
}
diff --git a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/validator/ParticipantValidator.java b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/validator/ParticipantValidator.java
index ddc4a7825df..e592897ece8 100644
--- a/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/validator/ParticipantValidator.java
+++ b/plugins/views/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/validator/ParticipantValidator.java
@@ -36,11 +36,11 @@ public class ParticipantValidator implements IParticipantValidator {
public final static ParticipantValidator getInstance() {
- if(ParticipantValidator.instance == null) {
+
synchronized(ParticipantValidator.class) {
- if(ParticipantValidator.instance == null) {
- ParticipantValidator.instance = new ParticipantValidator();
- }
+ if(ParticipantValidator.instance == null) {
+ ParticipantValidator.instance = new ParticipantValidator();
+
}
}
return ParticipantValidator.instance;

Back to the top