Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2013-07-30 08:57:26 +0000
committerFlorian Noyrit2013-07-30 08:57:26 +0000
commit2b8765d82cbb57fc898c2022cec9726139300c5b (patch)
tree24d52b043c0dc697616fb7a2f25dc0d0c8068041 /plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org
parent0cf8e396f1c70664a78562f7a07bffd7479bacd0 (diff)
downloadorg.eclipse.papyrus-2b8765d82cbb57fc898c2022cec9726139300c5b.tar.gz
org.eclipse.papyrus-2b8765d82cbb57fc898c2022cec9726139300c5b.tar.xz
org.eclipse.papyrus-2b8765d82cbb57fc898c2022cec9726139300c5b.zip
Search model element by types (UML metaclass or stereotype). No pointer
to matching element in results. Update results when models are modified. Update OCL search.
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java8
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java16
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java50
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java43
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java18
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java14
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java33
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java172
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java24
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java120
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java9
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java40
12 files changed, 285 insertions, 262 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java
index c524bf201a9..a429c3d292e 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/Messages.java
@@ -190,13 +190,19 @@ public class Messages extends NLS {
public static String TypesMatchFilter_2;
public static String TypesMatchFilter_3;
+
public static String PapyrusSearchPage_lblResearchKind_text;
+
public static String PapyrusSearchPage_txtSearchKind_text;
- public static String PapyrusSearchPage_group_text;
+
public static String PapyrusSearchPage_btnCheckButton_text;
+
public static String PapyrusSearchPage_btnGg_text;
+
public static String PapyrusSearchPage_btnRefreshTypes_text;
+
public static String PapyrusSearchPage_btnRefreshTypes_text_1;
+
public static String PapyrusSearchPage_btnNewButton_text;
static {
// initialize resource bundle
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java
index 443b15ecd27..1904b7e52fc 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/dialogs/ReplaceDialog.java
@@ -147,12 +147,12 @@ public class ReplaceDialog extends Dialog {
}
private void change(AttributeMatch match) {
- if(match.getTarget() instanceof EObject) {
+ if(match.getSource() instanceof EObject) {
- EObject target = (EObject)match.getTarget();
+ EObject target = (EObject)match.getSource();
- if(match.getSource() instanceof EAttribute) {
- Object value = target.eGet((EAttribute)match.getSource());
+ if(match.getMetaAttribute() instanceof EAttribute) {
+ Object value = target.eGet((EAttribute)match.getMetaAttribute());
if(value != null) {
if(value instanceof String) {
String originalvalue = (String)value;
@@ -160,12 +160,12 @@ public class ReplaceDialog extends Dialog {
String newValue = computeReplacementString(pattern, originalvalue, replaceText.getText());
- target.eSet((EAttribute)match.getSource(), newValue);
+ target.eSet((EAttribute)match.getMetaAttribute(), newValue);
}
}
- } else if(match.getSource() instanceof Property) {
- Property source = (Property)match.getSource();
+ } else if(match.getMetaAttribute() instanceof Property) {
+ Property source = (Property)match.getMetaAttribute();
Class containingClass = source.getClass_();
if(containingClass instanceof Stereotype) {
if(target instanceof Element) {
@@ -216,7 +216,7 @@ public class ReplaceDialog extends Dialog {
if(match instanceof AttributeMatch) {
final AttributeMatch attributeMatch = (AttributeMatch)match;
- EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(attributeMatch.getTarget());
+ EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(attributeMatch.getSource());
Object element = match.getElement();
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java
index 71b73a18e19..a8a1b2b84e3 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchPage.java
@@ -363,7 +363,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
}
- boolean test = ((Stereotype)parentElement.getElement()).isAbstract();
+
participantsList.put(parentElement, attributeList);
@@ -388,9 +388,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
protected void createAdvancedSearch() {
-
-
-
participantTypesTree = new CheckBoxFilteredTree(advancedSearchComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE, new PatternFilter(), true);
participantTypesTree.setLayout(new GridLayout());
GridData chechboxTreeViewerGridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
@@ -420,9 +417,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
participantManipualtionComposite.setLayout(new GridLayout(1, false));
participantManipualtionComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
-
-
-
Button btnSelectSub = new Button(participantManipualtionComposite, SWT.PUSH);
btnSelectSub.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnSelectSub.setText(Messages.PapyrusSearchPage_14);
@@ -520,7 +514,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
}
});
-
participantTypesTreeViewer.setInput(participantsList);
// participantTypesTreeViewer.setAllChecked(true);
@@ -679,37 +672,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
// TODO Auto-generated catch block
e1.printStackTrace();
}
-
-
-
-
-
- // for(Object element : participantsList.keySet()) {
- // if(element instanceof ParticipantTypeElement) {
- // if(((ParticipantTypeElement)element).getElement() instanceof EClass) {
- // List<EClass> superTypes = ((EClass)((ParticipantTypeElement)element).getElement()).getEAllSuperTypes();
- //
- // if(superTypes.contains(elementParent.getElement())) {
- // // participantTypesTreeViewer.setChecked(element, true);
- // ((ParticipantTypeElement)element).setChecked(true);
- //
- // //Proceed with attributes
- // for(ParticipantTypeAttribute attributeParent : attributeParentList) {
- // for(ParticipantTypeAttribute attributeToEvaluate : participantsList.get(element)) {
- // if(attributeParent.getElement() == attributeToEvaluate.getElement()) {
- //
- // attributeToEvaluate.setChecked(true);
- //
- //
- // }
- //
- // }
- // }
- // }
- // }
- // }
- // }
- //
}
@@ -809,7 +771,6 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
oclEditor.getViewer().getTextWidget().addVerifyKeyListener(new VerifyKeyListener() {
public void verifyKey(VerifyEvent e) {
- // System.out.println("verifyKey: " + e.keyCode);
if(e.keyCode == SWT.KEYPAD_CR || e.keyCode == SWT.CR) {
if((e.stateMask & (SWT.CTRL | SWT.SHIFT)) == 0) {
e.doit = false;
@@ -1028,15 +989,15 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) {
if(validateRegex()) {
Collection<IResource> scope = ScopeCollector.getInstance().computeSearchScope(container);
-
Collection<ScopeEntry> scopeEntries = createScopeEntries(scope);
ISearchQuery query;
if(searchKind.getSelectionIndex() == SIMPLE_SEARCH) {
- if(searchQueryText.getText().length() == 0) {
+ if(searchQueryText.getText().isEmpty()) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_29, Messages.PapyrusSearchPage_30);
return false;
} else {
initMetaClasses();
+
query = new PapyrusQuery(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), scopeEntries, umlMetaClasses.toArray(), btnSearchAllStringAttributes.getSelection());
}
} else {
@@ -1058,7 +1019,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_31, Messages.PapyrusSearchPage_32);
return false;
} else {
- if(searchQueryText.getText().length() == 0) {
+ if(searchQueryText.getText().isEmpty()) {
for(Object participantChecked : participantTypesTreeViewer.getCheckedElements()) {
if(participantChecked instanceof ParticipantTypeAttribute) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_33, Messages.PapyrusSearchPage_34);
@@ -1118,7 +1079,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
public boolean performReplace() {
if(queryKind.getSelectionIndex() == TEXT_QUERY_KIND) {
if(validateRegex()) {
- if(searchQueryText.getText().length() == 0) {
+ if(searchQueryText.getText().isEmpty()) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.PapyrusSearchPage_36, Messages.PapyrusSearchPage_37);
return false;
}
@@ -1157,6 +1118,7 @@ public class PapyrusSearchPage extends DialogPage implements ISearchPage, IRepla
query = new PapyrusAdvancedQuery(searchQueryText.getText(), btnCaseSensitive.getSelection(), btnRegularExpression.getSelection(), scopeEntries, participantsToEvaluate.toArray());
}
+
NewSearchUI.runQueryInForeground(container.getRunnableContext(), query);
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java
index dac2e439797..68385a536be 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/pages/PapyrusSearchResultPage.java
@@ -15,6 +15,9 @@ package org.eclipse.papyrus.uml.search.ui.pages;
import java.util.Set;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.ISelection;
@@ -35,6 +38,8 @@ import org.eclipse.papyrus.views.search.utils.MatchUtils;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
import org.eclipse.search.ui.text.Match;
+import org.eclipse.search2.internal.ui.SearchView;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
/**
@@ -42,7 +47,7 @@ import org.eclipse.ui.PartInitException;
* Papyrus specific search results page
*
*/
-public class PapyrusSearchResultPage extends AbstractTextSearchViewPage {
+public class PapyrusSearchResultPage extends AbstractTextSearchViewPage implements IResourceChangeListener {
ResultContentProvider fContentProvider = null;
@@ -51,11 +56,16 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage {
private static final int DEFAULT_ELEMENT_LIMIT = 1000;
public PapyrusSearchResultPage() {
+
super(FLAG_LAYOUT_TREE);
setElementLimit(new Integer(DEFAULT_ELEMENT_LIMIT));
fFiltertypesAction = new FilterTypesAction(this);
+
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
}
+
+
@Override
public Match[] getDisplayedMatches(Object element) {
@@ -157,6 +167,7 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage {
viewer.setContentProvider(new ResultContentProvider(this, viewer));
viewer.setLabelProvider(new ResultLabelProvider());
fContentProvider = (ResultContentProvider)viewer.getContentProvider();
+
}
@Override
@@ -164,4 +175,34 @@ public class PapyrusSearchResultPage extends AbstractTextSearchViewPage {
}
+ public void resourceChanged(IResourceChangeEvent event) {
+
+ if(event.getType() == IResourceChangeEvent.POST_CHANGE) {
+
+ if(this.getInput() != null && this.getViewer().getInput() != null && this.getViewPart() != null) {
+
+
+
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ ((SearchView)getViewPart()).showSearchResult(getInput());
+ getViewer().refresh();
+ }
+ });
+ }
+ }
+
+
+
+
+
+ }
+
+ @Override
+ public void dispose() {
+
+ super.dispose();
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ }
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
index e63ba98135b..83cac65d9fd 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
@@ -36,9 +36,9 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
LabelProviderService service = new LabelProviderServiceImpl();
try {
service.startService();
- return service.getLabelProvider().getImage(((AttributeMatch)element).getSource());
+ return service.getLabelProvider().getImage(((AttributeMatch)element).getMetaAttribute());
} catch (ServiceException e) {
- Activator.log.warn(Messages.AttributeMatchLabelProvider_0 + ((AttributeMatch)element).getSource());
+ Activator.log.warn(Messages.AttributeMatchLabelProvider_0 + ((AttributeMatch)element).getMetaAttribute());
}
}
return null;
@@ -52,10 +52,10 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
if(element instanceof AttributeMatch) {
AttributeMatch attributeMatch = ((AttributeMatch)element);
- if((attributeMatch).getTarget() instanceof EObject) {
- EObject target = (EObject)attributeMatch.getTarget();
- if(attributeMatch.getSource() instanceof EAttribute) {
- EAttribute source = (EAttribute)attributeMatch.getSource();
+ if((attributeMatch).getSource() instanceof EObject) {
+ EObject target = (EObject)attributeMatch.getSource();
+ if(attributeMatch.getMetaAttribute() instanceof EAttribute) {
+ EAttribute source = (EAttribute)attributeMatch.getMetaAttribute();
if(target.eGet(source) instanceof String) {
String value = (String)target.eGet(source);
return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
@@ -64,14 +64,14 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
String value = String.valueOf(target.eGet(source));
return printResult(value.substring(attributeMatch.getOffset(), attributeMatch.getLength()), value, attributeMatch.getOffset(), attributeMatch.getLength(), source.getName());
}
- } else if(attributeMatch.getSource() instanceof Property) {
+ } else if(attributeMatch.getMetaAttribute() instanceof Property) {
- Property source = (Property)attributeMatch.getSource();
+ Property source = (Property)attributeMatch.getMetaAttribute();
Class containingClass = source.getClass_();
if(containingClass instanceof Stereotype) {
if(target instanceof Element) {
- Object tagValue = ((Element)target).getValue((Stereotype)containingClass, ((Property)attributeMatch.getSource()).getName());
+ Object tagValue = ((Element)target).getValue((Stereotype)containingClass, ((Property)attributeMatch.getMetaAttribute()).getName());
if(tagValue instanceof String) {
String value = (String)tagValue;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
index c126e5f42ef..1486b31b7a8 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
@@ -43,6 +43,16 @@ public class ResultContentProvider implements ITreeContentProvider {
private AbstractTreeViewer fViewer;
+
+ public AbstractTreeViewer getfViewer() {
+ return fViewer;
+ }
+
+
+ public void setfViewer(AbstractTreeViewer fViewer) {
+ this.fViewer = fViewer;
+ }
+
private Map<Object, Set<Object>> fChildrenMap;
public ResultContentProvider(PapyrusSearchResultPage page, AbstractTreeViewer viewer) {
@@ -87,7 +97,7 @@ public class ResultContentProvider implements ITreeContentProvider {
fViewer.refresh();
}
- private void initialize() {
+ public void initialize() {
fChildrenMap = new HashMap<Object, Set<Object>>();
@@ -253,7 +263,7 @@ public class ResultContentProvider implements ITreeContentProvider {
}
}
- protected void remove(Object element, boolean refreshViewer) {
+ public void remove(Object element, boolean refreshViewer) {
if(hasChildren(element)) {
if(refreshViewer) {
fViewer.refresh(element);
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java
index 4f2881c69f5..a0309c2fd13 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusAdvancedQuery.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.papyrus.infra.core.resource.NotFoundException;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.viewersearch.impl.ViewerSearchService;
@@ -187,7 +188,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
* @param scopeEntry
* the scopeEntry that contains the participant
*/
- protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry) {
+ protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry, Stereotype stereotype) {
value = value != null ? value : ""; //$NON-NLS-1$
@@ -197,7 +198,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
if(m.matches()) {
int start = m.start();
int end = m.end();
- ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
fResults.add(match);
}
@@ -205,7 +206,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
while(m.find()) {
int start = m.start();
int end = m.end();
- AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, stereotype);
fResults.add(match);
}
}
@@ -263,10 +264,10 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
if(value instanceof String) {
String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry, null);
} else {
String stringValue = String.valueOf(value);
- evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry, null);
}
}
}
@@ -274,7 +275,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
}
}
- findAndShow(scopeEntry);
+ findInDiagram(scopeEntry);
}
@@ -298,7 +299,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
EList<Stereotype> stereotypesApplied = ((Element)participant).getAppliedStereotypes();
for(Stereotype stereotype : stereotypesApplied) {
for(Stereotype stereotypeSelected : stereotypeList.keySet()) {
- if(stereotype.getName().equals(stereotypeSelected.getName())) {
+ if(EcoreUtil.equals(stereotype, stereotypeSelected)) {
if(stereotypeList.get(stereotypeSelected).size() == 0) {
propertyList = this.getStereotypesAttributes(stereotype);
@@ -308,10 +309,10 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
if(value != null) {
if(value instanceof String) {
String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
} else {
String stringValue = String.valueOf(value);
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
}
}
}
@@ -319,15 +320,15 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
propertyList = this.getStereotypesAttributes(stereotype);
for(Property property : propertyList) {
for(Property property2 : (stereotypeList.get(stereotypeSelected))) {
- if(property.getName().equals(property2.getName())) {
+ if(EcoreUtil.equals(property, property2)) {
Object value = ((Element)participant).getValue(stereotype, property.getName());
if(value != null) {
if(value instanceof String) {
String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
} else {
String stringValue = String.valueOf(value);
- evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry);
+ evaluateAndAddToResult(stringValue, property, pattern, participant, scopeEntry, stereotype);
}
}
}
@@ -342,7 +343,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
}
- findAndShow(scopeEntry);
+ findInDiagram(scopeEntry);
}
@@ -371,7 +372,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
return result;
}
- protected void findAndShow(ScopeEntry scopeEntry) {
+ protected void findInDiagram(ScopeEntry scopeEntry) {
//Now, find in diagram and others the elements we found
ViewerSearchService viewerSearcherService = new ViewerSearchService();
try {
@@ -381,7 +382,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
for(AbstractResultEntry match : fResults) {
if(match instanceof AttributeMatch) {
- sources.add(((AttributeMatch)match).getTarget());
+ sources.add(((AttributeMatch)match).getSource());
} else {
sources.add(match.getSource());
}
@@ -409,7 +410,7 @@ public class PapyrusAdvancedQuery extends AbstractPapyrusQuery {
}
public boolean canRerun() {
- return false;
+ return true;
}
public boolean canRunInBackground() {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java
index d4f7adf459c..c94f09d3674 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusOCLQuery.java
@@ -13,11 +13,10 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.search.ui.query;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -52,6 +51,7 @@ import org.eclipse.ocl.examples.pivot.utilities.PivotUtil;
import org.eclipse.ocl.examples.xtext.console.messages.ConsoleMessages;
import org.eclipse.ocl.examples.xtext.essentialocl.ui.model.BaseDocument;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.uml.search.ui.Activator;
import org.eclipse.papyrus.uml.search.ui.Messages;
import org.eclipse.papyrus.uml.search.ui.results.PapyrusSearchResult;
import org.eclipse.papyrus.views.search.results.AbstractResultEntry;
@@ -96,6 +96,9 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
this.parserContext = parserContext;
this.metaModelManager = metaModelManager;
this.modelManager = modelManager;
+
+ Collection<ScopeEntry> scopeEntries = new ArrayList<ScopeEntry>();
+ scopeEntries.add(scopeEntry);
results = new PapyrusSearchResult(this);
fResults = new HashSet<AbstractResultEntry>();
}
@@ -125,19 +128,16 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
EvaluationRunnable runnable = new EvaluationRunnable((BaseResource)state, expression);
runnable.run(new NullProgressMonitor());
- // progressService.busyCursorWhile(runnable);
return runnable.getValue();
}
});
} catch (Exception e) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getMessage());
+ Activator.log.error(e);
}
if(value instanceof InvalidValueException) {
InvalidValueException exception = (InvalidValueException)value;
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", exception.getMessage());
Throwable cause = exception.getCause();
if((cause != null) && (cause != exception)) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", cause.getMessage());
}
} else if(value != null) {
CollectionValue collectionValue = ValuesUtil.isCollectionValue(value);
@@ -147,28 +147,25 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
ModelMatch match = new ModelElementMatch(elementValue, scopeEntry);
fResults.add(match);
}
- // System.err.println("Found : " + ValuesUtil.stringValueOf(elementValue));
}
} else {
if(value instanceof EObject) {
ModelMatch match = new ModelElementMatch(value, scopeEntry);
fResults.add(match);
}
- // System.err.println("Found : " + ValuesUtil.stringValueOf(value));
}
- } else {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", ValuesUtil.stringValueOf(value));
-
}
} catch (Exception e) {
result = false;
- if(e.getLocalizedMessage() == null) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getClass().getName());
- } else {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getLocalizedMessage());
- }
+ Activator.log.error(e);
+
+ // if(e.getLocalizedMessage() == null) {
+ // // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getClass().getName());
+ // } else {
+ // // MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", e.getLocalizedMessage());
+ // }
}
return result;
@@ -225,17 +222,6 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
try {
// metaModelManager.setMonitor(monitor);
CancelableEvaluationVisitor evaluationVisitor = new CancelableEvaluationVisitor(monitor, environment, evaluationEnvironment, modelManager2);
- // evaluationVisitor.setLogger(new DomainLogger() {
- //
- // public void append(final @NonNull String message) {
- // OCLConsolePage.this.getControl().getDisplay().asyncExec(new Runnable() {
- //
- // public void run() {
- // OCLConsolePage.this.append(message, ColorManager.DEFAULT, false);
- // }
- // });
- // }
- // });
value = evaluationVisitor.visitExpressionInOCL(expressionInOCL);
} catch (InvalidValueException e) {
value = e;
@@ -288,138 +274,6 @@ public class PapyrusOCLQuery extends AbstractPapyrusQuery {
return Status.OK_STATUS;
}
- /**
- * Evaluate if the value matches the pattern
- *
- * @param value
- * the value to evaluate
- * @param attribute
- * the attribute has the value
- * @param pattern
- * the pattern that is searched
- * @param participant
- * the element that contains the value
- * @param scopeEntry
- * the scopeEntry that contains the participant
- */
- protected void evaluateAndAddToResult(String value, Object attribute, Pattern pattern, Object participant, ScopeEntry scopeEntry) {
-
- value = value != null ? value : ""; //$NON-NLS-1$
-
- Matcher m = pattern.matcher(value);
-
- // if(isRegularExpression) {
- // if(m.matches()) {
- // int start = m.start();
- // int end = m.end();
- // ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
- //
- // fResults.add(match);
- // }
- // } else {
- // while(m.find()) {
- // int start = m.start();
- // int end = m.end();
- // AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
- // fResults.add(match);
- // }
- // }
-
-
- }
-
- /**
- * Try to find elements that match in the participants
- *
- * @param participants
- * @param scopeEntry
- */
- protected void evaluate(Collection<EObject> participants, ScopeEntry scopeEntry) {
-
- // for(EObject participant : participants) {
- //
- // String query = searchQueryText;
- // if(searchQueryText.equals("")) { //$NON-NLS-1$
- // query = ".*"; //$NON-NLS-1$
- // }
- //
- // Pattern pattern = PatternHelper.getInstance().createPattern(query, isCaseSensitive, isRegularExpression);
- //
- // if(pattern != null) {
- // if(searchAllStringAttributes) {
- //
- // for(EAttribute attribute : participant.eClass().getEAllAttributes()) {
- // Object value = participant.eGet(attribute);
- //
- // if(value instanceof String) {
- // String stringValue = (String)value;
- // evaluateAndAddToResult(stringValue, attribute, pattern, participant, scopeEntry);
- // }
- // }
- //
- // } else {
- // if(participant instanceof NamedElement) {
- // String umlElementName = ((NamedElement)participant).getName();
- // umlElementName = umlElementName != null ? umlElementName : ""; //$NON-NLS-1$
- //
- // evaluateAndAddToResult(umlElementName, UMLPackage.eINSTANCE.getNamedElement_Name(), pattern, participant, scopeEntry);
- // }
- // }
- // if(searchStereotypeAttributes) {
- // if(participant instanceof Element) {
- // EList<Stereotype> stereotypes = ((Element)participant).getAppliedStereotypes();
- // for(Stereotype stereotype : stereotypes) {
- // for(Property stereotypeProperty : stereotype.getAllAttributes()) {
- // if(!stereotypeProperty.getName().startsWith("base_")) {
- // Object value = ((Element)participant).getValue(stereotype, stereotypeProperty.getName());
- // if(value != null) {
- //
- // if(value instanceof String) {
- // String stringValue = (String)value;
- // evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
- // }
- // }
- // }
- // }
- //
- // }
- // }
- // }
- //
- // }
- // }
- //
- // //Now, find in diagram and others the elements we found
- // ViewerSearchService viewerSearcherService = new ViewerSearchService();
- // try {
- // viewerSearcherService.startService();
- //
- // //Get sources elements that matched
- // Set<Object> sources = new HashSet<Object>();
- // for(AbstractResultEntry match : fResults) {
- // if(match instanceof AttributeMatch) {
- // sources.add(((AttributeMatch)match).getTarget());
- // } else {
- // sources.add(match.getSource());
- // }
- // }
- //
- // //Get viewer of these sources
- // Map<Object, Map<Object, Object>> viewersMappings = viewerSearcherService.getViewers(sources, scopeEntry.getModelSet());
- //
- // //Add viewers to results
- // for(Object containingModelSet : viewersMappings.keySet()) {
- // for(Object view : viewersMappings.get(containingModelSet).keySet()) {
- // Object semanticElement = viewersMappings.get(containingModelSet).get(view);
- // ViewerMatch viewMatch = new ViewerMatch(view, scopeEntry, semanticElement);
- // fResults.add(viewMatch);
- // }
- // }
- //
- // } catch (ServiceException e) {
- // Activator.log.error(Messages.PapyrusQuery_5 + scopeEntry.getModelSet(), e);
- // }
- }
public String getLabel() {
return Messages.PapyrusQuery_6;
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java
index a2605a7a347..d65a2827e10 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/query/PapyrusQuery.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -79,7 +79,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
protected Set<AbstractResultEntry> fResults = null;
- private boolean searchStereotypeAttributes;
+
public PapyrusQuery(String searchQueryText, boolean isCaseSensitive, boolean isRegularExpression, Collection<ScopeEntry> scopeEntries, Object[] participantsTypes, boolean searchAllStringAttributes) {
this.searchQueryText = searchQueryText;
@@ -143,7 +143,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
if(m.matches()) {
int start = m.start();
int end = m.end();
- ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ ModelMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, null);
fResults.add(match);
}
@@ -151,7 +151,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
while(m.find()) {
int start = m.start();
int end = m.end();
- AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute);
+ AttributeMatch match = new AttributeMatch(start, end, participant, scopeEntry, attribute, null);
fResults.add(match);
}
}
@@ -200,16 +200,12 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
for(Property stereotypeProperty : stereotype.getAllAttributes()) {
if(!stereotypeProperty.getName().startsWith("base_")) { //$NON-NLS-1$
Object value = ((Element)participant).getValue(stereotype, stereotypeProperty.getName());
- if(value != null) {
- if(value instanceof String) {
- String stringValue = (String)value;
- evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
- }
+ if(value instanceof String) {
+ String stringValue = (String)value;
+ evaluateAndAddToResult(stringValue, stereotypeProperty, pattern, participant, scopeEntry);
}
-
}
-
}
}
}
@@ -227,7 +223,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
}
}
- //Now, find in diagram and others the elements we found
+ // Now, find in diagram and others the elements we found
ViewerSearchService viewerSearcherService = new ViewerSearchService();
try {
viewerSearcherService.startService();
@@ -236,7 +232,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
Set<Object> sources = new HashSet<Object>();
for(AbstractResultEntry match : fResults) {
if(match instanceof AttributeMatch) {
- sources.add(((AttributeMatch)match).getTarget());
+ sources.add(((AttributeMatch)match).getSource());
} else {
sources.add(match.getSource());
}
@@ -264,7 +260,7 @@ public class PapyrusQuery extends AbstractPapyrusQuery {
}
public boolean canRerun() {
- return false;
+ return true;
}
public boolean canRunInBackground() {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
index 6dd1ef67b0e..5b07cce5762 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/results/PapyrusSearchResult.java
@@ -13,15 +13,27 @@
*****************************************************************************/
package org.eclipse.papyrus.uml.search.ui.results;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.uml.search.ui.Activator;
import org.eclipse.papyrus.uml.search.ui.Messages;
import org.eclipse.papyrus.uml.search.ui.query.AbstractPapyrusQuery;
+import org.eclipse.papyrus.views.search.regex.PatternHelper;
import org.eclipse.papyrus.views.search.results.AbstractResultEntry;
+import org.eclipse.papyrus.views.search.results.AttributeMatch;
+import org.eclipse.papyrus.views.search.results.ModelElementMatch;
+import org.eclipse.papyrus.views.search.results.ModelMatch;
+import org.eclipse.papyrus.views.search.results.ViewerMatch;
import org.eclipse.papyrus.views.search.scope.ScopeEntry;
import org.eclipse.papyrus.views.search.utils.MatchUtils;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
@@ -31,6 +43,8 @@ import org.eclipse.search.ui.text.Match;
import org.eclipse.search.ui.text.MatchFilter;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Property;
import com.swtdesigner.ResourceManager;
@@ -38,8 +52,6 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
MatchFilter[] possibleMatchFilter;
-
-
private AbstractPapyrusQuery searchQuery;
public PapyrusSearchResult(AbstractPapyrusQuery query) {
@@ -88,6 +100,7 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
Set<Match> results = new HashSet<Match>();
+
Set<AbstractResultEntry> allMatches = MatchUtils.getMatches(result, true);
for(AbstractResultEntry modelMatch : allMatches) {
Object element = modelMatch.getElement();
@@ -126,9 +139,92 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
return false;
}
+ @Override
+ public Match[] getMatches(Object element) {
+
+ Match[] matchList = super.getMatches(element);
+ Set<Match> matchToKeep = new HashSet<Match>();
+ List<Object> sourceList = new ArrayList<Object>();
+ // Get matches which are still true
+ for(Match match : matchList) {
+ if(match instanceof AbstractResultEntry) {
+ if(((AbstractResultEntry)match).getSource() != null) {
+ if(match instanceof AttributeMatch) {
+
+ String value = null;
+ EObject target = (EObject)((AbstractResultEntry)match).getSource();
+ if(((AttributeMatch)match).getMetaAttribute() instanceof EAttribute) {
+
+ EAttribute attribute = (EAttribute)((AttributeMatch)match).getMetaAttribute();
+ value = String.valueOf(target.eGet(attribute));
+ } else if(((AttributeMatch)match).getMetaAttribute() instanceof Property) {
+
+ Property attribute = (Property)((AttributeMatch)match).getMetaAttribute();
+ value = (String)((Element)((AbstractResultEntry)match).getSource()).getValue(((AttributeMatch)match).getStereotype(), attribute.getName());
+
+
+ }
+ if(value != null && !this.getQuery().isRegularExpression()) {
+ if(value.length() >= match.getOffset() + match.getLength()) {
+ value = value.substring(match.getOffset(), match.getLength());
+ if(this.searchQuery.isCaseSensitive()) {
+ if(value.equals(this.searchQuery.getSearchQueryText())) {
+ ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)((AbstractResultEntry)match).getParent());
+ matchToKeep.add(match);
+ sourceList.add(((AbstractResultEntry)match).getSource());
+ }
+ } else {
+ if(value.equalsIgnoreCase(this.searchQuery.getSearchQueryText())) {
+
+ ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)((AbstractResultEntry)match).getParent());
+
+ matchToKeep.add(match);
+ sourceList.add(((AbstractResultEntry)match).getSource());
+ }
+ }
+ }
+ } else if(this.getQuery().isRegularExpression()) {
+ if(this.getQuery().getSearchQueryText() != null) {
+
+
+ Pattern pattern = PatternHelper.getInstance().createPattern(this.getQuery().getSearchQueryText(), false, true);
+ Matcher m = pattern.matcher(value);
+ if(m.matches()) {
+ int start = m.start();
+ int end = m.end();
+ if(start == match.getOffset() && end == match.getOffset() + match.getLength()) {
+ matchToKeep.add(match);
+ sourceList.add(((AbstractResultEntry)match).getSource());
+ }
+ }
+ }
+ }
+ } else if(match instanceof ModelElementMatch) {
+ ((AbstractResultEntry)match).recursiveHierarchy((AbstractResultEntry)match);
+
+ matchToKeep.add(match);
+ sourceList.add(((AbstractResultEntry)match).getSource());
+ }
+ }
+ }
+ }
+ // Now get Viewers
+ for(Match match : matchList) {
+ if(match instanceof ViewerMatch) {
+ Object source = ((ViewerMatch)match).getSemanticElement();
+ if(sourceList.contains(source)) {
+ matchToKeep.add(match);
+ }
+ }
+
+ }
+
+ return (Match[])matchToKeep.toArray(new Match[matchToKeep.size()]);
+
+ }
+
public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
Set<Object> results = new HashSet<Object>();
-
Set<AbstractResultEntry> allMatches = MatchUtils.getMatches(result, true);
for(AbstractResultEntry modelMatch : allMatches) {
Object element = modelMatch.getElement();
@@ -144,4 +240,22 @@ public class PapyrusSearchResult extends AbstractTextSearchResult implements IEd
return results.toArray(arrayResult);
}
+ @Override
+ public int getMatchCount() {
+
+ List<Object> elementList = Arrays.asList(this.getElements());
+ int count = 0;
+ for(Object element : elementList) {
+
+ for(Match match : this.getMatches(element)) {
+ if(match instanceof ModelMatch || match instanceof ViewerMatch)
+ count++;
+ }
+
+ }
+ return count;
+ }
+
+
+
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java
index 177ff26c248..38eb000b851 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/validator/ParticipantValidator.java
@@ -19,7 +19,9 @@ import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.Stereotype;
@@ -59,8 +61,9 @@ public class ParticipantValidator implements IParticipantValidator {
TreeIterator<EObject> it = root.eAllContents();
while(it.hasNext()) {
EObject modelElement = (EObject)it.next();
- //Check that metaclass of this element is a supported metaclass
+ //Check that metaclass of this element is a supported metaclass
+ EClass e = modelElement.eClass();
if(participantsTypesList.contains(modelElement.eClass())) {
results.add(modelElement);
}
@@ -85,10 +88,10 @@ public class ParticipantValidator implements IParticipantValidator {
while(it.hasNext()) {
EObject modelElement = (EObject)it.next();
if(modelElement instanceof Element) {
- for(Stereotype element : ((Element)modelElement).getAppliedStereotypes()) {
+ for(Stereotype appliedStereotype : ((Element)modelElement).getAppliedStereotypes()) {
//Check that metaclass of this element is a supported metaclass
for(Object stereotypeToGet : participantsTypesList) {
- if(element.getName().equals(((Stereotype)stereotypeToGet).getName())) {
+ if(EcoreUtil.equals(appliedStereotype, (EObject)stereotypeToGet)) {
results.add(modelElement);
}
}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java
index bf8d15d39bb..329e278692a 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/stereotypecollector/StereotypeCollector.java
@@ -32,6 +32,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.emf.utils.BusinessModelResolver;
@@ -129,7 +130,17 @@ public class StereotypeCollector implements IStereotypeCollector {
EObject umlElement = (EObject)UMLResourceContentIterator.next();
if(umlElement instanceof ProfileApplication) {
- profiles.add(((ProfileApplication)umlElement).getAppliedProfile());
+ boolean found = false;
+ Profile profileToProcess = ((ProfileApplication)umlElement).getAppliedProfile();
+ for(Profile alreadyAddedProfile : profiles) {
+
+ if(EcoreUtil.equals(alreadyAddedProfile, profileToProcess)) {
+ found = true;
+ }
+ }
+ if(!found) {
+ profiles.add(profileToProcess);
+ }
}
}
@@ -141,7 +152,18 @@ public class StereotypeCollector implements IStereotypeCollector {
while(profileContentIterator.hasNext()) {
EObject profileContent = (EObject)profileContentIterator.next();
if(profileContent instanceof Stereotype) {
- preResult.add((Stereotype)profileContent);
+ boolean found = false;
+ Stereotype stereotypeToProcess = (Stereotype)profileContent;
+ for(Stereotype alreadyAddedStereotype : preResult) {
+
+ if(EcoreUtil.equals(alreadyAddedStereotype, stereotypeToProcess)) {
+ found = true;
+ }
+ }
+
+ if(!found) {
+ preResult.add(stereotypeToProcess);
+ }
}
}
@@ -153,6 +175,20 @@ public class StereotypeCollector implements IStereotypeCollector {
for(Classifier parent : stereo.getGenerals()) {
if(parent instanceof Stereotype) {
result.add((Stereotype)parent);
+
+ boolean found = false;
+ Stereotype stereotypeToProcess = (Stereotype)parent;
+ for(Stereotype alreadyAddedStereotype : result) {
+
+ if(EcoreUtil.equals(alreadyAddedStereotype, stereotypeToProcess)) {
+ found = true;
+ }
+ }
+
+ if(!found) {
+ result.add(stereotypeToProcess);
+ }
+
}
}

Back to the top