Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-03-20 15:01:01 +0000
committercletavernie2013-03-20 15:01:01 +0000
commitd4f40bf7d766da75837344eb9a0f9b2220dd7020 (patch)
treebb64c4382caefe7edcff7f4d1ea24c61ee269597 /incoming
parent06f226c7d21b067a0a85d23c68654903d3a3b728 (diff)
downloadorg.eclipse.papyrus-d4f40bf7d766da75837344eb9a0f9b2220dd7020.tar.gz
org.eclipse.papyrus-d4f40bf7d766da75837344eb9a0f9b2220dd7020.tar.xz
org.eclipse.papyrus-d4f40bf7d766da75837344eb9a0f9b2220dd7020.zip
399856: [Search] Papyrus shall provide model-aware search capability
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399856
Diffstat (limited to 'incoming')
-rw-r--r--incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java2
-rw-r--r--incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java38
-rw-r--r--incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java52
-rw-r--r--incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ResourceVisitor.java2
-rw-r--r--incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java8
5 files changed, 52 insertions, 50 deletions
diff --git a/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java b/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
index 7dd59a97601..d6195e61ea4 100644
--- a/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
+++ b/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/AttributeMatchLabelProvider.java
@@ -45,7 +45,7 @@ public class AttributeMatchLabelProvider implements IFilteredLabelProvider {
}
private String printResult(String sectionThatMatch, String value, int offset, int lenght, String attributeName) {
- return "\"" + sectionThatMatch + "\"" + Messages.AttributeMatchLabelProvider_3 + "\"" + value + "\" [" + offset + "," + lenght + "] (" + attributeName + Messages.AttributeMatchLabelProvider_8 + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-9$
+ return "\"" + sectionThatMatch + "\"" + Messages.AttributeMatchLabelProvider_3 + "\"" + value + "\" [" + offset + "," + lenght + "] (" + attributeName + Messages.AttributeMatchLabelProvider_8 + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
}
public String getText(Object element) {
diff --git a/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java b/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
index 4bf00f575e3..aafaa9b5f2b 100644
--- a/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
+++ b/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultContentProvider.java
@@ -24,6 +24,8 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.papyrus.uml.search.ui.pages.PapyrusSearchResultPage;
import org.eclipse.papyrus.uml.search.ui.results.PapyrusSearchResult;
import org.eclipse.papyrus.views.search.results.AbstractResultEntry;
+import org.eclipse.papyrus.views.search.results.ModelMatch;
+import org.eclipse.papyrus.views.search.results.ResultEntry;
import org.eclipse.papyrus.views.search.utils.MatchUtils;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
@@ -35,21 +37,21 @@ import org.eclipse.search.ui.text.AbstractTextSearchResult;
public class ResultContentProvider implements ITreeContentProvider {
private final Object[] EMPTY_ARR = new Object[0];
-
+
private AbstractTextSearchResult fResult = null;
private PapyrusSearchResultPage fPage = null;
-
+
private AbstractTreeViewer fViewer;
private Map<Object, Set<Object>> fChildrenMap;
-
+
public ResultContentProvider(PapyrusSearchResultPage page, AbstractTreeViewer viewer) {
fPage = page;
-
+
this.fViewer = viewer;
}
-
+
public void dispose() {
}
@@ -77,7 +79,7 @@ public class ResultContentProvider implements ITreeContentProvider {
private int getElementLimit() {
return fPage.getElementLimit().intValue();
}
-
+
/**
* Used to clear the content
*/
@@ -85,7 +87,7 @@ public class ResultContentProvider implements ITreeContentProvider {
initialize();
fViewer.refresh();
}
-
+
private void initialize() {
fChildrenMap = new HashMap<Object, Set<Object>>();
@@ -106,7 +108,7 @@ public class ResultContentProvider implements ITreeContentProvider {
children = new HashSet<Object>();
fChildrenMap.put(parent, children);
}
-
+
boolean found = false;
for(Object object : children) {
@@ -138,8 +140,20 @@ public class ResultContentProvider implements ITreeContentProvider {
for(Object key : fChildrenMap.keySet()) {
if(key instanceof AbstractResultEntry) {
if(((AbstractResultEntry)key).equals(parent)) {
- parent = key;
- ((AbstractResultEntry)child).setParent(parent);
+ if((parent instanceof ModelMatch) && key instanceof ResultEntry) {
+ //Must replace ResultEntry in the tree by RealMatch
+ for(Object childInMap : fChildrenMap.get(key)) {
+ if(childInMap instanceof AbstractResultEntry) {
+ ((AbstractResultEntry)childInMap).setParent(parent);
+ }
+ }
+ key = parent;
+
+ } else {
+ parent = key;
+ ((AbstractResultEntry)child).setParent(parent);
+ }
+
}
}
@@ -207,7 +221,7 @@ public class ResultContentProvider implements ITreeContentProvider {
}
}
-
+
/**
* Signal the objects that changed in the content
*
@@ -243,7 +257,7 @@ public class ResultContentProvider implements ITreeContentProvider {
}
}
}
-
+
public Object[] getChildren(Object parentElement) {
Set<Object> children = fChildrenMap.get(parentElement);
if(children == null)
diff --git a/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java b/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java
index eac0ac47e2b..989ede3387c 100644
--- a/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java
+++ b/incoming/org.eclipse.papyrus.uml.search.ui/src/org/eclipse/papyrus/uml/search/ui/providers/ResultLabelProvider.java
@@ -16,30 +16,22 @@ package org.eclipse.papyrus.uml.search.ui.providers;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.papyrus.uml.search.ui.Activator;
-import org.eclipse.papyrus.uml.search.ui.Messages;
+import org.eclipse.papyrus.infra.services.labelprovider.service.impl.LabelProviderServiceImpl;
import org.eclipse.papyrus.views.search.results.AbstractResultEntry;
-import org.eclipse.papyrus.views.search.scope.ScopeEntry;
import org.eclipse.swt.graphics.Image;
public class ResultLabelProvider extends LabelProvider {
-
- @Override
- public Image getImage(Object element) {
- if(element instanceof AbstractResultEntry) {
- Object elementValue = ((AbstractResultEntry)element).getElement();
- if(elementValue instanceof ScopeEntry) {
- ScopeEntry scopeEntry = (ScopeEntry)elementValue;
- try {
- LabelProviderService service = scopeEntry.getServicesRegistry().getService(LabelProviderService.class);
- return service.getLabelProvider().getImage(((AbstractResultEntry)element).elementToDisplay());
+ private LabelProviderService labelProviderService;
- } catch (ServiceException e) {
- Activator.log.warn(Messages.ResultLabelProvider_0 + element);
- }
+ public ResultLabelProvider() {
+ labelProviderService = new LabelProviderServiceImpl();
+ }
- }
+ @Override
+ public Image getImage(Object element) {
+ if(element instanceof AbstractResultEntry) {
+ return labelProviderService.getLabelProvider().getImage(((AbstractResultEntry)element).elementToDisplay());
}
return null;
@@ -48,22 +40,20 @@ public class ResultLabelProvider extends LabelProvider {
@Override
public String getText(Object element) {
if(element instanceof AbstractResultEntry) {
- Object elementValue = ((AbstractResultEntry)element).getElement();
- if(elementValue instanceof ScopeEntry) {
- ScopeEntry scopeEntry = (ScopeEntry)elementValue;
- try {
- LabelProviderService service = scopeEntry.getServicesRegistry().getService(LabelProviderService.class);
-
- return service.getLabelProvider().getText(((AbstractResultEntry)element).elementToDisplay());
-
- } catch (ServiceException e) {
- Activator.log.warn(Messages.ResultLabelProvider_1 + element);
- }
-
- }
+ return labelProviderService.getLabelProvider().getText(((AbstractResultEntry)element).elementToDisplay());
}
return ""; //$NON-NLS-1$
}
-
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ try {
+ labelProviderService.disposeService();
+ } catch (ServiceException ex) {
+ //Ignore
+ }
+ }
+
}
diff --git a/incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ResourceVisitor.java b/incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ResourceVisitor.java
index a31c39feb4d..61d396c9c37 100644
--- a/incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ResourceVisitor.java
+++ b/incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ResourceVisitor.java
@@ -46,7 +46,7 @@ public class ResourceVisitor implements IResourceProxyVisitor {
URI uri = URI.createPlatformResourceURI(resource.getFullPath().toString(), true);
- if(uri.fileExtension().equals("di")) { //$NON-NLS-1$
+ if("di".equals(uri.fileExtension())) { //$NON-NLS-1$
//Verify that it is a true papyrus model
try {
ModelSet modelSet = ModelUtils.openFile(resource);
diff --git a/incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java b/incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java
index 14e0b69b967..b1a76dd602b 100644
--- a/incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java
+++ b/incoming/org.eclipse.papyrus.views.search/src/org/eclipse/papyrus/views/search/scope/ScopeEntry.java
@@ -17,8 +17,6 @@ import java.util.Collection;
import java.util.HashSet;
import org.eclipse.core.resources.IResource;
-import org.eclipse.papyrus.infra.core.editor.PageIconRegistryServiceFactory;
-import org.eclipse.papyrus.infra.core.editorsfactory.IPageIconsRegistry;
import org.eclipse.papyrus.infra.core.resource.ModelMultiException;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.services.ServiceException;
@@ -103,9 +101,9 @@ public class ScopeEntry {
ServicesRegistry serviceRegistry = new ServicesRegistry();
serviceRegistry.add(LabelProviderService.class, 10, new LabelProviderServiceImpl());
serviceRegistry.add(OpenElementService.class, 10, new OpenElementServiceImpl());
- PageIconRegistryServiceFactory factory = new PageIconRegistryServiceFactory();
- Object instance = factory.createServiceInstance();
- serviceRegistry.add(IPageIconsRegistry.class, 10, instance);
+ // PageIconRegistryServiceFactory factory = new PageIconRegistryServiceFactory();
+ // Object instance = factory.createServiceInstance();
+ // serviceRegistry.add(IPageIconsRegistry.class, 10, instance);
// serviceRegistry.add(IPageIconsRegistry.class, 10, new PageIconRegistryServiceFactory());
serviceRegistry.startRegistry();

Back to the top