org.eclipse.stp.core.saf.handler
Interface IInterfaceHandler

All Superinterfaces:
IHandler
All Known Implementing Classes:
AbstractInterfaceHandler

public interface IInterfaceHandler
extends IHandler

This interface must be implemented by all interface handlers.


Nested Class Summary
static interface IInterfaceHandler.IInterfaceLabelProvider
          The IInterfaceLabelProvider maps an interface object to an optional image and optional text string used to display the element in the viewer's control.
 
Method Summary
 boolean canCreateInterfaceFor(java.lang.Object interfaceObj)
          Queries if an interface of the kind supported by this handler can be created for the specified interface object.
 boolean canCreateInterfaceObject()
          Queries if this handler can create an interface object for the supported type.
 org.eclipse.stp.core.sca.Interface createInterfaceFor(java.lang.Object interfaceObj, IUIContext callback)
          Creates an SCA interface from the given interface object.
 java.lang.Object createInterfaceObject(org.eclipse.core.resources.IProject defaultLocation, java.lang.String interfaceName, IUIContext callback)
          Creates a new interface object to be used by an SCA interface.
 IInterfaceHandler.IInterfaceLabelProvider getInterfaceLabelProvider()
          This method returns the handler's instance of IInterfaceHandler.IInterfaceLabelProvider.
 java.lang.Object[] getInterfaceObjects(org.eclipse.core.resources.IResource searchScope)
          Returns an array of Object representing all interfaces found within the given search scope.
 void open(org.eclipse.stp.core.sca.Interface interfaceObj)
          This method opens a registered editor for the given interface type.
 
Methods inherited from interface org.eclipse.stp.core.saf.handler.IHandler
getDescription, getDescriptiveKindName, getKind, getLargeIcon, getName, getSmallIcon
 

Method Detail

canCreateInterfaceFor

public boolean canCreateInterfaceFor(java.lang.Object interfaceObj)
Queries if an interface of the kind supported by this handler can be created for the specified interface object. If this method returns true, the handler's createInterfaceFor() method may be called to create an interface for the file.

This method should be quick to execute as it may be called to populate a context menu or a user dialog. When interfaceObj is a container, a quick check should be performed to verify that an SCA interface can be created from one of the objects contained by interfaceObj. For example, if interfaceObj is a file, perhaps the file extension can be checked rather than opening the file to inspect its contents. If this method returns true for an invalid container, the createInterfaceFor(Object, IUIContext) can throw an InvalidOperationException to let the caller know that an interface could not be created from it.

Parameters:
interfaceObj - an object representing the interface
Returns:
true if the handler can create an interface from the specified object; false otherwise

canCreateInterfaceObject

public boolean canCreateInterfaceObject()
Queries if this handler can create an interface object for the supported type. If this method returns true, the handler's #createInterfaceObject(IProject, IUIContext) method may be called to create an interface object.

Returns:
true if the handler can create an interface object; false otherwise

createInterfaceFor

public org.eclipse.stp.core.sca.Interface createInterfaceFor(java.lang.Object interfaceObj,
                                                             IUIContext callback)
                                                      throws SAFException,
                                                             InvalidOperationException
Creates an SCA interface from the given interface object.

The interface object can be an object supported by the canCreateInterfaceFor(Object) or returned by the getInterfaceObjects(IResource) method.

Parameters:
interfaceObj - the object representing the interface
callback - callback object that the handler can use to obtain additional information needed to create the interface object. For example, what object can be used when creating the SCA interface if interfaceObj is a container, such as a file.
Returns:
the new interface
Throws:
SAFException - An unexpected exception occurred.
InvalidOperationException - An interface cannot be created from the given interface object.

createInterfaceObject

public java.lang.Object createInterfaceObject(org.eclipse.core.resources.IProject defaultLocation,
                                              java.lang.String interfaceName,
                                              IUIContext callback)
                                       throws SAFException,
                                              InvalidOperationException,
                                              java.lang.InterruptedException
Creates a new interface object to be used by an SCA interface. This method takes an optional interface name that the handler can choose to use if appropriate. Also, the IUIContext is optionally used by this method to display the corresponding wizard used to create the new interface object.

Parameters:
defaultLocation - the default project to use when creating the interface
callback - callback object that the handler can use to obtain additional information needed to create the interface object
Returns:
the new interface object
Throws:
SAFException - An unexpected exception occurred.
InvalidOperationException - The interface object cannot be created.
java.lang.InterruptedException - The caller did not provide a callback object needed by the handler, or the callback request was canceled or aborted.

getInterfaceObjects

public java.lang.Object[] getInterfaceObjects(org.eclipse.core.resources.IResource searchScope)
                                       throws SAFException
Returns an array of Object representing all interfaces found within the given search scope. The handler determines how it will use the search scope. Depending on the interface type being sought, the handler may look at a single project or folder or look in the workspace or in a project's classpath.

The objects returned by this method must be supported as the argument to the canCreateInterfaceFor(Object) method.

Parameters:
searchScope - the IResource used to determine the search scope used by this handler
Returns:
an array of Object
Throws:
SAFException - The search cannot be completed.

open

public void open(org.eclipse.stp.core.sca.Interface interfaceObj)
          throws SAFException,
                 InvalidOperationException
This method opens a registered editor for the given interface type.

Parameters:
interfaceObj - the interface to open
Throws:
SAFException - An unexpected exception occurred.
InvalidOperationException - The interface cannot be opened.

getInterfaceLabelProvider

public IInterfaceHandler.IInterfaceLabelProvider getInterfaceLabelProvider()
This method returns the handler's instance of IInterfaceHandler.IInterfaceLabelProvider. The provider is reponsible for generating label information for objects returned by getInterfaceObjects(IResource).

Returns:
the IInterfaceHandler.IInterfaceLabelProvider instance