Author: dazarov
Date: 2009-12-10 11:13:45 -0500 (Thu, 10 Dec 2009)
New Revision: 19191
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELRefactorContributionFactory.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELReferencesQueryParticipant.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/FieldEditorFactory.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameELVariableWizard.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java
trunk/jsf/plugins/org.jboss.tools.jsf/schemas/elProjectSet.exsd
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELProjectSetExtension.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELRenameProcessor.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ProjectsSet.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RefactorSearcher.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableProcessor.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableRefactoring.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.classpath
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.project
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/.jsdtscope
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.common.component
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.container
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.name
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/Messages.properties
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/User.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/META-INF/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/Messages.properties
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/User.class
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/common-annotations.jar
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-beanutils.jar
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-collections.jar
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-digester.jar
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-logging.jar
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/jsf-tlds.jar
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/jstl.jar
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/standard.jar
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/web.xml
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/index.jsp
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello.jsp
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/build.properties
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/build.xml
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/ELRefactoringTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/ELReferencesRenameTest.java
Removed:
trunk/common/plugins/org.jboss.tools.common.el.core/schema/elProjectSet.exsd
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/refactoring/
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/refactoring/
trunk/common/tests/org.jboss.tools.common.el.core.test/projects/testJSFProject/
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/Messages.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.el.core/plugin.xml
trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.el.ui/plugin.xml
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/attribute/adapter/JSFKnowledgeBaseAdapter.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/attribute/adapter/JSFManagedPropertyNameAdapter.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/FacesConfigGuiEditor.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/edit/JSFDiagramEditPart.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/edit/LinkEditPart.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizardPage.java
trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/ELProjectSet.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5289
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/META-INF/MANIFEST.MF 2009-12-10
16:11:35 UTC (rev 19190)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/META-INF/MANIFEST.MF 2009-12-10
16:13:45 UTC (rev 19191)
@@ -10,7 +10,6 @@
org.jboss.tools.common.el.core.ca,
org.jboss.tools.common.el.core.model,
org.jboss.tools.common.el.core.parser,
- org.jboss.tools.common.el.core.refactoring,
org.jboss.tools.common.el.core.resolver,
org.jboss.tools.common.el.internal.core.parser,
org.jboss.tools.common.el.internal.core.parser.token
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/plugin.xml 2009-12-10 16:11:35 UTC
(rev 19190)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/plugin.xml 2009-12-10 16:13:45 UTC
(rev 19191)
@@ -2,6 +2,5 @@
<?eclipse version="3.4"?>
<plugin>
<extension-point id="elResolver" name="EL Resolver"
schema="schema/elResolver.exsd"/>
- <extension-point id="elProjectSet" name="EL Project Set"
schema="schema/elProjectSet.exsd"/>
</plugin>
Deleted: trunk/common/plugins/org.jboss.tools.common.el.core/schema/elProjectSet.exsd
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/schema/elProjectSet.exsd 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/schema/elProjectSet.exsd 2009-12-10
16:13:45 UTC (rev 19191)
@@ -1,127 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.jboss.tools.common.el.core"
xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.jboss.tools.common.el.core"
id="elSearch" name="EL Search"/>
- </appinfo>
- <documentation>
- This extenion point is used to send information about seam project to search and
rename participants. In order to have one search participand and one rename participant
for seam and jsf projects.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="project-set" minOccurs="1"
maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string"
use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="project-set">
- <complexType>
- <attribute name="id" type="string"
use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="identifier"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="projectset-class" type="string"
use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java"
basedOn=":org.jboss.tools.common.el.core.refactoring.ProjectsSet"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- JBoss Tools 3.1
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- 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
- </documentation>
- </annotation>
-
-</schema>
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-12-10
16:11:35 UTC (rev 19190)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/META-INF/MANIFEST.MF 2009-12-10
16:13:45 UTC (rev 19191)
@@ -6,8 +6,7 @@
Bundle-SymbolicName: org.jboss.tools.common.el.ui;singleton:=true
Bundle-Version: 1.0.0
Export-Package: org.jboss.tools.common.el.ui,
- org.jboss.tools.common.el.ui.ca,
- org.jboss.tools.common.el.ui.refactoring
+ org.jboss.tools.common.el.ui.ca
Bundle-Activator: org.jboss.tools.common.el.ui.ElUiPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
Modified: trunk/common/plugins/org.jboss.tools.common.el.ui/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.ui/plugin.xml 2009-12-10 16:11:35 UTC
(rev 19190)
+++ trunk/common/plugins/org.jboss.tools.common.el.ui/plugin.xml 2009-12-10 16:13:45 UTC
(rev 19191)
@@ -1,39 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
- <extension
- point="org.eclipse.jdt.ui.queryParticipants">
- <queryParticipant
-
class="org.jboss.tools.common.el.ui.refactoring.ELReferencesQueryParticipant"
-
id="org.jboss.tools.common.el.ui.refactoring.ELReferencesQueryParticipant"
- name="jsf-SearchELReferencesParticipant"
- nature="org.jboss.tools.jsf.jsfnature">
- </queryParticipant>
- </extension>
-<extension
- point="org.eclipse.ltk.core.refactoring.renameParticipants">
- <renameParticipant
-
class="org.jboss.tools.common.el.ui.refactoring.RenameMethodParticipant"
-
id="org.jboss.tools.common.el.ui.refactoring.RenameMethodParticipant"
- name="el-RenameMethodParticipant">
- <enablement>
- <with variable="element">
- <or>
- <instanceof value="org.eclipse.jdt.core.IMethod"/>
- <instanceof value="org.eclipse.jdt.core.IType"/>
- </or>
- </with>
- </enablement>
- </renameParticipant>
- </extension>
-
- <!-- Refactorng -->
- <!--extension
- point="org.eclipse.ui.menus">
- <menuContribution
-
class="org.jboss.tools.common.el.ui.refactoring.ELRefactorContributionFactory"
- locationURI="popup:org.eclipse.ui.popup.any?after=save">
- </menuContribution>
- </extension-->
</plugin>
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-12-10
16:11:35 UTC (rev 19190)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/messages.properties 2009-12-10
16:13:45 UTC (rev 19191)
@@ -1,11 +1 @@
SUBSTITUTED_EL_EXPRESSIONS=Substituted El expressions
-RENAME_METHOD_PARTICIPANT_GETTER_WARNING=Be sure, may be you also should rename setter
method to avoid compilation problems.
-RENAME_METHOD_PARTICIPANT_SETTER_WARNING=Be sure, may be you also should rename getter
method to avoid compilation problems.
-RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE=Cannot change file. File
''{0}'' is not in sync.
-RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE=Cannot change phantom file:
''{0}''.
-RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE=Cannot change read-only file:
''{0}''.
-RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES=Update method references in EL
-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/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.common.el.core.test;
-import org.jboss.tools.common.el.core.test.refactoring.ELReferencesRenameTest;
import org.jboss.tools.test.util.ProjectImportTestSetup;
import junit.framework.Test;
@@ -27,10 +26,6 @@
suite.setName("All tests for " + PLUGIN_ID);
suite.addTestSuite(ELParserTest.class);
suite.addTestSuite(ELModelTest.class);
- suite.addTest(new ProjectImportTestSetup(new TestSuite(ELReferencesRenameTest.class),
- "org.jboss.tools.common.el.core.test",
- new String[]{"projects/testJSFProject",},
- new String[]{"testJSFProject"}));
return suite;
}
}
Deleted:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELRefactoringTest.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -1,131 +0,0 @@
-package org.jboss.tools.common.el.core.test.refactoring;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
-import org.jboss.tools.common.EclipseUtil;
-import org.jboss.tools.test.util.JobUtils;
-import org.jboss.tools.test.util.ProjectImportTestSetup;
-
-import junit.framework.TestCase;
-
-public class ELRefactoringTest extends TestCase {
- static String jsfProjectName = "testJSFProject";
- static IProject jsfProject;
-
- public ELRefactoringTest(String name){
- super(name);
- }
-
- protected void setUp() throws Exception {
- loadProjects();
- List<IProject> projectList = new ArrayList<IProject>();
- projectList.add(jsfProject);
- J2EEComponentClasspathUpdater.getInstance().forceUpdate(projectList);
- loadProjects();
- }
-
- private void loadProjects() throws Exception {
- jsfProject = ProjectImportTestSetup.loadProject(jsfProjectName);
- jsfProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
- }
-
- protected TestChangeStructure findChange(List<TestChangeStructure> changeList,
IFile file){
- for(TestChangeStructure tcs : changeList){
- if(tcs.getFileName().equals("/"+file.getFullPath().removeFirstSegments(1).toString()))
- return tcs;
- }
- return null;
- }
-
- protected IType getJavaType(IProject project, String className){
- IJavaProject javaProject = EclipseUtil.getJavaProject(project);
- if(javaProject != null){
- try{
- return javaProject.findType(className);
- }catch(JavaModelException ex){
- fail(ex.getMessage());
- }
- }
-
- return null;
- }
-
- protected IMethod getJavaMethod(IProject project, String className, String methodName){
- IType type = getJavaType(project, className);
- if(type != null){
- return type.getMethod(methodName, new String[0]);
- }
- return null;
- }
-
- class TestChangeStructure{
- private IProject project;
- private String fileName;
- ArrayList<TestTextChange> textChanges = new ArrayList<TestTextChange>();
-
-
- public TestChangeStructure(IProject project, String fileName){
- this.project = project;
- this.fileName = fileName;
- }
-
- public IProject getProject(){
- return project;
- }
-
- public String getFileName(){
- return fileName;
- }
-
- public ArrayList<TestTextChange> getTextChanges(){
- return textChanges;
- }
-
- public void addTextChange(TestTextChange change){
- textChanges.add(change);
- }
-
- public int size(){
- return textChanges.size();
- }
-
- }
-
- class TestTextChange{
- private int offset;
- private int length;
- private String text;
-
- public TestTextChange(int offset, int length, String text){
- this.offset = offset;
- this.length = length;
- this.text = text;
- }
-
- public int getOffset(){
- return offset;
- }
-
- public int getLength(){
- return length;
- }
-
- public String getText(){
- return text;
- }
- }
-}
Deleted:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/refactoring/ELReferencesRenameTest.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -1,109 +0,0 @@
-package org.jboss.tools.common.el.core.test.refactoring;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.ltk.core.refactoring.CompositeChange;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.jboss.tools.common.el.ui.refactoring.RenameMethodParticipant;
-import org.jboss.tools.common.util.FileUtil;
-import org.jboss.tools.test.util.JobUtils;
-
-public class ELReferencesRenameTest extends ELRefactoringTest {
-
-
- public ELReferencesRenameTest(){
- super("Rename Method Refactoring Test");
- }
-
-
-
- public void testRenameMethod() throws CoreException {
- ArrayList<TestChangeStructure> list = new
ArrayList<TestChangeStructure>();
-
-
- TestChangeStructure structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/hello.jsp");
- TestTextChange change = new TestTextChange(353, 4, "name");
- structure.addTextChange(change);
- list.add(structure);
-
- structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/inputUserName.jsp");
- change = new TestTextChange(499, 4, "name");
- structure.addTextChange(change);
- list.add(structure);
-
- IMethod method = getJavaMethod(jsfProject, "demo.User",
"getName");
-
- renameELReferences(method, "alias", list);
- }
-
- public void testRenameClass() throws CoreException {
- ArrayList<TestChangeStructure> list = new
ArrayList<TestChangeStructure>();
-
-
- TestChangeStructure structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/hello.jsp");
- TestTextChange change = new TestTextChange(348, 4, "user");
- structure.addTextChange(change);
- list.add(structure);
-
- structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/inputUserName.jsp");
- change = new TestTextChange(494, 4, "user");
- structure.addTextChange(change);
- list.add(structure);
-
- IType type = getJavaType(jsfProject, "demo.User");
-
- renameELReferences(type, "person", list);
- }
-
- private void renameELReferences(IJavaElement element, String newName,
List<TestChangeStructure> changeList) throws CoreException{
- JobUtils.waitForIdle();
-
-
- // Rename EL references
- RenameMethodParticipant participant = new RenameMethodParticipant();
- participant.initialize(element, newName);
- participant.checkConditions(new NullProgressMonitor(), null);
- CompositeChange rootChange = (CompositeChange)participant.createChange(new
NullProgressMonitor());
-
- assertEquals("There is unexpected number of changes",changeList.size(),
rootChange.getChildren().length);
-
- for(int i = 0; i < rootChange.getChildren().length;i++){
- TextFileChange fileChange = (TextFileChange)rootChange.getChildren()[i];
-
- MultiTextEdit edit = (MultiTextEdit)fileChange.getEdit();
-
- TestChangeStructure change = findChange(changeList, fileChange.getFile());
- if(change != null){
- assertEquals(change.size(), edit.getChildrenSize());
- }
- }
-
- rootChange.perform(new NullProgressMonitor());
- JobUtils.waitForIdle();
- // Test results
-
- for(TestChangeStructure changeStructure : changeList){
- IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
- String content = null;
- try {
- content = FileUtil.readStream(file);
- } catch (CoreException e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- //System.out.println("File - "+file.getName()+" offset -
"+changeStructure.getOffset()+" expected -
["+changeStructure.getText()+"] actual -
["+content.substring(changeStructure.getOffset(),
changeStructure.getOffset()+changeStructure.getLength())+"]");
- for(TestTextChange change : changeStructure.getTextChanges()){
- assertEquals("There is unexpected change in resource - "+file.getName(),
newName, content.substring(change.getOffset(), change.getOffset()+newName.length()));
- }
- }
- }
-}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF 2009-12-10 16:11:35 UTC
(rev 19190)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/META-INF/MANIFEST.MF 2009-12-10 16:13:45 UTC
(rev 19191)
@@ -6,6 +6,7 @@
Bundle-SymbolicName: org.jboss.tools.jsf;singleton:=true
Bundle-Localization: plugin
Export-Package: org.jboss.tools.jsf,
+ org.jboss.tools.jsf.el.refactoring,
org.jboss.tools.jsf.facelet.model,
org.jboss.tools.jsf.jsf2.model,
org.jboss.tools.jsf.messages,
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2009-12-10 16:11:35 UTC (rev 19190)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2009-12-10 16:13:45 UTC (rev 19191)
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
-
+ <extension-point id="elProjectSet" name="EL Project Set"
schema="schemas/elProjectSet.exsd"/>
+
<extension point="org.jboss.tools.common.model.meta">
<meta path="meta/jsf.meta">
</meta>
Added: trunk/jsf/plugins/org.jboss.tools.jsf/schemas/elProjectSet.exsd
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/schemas/elProjectSet.exsd
(rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/schemas/elProjectSet.exsd 2009-12-10 16:13:45
UTC (rev 19191)
@@ -0,0 +1,127 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.jboss.tools.common.el.core"
xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.jboss.tools.common.el.core"
id="elSearch" name="EL Search"/>
+ </appinfo>
+ <documentation>
+ This extenion point is used to send information about seam project to search and
rename participants. In order to have one search participand and one rename participant
for seam and jsf projects.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="project-set" minOccurs="1"
maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="project-set">
+ <complexType>
+ <attribute name="id" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="projectset-class" type="string"
use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java"
basedOn=":org.jboss.tools.common.el.core.refactoring.ProjectsSet"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ JBoss Tools 3.1
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="copyright"/>
+ </appinfo>
+ <documentation>
+ 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
+ </documentation>
+ </annotation>
+
+</schema>
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELProjectSetExtension.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELProjectSetExtension.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELProjectSetExtension.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,47 @@
+package org.jboss.tools.jsf.el.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.common.el.core.ELCorePlugin;
+
+public class ELProjectSetExtension {
+ public static String EXTENSION_POINT = "org.jboss.tools.jsf.elProjectSet";
//$NON-NLS-1$
+
+ String id;
+ ProjectsSet searcher;
+
+ public ELProjectSetExtension() {}
+
+ public String getId() {
+ return id;
+ }
+
+ public ProjectsSet getProjectSet() {
+ return searcher;
+ }
+
+ static ELProjectSetExtension[] INSTANCES;
+
+ public static ELProjectSetExtension[] getInstances() {
+ if(INSTANCES != null) return INSTANCES;
+ List<ELProjectSetExtension> list = new ArrayList<ELProjectSetExtension>();
+ IExtensionPoint point =
Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT);
+ IConfigurationElement[] es = point.getConfigurationElements();
+ for (IConfigurationElement e: es) {
+ ELProjectSetExtension n = new ELProjectSetExtension();
+ n.id = e.getAttribute("id"); //$NON-NLS-1$
+ try{
+ n.searcher = (ProjectsSet)e.createExecutableExtension("projectset-class");
//$NON-NLS-1$
+ }catch(CoreException ex){
+ ELCorePlugin.getDefault().logError(ex);
+ }
+ list.add(n);
+ }
+ return INSTANCES = list.toArray(new ELProjectSetExtension[0]);
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELRenameProcessor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELRenameProcessor.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ELRenameProcessor.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,276 @@
+/*******************************************************************************
+ * 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.jsf.el.refactoring;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+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;
+
+/**
+ * @author Daniel Azarov
+ */
+public abstract class ELRenameProcessor extends RenameProcessor {
+ protected static final String JAVA_EXT = "java"; //$NON-NLS-1$
+ protected static final String XML_EXT = "xml"; //$NON-NLS-1$
+ protected static final String XHTML_EXT = "xhtml"; //$NON-NLS-1$
+ protected static final String JSP_EXT = "jsp"; //$NON-NLS-1$
+ protected static final String PROPERTIES_EXT = "properties"; //$NON-NLS-1$
+
+ protected static final RefactoringParticipant[] EMPTY_REF_PARTICIPANT = new
RefactoringParticipant[0];
+
+ protected static final String SEAM_PROPERTIES_FILE = "seam.properties";
//$NON-NLS-1$
+
+ protected RefactoringStatus status;
+
+ protected CompositeChange rootChange;
+ protected TextFileChange lastChange;
+ protected IFile declarationFile=null;
+
+ private ArrayList<String> keys = new ArrayList<String>();
+
+ private String newName;
+ private String oldName;
+
+ private ELSearcher searcher = null;
+
+ public ELRenameProcessor(IFile file, String oldName){
+ searcher = new ELSearcher(file, oldName);
+ }
+
+
+ protected RefactorSearcher getSearcher(){
+ return searcher;
+ }
+
+ public void setNewName(String newName){
+ this.newName = newName;
+ }
+
+ protected String getNewName(){
+ return newName;
+ }
+
+ protected void setOldName(String oldName){
+ this.oldName = oldName;
+ }
+
+ public String getOldName(){
+ return oldName;
+ }
+
+ // lets collect all changes for the same files in one MultiTextEdit
+ protected TextFileChange getChange(IFile file){
+ if(lastChange != null && lastChange.getFile().equals(file))
+ return lastChange;
+
+ for(int i=0; i < rootChange.getChildren().length; i++){
+ TextFileChange change = (TextFileChange)rootChange.getChildren()[i];
+ if(change.getFile().equals(file)){
+ lastChange = change;
+ return lastChange;
+ }
+ }
+ lastChange = new TextFileChange(file.getName(), file);
+ MultiTextEdit root = new MultiTextEdit();
+ lastChange.setEdit(root);
+ rootChange.add(lastChange);
+
+ return lastChange;
+ }
+
+ private boolean isBadLocation(ITextSourceReference location, IFile file){
+ boolean flag;
+ if(location == null)
+ flag = true;
+ else
+ flag = location.getStartPosition() == 0 && location.getLength() == 0;
+
+// if(flag)
+// status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_LOCATION_NOT_FOUND,
file.getFullPath().toString()));
+ return flag;
+ }
+
+ private void changeXMLNode(ITextSourceReference location, IFile file){
+ if(isBadLocation(location, file))
+ return;
+
+ if(!isFileCorrect(file))
+ return;
+
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ ELCorePlugin.getDefault().logError(e);
+ }
+
+ String text = content.substring(location.getStartPosition(),
location.getStartPosition()+location.getLength());
+ if(text.startsWith("<")){ //$NON-NLS-1$
+ int position = text.lastIndexOf("/>"); //$NON-NLS-1$
+ if(position < 0){
+ position = text.lastIndexOf(">"); //$NON-NLS-1$
+ }
+ change(file, location.getStartPosition()+position, 0, "
name=\""+getNewName()+"\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }else{
+ change(file, location.getStartPosition(), location.getLength(), getNewName());
+ }
+ }
+
+ private void changeAnnotation(ITextSourceReference location, IFile file){
+ if(isBadLocation(location, file))
+ return;
+
+ if(!isFileCorrect(file))
+ return;
+
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ ELCorePlugin.getDefault().logError(e);
+ }
+
+ String text = content.substring(location.getStartPosition(),
location.getStartPosition()+location.getLength());
+ int openBracket = text.indexOf("("); //$NON-NLS-1$
+ int openQuote = text.indexOf("\""); //$NON-NLS-1$
+ if(openBracket >= 0){
+ int closeBracket = text.indexOf(")", openBracket); //$NON-NLS-1$
+
+ int equals = text.indexOf("=", openBracket); //$NON-NLS-1$
+ int value = text.indexOf("value", openBracket); //$NON-NLS-1$
+
+ if(closeBracket == openBracket+1){ // empty brackets
+ String newText = "\""+getNewName()+"\""; //$NON-NLS-1$
//$NON-NLS-2$
+ change(file, location.getStartPosition()+openBracket+1, 0, newText);
+ }else if(value > 0){ // construction value="name" found so change name
+ String newText = text.replace(getOldName(), getNewName());
+ change(file, location.getStartPosition(), location.getLength(), newText);
+ }else if(equals > 0){ // other parameters are found
+ String newText = "value=\""+getNewName()+"\",";
//$NON-NLS-1$ //$NON-NLS-2$
+ change(file, location.getStartPosition()+openBracket+1, 0, newText);
+ }else{ // other cases
+ String newText = text.replace(getOldName(), getNewName());
+ change(file, location.getStartPosition(), location.getLength(), newText);
+ }
+ }else if(openQuote >= 0){
+ int closeQuota = text.indexOf("\"", openQuote); //$NON-NLS-1$
+
+ if(closeQuota == openQuote+1){ // empty quotas
+ String newText = "\""+getNewName()+"\""; //$NON-NLS-1$
//$NON-NLS-2$
+ change(file, location.getStartPosition()+openQuote+1, 0, newText);
+ }else{ // the other cases
+ String newText = text.replace(getOldName(), getNewName());
+ change(file, location.getStartPosition(), location.getLength(), newText);
+ }
+ }else{
+ String newText = "(\""+getNewName()+"\")"; //$NON-NLS-1$
//$NON-NLS-2$
+ change(file, location.getStartPosition()+location.getLength(), 0, newText);
+ }
+ }
+
+ private void clearChanges(){
+ keys.clear();
+ }
+
+ private void change(IFile file, int offset, int length, String text){
+ //System.out.println("change file - "+file.getFullPath()+" offset -
"+offset+" len - "+length+" text"+text);
+ String key = file.getFullPath().toString()+" "+offset;
+ if(!keys.contains(key)){
+ TextFileChange change = getChange(file);
+ TextEdit edit = new ReplaceEdit(offset, length, text);
+ change.addEdit(edit);
+ keys.add(key);
+ }
+ }
+
+ protected boolean isFileCorrect(IFile file){
+ if(!file.isSynchronized(IResource.DEPTH_ZERO)){
+ status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
+ return false;
+ }else if(file.isPhantom()){
+ status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
+ return false;
+ }else if(file.isReadOnly()){
+ status.addFatalError(Messages.format(ElCoreMessages.EL_RENAME_PROCESSOR_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+ return false;
+ }
+ return true;
+ }
+
+
+ public class ELSearcher extends RefactorSearcher{
+
+ public ELSearcher(IFile file, String oldName){
+ super(file, oldName);
+ }
+
+
+ private boolean checkFolder(IResource resource, IResource[] sources, IPath output){
+ for(IResource folder : sources){
+ if(resource.equals(folder))
+ return false;
+ }
+
+ if(resource.getFullPath().equals(output))
+ return false;
+
+ return true;
+ }
+
+ ArrayList<String> keys = new ArrayList<String>();
+
+ @Override
+ protected IProject[] getProjects() {
+ return new IProject[]{baseFile.getProject()};
+ }
+
+ @Override
+ protected IContainer getViewFolder(IProject project) {
+ 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) {
+ change(file, offset, length, newName);
+ }
+
+
+ @Override
+ protected boolean isFileCorrect(IFile file) {
+ return ELRenameProcessor.this.isFileCorrect(file);
+ }
+
+ }
+}
\ No newline at end of file
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ProjectsSet.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ProjectsSet.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/ProjectsSet.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.jsf.el.refactoring;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+
+/**
+ *
+ * @author Daniel
+ *
+ * This interface is used for transmit information about seam project structure from seam
plugins through org.jboss.tools.common.el.core.elSearcher extension point
+ */
+public interface ProjectsSet {
+ /**
+ * inits seam project structure
+ * @param project
+ */
+ public void init(IProject project);
+
+ /**
+ * returns all linked seam projects
+ * @return
+ */
+ public IProject[] getLinkedProjects();
+
+ /**
+ * returns view folder (like WEB_CONTENT, EAR_CONTENT) for each seam project
+ * @param project
+ * @return
+ */
+ public IContainer getViewFolder(IProject project);
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RefactorSearcher.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RefactorSearcher.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RefactorSearcher.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,540 @@
+/*******************************************************************************
+ * 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.jsf.el.refactoring;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
+import org.eclipse.jdt.ui.text.IJavaPartitions;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.jboss.tools.common.el.core.ELCorePlugin;
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELMethodInvocation;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
+import org.jboss.tools.common.el.core.resolver.ELResolution;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
+import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
+import org.jboss.tools.common.el.core.resolver.ELSegment;
+import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.el.core.resolver.SimpleELContext;
+import org.jboss.tools.common.el.core.resolver.Var;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.FileUtil;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public abstract class RefactorSearcher {
+ protected static final String JAVA_EXT = "java"; //$NON-NLS-1$
+ protected static final String XML_EXT = "xml"; //$NON-NLS-1$
+ protected static final String XHTML_EXT = "xhtml"; //$NON-NLS-1$
+ protected static final String JSP_EXT = "jsp"; //$NON-NLS-1$
+ protected static final String PROPERTIES_EXT = "properties"; //$NON-NLS-1$
+
+ private static final String GET = "get"; //$NON-NLS-1$
+ private static final String SET = "set"; //$NON-NLS-1$
+ private static final String IS = "is"; //$NON-NLS-1$
+
+ protected static final String SEAM_PROPERTIES_FILE = "seam.properties";
//$NON-NLS-1$
+
+ protected IFile baseFile;
+ protected String propertyName;
+ protected IJavaElement javaElement;
+ protected IJavaSearchScope searchScope;
+
+
+ public RefactorSearcher(IFile baseFile, String propertyName){
+ this.baseFile = baseFile;
+ this.propertyName = propertyName;
+ }
+
+ public RefactorSearcher(IFile baseFile, String propertyName, IJavaElement javaElement){
+ this(baseFile, propertyName);
+ this.javaElement = javaElement;
+ }
+
+ public void setSearchScope(IJavaSearchScope searchScope){
+ this.searchScope = searchScope;
+ }
+
+ public void findELReferences(){
+ if(baseFile == null)
+ return;
+
+ //startStatistics();
+
+ IProject[] projects = getProjects();
+ for (IProject project : projects) {
+ if(project == null) continue;
+
+ if(!containsInSearchScope(project))
+ continue;
+
+ updateEnvironment(project);
+
+ IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
+
+ // searching java, xml and property files in source folders
+ if(javaProject != null){
+ for(IResource resource : EclipseResourceUtil.getJavaSourceRoots(project)){
+ if(resource instanceof IFolder)
+ scanForJava((IFolder) resource);
+ else if(resource instanceof IFile)
+ scanForJava((IFile) resource);
+ }
+ }
+
+ // searching jsp, xhtml and xml files in WebContent folders
+
+ if(getViewFolder(project) != null)
+ scan(getViewFolder(project));
+ else
+ scan(project);
+ }
+ //stopStatistic();
+ }
+
+ protected void updateEnvironment(IProject project){
+
+ }
+
+ protected abstract IProject[] getProjects();
+
+ protected abstract IContainer getViewFolder(IProject project);
+
+ private void scanForJava(IContainer container){
+ try{
+ for(IResource resource : container.members()){
+ if(resource instanceof IFolder)
+ scanForJava((IFolder) resource);
+ else if(resource instanceof IFile)
+ scanForJava((IFile) resource);
+ }
+ }catch(CoreException ex){
+ ELCorePlugin.getDefault().logError(ex);
+ }
+ }
+
+ private void scan(IContainer container){
+ try{
+ for(IResource resource : container.members()){
+ if(resource instanceof IFolder)
+ scan((IFolder) resource);
+ else if(resource instanceof IFile)
+ scan((IFile) resource);
+ }
+ }catch(CoreException ex){
+ ELCorePlugin.getDefault().logError(ex);
+ }
+ }
+
+ private String getFileContent(IFile file){
+ try {
+ return FileUtil.readStream(file);
+ //collectStatistic(content.length());
+ } catch (CoreException e) {
+ ELCorePlugin.getDefault().logError(e);
+ }
+ return null;
+ }
+
+ private void scanForJava(IFile file){
+ if(isFileCorrect(file)) {
+ String content = null;
+ if(content!= null) {
+ String ext = file.getFileExtension();
+ if(JAVA_EXT.equalsIgnoreCase(ext)){
+ content = getFileContent(file);
+ scanJava(file, content);
+ } else if(XML_EXT.equalsIgnoreCase(ext)) {
+ content = getFileContent(file);
+ scanDOM(file, content);
+ } else if(PROPERTIES_EXT.equalsIgnoreCase(ext)) {
+ content = getFileContent(file);
+ scanProperties(file, content);
+ }
+ }
+ }
+ }
+
+ private void scan(IFile file){
+ if(isFileCorrect(file)) {
+ String ext = file.getFileExtension();
+ if(XML_EXT.equalsIgnoreCase(ext)
+ || XHTML_EXT.equalsIgnoreCase(ext)
+ || JSP_EXT.equalsIgnoreCase(ext)) {
+ String content = getFileContent(file);
+ scanDOM(file, content);
+ }
+ }
+ }
+
+ private void scanJava(IFile file, String content){
+ try {
+ FastJavaPartitionScanner scaner = new FastJavaPartitionScanner();
+ Document document = new Document(content);
+ scaner.setRange(document, 0, document.getLength());
+ IToken token = scaner.nextToken();
+ while(token!=null && token!=Token.EOF) {
+ if(IJavaPartitions.JAVA_STRING.equals(token.getData())) {
+ int length = scaner.getTokenLength();
+ int offset = scaner.getTokenOffset();
+ String value = document.get(offset, length);
+ if(value.indexOf('{')>-1) {
+ scanString(file, value, offset);
+ }
+ }
+ token = scaner.nextToken();
+ }
+ } catch (BadLocationException e) {
+ ELCorePlugin.getDefault().logError(e);
+ }
+ }
+
+// private void searchInCach(IFile file){
+// //ELResolver[] resolvers =
PageContextFactory.createPageContext(file).getElResolvers();
+//
+// }
+
+ private void scanDOM(IFile file, String content){
+ IModelManager manager = StructuredModelManager.getModelManager();
+ if(manager != null) {
+ IStructuredModel model = null;
+ try {
+ model = manager.getModelForRead(file);
+ if (model instanceof IDOMModel) {
+ IDOMModel domModel = (IDOMModel) model;
+ IDOMDocument document = domModel.getDocument();
+ scanChildNodes(file, document);
+ }
+ } catch (CoreException e) {
+ ELCorePlugin.getDefault().logError(e);
+ } catch (IOException e) {
+ ELCorePlugin.getDefault().logError(e);
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ }
+ }
+
+ private void scanChildNodes(IFile file, Node parent) {
+ NodeList children = parent.getChildNodes();
+ for(int i=0; i<children.getLength(); i++) {
+ Node curentValidatedNode = children.item(i);
+ if(Node.ELEMENT_NODE == curentValidatedNode.getNodeType()) {
+ scanNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE);
+ } else if(Node.TEXT_NODE == curentValidatedNode.getNodeType()) {
+ scanNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_CONTENT);
+ }
+ scanChildNodes(file, curentValidatedNode);
+ }
+ }
+
+ private void scanNodeContent(IFile file, IStructuredDocumentRegion node, String
regionType) {
+ ITextRegionList regions = node.getRegions();
+ for(int i=0; i<regions.size(); i++) {
+ ITextRegion region = regions.get(i);
+ if(region.getType() == regionType) {
+ String text = node.getFullText(region);
+ if(text.indexOf("{")>-1) { //$NON-NLS-1$
+ int offset = node.getStartOffset() + region.getStart();
+ scanString(file, text, offset);
+ }
+ }
+ }
+ }
+
+ // looking for component references in EL
+ private void scanString(IFile file, String string, int offset) {
+ int startEl = string.indexOf("#{"); //$NON-NLS-1$
+ if(startEl<0)
+ startEl = string.indexOf("${"); //$NON-NLS-1$
+ if(startEl>-1) {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(string);
+ for (ELInstance instance : model.getInstances()) {
+ for(ELInvocationExpression ie : instance.getExpression().getInvocations()){
+ ELInvocationExpression expression = findComponentReference(ie);
+ if(expression != null){
+ checkMatch(file, expression, offset+getOffset(expression), getLength(expression));
+ }
+ }
+ }
+ }
+ }
+
+ protected int getOffset(ELInvocationExpression expression){
+ if(expression instanceof ELPropertyInvocation){
+ ELPropertyInvocation pi = (ELPropertyInvocation)expression;
+
+ if(pi.getName() != null)
+ return pi.getName().getStart();
+ }else if(expression instanceof ELMethodInvocation){
+ ELMethodInvocation mi = (ELMethodInvocation)expression;
+
+ if(mi.getName() != null)
+ return mi.getName().getStart();
+ }
+ return 0;
+ }
+
+ private int getLength(ELInvocationExpression expression){
+ if(expression instanceof ELPropertyInvocation){
+ ELPropertyInvocation pi = (ELPropertyInvocation)expression;
+
+ if(pi.getName() != null)
+ return pi.getName().getLength();
+ }else if(expression instanceof ELMethodInvocation){
+ ELMethodInvocation mi = (ELMethodInvocation)expression;
+
+ if(mi.getName() != null)
+ return mi.getName().getLength();
+ }
+ return 0;
+ }
+
+ private void scanProperties(IFile file, String content){
+ scanString(file, content, 0);
+
+ if(!file.getName().equals(SEAM_PROPERTIES_FILE))
+ return;
+
+ StringTokenizer tokenizer = new StringTokenizer(content, "#= \t\r\n\f",
true); //$NON-NLS-1$
+
+ String lastToken = "\n"; //$NON-NLS-1$
+ int offset = 0;
+ boolean comment = false;
+ boolean key = true;
+
+ while(tokenizer.hasMoreTokens()){
+ String token = tokenizer.nextToken("#= \t\r\n\f"); //$NON-NLS-1$
+ if(token.equals("\r")) //$NON-NLS-1$
+ token = "\n"; //$NON-NLS-1$
+
+ if(token.equals("#") && lastToken.equals("\n"))
//$NON-NLS-1$ //$NON-NLS-2$
+ comment = true;
+ else if(token.equals("\n") && comment) //$NON-NLS-1$
+ comment = false;
+
+ if(!comment){
+ if(!token.equals("\n") && lastToken.equals("\n"))
//$NON-NLS-1$ //$NON-NLS-2$
+ key = true;
+ else if(key && (token.equals("=") || token.equals(" ")))
//$NON-NLS-1$ //$NON-NLS-2$
+ key = false;
+
+ if(key && token.startsWith(propertyName)){
+ match(file, offset, token.length());
+ }
+ }
+
+ lastToken = token;
+ offset += token.length();
+ }
+ }
+
+ protected ELInvocationExpression findComponentReference(ELInvocationExpression
invocationExpression){
+ return invocationExpression;
+ }
+
+ protected abstract boolean isFileCorrect(IFile file);
+
+ protected abstract void match(IFile file, int offset, int length);
+
+ protected void checkMatch(IFile file, ELExpression operand, int offset, int length){
+ if(javaElement != null && operand != null)
+ resolve(file, operand, offset-getOffset((ELInvocationExpression)operand));
+ else
+ match(file, offset, length);
+ }
+
+ // TODO: move to util class
+ public static boolean isGetter(IMethod method) {
+ String name = method.getElementName();
+ int numberOfParameters = method.getNumberOfParameters();
+
+ return (((name.startsWith(GET) && !name.equals(GET)) || name.startsWith(IS))
&& numberOfParameters == 0);
+ }
+
+ // TODO: move to util class
+ public static boolean isSetter(IMethod method) {
+ String name = method.getElementName();
+ int numberOfParameters = method.getNumberOfParameters();
+
+ return ((name.startsWith(SET) && !name.equals(SET)) &&
numberOfParameters == 1);
+ }
+
+ // TODO: move to util class
+ public static String getPropertyName(IMethod method, String methodName){
+ if (isGetter(method) || isSetter(method)) {
+ StringBuffer name = new StringBuffer(methodName);
+ if(methodName.startsWith("i")) { //$NON-NLS-1$
+ name.delete(0, 2);
+ } else {
+ name.delete(0, 3);
+ }
+ if(name.length()<2 || Character.isLowerCase(name.charAt(1))) {
+ name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+ }
+ String propertyName = name.toString();
+ return propertyName;
+ }
+ return methodName;
+ }
+
+ public static String getPropertyName(IType method, String className){
+ StringBuffer name = new StringBuffer(className);
+ if(name.length()<2 || Character.isLowerCase(name.charAt(1))) {
+ name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
+ }
+ String propertyName = name.toString();
+ return propertyName;
+ }
+
+ private boolean containsInSearchScope(IProject project){
+ if(searchScope == null)
+ return true;
+ IPath[] paths = searchScope.enclosingProjectsAndJars();
+ for(IPath path : paths){
+ if(path.equals(project.getFullPath()))
+ return true;
+ }
+ return false;
+ }
+
+ protected void resolve(IFile file, ELExpression operand, int offset) {
+ ELResolver[] resolvers = ELResolverFactoryManager.getInstance()
+ .getResolvers(file);
+
+ for (ELResolver resolver : resolvers) {
+ if (!(resolver instanceof ELCompletionEngine))
+ continue;
+
+ SimpleELContext context = new SimpleELContext();
+
+ context.setResource(file);
+ context.setElResolvers(resolvers);
+
+ List<Var> vars = ElVarSearcher.findAllVars(context, offset,
+ resolver);
+
+ context.setVars(vars);
+
+ ELResolution resolution = resolver.resolve(context, operand, offset);
+
+ List<ELSegment> segments = resolution.findSegmentsByJavaElement(javaElement);
+
+ for(ELSegment segment : segments){
+ match(file, offset+segment.getSourceReference().getStartPosition(),
segment.getSourceReference().getLength());
+ }
+ }
+ }
+ // performance measure
+// private int totalSize = 0;
+// private int filesNumber = 0;
+// private long startTime = 0;
+// private long stopTime = 0;
+// private long startMem = 0;
+// private long stopMem = 0;
+//
+// private boolean log = false;
+//
+// private void clearHistory(){
+// totalSize = 0;
+// filesNumber = 0;
+// startTime = 0;
+// stopTime = 0;
+// startMem = 0;
+// stopMem = 0;
+// }
+//
+// private void startStatistics(){
+// clearHistory();
+// startTime = System.currentTimeMillis();
+// startMem = Runtime.getRuntime().freeMemory();
+// }
+//
+// private void stopStatistic(){
+// stopTime = System.currentTimeMillis();
+// stopMem = Runtime.getRuntime().freeMemory();
+// printELSearchStatistics();
+// }
+//
+// private void collectStatistic(int fileSize){
+// filesNumber++;
+// totalSize += fileSize;
+// }
+//
+// private void printELSearchStatistics(){
+// if(log){
+// System.out.println("EL Search"); //$NON-NLS-1$
+// System.out.println("Total files number: "+getFilesNumber());
//$NON-NLS-1$
+// System.out.println("Total files size: "+getTotlalFilesSize()+"
Mb"); //$NON-NLS-1$ $NON-NLS-2$
+// System.out.println("Memory usage size: "+getTotlalMemorySize()+"
Mb"); //$NON-NLS-1$ $NON-NLS-2$
+// System.out.println("Free Memory size: "+getRestMemorySize()+"
Mb"); //$NON-NLS-1$ $NON-NLS-2$
+// System.out.println("Total time: "+getTotalTime()+" sec");
//$NON-NLS-1$ $NON-NLS-2$
+// }
+// }
+//
+// private double getTotlalFilesSize(){
+// return (double)totalSize/(1024*1025);
+// }
+//
+// private double getTotlalMemorySize(){
+// return (double)(startMem-stopMem)/(1024*1025);
+// }
+//
+// private double getRestMemorySize(){
+// return (double)stopMem/(1024*1025);
+// }
+//
+// private int getFilesNumber(){
+// return filesNumber;
+// }
+//
+// private double getTotalTime(){
+// return (double)(stopTime - startTime)/1000;
+// }
+
+}
\ No newline at end of file
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableProcessor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableProcessor.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableProcessor.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,147 @@
+ /*******************************************************************************
+ * 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.jsf.el.refactoring;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
+import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.jboss.tools.common.el.core.ElCoreMessages;
+
+/**
+ * @author Daniel Azarov
+ */
+public class RenameELVariableProcessor extends ELRenameProcessor {
+ IFile file;
+
+ /**
+ * @param file where refactor was called
+ */
+ public RenameELVariableProcessor(IFile file, String oldName) {
+ super(file, oldName);
+ this.file = file;
+ setOldName(oldName);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkFinalConditions(org.eclipse.core.runtime.IProgressMonitor,
org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext)
+ */
+ @Override
+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws CoreException,
+ OperationCanceledException {
+ status = new RefactoringStatus();
+
+ rootChange = new CompositeChange(ElCoreMessages.RENAME_EL_VARIABLE_PROCESSOR_TITLE);
+
+ renameELVariable(pm, file);
+
+ return status;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#checkInitialConditions(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+ throws CoreException, OperationCanceledException {
+ RefactoringStatus result = new RefactoringStatus();
+ boolean status = false;
+
+ status = checkELContextVariable();
+
+ if(!status)
+ result.addFatalError(Messages.format(ElCoreMessages.RENAME_EL_VARIABLE_PROCESSOR_CAN_NOT_FIND_EL_VARIABLE,
getOldName()));
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#createChange(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+
+ return rootChange;
+ }
+
+
+ private boolean checkELContextVariable(){
+ boolean status = true;
+
+ IProject[] projects = getSearcher().getProjects();
+ for (IProject project : projects) {
+ // TODO:
+ }
+ return status;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getElements()
+ */
+ @Override
+ public Object[] getElements() {
+ return new String[]{getNewName()};
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getIdentifier()
+ */
+ @Override
+ public String getIdentifier() {
+ return getClass().getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#getProcessorName()
+ */
+ @Override
+ public String getProcessorName() {
+ return ElCoreMessages.RENAME_EL_VARIABLE_PROCESSOR_TITLE;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#isApplicable()
+ */
+ @Override
+ public boolean isApplicable() throws CoreException {
+ return getNewName()!=null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor#loadParticipants(org.eclipse.ltk.core.refactoring.RefactoringStatus,
org.eclipse.ltk.core.refactoring.participants.SharableParticipants)
+ */
+ @Override
+ public RefactoringParticipant[] loadParticipants(RefactoringStatus status,
+ SharableParticipants sharedParticipants) throws CoreException {
+ return EMPTY_REF_PARTICIPANT;
+ }
+
+ private void renameELVariable(IProgressMonitor pm, IFile file){
+ getSearcher().findELReferences();
+ }
+}
\ No newline at end of file
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableRefactoring.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableRefactoring.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/el/refactoring/RenameELVariableRefactoring.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,24 @@
+ /*******************************************************************************
+ * Copyright (c) 2008 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.jsf.el.refactoring;
+
+import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class RenameELVariableRefactoring extends RenameRefactoring {
+
+ public RenameELVariableRefactoring(RenameProcessor processor) {
+ super(processor);
+ }
+}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF 2009-12-10 16:11:35 UTC
(rev 19190)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/META-INF/MANIFEST.MF 2009-12-10 16:13:45 UTC
(rev 19191)
@@ -22,15 +22,16 @@
org.jboss.tools.jsf.ui.editor.palette,
org.jboss.tools.jsf.ui.editor.print,
org.jboss.tools.jsf.ui.editor.wizard,
+ org.jboss.tools.jsf.ui.el.refactoring,
org.jboss.tools.jsf.ui.navigator,
org.jboss.tools.jsf.ui.operation,
org.jboss.tools.jsf.ui.perspective,
org.jboss.tools.jsf.ui.preferences,
org.jboss.tools.jsf.ui.wizard.bean,
+ org.jboss.tools.jsf.ui.wizard.capabilities,
org.jboss.tools.jsf.ui.wizard.newfile,
- org.jboss.tools.jsf.ui.wizard.project,
org.jboss.tools.jsf.ui.wizard.palette,
- org.jboss.tools.jsf.ui.wizard.capabilities
+ org.jboss.tools.jsf.ui.wizard.project
Require-Bundle: org.jboss.tools.common.model.ui,
org.jboss.tools.jst.web.ui,
org.jboss.tools.jst.jsp,
@@ -47,7 +48,11 @@
org.eclipse.core.expressions,
org.eclipse.ui.forms,
org.jboss.tools.common.gef,
- org.jboss.tools.common.ui
+ org.jboss.tools.common.ui,
+ org.eclipse.ltk.ui.refactoring;bundle-version="3.4.100",
+ org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
+ org.eclipse.search;bundle-version="3.5.0",
+ org.jboss.tools.common.el.core;bundle-version="2.0.0"
Bundle-Version: 2.0.0
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2009-12-10 16:11:35 UTC (rev
19190)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2009-12-10 16:13:45 UTC (rev
19191)
@@ -417,5 +417,40 @@
</newWizardShortcut>
</perspectiveExtension>
</extension>
+
+ <extension
+ point="org.eclipse.jdt.ui.queryParticipants">
+ <queryParticipant
+
class="org.jboss.tools.jsf.ui.el.refactoring.ELReferencesQueryParticipant"
+
id="org.jboss.tools.jsf.ui.el.refactoring.ELReferencesQueryParticipant"
+ name="jsf-SearchELReferencesParticipant"
+ nature="org.jboss.tools.jsf.jsfnature">
+ </queryParticipant>
+ </extension>
+ <extension
+ point="org.eclipse.ltk.core.refactoring.renameParticipants">
+ <renameParticipant
+
class="org.jboss.tools.jsf.ui.el.refactoring.RenameMethodParticipant"
+
id="org.jboss.tools.jsf.ui..el.refactoring.RenameMethodParticipant"
+ name="el-RenameMethodParticipant">
+ <enablement>
+ <with variable="element">
+ <or>
+ <instanceof value="org.eclipse.jdt.core.IMethod"/>
+ <instanceof value="org.eclipse.jdt.core.IType"/>
+ </or>
+ </with>
+ </enablement>
+ </renameParticipant>
+ </extension>
+
+ <!-- Refactorng -->
+ <!--extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+
class="org.jboss.tools.jsf.ui.el.refactoring.ELRefactorContributionFactory"
+ locationURI="popup:org.eclipse.ui.popup.any?after=save">
+ </menuContribution>
+ </extension-->
</plugin>
Copied:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
(from rev 19147,
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/Messages.java)
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/JsfUIMessages.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,40 @@
+package org.jboss.tools.jsf.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class JsfUIMessages extends NLS {
+ private static final String BUNDLE_NAME = "org.jboss.tools.jsf.ui.messages";
//$NON-NLS-1$
+ public static String DataTableWizardPage_BeanProperties;
+ public static String DataTableWizardPage_DeselectAll;
+ public static String DataTableWizardPage_Properties;
+ public static String DataTableWizardPage_SelectAll;
+ public static String DataTableWizardPage_ValueELNotCorrect;
+ public static String DataTableWizardPage_ValueMustBeSetWithEL;
+ public static String FacesConfigGuiEditor_DiagramTitle;
+ public static String JSFDiagramEditPart_JSFDiagram;
+ public static String JSFKnowledgeBaseAdapter_Browse;
+ public static String JSFKnowledgeBaseAdapter_Edit;
+ public static String JSFManagedPropertyNameAdapter_Rename;
+ public static String LinkEditPart_Link;
+
+ public static String RENAME_METHOD_PARTICIPANT_GETTER_WARNING;
+ public static String RENAME_METHOD_PARTICIPANT_SETTER_WARNING;
+ public static String RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE;
+ public static String RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE;
+ public static String RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE;
+ public static String RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES;
+ public static String RESOURCE_BUNDLES_RENAME_PARTICIPANT_UPDATE_BUNDLE_REFERENCES;
+
+ 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;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, JsfUIMessages.class);
+ }
+
+ private JsfUIMessages() {
+ }
+}
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/Messages.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/Messages.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/Messages.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -1,26 +0,0 @@
-package org.jboss.tools.jsf.ui;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.jboss.tools.jsf.ui.messages";
//$NON-NLS-1$
- public static String DataTableWizardPage_BeanProperties;
- public static String DataTableWizardPage_DeselectAll;
- public static String DataTableWizardPage_Properties;
- public static String DataTableWizardPage_SelectAll;
- public static String DataTableWizardPage_ValueELNotCorrect;
- public static String DataTableWizardPage_ValueMustBeSetWithEL;
- public static String FacesConfigGuiEditor_DiagramTitle;
- public static String JSFDiagramEditPart_JSFDiagram;
- public static String JSFKnowledgeBaseAdapter_Browse;
- public static String JSFKnowledgeBaseAdapter_Edit;
- public static String JSFManagedPropertyNameAdapter_Rename;
- public static String LinkEditPart_Link;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/attribute/adapter/JSFKnowledgeBaseAdapter.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/attribute/adapter/JSFKnowledgeBaseAdapter.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/attribute/adapter/JSFKnowledgeBaseAdapter.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -16,7 +16,7 @@
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
import org.eclipse.swt.widgets.Control;
import org.jboss.tools.common.meta.key.WizardKeys;
-import org.jboss.tools.jsf.ui.Messages;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
import org.jboss.tools.jst.jsp.contentassist.JSPDialogContentProposalProvider;
import org.jboss.tools.jst.jsp.outline.*;
@@ -28,7 +28,7 @@
}
public String getCommand() {
- return Messages.JSFKnowledgeBaseAdapter_Browse;
+ return JsfUIMessages.JSFKnowledgeBaseAdapter_Browse;
}
public String invoke(Control control) {
@@ -50,7 +50,7 @@
String query = "/" + nodeName + "@" + attrName; //$NON-NLS-1$
//$NON-NLS-2$
context.setProperty("query", query); //$NON-NLS-1$
context.setProperty("help", query); //$NON-NLS-1$
- context.setProperty("title",
MessageFormat.format(Messages.JSFKnowledgeBaseAdapter_Edit,
WizardKeys.toDisplayName(attrName))); //$NON-NLS-1$
+ context.setProperty("title",
MessageFormat.format(JsfUIMessages.JSFKnowledgeBaseAdapter_Edit,
WizardKeys.toDisplayName(attrName))); //$NON-NLS-1$
context.setProperty("subtitle", "<" +
context.getProperty("nodeName") + ">"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
if(getValue() instanceof String) context.put("value", getValue());
//$NON-NLS-1$
JSPTreeDialog dialog = new JSPTreeDialog();
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/attribute/adapter/JSFManagedPropertyNameAdapter.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/attribute/adapter/JSFManagedPropertyNameAdapter.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/attribute/adapter/JSFManagedPropertyNameAdapter.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -14,12 +14,12 @@
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
import org.eclipse.swt.widgets.Control;
import org.jboss.tools.common.meta.action.XActionInvoker;
-import org.jboss.tools.jsf.ui.Messages;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
public class JSFManagedPropertyNameAdapter extends DefaultValueAdapter implements
IActionHelper, IActionHelperExtension {
public String getCommand() {
- return Messages.JSFManagedPropertyNameAdapter_Rename;
+ return JsfUIMessages.JSFManagedPropertyNameAdapter_Rename;
}
public String invoke(Control control) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/FacesConfigGuiEditor.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/FacesConfigGuiEditor.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/FacesConfigGuiEditor.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -20,7 +20,7 @@
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.jsf.model.JSFConstants;
import org.jboss.tools.jsf.ui.JsfUiPlugin;
-import org.jboss.tools.jsf.ui.Messages;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
import org.jboss.tools.jsf.ui.editor.model.impl.JSFModel;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.jst.web.model.WebProcess;
@@ -111,7 +111,7 @@
}
public String getTitle() {
- return Messages.FacesConfigGuiEditor_DiagramTitle;
+ return JsfUIMessages.FacesConfigGuiEditor_DiagramTitle;
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/edit/JSFDiagramEditPart.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/edit/JSFDiagramEditPart.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/edit/JSFDiagramEditPart.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -23,7 +23,7 @@
import org.eclipse.gef.tools.MarqueeDragTracker;
import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.jboss.tools.jsf.ui.Messages;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
import org.jboss.tools.jsf.ui.editor.figures.DiagramFigure;
import org.jboss.tools.jsf.ui.editor.model.IGroup;
import org.jboss.tools.jsf.ui.editor.model.IJSFModel;
@@ -144,7 +144,7 @@
protected AccessibleEditPart createAccessible() {
return new AccessibleGraphicalEditPart() {
public void getName(AccessibleEvent event) {
- event.result = Messages.JSFDiagramEditPart_JSFDiagram;
+ event.result = JsfUIMessages.JSFDiagramEditPart_JSFDiagram;
}
};
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/edit/LinkEditPart.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/edit/LinkEditPart.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/editor/edit/LinkEditPart.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -34,7 +34,7 @@
import org.jboss.tools.common.gef.figures.GEFLabel;
import org.jboss.tools.common.gef.figures.xpl.CustomLocator;
import org.jboss.tools.jsf.ui.JsfUiPlugin;
-import org.jboss.tools.jsf.ui.Messages;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
import org.jboss.tools.jsf.ui.editor.JSFEditor;
import org.jboss.tools.jsf.ui.editor.figures.ConnectionFigure;
import org.jboss.tools.jsf.ui.editor.figures.FigureFactory;
@@ -180,7 +180,7 @@
if (acc == null)
acc = new AccessibleGraphicalEditPart() {
public void getName(AccessibleEvent e) {
- e.result = Messages.LinkEditPart_Link;
+ e.result = JsfUIMessages.LinkEditPart_Link;
}
};
return acc;
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELRefactorContributionFactory.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELRefactorContributionFactory.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELRefactorContributionFactory.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,357 @@
+/*******************************************************************************
+ * 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.jsf.ui.el.refactoring;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
+import org.eclipse.jdt.ui.text.IJavaPartitions;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.internal.services.IWorkbenchLocationService;
+import org.eclipse.ui.menus.AbstractContributionFactory;
+import org.eclipse.ui.menus.IContributionRoot;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.services.IServiceLocator;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.propertieseditor.PropertiesCompoundEditor;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jsf.el.refactoring.RenameELVariableProcessor;
+import org.jboss.tools.jsf.el.refactoring.RenameELVariableRefactoring;
+import org.jboss.tools.jsf.ui.JsfUiPlugin;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
+import org.jboss.tools.jst.web.ui.editors.WebCompoundEditor;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author Daniel Azarov
+ */
+public class ELRefactorContributionFactory extends AbstractContributionFactory {
+ //private static final String ANNOTATION_NAME =
"org.jboss.seam.annotations.Name"; //$NON-NLS-1$
+ private static final String JAVA_EXT = "java"; //$NON-NLS-1$
+ private static final String XML_EXT = "xml"; //$NON-NLS-1$
+ private static final String XHTML_EXT = "xhtml"; //$NON-NLS-1$
+ private static final String JSP_EXT = "jsp"; //$NON-NLS-1$
+ private static final String PROPERTIES_EXT = "properties"; //$NON-NLS-1$
+ private static final String GET = "get"; //$NON-NLS-1$
+ private static final String SET = "set"; //$NON-NLS-1$
+ private static final String IS = "is"; //$NON-NLS-1$
+
+ static private String selectedText;
+ static private IFile editorFile;
+ private String fileContent;
+ private IEditorPart editor;
+ private Shell shell;
+
+ public ELRefactorContributionFactory(){
+ super("","");
+ }
+
+ public ELRefactorContributionFactory(String location, String namespace){
+ super(location, namespace);
+ }
+
+ @Override
+ public void createContributionItems(IServiceLocator serviceLocator,
+ IContributionRoot additions) {
+
+ if(serviceLocator.hasService(IWorkbenchLocationService.class)){
+ IWorkbenchLocationService service =
(IWorkbenchLocationService)serviceLocator.getService(IWorkbenchLocationService.class);
+ editor = service.getWorkbenchWindow().getActivePage().getActiveEditor();
+ shell = service.getWorkbench().getActiveWorkbenchWindow().getShell();
+
+ if(!(editor.getEditorInput() instanceof FileEditorInput))
+ return;
+
+ FileEditorInput input = (FileEditorInput)editor.getEditorInput();
+
+ editorFile = input.getFile();
+ String ext = editorFile.getFileExtension();
+
+ if (!JAVA_EXT.equalsIgnoreCase(ext)
+ && !XML_EXT.equalsIgnoreCase(ext)
+ && !XHTML_EXT.equalsIgnoreCase(ext)
+ && !JSP_EXT.equalsIgnoreCase(ext)
+ && !PROPERTIES_EXT.equalsIgnoreCase(ext))
+ return;
+
+ MenuManager mm = new MenuManager(JsfUIMessages.REFACTOR_CONTRIBUTOR_MAIN_MENU);
+ mm.setVisible(true);
+
+ boolean separatorIsAdded = false;
+
+ ISelection sel = editor.getEditorSite().getSelectionProvider().getSelection();
+
+ if(sel == null || sel.isEmpty())
+ return;
+
+ if(sel instanceof StructuredSelection){
+ if(editor instanceof PropertiesCompoundEditor){
+ sel =
((PropertiesCompoundEditor)editor).getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }else if(editor instanceof EditorPartWrapper){
+ EditorPartWrapper wrapperEditor = (EditorPartWrapper)editor;
+ if(wrapperEditor.getEditor() instanceof WebCompoundEditor){
+ WebCompoundEditor xmlEditor = (WebCompoundEditor)wrapperEditor.getEditor();
+ sel = xmlEditor.getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }
+ }else if(editor instanceof WebCompoundEditor)
+ sel =
((WebCompoundEditor)editor).getActiveEditor().getSite().getSelectionProvider().getSelection();
+ }
+
+ if(sel instanceof TextSelection){
+ TextSelection selection = (TextSelection)sel;
+
+ selectedText = selection.getText();
+
+ try {
+ fileContent = FileUtil.readStream(editorFile);
+ } catch (CoreException e) {
+ JsfUiPlugin.getDefault().logError(e);
+ }
+
+ boolean status = false;
+
+ if(JAVA_EXT.equalsIgnoreCase(ext)){
+ status = checkContextVariableInJava(editorFile, fileContent, selection);
+ } else if(XML_EXT.equalsIgnoreCase(ext) || XHTML_EXT.equalsIgnoreCase(ext) ||
JSP_EXT.equalsIgnoreCase(ext))
+ status = checkContextVariableInDOM(editorFile, fileContent, selection);
+ else if(PROPERTIES_EXT.equalsIgnoreCase(ext))
+ status = checkContextVariableInProperties(editorFile, fileContent, selection);
+
+ if(status){
+ mm.add(new RenameELVariableAction());
+
+ if(!separatorIsAdded)
+ additions.addContributionItem(new Separator(), null);
+ additions.addContributionItem(mm, null);
+ }
+ }
+ }
+ }
+
+ private boolean checkContextVariableInJava(IFile file, String content, TextSelection
selection){
+ try {
+ FastJavaPartitionScanner scaner = new FastJavaPartitionScanner();
+ Document document = new Document(content);
+ scaner.setRange(document, 0, document.getLength());
+ IToken token = scaner.nextToken();
+ while(token!=null && token!=Token.EOF) {
+ if(IJavaPartitions.JAVA_STRING.equals(token.getData())) {
+ int length = scaner.getTokenLength();
+ int offset = scaner.getTokenOffset();
+ if(offset <= selection.getOffset() && (offset+length) >=
(selection.getOffset()+selection.getLength())){
+ String value = document.get(offset, length);
+ if(value.indexOf('{')>-1) {
+ return scanString(file, value, offset, selection);
+ }
+ }
+ }
+ token = scaner.nextToken();
+ }
+ } catch (BadLocationException e) {
+ JsfUiPlugin.getDefault().logError(e);
+ }
+ return false;
+ }
+
+ private boolean scanString(IFile file, String string, int offset, TextSelection
selection) {
+ int startEl = string.indexOf("#{"); //$NON-NLS-1$
+ if(startEl>-1) {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = parser.parse(string);
+ for (ELInstance instance : model.getInstances()) {
+ for(ELInvocationExpression ie : instance.getExpression().getInvocations()){
+ ELPropertyInvocation pi = findELVariable(ie);
+ if(pi != null){
+ if(offset+pi.getStartPosition() == selection.getOffset() && pi.getLength()
== selection.getLength())
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private ELPropertyInvocation findELVariable(ELInvocationExpression
invocationExpression){
+ ELInvocationExpression invExp = invocationExpression;
+ while(invExp != null){
+ if(invExp instanceof ELPropertyInvocation){
+ if(((ELPropertyInvocation)invExp).getQualifiedName() != null &&
((ELPropertyInvocation)invExp).getQualifiedName().equals(selectedText))
+ return (ELPropertyInvocation)invExp;
+ else
+ invExp = invExp.getLeft();
+
+ }else{
+ invExp = invExp.getLeft();
+ }
+ }
+ return null;
+ }
+
+ private boolean checkContextVariableInDOM(IFile file, String content, TextSelection
selection){
+ IModelManager manager = StructuredModelManager.getModelManager();
+ if(manager == null) {
+ return false;
+ }
+ IStructuredModel model = null;
+ try {
+ model = manager.getModelForRead(file);
+ if (model instanceof IDOMModel) {
+ IDOMModel domModel = (IDOMModel) model;
+ IDOMDocument document = domModel.getDocument();
+ return scanChildNodes(file, document, selection);
+ }
+ } catch (CoreException e) {
+ JsfUiPlugin.getDefault().logError(e);
+ } catch (IOException e) {
+ JsfUiPlugin.getDefault().logError(e);
+ } finally {
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ return false;
+ }
+
+ private boolean scanChildNodes(IFile file, Node parent, TextSelection selection) {
+ boolean status = false;
+ NodeList children = parent.getChildNodes();
+ for(int i=0; i<children.getLength(); i++) {
+ Node curentValidatedNode = children.item(i);
+ if(Node.ELEMENT_NODE == curentValidatedNode.getNodeType()) {
+ status = scanNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, selection);
+ if(status)
+ return status;
+ } else if(Node.TEXT_NODE == curentValidatedNode.getNodeType()) {
+ status = scanNodeContent(file,
((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(),
DOMRegionContext.XML_CONTENT, selection);
+ if(status)
+ return status;
+ }
+ status = scanChildNodes(file, curentValidatedNode, selection);
+ if(status)
+ return status;
+ }
+ return false;
+ }
+
+ private boolean scanNodeContent(IFile file, IStructuredDocumentRegion node, String
regionType, TextSelection selection) {
+ boolean status = false;
+ ITextRegionList regions = node.getRegions();
+ for(int i=0; i<regions.size(); i++) {
+ ITextRegion region = regions.get(i);
+ if(region.getType() == regionType) {
+ String text = node.getFullText(region);
+ if(text.indexOf("{")>-1) { //$NON-NLS-1$
+ int offset = node.getStartOffset() + region.getStart();
+ status = scanString(file, text, offset, selection);
+ if(status)
+ return status;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean checkContextVariableInProperties(IFile file, String content,
TextSelection selection){
+ return scanString(file, content, 0, selection);
+ }
+
+ private String getPropertyName(IMethod method){
+ String name = method.getElementName();
+
+ if(name.startsWith(GET) || name.startsWith(SET))
+ return name.substring(3).toLowerCase();
+
+ if(name.startsWith(IS))
+ return name.substring(2).toLowerCase();
+
+ return name.toLowerCase();
+ }
+
+ private static void saveAndBuild(){
+ if(!JsfUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().saveAllEditors(true))
+ return;
+
+ try {
+ Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ }
+
+ public static void invokeRenameELVariableWizard(String oldName, Shell activeShell) {
+ saveAndBuild();
+
+ 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 = JsfUIMessages.EL_REFACTOR_RENAME_HANDLER_ERROR;
+ op.run(activeShell, titleForFailedChecks);
+ } catch (final InterruptedException irex) {
+ // operation was canceled
+ }
+ }
+
+ class RenameELVariableAction extends Action{
+ public RenameELVariableAction(){
+ super(JsfUIMessages.REFACTOR_CONTRIBUTOR_RENAME_EL_VARIABLE);
+ }
+ public void run(){
+ saveAndBuild();
+
+ invokeRenameELVariableWizard(selectedText, shell);
+ }
+ }
+
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELReferencesQueryParticipant.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELReferencesQueryParticipant.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/ELReferencesQueryParticipant.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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.jsf.ui.el.refactoring;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
+import org.eclipse.jdt.ui.search.ElementQuerySpecification;
+import org.eclipse.jdt.ui.search.IMatchPresentation;
+import org.eclipse.jdt.ui.search.IQueryParticipant;
+import org.eclipse.jdt.ui.search.ISearchRequestor;
+import org.eclipse.jdt.ui.search.QuerySpecification;
+import org.eclipse.search.ui.text.Match;
+import org.jboss.tools.common.model.project.ProjectHome;
+import org.jboss.tools.jsf.el.refactoring.ELProjectSetExtension;
+import org.jboss.tools.jsf.el.refactoring.ProjectsSet;
+import org.jboss.tools.jsf.el.refactoring.RefactorSearcher;
+
+public class ELReferencesQueryParticipant implements IQueryParticipant{
+ private ELSearcher searcher;
+
+ public int estimateTicks(QuerySpecification specification) {
+ return 10;
+ }
+
+ public IMatchPresentation getUIParticipant() {
+ return null;
+ }
+
+ public void search(ISearchRequestor requestor,
+ QuerySpecification querySpecification, IProgressMonitor monitor)
+ throws CoreException {
+
+ if(querySpecification instanceof ElementQuerySpecification){
+ if (!isSearchForReferences(querySpecification.getLimitTo()))
+ return;
+
+ ElementQuerySpecification qs = (ElementQuerySpecification)querySpecification;
+ if(qs.getElement() instanceof IMethod || qs.getElement() instanceof IType){
+ IFile file = (IFile)qs.getElement().getResource();
+ String name = qs.getElement().getElementName();
+
+ searcher = new ELSearcher(requestor, qs.getElement(), file, name);
+ searcher.setSearchScope(qs.getScope());
+
+ searcher.findELReferences();
+ }
+ }
+ }
+
+ public boolean isSearchForReferences(int limitTo) {
+ int maskedLimitTo = limitTo &
~(IJavaSearchConstants.IGNORE_DECLARING_TYPE+IJavaSearchConstants.IGNORE_RETURN_TYPE);
+ if (maskedLimitTo == IJavaSearchConstants.REFERENCES || maskedLimitTo ==
IJavaSearchConstants.ALL_OCCURRENCES) {
+ return true;
+ }
+
+ return false;
+ }
+
+ class ELSearcher extends RefactorSearcher{
+ ISearchRequestor requestor;
+ ProjectsSet projectSet=null;
+
+ public ELSearcher(ISearchRequestor requestor, IJavaElement element, IFile file, String
name){
+ super(file, name, element);
+ this.requestor = requestor;
+ ELProjectSetExtension[] extensions = ELProjectSetExtension.getInstances();
+ if(extensions.length > 0){
+ projectSet = extensions[0].getProjectSet();
+ if(projectSet != null)
+ projectSet.init(file.getProject());
+ }
+
+ }
+
+ protected boolean isFileCorrect(IFile file){
+ if(!file.isSynchronized(IResource.DEPTH_ZERO)){
+ return false;
+ }else if(file.isPhantom()){
+ return false;
+ }else if(file.isReadOnly()){
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ protected void match(IFile file, int offset, int length) {
+ Match match = new Match(file, offset, length);
+ requestor.reportMatch(match);
+ }
+
+ protected IProject[] getProjects(){
+ if(projectSet != null){
+ return projectSet.getLinkedProjects();
+ }
+ return new IProject[]{baseFile.getProject()};
+ }
+
+ protected IContainer getViewFolder(IProject project){
+ if(projectSet != null){
+ return projectSet.getViewFolder(project);
+ }
+
+ IPath path = ProjectHome.getFirstWebContentPath(baseFile.getProject());
+
+ if(path != null)
+ return project.getFolder(path.removeFirstSegments(1));
+
+ return null;
+ }
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/FieldEditorFactory.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/FieldEditorFactory.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/FieldEditorFactory.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -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.jsf.ui.el.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;
+ }
+}
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameELVariableWizard.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameELVariableWizard.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameELVariableWizard.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,109 @@
+ /*******************************************************************************
+ * 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.jsf.ui.el.refactoring;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+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.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.ui.widget.editor.CompositeEditor;
+import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
+import org.jboss.tools.jsf.el.refactoring.RenameELVariableProcessor;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
+
+/**
+ * @author Daniel Azarov
+ */
+public class RenameELVariableWizard extends RefactoringWizard {
+
+ private String variableName;
+ private IFieldEditor editor;
+
+ public RenameELVariableWizard(Refactoring refactoring, IFile editorFile) {
+ super(refactoring, WIZARD_BASED_USER_INTERFACE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.ui.refactoring.RefactoringWizard#addUserInputPages()
+ */
+ @Override
+ protected void addUserInputPages() {
+ setDefaultPageTitle(getRefactoring().getName());
+ RenameELVariableProcessor processor= (RenameELVariableProcessor)
getRefactoring().getAdapter(RenameELVariableProcessor.class);
+ addPage(new RenameELVariableWizardPage(processor));
+ }
+
+ class RenameELVariableWizardPage extends UserInputWizardPage{
+ private RenameELVariableProcessor processor;
+
+ public RenameELVariableWizardPage(RenameELVariableProcessor processor){
+ super("");
+ this.processor = processor;
+ variableName = processor.getOldName();
+ }
+
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 2;
+
+ String defaultName = variableName;
+ editor = FieldEditorFactory.createTextEditor(variableName,
JsfUIMessages.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);
+ }
+
+ protected final void validatePage() {
+ RefactoringStatus status= new RefactoringStatus();
+ setPageComplete(status);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.ui.refactoring.UserInputWizardPage#performFinish()
+ */
+ protected boolean performFinish() {
+
+ initializeRefactoring();
+ return super.performFinish();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ltk.ui.refactoring.UserInputWizardPage#getNextPage()
+ */
+ public IWizardPage getNextPage() {
+ initializeRefactoring();
+ return super.getNextPage();
+ }
+
+ private void initializeRefactoring() {
+ //processor.setNewName(editor.getValueAsString());
+ }
+
+ }
+}
\ No newline at end of file
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java
(rev 0)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/el/refactoring/RenameMethodParticipant.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * 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.jsf.ui.el.refactoring;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.ltk.internal.core.refactoring.Messages;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.jboss.tools.common.model.project.ProjectHome;
+import org.jboss.tools.jsf.el.refactoring.ELProjectSetExtension;
+import org.jboss.tools.jsf.el.refactoring.ProjectsSet;
+import org.jboss.tools.jsf.el.refactoring.RefactorSearcher;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
+
+public class RenameMethodParticipant extends RenameParticipant{
+ private IJavaElement element;
+ private String oldName;
+ private String newName;
+ private SeamRenameMethodSearcher searcher;
+ private RefactoringStatus status;
+ private CompositeChange rootChange;
+ private TextFileChange lastChange;
+ private ArrayList<String> keys = new ArrayList<String>();
+
+ private static boolean added = false;
+
+
+ @Override
+ public RefactoringStatus checkConditions(IProgressMonitor pm,
+ CheckConditionsContext context) throws OperationCanceledException {
+ if(searcher == null)
+ return status;
+ if(element instanceof IMethod){
+ IMethod method = (IMethod)element;
+ if(method != null && !added){
+ if(searcher.isGetter(method))
+ status.addWarning(JsfUIMessages.RENAME_METHOD_PARTICIPANT_GETTER_WARNING);
+ else if(searcher.isSetter(method))
+ status.addWarning(JsfUIMessages.RENAME_METHOD_PARTICIPANT_SETTER_WARNING);
+ added = true;
+ }
+ }
+
+ searcher.findELReferences();
+
+ return status;
+ }
+
+ @Override
+ public Change createChange(IProgressMonitor pm) throws CoreException,
+ OperationCanceledException {
+ return rootChange;
+ }
+
+ @Override
+ public String getName() {
+ return oldName;
+ }
+
+ @Override
+ protected boolean initialize(Object element) {
+ if(element instanceof IMethod){
+ IMethod method = (IMethod)element;
+ status = new RefactoringStatus();
+
+ rootChange = new
CompositeChange(JsfUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
+
+ this.element = method;
+
+ oldName = method.getElementName();
+
+ newName = RefactorSearcher.getPropertyName(method, getArguments().getNewName());
+ searcher = new SeamRenameMethodSearcher((IFile)method.getResource(), oldName);
+ added = false;
+ return true;
+ }else if(element instanceof IType){
+ IType type = (IType)element;
+ status = new RefactoringStatus();
+
+ rootChange = new
CompositeChange(JsfUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
+
+ this.element = type;
+
+ oldName = type.getElementName();
+
+ newName = RefactorSearcher.getPropertyName(type, getArguments().getNewName());
+ searcher = new SeamRenameMethodSearcher((IFile)type.getResource(), oldName);
+ added = false;
+ return true;
+ }
+ return false;
+ }
+
+ // for test only
+ public boolean initialize(Object element, String newName) {
+ if(element instanceof IMethod){
+ IMethod method = (IMethod)element;
+ status = new RefactoringStatus();
+
+ rootChange = new
CompositeChange(JsfUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
+
+ this.element = method;
+
+ oldName = method.getElementName();
+
+ this.newName = newName;
+ searcher = new SeamRenameMethodSearcher((IFile)method.getResource(), oldName);
+ added = false;
+ return true;
+ }else if(element instanceof IType){
+ IType type = (IType)element;
+ status = new RefactoringStatus();
+
+ rootChange = new
CompositeChange(JsfUIMessages.RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES);
+
+ this.element = type;
+
+ oldName = type.getElementName();
+
+ this.newName = newName;
+ searcher = new SeamRenameMethodSearcher((IFile)type.getResource(), oldName);
+ added = false;
+ return true;
+ }
+ return false;
+ }
+
+ protected TextFileChange getChange(IFile file){
+ if(lastChange != null && lastChange.getFile().equals(file))
+ return lastChange;
+
+ for(int i=0; i < rootChange.getChildren().length; i++){
+ TextFileChange change = (TextFileChange)rootChange.getChildren()[i];
+ if(change.getFile().equals(file)){
+ lastChange = change;
+ return lastChange;
+ }
+ }
+ lastChange = new TextFileChange(file.getName(), file);
+ MultiTextEdit root = new MultiTextEdit();
+ lastChange.setEdit(root);
+ rootChange.add(lastChange);
+
+ return lastChange;
+ }
+
+ private void change(IFile file, int offset, int length, String text){
+ String key = file.getFullPath().toString()+" "+offset;
+ if(!keys.contains(key)){
+ TextFileChange change = getChange(file);
+ TextEdit edit = new ReplaceEdit(offset, length, text);
+ change.addEdit(edit);
+ keys.add(key);
+ }
+ }
+
+ class SeamRenameMethodSearcher extends RefactorSearcher{
+ ProjectsSet projectSet=null;
+ public SeamRenameMethodSearcher(IFile file, String name){
+ super(file, name, element);
+ ELProjectSetExtension[] extensions = ELProjectSetExtension.getInstances();
+ if(extensions.length > 0){
+ projectSet = extensions[0].getProjectSet();
+ if(projectSet != null)
+ projectSet.init(file.getProject());
+ }
+ }
+
+ @Override
+ protected boolean isFileCorrect(IFile file) {
+ if(!file.isSynchronized(IResource.DEPTH_ZERO)){
+ status.addFatalError(Messages.format(JsfUIMessages.RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE,
file.getFullPath().toString()));
+ return false;
+ }else if(file.isPhantom()){
+ status.addFatalError(Messages.format(JsfUIMessages.RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE,
file.getFullPath().toString()));
+ return false;
+ }else if(file.isReadOnly()){
+ status.addFatalError(Messages.format(JsfUIMessages.RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE,
file.getFullPath().toString()));
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ protected void match(IFile file, int offset, int length) {
+ change(file, offset, length, newName);
+ }
+
+ protected IProject[] getProjects(){
+ if(projectSet != null){
+ return projectSet.getLinkedProjects();
+ }
+ return new IProject[]{baseFile.getProject()};
+ }
+
+ protected IContainer getViewFolder(IProject project){
+ if(projectSet != null){
+ return projectSet.getViewFolder(project);
+ }
+
+ IPath path = ProjectHome.getFirstWebContentPath(baseFile.getProject());
+
+ if(path != null)
+ return project.getFolder(path.removeFirstSegments(1));
+
+ return null;
+ }
+ }
+
+}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/messages.properties 2009-12-10
16:13:45 UTC (rev 19191)
@@ -10,3 +10,14 @@
JSFKnowledgeBaseAdapter_Edit=Edit {0}
JSFManagedPropertyNameAdapter_Rename=Rename...
LinkEditPart_Link=Link
+RENAME_METHOD_PARTICIPANT_GETTER_WARNING=Be sure, may be you also should rename setter
method to avoid compilation problems.
+RENAME_METHOD_PARTICIPANT_SETTER_WARNING=Be sure, may be you also should rename getter
method to avoid compilation problems.
+RENAME_METHOD_PARTICIPANT_OUT_OF_SYNC_FILE=Cannot change file. File
''{0}'' is not in sync.
+RENAME_METHOD_PARTICIPANT_ERROR_PHANTOM_FILE=Cannot change phantom file:
''{0}''.
+RENAME_METHOD_PARTICIPANT_ERROR_READ_ONLY_FILE=Cannot change read-only file:
''{0}''.
+RENAME_METHOD_PARTICIPANT_UPDATE_METHOD_REFERENCES=Update method references in EL
+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/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizardPage.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizardPage.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizardPage.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -43,7 +43,7 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jsf.model.pv.JSFPromptingProvider;
import org.jboss.tools.jsf.ui.JsfUiPlugin;
-import org.jboss.tools.jsf.ui.Messages;
+import org.jboss.tools.jsf.ui.JsfUIMessages;
import org.jboss.tools.jsf.ui.attribute.adapter.JSFKnowledgeBaseAdapter;
import org.jboss.tools.jst.jsp.jspeditor.dnd.TagProposal;
import org.jboss.tools.common.model.ui.editors.dnd.*;
@@ -200,7 +200,7 @@
generalTabContent.setLayoutData(data);
Label properties = new Label(generalTabContent, SWT.NONE);
- properties.setText(Messages.DataTableWizardPage_Properties);
+ properties.setText(JsfUIMessages.DataTableWizardPage_Properties);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 3;
properties.setLayoutData(data);
@@ -223,11 +223,11 @@
try {
boolean b1 = value.matches("[#\\$]\\{[^#\\$\\}\\{]*\\}"); //$NON-NLS-1$
if(!b1) {
- throw new ValidationException(Messages.DataTableWizardPage_ValueMustBeSetWithEL);
+ throw new
ValidationException(JsfUIMessages.DataTableWizardPage_ValueMustBeSetWithEL);
}
boolean b2 =
value.matches("[#\\$]\\{[^#\\$\\}\\{\\.]+(\\.[^#\\$\\}\\{\\.]+)*\\}");
//$NON-NLS-1$
if(!b2) {
- throw new ValidationException(Messages.DataTableWizardPage_ValueELNotCorrect);
+ throw new ValidationException(JsfUIMessages.DataTableWizardPage_ValueELNotCorrect);
}
} catch (PatternSyntaxException e) {
JsfUiPlugin.getPluginLog().logError(e);
@@ -333,7 +333,7 @@
p.put("data", vs); //$NON-NLS-1$
SelectPropertiesWizard w = new SelectPropertiesWizard();
- p.setProperty("title", Messages.DataTableWizardPage_BeanProperties);
//$NON-NLS-1$
+ p.setProperty("title", JsfUIMessages.DataTableWizardPage_BeanProperties);
//$NON-NLS-1$
w.setObject(p);
int r = w.execute();
if (r != 0)
@@ -451,17 +451,17 @@
class SelectPropertiesWizardView extends AbstractListWizardView {
protected String[] getActions() {
- return new String[] { Messages.DataTableWizardPage_SelectAll,
Messages.DataTableWizardPage_DeselectAll };
+ return new String[] { JsfUIMessages.DataTableWizardPage_SelectAll,
JsfUIMessages.DataTableWizardPage_DeselectAll };
}
protected void internalAction(String command) {
- if (command.equals(Messages.DataTableWizardPage_SelectAll)) {
+ if (command.equals(JsfUIMessages.DataTableWizardPage_SelectAll)) {
for (int i = 0; i < boxes.length; i++)
if ("yes".equals(vs[i][1])) { //$NON-NLS-1$
boxes[i].setSelection(true);
apply(i);
}
- } else if (command.equals(Messages.DataTableWizardPage_DeselectAll)) {
+ } else if (command.equals(JsfUIMessages.DataTableWizardPage_DeselectAll)) {
for (int i = 0; i < boxes.length; i++)
if ("no".equals(vs[i][1])) { //$NON-NLS-1$
boxes[i].setSelection(false);
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF 2009-12-10 16:11:35
UTC (rev 19190)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/META-INF/MANIFEST.MF 2009-12-10 16:13:45
UTC (rev 19191)
@@ -15,7 +15,9 @@
org.jboss.tools.jst.web.ui;bundle-version="2.0.0",
org.jboss.tools.jst.jsp;bundle-version="2.0.0",
org.jboss.tools.common.model.ui;bundle-version="2.0.0",
- org.eclipse.ui.ide;bundle-version="3.4.1"
+ org.eclipse.ui.ide;bundle-version="3.4.1",
+ org.eclipse.ltk.core.refactoring;bundle-version="3.5.0",
+ org.eclipse.jst.j2ee;bundle-version="1.1.300"
Bundle-Localization: plugin
Bundle-ClassPath: jsf-ui-test.jar
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.classpath
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.classpath
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.classpath 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="JavaSource"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.web.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con"
path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss
4.2 Runtime">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.web"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER">
+ <attributes>
+ <attribute name="owner.project.facets" value="jst.java"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output"
path="WebContent/WEB-INF/classes"/>
+</classpath>
Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.project
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.project
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.project 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>testJSFProject</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.common.verification.verifybuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.jboss.tools.jsf.jsfnature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.jboss.tools.jst.web.kb.kbnature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/.jsdtscope
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/.jsdtscope
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/.jsdtscope 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con"
path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.jdt.core.prefs 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,7 @@
+#Mon Dec 07 18:26:41 MSK 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.common.component
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.common.component
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.common.component 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+<wb-module deploy-name="testJSFProject">
+<wb-resource deploy-path="/" source-path="/WebContent"/>
+<wb-resource deploy-path="/WEB-INF/classes"
source-path="/JavaSource"/>
+<property name="context-root" value="testJSFProject"/>
+<property name="java-output-path"/>
+</wb-module>
+</project-modules>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.common.project.facet.core.xml 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <runtime name="JBoss 4.2 Runtime"/>
+ <fixed facet="jst.java"/>
+ <fixed facet="jst.web"/>
+ <installed facet="jst.java" version="5.0"/>
+ <installed facet="jst.web" version="2.5"/>
+</faceted-project>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.container
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.container
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.container 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.name
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.name
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/.settings/org.eclipse.wst.jsdt.ui.superType.name 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1 @@
+Window
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/Messages.properties
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/Messages.properties
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/Messages.properties 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,3 @@
+header=Hello Demo Application
+prompt_message=Name:
+hello_message=Hello
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/User.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/User.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/JavaSource/demo/User.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package demo;
+
+/**
+ * Created by JBoss Developer Studio
+ */
+public class User {
+
+ private String name;
+
+ /**
+ * @return User Name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param User Name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+}
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/META-INF/MANIFEST.MF 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/Messages.properties
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/Messages.properties
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/Messages.properties 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,3 @@
+header=Hello Demo Application
+prompt_message=Name:
+hello_message=Hello
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/User.class
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/classes/demo/User.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/faces-config.xml 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="1.2"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xi="http://www.w3.org/2001/XInclude"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+ <managed-bean>
+ <description>User Name Bean</description>
+ <managed-bean-name>user</managed-bean-name>
+ <managed-bean-class>demo.User</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ <managed-property>
+ <property-name>name</property-name>
+ <property-class>java.lang.String</property-class>
+ <value/>
+ </managed-property>
+ </managed-bean>
+ <navigation-rule>
+ <from-view-id>/pages/inputUserName.jsp</from-view-id>
+ <navigation-case>
+ <from-outcome>hello</from-outcome>
+ <to-view-id>/pages/hello.jsp</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+ <application>
+ <locale-config/>
+ </application>
+ <factory/>
+ <lifecycle/>
+</faces-config>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/common-annotations.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/common-annotations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-beanutils.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-beanutils.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-collections.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-collections.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-digester.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-digester.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-logging.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/commons-logging.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/jsf-tlds.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/jsf-tlds.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/jstl.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/jstl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/standard.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/lib/standard.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/web.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/web.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/WEB-INF/web.xml 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <display-name>testJSFProject</display-name>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <listener>
+ <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
+ </listener>
+ <!-- Faces Servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <!-- Faces Servlet Mapping -->
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/index.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/index.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/index.jsp 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,7 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+
+<html>
+ <body>
+ <jsp:forward page="/pages/inputUserName.jsf" />
+ </body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/hello.jsp 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,20 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages" />
+
+<html>
+ <head>
+ <title>Hello!</title>
+ </head>
+
+ <body>
+ <f:view>
+ <h3>
+ <h:outputText value="#{Message.hello_message}" />,
+ <h:outputText value="#{user.name}" />!
+ </h3>
+ </f:view>
+ </body>
+
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/WebContent/pages/inputUserName.jsp 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,28 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+ <head>
+ <title>Input User Name Page</title>
+ </head>
+ <body>
+
+ <f:view>
+ <h1><h:outputText value="#{Message.header}"/></h1>
+
+ <h:messages style="color: red"/>
+
+ <h:form id="greetingForm">
+ <h:outputText value="#{Message.prompt_message}"/>
+ <h:inputText value="#{user.name}" required="true">
+ <f:validateLength maximum="30" minimum="3"/>
+ </h:inputText>
+
+ <h:commandButton action="hello" value="Say Hello!" />
+
+ </h:form>
+ </f:view>
+ </body>
+</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/build.properties
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/build.properties
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/build.properties 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,3 @@
+#
+#Mon Dec 07 18:26:39 MSK 2009
+classpath.external=
Added: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/build.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/build.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/testJSFProject/ant/build.xml 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,74 @@
+<project name="KickStart" default="deploy"
basedir="../">
+
+ <!-- Project settings -->
+ <property file="${basedir}/ant/build.properties" />
+
+ <property name="project.name" value="KickStart" />
+ <property name="web.content.dir" value="${basedir}/WebContent"
/>
+ <property name="web-inf.dir" value="${web.content.dir}/WEB-INF"
/>
+ <property name="build.dir" value="build" />
+ <property name="war.name"
value="${build.dir}/${project.name}.war" />
+
+ <!-- Define a folder for deployment -->
+ <property name="deploy.dir" value="deploy" />
+
+ <!-- Compile classpath -->
+ <path id="compile.classpath">
+ <fileset dir="${webinf.dir}/lib">
+ <include name="**/*.jar" />
+ </fileset>
+ <pathelement path="${classpath}" />
+ <pathelement path="${classpath.external}" />
+ <pathelement path="${webinf.dir}/classes" />
+ </path>
+
+ <!-- Copy any resource or configuration files -->
+ <target name="copyResources">
+ <copy todir="${web-inf.dir}/classes" includeEmptyDirs="no">
+ <fileset dir="JavaSource">
+ <patternset>
+ <include name="**/*.*" />
+ <exclude name="**/*.java" />
+ </patternset>
+ </fileset>
+ </copy>
+ </target>
+
+ <!-- Check timestamp on files -->
+ <target name="prepare">
+ <tstamp />
+ </target>
+
+ <!-- Remove classes directory for clean build -->
+ <target name="clean" description="Prepare for clean build">
+ <delete dir="${web-inf.dir}/classes" failonerror="false"/>
+ <mkdir dir="${web-inf.dir}/classes" />
+ </target>
+
+ <!-- Normal build of application -->
+ <target name="compile" depends="prepare, copyResources">
+ <javac srcdir="JavaSource" destdir="${web-inf.dir}/classes">
+ <classpath refid="compile.classpath" />
+ </javac>
+ </target>
+
+ <!-- Build Project -->
+ <target name="build" depends="prepare, compile" />
+
+ <!-- Rebuild Project -->
+ <target name="rebuild" depends="clean, prepare, compile" />
+
+ <!-- Build WAR -->
+ <target name="war" depends="build">
+ <mkdir dir="${build.dir}" />
+ <war warfile="${war.name}" basedir="${web.content.dir}"
webxml="${web-inf.dir}/web.xml">
+ <exclude name="WEB-INF/web.xml" />
+ </war>
+ </target>
+
+ <target name="deploy" depends="war">
+ <delete dir="${deploy.dir}/${project.name}"
failonerror="false"/>
+ <copy file="${war.name}" todir="${deploy.dir}" />
+ </target>
+
+</project>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/JsfUiAllTests.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -12,6 +12,8 @@
package org.jboss.tools.jsf.ui.test;
import org.jboss.tools.jsf.ui.preferences.JSFCapabilitiesPreferencesPage;
+import org.jboss.tools.jsf.ui.test.refactoring.ELReferencesRenameTest;
+import org.jboss.tools.test.util.ProjectImportTestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -31,6 +33,10 @@
suite.addTestSuite(PropertiesNewWizardTest.class);
suite.addTestSuite(XhtmlFileNewWizardTest.class);
suite.addTestSuite(JsfUiPreferencesPagesTest.class);
+ suite.addTest(new ProjectImportTestSetup(new TestSuite(ELReferencesRenameTest.class),
+ "org.jboss.tools.jsf.ui.test",
+ new String[]{"projects/testJSFProject",},
+ new String[]{"testJSFProject"}));
return new TestWizardsProject(suite);
}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/ELRefactoringTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/ELRefactoringTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/ELRefactoringTest.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,131 @@
+package org.jboss.tools.jsf.ui.test.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ProjectImportTestSetup;
+
+import junit.framework.TestCase;
+
+public class ELRefactoringTest extends TestCase {
+ static String jsfProjectName = "testJSFProject";
+ static IProject jsfProject;
+
+ public ELRefactoringTest(String name){
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ loadProjects();
+ List<IProject> projectList = new ArrayList<IProject>();
+ projectList.add(jsfProject);
+ J2EEComponentClasspathUpdater.getInstance().forceUpdate(projectList);
+ loadProjects();
+ }
+
+ private void loadProjects() throws Exception {
+ jsfProject = ProjectImportTestSetup.loadProject(jsfProjectName);
+ jsfProject.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ }
+
+ protected TestChangeStructure findChange(List<TestChangeStructure> changeList,
IFile file){
+ for(TestChangeStructure tcs : changeList){
+ if(tcs.getFileName().equals("/"+file.getFullPath().removeFirstSegments(1).toString()))
+ return tcs;
+ }
+ return null;
+ }
+
+ protected IType getJavaType(IProject project, String className){
+ IJavaProject javaProject = EclipseUtil.getJavaProject(project);
+ if(javaProject != null){
+ try{
+ return javaProject.findType(className);
+ }catch(JavaModelException ex){
+ fail(ex.getMessage());
+ }
+ }
+
+ return null;
+ }
+
+ protected IMethod getJavaMethod(IProject project, String className, String methodName){
+ IType type = getJavaType(project, className);
+ if(type != null){
+ return type.getMethod(methodName, new String[0]);
+ }
+ return null;
+ }
+
+ class TestChangeStructure{
+ private IProject project;
+ private String fileName;
+ ArrayList<TestTextChange> textChanges = new ArrayList<TestTextChange>();
+
+
+ public TestChangeStructure(IProject project, String fileName){
+ this.project = project;
+ this.fileName = fileName;
+ }
+
+ public IProject getProject(){
+ return project;
+ }
+
+ public String getFileName(){
+ return fileName;
+ }
+
+ public ArrayList<TestTextChange> getTextChanges(){
+ return textChanges;
+ }
+
+ public void addTextChange(TestTextChange change){
+ textChanges.add(change);
+ }
+
+ public int size(){
+ return textChanges.size();
+ }
+
+ }
+
+ class TestTextChange{
+ private int offset;
+ private int length;
+ private String text;
+
+ public TestTextChange(int offset, int length, String text){
+ this.offset = offset;
+ this.length = length;
+ this.text = text;
+ }
+
+ public int getOffset(){
+ return offset;
+ }
+
+ public int getLength(){
+ return length;
+ }
+
+ public String getText(){
+ return text;
+ }
+ }
+}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/ELReferencesRenameTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/ELReferencesRenameTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/refactoring/ELReferencesRenameTest.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -0,0 +1,115 @@
+package org.jboss.tools.jsf.ui.test.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jsf.ui.el.refactoring.RenameMethodParticipant;
+import org.jboss.tools.test.util.JobUtils;
+
+public class ELReferencesRenameTest extends ELRefactoringTest {
+
+
+ public ELReferencesRenameTest(){
+ super("Rename Method Refactoring Test");
+ }
+
+
+
+ public void testRenameMethod() throws CoreException {
+ ArrayList<TestChangeStructure> list = new
ArrayList<TestChangeStructure>();
+
+
+ TestChangeStructure structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/hello.jsp");
+ TestTextChange change = new TestTextChange(353, 4, "name");
+ structure.addTextChange(change);
+ list.add(structure);
+
+ structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/inputUserName.jsp");
+ change = new TestTextChange(499, 4, "name");
+ structure.addTextChange(change);
+ list.add(structure);
+
+ IMethod method = getJavaMethod(jsfProject, "demo.User",
"getName");
+
+ renameELReferences(method, "alias", list);
+ }
+
+ public void testRenameClass() throws CoreException {
+ ArrayList<TestChangeStructure> list = new
ArrayList<TestChangeStructure>();
+
+
+ TestChangeStructure structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/hello.jsp");
+ TestTextChange change = new TestTextChange(348, 4, "user");
+ structure.addTextChange(change);
+ list.add(structure);
+
+ structure = new TestChangeStructure(jsfProject,
"/WebContent/pages/inputUserName.jsp");
+ change = new TestTextChange(494, 4, "user");
+ structure.addTextChange(change);
+ list.add(structure);
+
+ IType type = getJavaType(jsfProject, "demo.User");
+
+ renameELReferences(type, "person", list);
+ }
+
+ private void renameELReferences(IJavaElement element, String newName,
List<TestChangeStructure> changeList) throws CoreException{
+ JobUtils.waitForIdle();
+
+
+ // Rename EL references
+ RenameMethodParticipant participant = new RenameMethodParticipant();
+ participant.initialize(element, newName);
+ RefactoringStatus status = participant.checkConditions(new NullProgressMonitor(),
null);
+
+ assertNotNull("Rename participant returned null status", status);
+
+ assertFalse("There is fatal errors in rename participant",
status.hasFatalError());
+
+ CompositeChange rootChange = (CompositeChange)participant.createChange(new
NullProgressMonitor());
+
+ assertEquals("There is unexpected number of changes",changeList.size(),
rootChange.getChildren().length);
+
+ for(int i = 0; i < rootChange.getChildren().length;i++){
+ TextFileChange fileChange = (TextFileChange)rootChange.getChildren()[i];
+
+ MultiTextEdit edit = (MultiTextEdit)fileChange.getEdit();
+
+ TestChangeStructure change = findChange(changeList, fileChange.getFile());
+ if(change != null){
+ assertEquals(change.size(), edit.getChildrenSize());
+ }
+ }
+
+ rootChange.perform(new NullProgressMonitor());
+ JobUtils.waitForIdle();
+ // Test results
+
+ for(TestChangeStructure changeStructure : changeList){
+ IFile file = changeStructure.getProject().getFile(changeStructure.getFileName());
+ String content = null;
+ try {
+ content = FileUtil.readStream(file);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ //System.out.println("File - "+file.getName()+" offset -
"+changeStructure.getOffset()+" expected -
["+changeStructure.getText()+"] actual -
["+content.substring(changeStructure.getOffset(),
changeStructure.getOffset()+changeStructure.getLength())+"]");
+ for(TestTextChange change : changeStructure.getTextChanges()){
+ assertEquals("There is unexpected change in resource - "+file.getName(),
newName, content.substring(change.getOffset(), change.getOffset()+newName.length()));
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2009-12-10 16:11:35 UTC (rev
19190)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2009-12-10 16:13:45 UTC (rev
19191)
@@ -503,7 +503,7 @@
</extension>
<extension
- point="org.jboss.tools.common.el.core.elProjectSet">
+ point="org.jboss.tools.jsf.elProjectSet">
<project-set id="seam.searcher"
projectset-class="org.jboss.tools.seam.internal.core.refactoring.ELProjectSet"
/>
</extension>
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/ELProjectSet.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/ELProjectSet.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/ELProjectSet.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -13,8 +13,8 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
-import org.jboss.tools.common.el.core.refactoring.ProjectsSet;
import org.jboss.tools.common.model.project.ProjectHome;
+import org.jboss.tools.jsf.el.refactoring.ProjectsSet;
import org.jboss.tools.seam.core.SeamProjectsSet;
public class ELProjectSet implements ProjectsSet {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2009-12-10
16:11:35 UTC (rev 19190)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2009-12-10
16:13:45 UTC (rev 19191)
@@ -20,7 +20,6 @@
import org.eclipse.jdt.core.IJavaElement;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
-import org.jboss.tools.common.el.core.refactoring.RefactorSearcher;
import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
import org.jboss.tools.common.el.core.resolver.ELResolution;
import org.jboss.tools.common.el.core.resolver.ELResolver;
@@ -29,6 +28,7 @@
import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
import org.jboss.tools.common.el.core.resolver.SimpleELContext;
import org.jboss.tools.common.el.core.resolver.Var;
+import org.jboss.tools.jsf.el.refactoring.RefactorSearcher;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;