Eclipse JDT
Release 3.0

org.eclipse.ltk.core.refactoring.participants
Class RefactoringParticipant

java.lang.Object
  extended byorg.eclipse.core.runtime.PlatformObject
      extended byorg.eclipse.ltk.core.refactoring.participants.RefactoringParticipant
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable
Direct Known Subclasses:
CreateParticipant, DeleteParticipant, MoveParticipant, RenameParticipant

public abstract class RefactoringParticipant
extends org.eclipse.core.runtime.PlatformObject

A refactoring participant can participate in the condition checking and change creation of a refactoring processor.

If the severity of the condition checking result is RefactoringStatus.FATAL then the whole refactoring will not be carried out.

The change created from a participant MUST not conflict with any changes provided by other participants or the refactoring itself. To ensure this a participant is only allowed to manipulate resources belonging to its domain. For example a rename type participant updating launch configuration is only allowed to update launch configurations. It is not allowed to manipulate any Java resources or any other resources not belonging to its domain. If a change conflicts with another change during execution then the participant who created the change will be disabled for the rest of the eclipse session.

A refactoring participant can not assume that all resources are saved before any methods are called on it. Therefore a participant must be able to deal with unsaved resources.

This class should be subclassed by clients wishing to provide special refactoring participants extension points.

Since:
3.0
See Also:
RefactoringProcessor

Constructor Summary
RefactoringParticipant()
           
 
Method Summary
abstract  RefactoringStatus checkConditions(org.eclipse.core.runtime.IProgressMonitor pm, CheckConditionsContext context)
          Checks the conditions of the refactoring participant.
abstract  Change createChange(org.eclipse.core.runtime.IProgressMonitor pm)
          Creates a Changeobject that contains the workspace modifications of this participant.
abstract  String getName()
          Returns a human readable name of this participant.
 RefactoringProcessor getProcessor()
          Returns the processor that is associated with this participant.
protected abstract  boolean initialize(Object element)
          Initializes the participant with the element to be refactored.
protected abstract  void initialize(RefactoringArguments arguments)
          Initializes the participant with the refactoring arguments
 boolean initialize(RefactoringProcessor processor, Object element, RefactoringArguments arguments)
          Initializes the participant.
 
Methods inherited from class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RefactoringParticipant

public RefactoringParticipant()
Method Detail

getProcessor

public RefactoringProcessor getProcessor()
Returns the processor that is associated with this participant.

Returns:
the processor that is associated with this participant

initialize

public boolean initialize(RefactoringProcessor processor,
                          Object element,
                          RefactoringArguments arguments)
Initializes the participant. This method is called by the framework when a participant gets instantiated.

This method isn't intended to be extended or reimplemented by clients.

Parameters:
processor - the processor this participant is associated with
element - the element to be refactored
arguments - the refactoring arguments
Returns:
true if the participant could be initialized; otherwise false is returned. If false is returned then the participant will not be added to the refactoring.
See Also:
initialize(Object)

initialize

protected abstract boolean initialize(Object element)
Initializes the participant with the element to be refactored. If this method returns false then the framework will consider the participant as not being initialized and the participant will be dropped by the framework.

Parameters:
element - the element to be refactored
Returns:
true if the participant could be initialized; otherwise false is returned.

initialize

protected abstract void initialize(RefactoringArguments arguments)
Initializes the participant with the refactoring arguments

Parameters:
arguments - the refactoring arguments

getName

public abstract String getName()
Returns a human readable name of this participant.

Returns:
a human readable name

checkConditions

public abstract RefactoringStatus checkConditions(org.eclipse.core.runtime.IProgressMonitor pm,
                                                  CheckConditionsContext context)
                                           throws org.eclipse.core.runtime.OperationCanceledException
Checks the conditions of the refactoring participant.

The refactoring is considered as not being executable if the returned status has the severity of RefactoringStatus#FATAL.

This method can be called more than once.

Parameters:
pm - a progress monitor to report progress
context - a condition checking context to collect shared condition checks
Returns:
a refactoring status. If the status is RefactoringStatus#FATAL the refactoring is considered as not being executable.
Throws:
org.eclipse.core.runtime.OperationCanceledException - if the condition checking got cancelled
See Also:
Refactoring.checkInitialConditions(IProgressMonitor), RefactoringStatus.FATAL

createChange

public abstract Change createChange(org.eclipse.core.runtime.IProgressMonitor pm)
                             throws org.eclipse.core.runtime.CoreException,
                                    org.eclipse.core.runtime.OperationCanceledException
Creates a Changeobject that contains the workspace modifications of this participant. The changes provided by a participant must not conflict with any change provided by other participants or by the refactoring itself.

If the change conflicts with any change provided by other participants or by the refactoring itself then change execution will fail and the participant will be disabled for the rest of the eclipse session.

If an exception occurs while creating the change the refactoring can not be carried out and the participant will be disabled for the rest of the eclipse session.

Parameters:
pm - a progress monitor to report progress
Returns:
the change representing the workspace modifications
Throws:
org.eclipse.core.runtime.CoreException - if an error occurred while creating the change
org.eclipse.core.runtime.OperationCanceledException - if the condition checking got cancelled

Eclipse JDT
Release 3.0

Copyright (c) IBM Corp. and others 2000, 2004. All Rights Reserved.