A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ltk / core / RenamePHPProcessor.java
1 // Copyright (c) 2005 by Leif Frenzel. All rights reserved.
2 // See http://leiffrenzel.de
3 // modified for phpeclipse.de project by axelcl
4 package net.sourceforge.phpdt.ltk.core;
5
6 import org.eclipse.core.runtime.CoreException;
7 import org.eclipse.core.runtime.IProgressMonitor;
8 import org.eclipse.ltk.core.refactoring.Change;
9 import org.eclipse.ltk.core.refactoring.CompositeChange;
10 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
11 import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
12 import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
13 import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
14 import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
15
16 /**
17  * <p>
18  * The processor is where the work is delegated to if participants are involved.
19  * The processor loads the participants and manages the lifecycle of the
20  * refactoring. In order to do that, the refactoring entry point methods must be
21  * implemented.
22  * </p>
23  * 
24  */
25 public class RenamePHPProcessor extends RefactoringProcessor {
26
27         private final RenameIdentifierInfo info;
28
29         private final RenameIdentifierDelegate delegate;
30
31         public RenamePHPProcessor(final RenameIdentifierInfo info,
32                         final RenameIdentifierDelegate delegate) {
33                 this.info = info;
34                 this.delegate = delegate;
35         }
36
37         public Object[] getElements() {
38                 // usually, this would be some element object in the object model on
39                 // which
40                 // we work (e.g. a Java element if we were in the Java Model); in this
41                 // case
42                 // we have only the property name
43                 return new Object[] { info.getOldName() };
44         }
45
46         public String getIdentifier() {
47                 return getClass().getName();
48         }
49
50         public String getProcessorName() {
51                 return CoreTexts.renamePropertyProcessor_name;
52         }
53
54         public boolean isApplicable() throws CoreException {
55                 return true;
56         }
57
58         public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) {
59                 return delegate.checkInitialConditions();
60         }
61
62         public RefactoringStatus checkFinalConditions(final IProgressMonitor pm,
63                         final CheckConditionsContext context) {
64                 return delegate.checkFinalConditions(pm, context);
65         }
66
67         public Change createChange(final IProgressMonitor pm) {
68                 CompositeChange result = new CompositeChange(getProcessorName());
69                 delegate.createChange(pm, result);
70                 return result;
71         }
72
73         public RefactoringParticipant[] loadParticipants(
74                         final RefactoringStatus status,
75                         final SharableParticipants sharedParticipants) {
76                 // This would be the place to load the participants via the
77                 // ParticipantManager and decide which of them are allowed to
78                 // participate.
79                 return new RefactoringParticipant[0];
80         }
81 }