Runtime

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

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

public class ElementSelectionService
extends Service
implements IElementSelectionProvider, IElementSelectionListener

The element selection service.


Field Summary
 
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.
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.
protected  java.lang.String getJobName()
          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.

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.

 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.

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

 
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
 

Constructor Detail

ElementSelectionService

protected ElementSelectionService()
Constructs a new type selection service.

Method Detail

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.

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.

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()
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.

Runtime

Guidelines for using Eclipse APIs.

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