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