Runtime

org.eclipse.gmf.runtime.common.ui.services.elementselection
Class ElementSelectionService

java.lang.Object
  extended by org.eclipse.gmf.runtime.common.core.service.AbstractProvider
      extended by org.eclipse.gmf.runtime.common.core.service.Service
          extended by org.eclipse.gmf.runtime.common.ui.services.elementselection.ElementSelectionService
All Implemented Interfaces:
java.util.EventListener, IProvider, IProviderChangeListener, IElementSelectionListener, IElementSelectionProvider

public class ElementSelectionService
extends Service
implements IElementSelectionProvider, IElementSelectionListener

The element selection service.


Nested Class Summary
protected  class ElementSelectionService.JobData
           
 
Field Summary
static IJobManager jobManager
           
 
Fields inherited from class org.eclipse.gmf.runtime.common.core.service.Service
INVALID_ELEMENT_MESSAGE_PATTERN
 
Constructor Summary
protected ElementSelectionService()
          Constructs a new type selection service.
 
Method Summary
protected  void cancelAllJobs()
          Cancel the jobs running for the element selection service.
 void cancelJob(ElementSelectionServiceJob job)
           
protected  void configureProviders()
          Configures my providers from the elementSelectionProviders extension point.
protected  ElementSelectionServiceJob createSelectionJob()
          Creates the selection service job that manages the individual provider search jobs.
protected  void fireEndOfMatchesEvent()
          Fire an end of matches event since there are no more matches.
protected  void fireMatchingObjectEvent(IMatchingObjectEvent matchingObjectEvent)
          Send the matching object event to the listener.
static ElementSelectionService getInstance()
          Retrieves the singleton instance of the type selection service.
 ElementSelectionService.JobData getJobData()
           
protected  java.lang.String getJobName()
           
protected  java.lang.String getJobName(ElementSelectionService.JobData data)
          Get the name for the ElementSelectionServiceJob.
 java.util.List getMatchingObjects(IElementSelectionInput input)
          For backward compatibility, use the element selection service and return the results in a list.
 ElementSelectionServiceJob getMatchingObjects(IElementSelectionInput input, IElementSelectionListener listener)
          Retrieve a list of matching objects from the provider.
 void matchingObjectEvent(IMatchingObjectEvent matchingObjectEvent)
          A matching object event has been sent.
protected  Service.ProviderDescriptor newProviderDescriptor(IConfigurationElement element)
          Creates a new provider descriptor for the specified configuration element.
 java.lang.Object resolve(IMatchingObject object)
          Resolve the matching object to a modeling object.
 void run(IProgressMonitor monitor)
          Retrieve the list of matching objects from the provider.
protected  void schedule(IElementSelectionProvider provider, ElementSelectionServiceJob job)
          Schedules the specified selection provider job.
 
Methods inherited from class org.eclipse.gmf.runtime.common.core.service.Service
addProvider, clearCache, configureProviders, configureProviders, createPriorityCache, execute, executeUnique, getAllProviders, getCachingKey, getPriority, getProviders, isOptimistic, isOptimized, providerChanged, provides, provides, removeProvider
 
Methods inherited from class org.eclipse.gmf.runtime.common.core.service.AbstractProvider
addProviderChangeListener, fireProviderChange, removeProviderChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.gmf.runtime.common.core.service.IProvider
addProviderChangeListener, provides, removeProviderChangeListener
 

Field Detail

jobManager

public static final IJobManager jobManager
Constructor Detail

ElementSelectionService

protected ElementSelectionService()
Constructs a new type selection service.

Method Detail

getJobData

public ElementSelectionService.JobData getJobData()

getInstance

public static ElementSelectionService getInstance()
Retrieves the singleton instance of the type selection service.

Returns:
The type selection service singleton.

getMatchingObjects

public java.util.List getMatchingObjects(IElementSelectionInput input)
For backward compatibility, use the element selection service and return the results in a list.

Parameters:
input - the element selection input.
Returns:
list of matching objects.

getMatchingObjects

public ElementSelectionServiceJob getMatchingObjects(IElementSelectionInput input,
                                                     IElementSelectionListener listener)
Retrieve a list of matching objects from the provider.

The provider is given an IElementSelectionInput and IElementSelectionListener and creates a ElementSelectionServiceJob.

The provider returns IMatchingObjectEvent to the IElementSelectionListener. If there are ten matching objects, then eleven IMatchingObjectEvent will be sent to the listener. The first ten will have type MatchingObjectEventType.MATCH and will have a matching object. The eleventh event will have type MatchingObjectEventType.END_OF_MATCHES.

Specified by:
getMatchingObjects in interface IElementSelectionProvider
Parameters:
input - the element selection input.
listener - the provider will send matching object events to this listener.
Returns:
the job that is running this provider.

getJobName

protected java.lang.String getJobName()

createSelectionJob

protected ElementSelectionServiceJob createSelectionJob()
Creates the selection service job that manages the individual provider search jobs. This method should configure the new job with the appropriate priority, scheduling rules, etc. but should not schedule it.

Returns:
a new selection service job

run

public void run(IProgressMonitor monitor)
Retrieve the list of matching objects from the provider.

The ElementSelectionServiceJob will invoke run. Clients must not call this method.

Specified by:
run in interface IElementSelectionProvider
Parameters:
monitor - a progress monitor in which the provider is running.

schedule

protected void schedule(IElementSelectionProvider provider,
                        ElementSelectionServiceJob job)
Schedules the specified selection provider job.

Parameters:
provider - a selection provider
job - the provider's job

resolve

public java.lang.Object resolve(IMatchingObject object)
Resolve the matching object to a modeling object. The service always returns null since the client should be asking the correct provider to resolve the object.

Specified by:
resolve in interface IElementSelectionProvider
Parameters:
object - the matching object.
Returns:
null.

getJobName

protected java.lang.String getJobName(ElementSelectionService.JobData data)
Get the name for the ElementSelectionServiceJob. Clients can override.

Returns:
the name for the job.

fireMatchingObjectEvent

protected void fireMatchingObjectEvent(IMatchingObjectEvent matchingObjectEvent)
Send the matching object event to the listener.

Parameters:
matchingObjectEvent - the matching object event.

fireEndOfMatchesEvent

protected void fireEndOfMatchesEvent()
Fire an end of matches event since there are no more matches.


matchingObjectEvent

public void matchingObjectEvent(IMatchingObjectEvent matchingObjectEvent)
A matching object event has been sent.

Specified by:
matchingObjectEvent in interface IElementSelectionListener

cancelAllJobs

protected void cancelAllJobs()
Cancel the jobs running for the element selection service.


newProviderDescriptor

protected Service.ProviderDescriptor newProviderDescriptor(IConfigurationElement element)
Description copied from class: Service
Creates a new provider descriptor for the specified configuration element.

Overrides:
newProviderDescriptor in class Service
Parameters:
element - The configuration element from which to create the descriptor.
Returns:
A new provider descriptor.

configureProviders

protected void configureProviders()
Configures my providers from the elementSelectionProviders extension point.


cancelJob

public void cancelJob(ElementSelectionServiceJob job)

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.