001: /**
002: *
003: */package core;
004:
005: import org.eclipse.core.runtime.CoreException;
006: import org.eclipse.core.runtime.IProgressMonitor;
007: import org.eclipse.core.runtime.OperationCanceledException;
008: import org.eclipse.ltk.core.refactoring.Change;
009: import org.eclipse.ltk.core.refactoring.CompositeChange;
010: import org.eclipse.ltk.core.refactoring.RefactoringStatus;
011: import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
012: import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
013: import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
014: import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
015:
016: /** <p>The processor is where the work is delegated to if participants are
017: * involved. The processor loads the participants and manages the lifecycle
018: * of the refactoring. In order to do that, the refactoring entry point
019: * methods must be implemented.</p>
020: *
021: * @author sh
022: */
023: public class RenameImplementationProcessor extends RefactoringProcessor {
024:
025: // the info object containing all necesary info for the refactoring
026: private final ModelInfo info;
027:
028: // the delegate object which does all the refactoring work
029: private final RenameImplementationDelegate delegate;
030:
031: /**
032: * Constructor
033: * @param info the model info object
034: */
035: public RenameImplementationProcessor(ModelInfo info) {
036: super ();
037: this .info = info;
038: delegate = new RenameImplementationDelegate(info);
039: }
040:
041: /* (non-Javadoc)
042: * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
043: */
044: @Override
045: public Object[] getElements() {
046: // usually, this would be some element object in the object model on which
047: // we work (e.g. a Java element if we were in the Java Model); in this case
048: // we have only the property name
049:
050: return new Object[] { info.getOldImplementation() };
051: }
052:
053: /* (non-Javadoc)
054: * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier()
055: */
056: @Override
057: public String getIdentifier() {
058: return getClass().getName();
059: }
060:
061: /* (non-Javadoc)
062: * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName()
063: */
064: @Override
065: public String getProcessorName() {
066: return "Rename Implementation";
067: }
068:
069: /* (non-Javadoc)
070: * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable()
071: */
072: @Override
073: public boolean isApplicable() throws CoreException {
074: return true;
075: }
076:
077: /* (non-Javadoc)
078: * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
079: */
080: @Override
081: public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
082: throws CoreException, OperationCanceledException {
083: return delegate.checkInitialConditions();
084: }
085:
086: /* (non-Javadoc)
087: * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
088: */
089: @Override
090: public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
091: CheckConditionsContext context) throws CoreException,
092: OperationCanceledException {
093: return delegate.checkFinalConditions(pm, context);
094: }
095:
096: /* (non-Javadoc)
097: * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
098: */
099: @Override
100: public Change createChange(IProgressMonitor pm)
101: throws CoreException, OperationCanceledException {
102:
103: CompositeChange result = new CompositeChange(getProcessorName());
104: delegate.createChange(pm, result);
105: return result;
106: }
107:
108: /* (non-Javadoc)
109: * @see org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#loadParticipants(org.eclipse.ltk.core.refactoring.RefactoringStatus, org.eclipse.ltk.core.refactoring.participants.SharableParticipants)
110: */
111: @Override
112: public RefactoringParticipant[] loadParticipants(
113: RefactoringStatus status,
114: SharableParticipants sharedParticipants)
115: throws CoreException {
116: // This would be the place to load the participants via the
117: // ParticipantManager and decide which of them are allowed to participate.
118: return new RefactoringParticipant[0];
119: }
120: }
|