// Copyright (c) 2005 by Leif Frenzel. All rights reserved.
// See http://leiffrenzel.de
+// modified for phpeclipse.de project by axelcl
package net.sourceforge.phpdt.ltk.ui.actions;
import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
-import net.sourceforge.phpdt.ltk.core.RenamePropertyInfo;
-import net.sourceforge.phpdt.ltk.core.RenamePropertyProcessor;
-import net.sourceforge.phpdt.ltk.core.RenamePropertyRefactoring;
+import net.sourceforge.phpdt.ltk.core.RenameIdentifierDelegate;
+import net.sourceforge.phpdt.ltk.core.RenameIdentifierInfo;
+import net.sourceforge.phpdt.ltk.core.RenameIdentifierRefactoring;
+import net.sourceforge.phpdt.ltk.core.RenamePHPProcessor;
import net.sourceforge.phpdt.ltk.ui.UITexts;
-import net.sourceforge.phpdt.ltk.ui.wizards.RenamePropertyWizard;
+import net.sourceforge.phpdt.ltk.ui.wizards.RenameIdentifierWizard;
import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor;
* <p>
* action that is triggered from the editor context menu.
* </p>
- *
+ *
* <p>
* This action is declared in the <code>plugin.xml</code>.
* </p>
- *
- * @author Leif Frenzel
+ *
*/
public class RenamePHPIdentifier implements IEditorActionDelegate {
- private static final String EXT_PROPERTIES = "properties"; //$NON-NLS-1$
-
private ISelection selection;
private IEditorPart targetEditor;
- private boolean onPropertiesFile;
+ private boolean onPHPFile;
- private RenamePropertyInfo info = new RenamePropertyInfo();
+ private RenameIdentifierInfo info = new RenameIdentifierInfo();
// interface methods of IEditorActionDelegate
// ///////////////////////////////////////////
- public void setActiveEditor(final IAction action, final IEditorPart targetEditor) {
+ public void setActiveEditor(final IAction action,
+ final IEditorPart targetEditor) {
this.targetEditor = targetEditor;
- onPropertiesFile = false;
+ onPHPFile = false;
IFile file = getFile();
if (file != null && PHPFileUtil.isPHPFile(file)) {
- onPropertiesFile = true;
+ onPHPFile = true;
}
}
public void run(final IAction action) {
- if (!onPropertiesFile) {
+ if (!onPHPFile) {
refuse();
} else {
if (selection != null && selection instanceof ITextSelection) {
if (targetEditor != null && (targetEditor instanceof PHPEditor)) {
PHPEditor editor = (PHPEditor) targetEditor;
if (editor != null) {
- ITextSelection textSelection = (ITextSelection) editor.getSelectionProvider().getSelection();
- IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ ITextSelection textSelection = (ITextSelection) editor
+ .getSelectionProvider().getSelection();
+ IDocument doc = editor.getDocumentProvider()
+ .getDocument(editor.getEditorInput());
int pos = textSelection.getOffset();
point = PHPWordExtractor.findWord(doc, pos);
if (point != null) {
}
}
- public void selectionChanged(final IAction action, final ISelection selection) {
+ public void selectionChanged(final IAction action,
+ final ISelection selection) {
this.selection = selection;
}
// helping methods
// ////////////////
- private void applySelection(final ITextSelection textSelection, String word, Point point) {
+ private void applySelection(final ITextSelection textSelection,
+ String word, Point point) {
if (word != null) {
info.setOldName(word);
info.setNewName(word);
}
private void openWizard() {
- RefactoringProcessor processor = new RenamePropertyProcessor(info);
- RenamePropertyRefactoring ref = new RenamePropertyRefactoring(processor);
- RenamePropertyWizard wizard = new RenamePropertyWizard(ref, info);
- RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
+ RenameIdentifierDelegate delegate = new RenameIdentifierDelegate(info);
+ RefactoringProcessor processor = new RenamePHPProcessor(info, delegate);
+ RenameIdentifierRefactoring ref = new RenameIdentifierRefactoring(
+ processor);
+ RenameIdentifierWizard wizard = new RenameIdentifierWizard(ref, info);
+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(
+ wizard);
try {
String titleForFailedChecks = ""; //$NON-NLS-1$
op.run(getShell(), titleForFailedChecks);
if (targetEditor != null) {
result = targetEditor.getSite().getShell();
} else {
- result = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ result = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell();
}
return result;
}