Difference between revisions of "EMF Search---Developer Guide"

From Eclipsepedia

Jump to: navigation, search
(/)
(Ecore Query & Helper)
Line 56: Line 56:
  
 
<source lang='java'>
 
<source lang='java'>
IModelSearchScope scope = ModelSearchWorkspaceScopeFactory.getInstance().createModelSearchWorkspaceScope("org.eclipse.emf.search.ecoreSearchEngine");
+
IModelSearchScope scope =  
query = EcoreTextualModelSearchQueryBuilderHelper.getInstance().buildGlobalTextualModelSearchQuery(regex, scope, EcorePackage.eNS_URI);
+
    ModelSearchWorkspaceScopeFactory.getInstance().
 +
        createModelSearchWorkspaceScope(
 +
            "org.eclipse.emf.search.ecoreSearchEngine"
 +
        );
 +
 
 +
IModelSearchResult query =  
 +
    EcoreTextualModelSearchQueryBuilderHelper.getInstance().
 +
        buildGlobalTextualModelSearchQuery(
 +
            regex,
 +
            scope,
 +
            EcorePackage.eNS_URI
 +
    );
 
 
query.run(new NullProgressMonitor());
+
query.run(new NullProgressMonitor());
 
 
ISearchResult result = query.getModelSearchResult();
+
ISearchResult result = query.getModelSearchResult();
 
 
if (result instanceof IModelSearchResult) {
+
if (result instanceof IModelSearchResult) {
                    // Help yourself with model result entry
+
    // Help yourself with model result entry
    Collection<IModelResultEntry> reultEntries = ((IModelSearchResult)result).getResultsFlatenned();
+
    Collection<IModelResultEntry> reultEntries = ((IModelSearchResult)result).getResultsFlatenned();
}
+
}
 
+
 
</source>
 
</source>
  

Revision as of 10:53, 25 April 2008

Contents

Introduction

Developers have several levels/contexts/persitences configurations for which they want to use EMF Search.

One aspect is which modeling level they want their extension to address :

  • meta modeling level
    • Ecore meta-modeling (M3)
    • UML2 meta-modeling or custom meta-models (M2)
    • Model instance (M1)


Another aspect is where and how their meta models are stored :

  • meta model perstistence layer type
    • Eclipse Resources
    • Local File System
    • WWW distant resources (Close to be supported)
    • DB persitence (Support planned)


Depending on these particular situations, EMF Search typical usages exist.

Search Scope & Visitors

EMF Search defines a Scope API contract with IModelSearchScope :

    public interface IModelSearchScope<P, O> {
        List<P> getParticipants();
        void addParticipant(P resource);
        void addParticipants(P[] resources);
        void removeParticipant(P resource);
        void removeParticipants(P[] resources);
        List<P> findPartcipant(Class<O> clazz);
        String getLabel();
    }
  • Eclipse Workspace resource
  • Local File System
  • Distant locations (Http URIs)
  • EE repositories

Ecore Query & Helper

Ecore EMF Search comes with several helpers for query building & launching :


Ecore Textual Model Search Query Builder Helper


IModelSearchScope scope = 
    ModelSearchWorkspaceScopeFactory.getInstance().
        createModelSearchWorkspaceScope(
            "org.eclipse.emf.search.ecoreSearchEngine"
        );
 
IModelSearchResult query = 
    EcoreTextualModelSearchQueryBuilderHelper.getInstance().
        buildGlobalTextualModelSearchQuery(
            regex,
            scope,
            EcorePackage.eNS_URI
    );
 
query.run(new NullProgressMonitor());
 
ISearchResult result = query.getModelSearchResult();
 
if (result instanceof IModelSearchResult) {
    // Help yourself with model result entry
    Collection<IModelResultEntry> reultEntries = ((IModelSearchResult)result).getResultsFlatenned();
}



Ecore Textual Model Search Query Launcher Helper

Custom Queries & Helper

Custom Dialogs

Custom Wizards