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