Author: dazarov
Date: 2009-11-27 04:53:46 -0500 (Fri, 27 Nov 2009)
New Revision: 18872
Added:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/FieldEditorFactory.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/ELRenameProcessor.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RenameELVariableProcessor.java
trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameELVariableWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4990
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java 2009-11-27
08:23:38 UTC (rev 18871)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java 2009-11-27
09:53:46 UTC (rev 18872)
@@ -23,12 +23,11 @@
public static String StringTokenDescription_Name;
public static String WhiteSpaceTokenDescription_Name;
- public static String EL_RENAME_PROCESSOR_LOCATION_NOT_FOUND;
public static String EL_RENAME_PROCESSOR_OUT_OF_SYNC_FILE;
public static String EL_RENAME_PROCESSOR_ERROR_PHANTOM_FILE;
public static String EL_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE;
public static String RENAME_EL_VARIABLE_PROCESSOR_TITLE;
- public static String RENAME_EL_VARIABLE_PROCESSOR_CAN_NOT_FIND_CONTEXT_VARIABLE;
+ public static String RENAME_EL_VARIABLE_PROCESSOR_CAN_NOT_FIND_EL_VARIABLE;
static {
// initialize resource bundle
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties 2009-11-27
08:23:38 UTC (rev 18871)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties 2009-11-27
09:53:46 UTC (rev 18872)
@@ -16,3 +16,9 @@
PrimitiveValueTokenDescription_Name=Primitive
StringTokenDescription_Name=String
WhiteSpaceTokenDescription_Name=Whitespace
+EL_RENAME_PROCESSOR_OUT_OF_SYNC_FILE=Cannot change file. File ''{0}'' is
not in sync.
+EL_RENAME_PROCESSOR_ERROR_PHANTOM_FILE=Cannot change phantom file:
''{0}''.
+EL_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE=Cannot change read-only file:
''{0}''.
+RENAME_EL_VARIABLE_PROCESSOR_TITLE=Rename EL Variable
+RENAME_EL_VARIABLE_PROCESSOR_CAN_NOT_FIND_EL_VARIABLE=Can not find EL Variable:
''{0}''.
+
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/ELRenameProcessor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/ELRenameProcessor.java 2009-11-27
08:23:38 UTC (rev 18871)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/ELRenameProcessor.java 2009-11-27
09:53:46 UTC (rev 18872)
@@ -29,6 +29,7 @@
import org.eclipse.text.edits.TextEdit;
import org.jboss.tools.common.el.core.ELCorePlugin;
import org.jboss.tools.common.el.core.ElCoreMessages;
+import org.jboss.tools.common.model.project.ProjectHome;
import org.jboss.tools.common.text.ITextSourceReference;
import org.jboss.tools.common.util.FileUtil;
@@ -59,7 +60,11 @@
private ELSearcher searcher = null;
+ public ELRenameProcessor(IFile file, String oldName){
+ searcher = new ELSearcher(file, oldName);
+ }
+
protected RefactorSearcher getSearcher(){
return searcher;
}
@@ -107,8 +112,8 @@
else
flag = location.getStartPosition() == 0 && location.getLength() == 0;
- if(flag)
- status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_LOCATION_NOT_FOUND,
file.getFullPath().toString()));
+// if(flag)
+// status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_LOCATION_NOT_FOUND,
file.getFullPath().toString()));
return flag;
}
@@ -239,29 +244,32 @@
return true;
}
-
ArrayList<String> keys = new ArrayList<String>();
@Override
protected IProject[] getProjects() {
- // TODO Auto-generated method stub
- return null;
+ return new IProject[]{baseFile.getProject()};
}
+
@Override
protected IContainer getViewFolder(IProject project) {
- // TODO Auto-generated method stub
+ IPath path = ProjectHome.getFirstWebContentPath(baseFile.getProject());
+
+ if(path != null)
+ return project.getFolder(path.removeFirstSegments(1));
+
return null;
}
+
@Override
protected void match(IFile file, int offset, int length) {
- // TODO Auto-generated method stub
-
+ change(file, offset, length, newName);
}
@Override
protected boolean isFileCorrect(IFile file) {
- return isFileCorrect(file);
+ return ELRenameProcessor.this.isFileCorrect(file);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RenameELVariableProcessor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RenameELVariableProcessor.java 2009-11-27
08:23:38 UTC (rev 18871)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/RenameELVariableProcessor.java 2009-11-27
09:53:46 UTC (rev 18872)
@@ -34,7 +34,7 @@
* @param file where refactor was called
*/
public RenameELVariableProcessor(IFile file, String oldName) {
- super();
+ super(file, oldName);
this.file = file;
setOldName(oldName);
}
@@ -51,7 +51,7 @@
rootChange = new CompositeChange(ElCoreMessages.RENAME_EL_VARIABLE_PROCESSOR_TITLE);
- //renameELContextVariable(pm, file);
+ renameELVariable(pm, file);
return status;
}
@@ -69,7 +69,7 @@
status = checkELContextVariable();
if(!status)
- result.addFatalError(Messages.format(ElCoreMessages.RENAME_EL_VARIABLE_PROCESSOR_CAN_NOT_FIND_CONTEXT_VARIABLE,
getOldName()));
+ result.addFatalError(Messages.format(ElCoreMessages.RENAME_EL_VARIABLE_PROCESSOR_CAN_NOT_FIND_EL_VARIABLE,
getOldName()));
return result;
}
@@ -86,7 +86,7 @@
private boolean checkELContextVariable(){
- boolean status = false;
+ boolean status = true;
IProject[] projects = getSearcher().getProjects();
for (IProject project : projects) {
@@ -140,4 +140,8 @@
SharableParticipants sharedParticipants) throws CoreException {
return EMPTY_REF_PARTICIPANT;
}
+
+ private void renameELVariable(IProgressMonitor pm, IFile file){
+ getSearcher().findELReferences();
+ }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-11-27
08:23:38 UTC (rev 18871)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-11-27
09:53:46 UTC (rev 18872)
@@ -20,7 +20,8 @@
org.jboss.tools.jst.web.ui;bundle-version="2.0.0",
org.eclipse.jface.text;bundle-version="3.5.0",
org.eclipse.core.expressions;bundle-version="3.4.100",
- org.eclipse.ltk.ui.refactoring;bundle-version="3.4.100"
+ org.eclipse.ltk.ui.refactoring;bundle-version="3.4.100",
+ org.jboss.tools.common.ui;bundle-version="1.0.0"
Bundle-Vendor: %Bundle-Vendor.0
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.jboss.tools.vpe.resref.core
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java 2009-11-27
08:23:38 UTC (rev 18871)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ElUIMessages.java 2009-11-27
09:53:46 UTC (rev 18872)
@@ -20,4 +20,5 @@
public static String REFACTOR_CONTRIBUTOR_MAIN_MENU;
public static String REFACTOR_CONTRIBUTOR_RENAME_EL_VARIABLE;
public static String EL_REFACTOR_RENAME_HANDLER_ERROR;
+ public static String RENAME_EL_VARIABLE_WIZARD_EL_VARIABLE_NAME;
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties 2009-11-27
08:23:38 UTC (rev 18871)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties 2009-11-27
09:53:46 UTC (rev 18872)
@@ -8,3 +8,4 @@
RESOURCE_BUNDLES_RENAME_PARTICIPANT_UPDATE_BUNDLE_REFERENCES=Update bundle references in
EL
REFACTOR_CONTRIBUTOR_MAIN_MENU=EL Refactor
REFACTOR_CONTRIBUTOR_RENAME_EL_VARIABLE=Rename EL Variable
+RENAME_EL_VARIABLE_WIZARD_EL_VARIABLE_NAME=Seam component name:
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java 2009-11-27
08:23:38 UTC (rev 18871)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/ELRefactorContributionFactory.java 2009-11-27
09:53:46 UTC (rev 18872)
@@ -333,14 +333,14 @@
RenameELVariableProcessor processor = new RenameELVariableProcessor(editorFile,
selectedText);
RenameELVariableRefactoring refactoring = new RenameELVariableRefactoring(processor);
- //RenameELVariableWizard wizard = new RenameELVariableWizard(refactoring, editorFile);
-// RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
-// try {
-// String titleForFailedChecks = ElUIMessages.EL_REFACTOR_RENAME_HANDLER_ERROR;
-// op.run(activeShell, titleForFailedChecks);
-// } catch (final InterruptedException irex) {
-// // operation was canceled
-// }
+ RenameELVariableWizard wizard = new RenameELVariableWizard(refactoring, editorFile);
+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
+ try {
+ String titleForFailedChecks = ElUIMessages.EL_REFACTOR_RENAME_HANDLER_ERROR;
+ op.run(activeShell, titleForFailedChecks);
+ } catch (final InterruptedException irex) {
+ // operation was canceled
+ }
}
class RenameELVariableAction extends Action{
Added:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/FieldEditorFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/FieldEditorFactory.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/FieldEditorFactory.java 2009-11-27
09:53:46 UTC (rev 18872)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.ui.refactoring;
+
+import org.jboss.tools.common.ui.widget.editor.CompositeEditor;
+import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
+import org.jboss.tools.common.ui.widget.editor.LabelFieldEditor;
+import org.jboss.tools.common.ui.widget.editor.TextFieldEditor;
+
+public class FieldEditorFactory {
+ public static IFieldEditor createTextEditor(String name, String label, String
defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+ editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
+ new TextFieldEditor(name,label, defaultValue)});
+ return editor;
+ }
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/FieldEditorFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameELVariableWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameELVariableWizard.java 2009-11-27
08:23:38 UTC (rev 18871)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/RenameELVariableWizard.java 2009-11-27
09:53:46 UTC (rev 18872)
@@ -12,32 +12,31 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.util.Map;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.resources.IFile;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.jboss.tools.common.el.core.refactoring.RenameELVariableProcessor;
-import org.jboss.tools.common.model.ui.attribute.editor.IFieldEditor;
+import org.jboss.tools.common.el.ui.ElUIMessages;
+import org.jboss.tools.common.ui.widget.editor.CompositeEditor;
+import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
/**
* @author Daniel Azarov
*/
public class RenameELVariableWizard extends RefactoringWizard {
- private String componentName;
+ private String variableName;
private IFieldEditor editor;
- public RenameELVariableWizard(Refactoring refactoring) {
+ public RenameELVariableWizard(Refactoring refactoring, IFile editorFile) {
super(refactoring, WIZARD_BASED_USER_INTERFACE);
}
@@ -57,6 +56,7 @@
public RenameELVariableWizardPage(RenameELVariableProcessor processor){
super("");
this.processor = processor;
+ variableName = processor.getOldName();
}
public void createControl(Composite parent) {
@@ -66,15 +66,15 @@
container.setLayout(layout);
layout.numColumns = 2;
-// String defaultName = component.getName();
-// editor = IFieldEditorFactory.INSTANCE.createTextEditor(componentName,
SeamUIMessages.SEAM_WIZARD_FACTORY_SEAM_COMPONENT_NAME, defaultName);
-// editor.doFillIntoGrid(container);
-//
-// ((CompositeEditor)editor).addPropertyChangeListener(new
PropertyChangeListener(){
-// public void propertyChange(PropertyChangeEvent evt){
-// validatePage();
-// }
-// });
+ String defaultName = variableName;
+ editor = FieldEditorFactory.createTextEditor(variableName,
ElUIMessages.RENAME_EL_VARIABLE_WIZARD_EL_VARIABLE_NAME, defaultName);
+ editor.doFillIntoGrid(container);
+
+ ((CompositeEditor)editor).addPropertyChangeListener(new
PropertyChangeListener(){
+ public void propertyChange(PropertyChangeEvent evt){
+ validatePage();
+ }
+ });
setControl(container);
setPageComplete(false);
}