Added a new refactoring action: net.sourceforge.phpdt.ltk.ui.actions.RenameLocalVariable
[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.*;
7 import org.eclipse.ltk.core.refactoring.*;
8 import org.eclipse.ltk.core.refactoring.participants.*;
9
10 /** <p>The processor is where the work is delegated to if participants are
11   * involved. The processor loads the participants and manages the lifecycle
12   * of the refactoring. In order to do that, the refactoring entry point
13   * methods must be implemented.</p>
14   *
15   */
16 public class RenamePHPProcessor extends RefactoringProcessor {
17
18   private final RenameIdentifierInfo info;
19   private final RenameIdentifierDelegate delegate;
20
21   public RenamePHPProcessor( final RenameIdentifierInfo info, final RenameIdentifierDelegate delegate ) {
22     this.info = info;
23     this.delegate = delegate;
24   }
25
26
27   public Object[] getElements() {
28     // usually, this would be some element object in the object model on which
29     // we work (e.g. a Java element if we were in the Java Model); in this case
30     // we have only the property name
31     return new Object[] { info.getOldName() };
32   }
33
34   public String getIdentifier() {
35     return getClass().getName();
36   }
37
38   public String getProcessorName() {
39     return CoreTexts.renamePropertyProcessor_name;
40   }
41
42   public boolean isApplicable() throws CoreException {
43     return true;
44   }
45
46   public RefactoringStatus checkInitialConditions( final IProgressMonitor pm ) {
47     return delegate.checkInitialConditions();
48   }
49
50   public RefactoringStatus checkFinalConditions(
51             final IProgressMonitor pm,  final CheckConditionsContext context ) {
52     return delegate.checkFinalConditions( pm, context );
53   }
54
55   public Change createChange( final IProgressMonitor pm ) {
56     CompositeChange result = new CompositeChange( getProcessorName() );
57     delegate.createChange( pm, result );
58     return result;
59   }
60
61   public RefactoringParticipant[] loadParticipants(
62                                final RefactoringStatus status,
63                                final SharableParticipants sharedParticipants ) {
64     // This would be the place to load the participants via the
65     // ParticipantManager and decide which of them are allowed to participate.
66     return new RefactoringParticipant[ 0 ];
67   }
68 }