Author: dazarov
Date: 2010-10-12 03:26:41 -0400 (Tue, 12 Oct 2010)
New Revision: 25741
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamFolderMoveChange.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamFolderRenameChange.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamJavaPackageRenameChange.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamProjectChange.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamProjectRenameChange.java
Log:
https://jira.jboss.org/browse/JBIDE-6482
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamFolderMoveChange.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamFolderMoveChange.java 2010-10-12
05:18:16 UTC (rev 25740)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamFolderMoveChange.java 2010-10-12
07:26:41 UTC (rev 25741)
@@ -54,8 +54,23 @@
relevantProperties.add(FOLDER_PROPERTIES[i]);
}
}
+ findPreferences(ps);
}
}
+
+ private void findPreferences(IEclipsePreferences ps){
+ for (String propertyName: relevantProperties) {
+ String propertyValue = ps.get(propertyName, "");
+ String oldPathString = oldResource.getFullPath().toString();
+ String newPath = destination.getFullPath().append(oldResource.getName()).toString();
+ if(propertyValue.equals(oldPathString)) {
+ preferences.put(propertyName, newPath);
+ } else if(propertyValue.startsWith(oldPathString + "/")) {
+ newPath = newPath + propertyValue.substring(oldPathString.length());
+ preferences.put(propertyName, newPath);
+ }
+ }
+ }
/* (non-Javadoc)
* @see org.jboss.tools.seam.internal.core.refactoring.SeamProjectChange#isRelevant()
@@ -77,17 +92,11 @@
pm.beginTask(getName(), 1);
IEclipsePreferences ps = getSeamPreferences();
- for (String propertyName: relevantProperties) {
- String propertyValue = ps.get(propertyName, "");
- String oldPathString = oldResource.getFullPath().toString();
- String newPath =
destination.getFullPath().append(oldResource.getName()).toString();
- if(propertyValue.equals(oldPathString)) {
- ps.put(propertyName, newPath);
- } else if(propertyValue.startsWith(oldPathString + "/")) {
- newPath = newPath + propertyValue.substring(oldPathString.length());
- ps.put(propertyName, newPath);
- }
+
+ for(String key : preferences.keySet()){
+ ps.put(key, preferences.get(key));
}
+
try {
ps.flush();
} catch (BackingStoreException e) {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamFolderRenameChange.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamFolderRenameChange.java 2010-10-12
05:18:16 UTC (rev 25740)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamFolderRenameChange.java 2010-10-12
07:26:41 UTC (rev 25741)
@@ -49,7 +49,21 @@
relevantProperties.add(FOLDER_PROPERTIES[i]);
}
}
+ findPreferences(ps);
}
+
+ private void findPreferences(IEclipsePreferences ps){
+ for (String propertyName: relevantProperties) {
+ String propertyValue = ps.get(propertyName, "");
+ String oldPathString = oldPath.toString();
+ if(propertyValue.equals(oldPathString)) {
+ preferences.put(propertyName, newPath.toString());
+ } else if(propertyValue.startsWith(oldPathString + "/")) {
+ String newPathString = newPath.toString() +
propertyValue.substring(oldPathString.length());
+ preferences.put(propertyName, newPathString);
+ }
+ }
+ }
/*
* (non-Javadoc)
@@ -70,17 +84,10 @@
}
try {
pm.beginTask(getName(), 1);
-
IEclipsePreferences ps = getSeamPreferences();
- for (String propertyName: relevantProperties) {
- String propertyValue = ps.get(propertyName, "");
- String oldPathString = oldPath.toString();
- if(propertyValue.equals(oldPathString)) {
- ps.put(propertyName, newPath.toString());
- } else if(propertyValue.startsWith(oldPathString + "/")) {
- String newPathString = newPath.toString() +
propertyValue.substring(oldPathString.length());
- ps.put(propertyName, newPathString);
- }
+
+ for(String key : preferences.keySet()){
+ ps.put(key, preferences.get(key));
}
try {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamJavaPackageRenameChange.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamJavaPackageRenameChange.java 2010-10-12
05:18:16 UTC (rev 25740)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamJavaPackageRenameChange.java 2010-10-12
07:26:41 UTC (rev 25741)
@@ -59,8 +59,29 @@
relevantPropertyIndexes.add(new Integer(i));
}
}
+ findPreferences(ps);
}
+
+ private void findPreferences(IEclipsePreferences ps){
+ for (Integer index: relevantPropertyIndexes) {
+ String sourceFolderProperty = ps.get(SOURCE_NAME_PROPERTIES[index], null);
+ if(!source.getResource().getFullPath().toString().equals(sourceFolderProperty)) {
+ continue;
+ }
+ String packageProperty = PACKAGE_NAME_PROPERTIES[index];
+ String name = ps.get(packageProperty, null);
+ if(name==null) {
+ continue;
+ }
+ if(oldName.equals(name)) {
+ preferences.put(packageProperty, newName);
+ } else if(name.startsWith(oldName + ".")) {
+ preferences.put(packageProperty, newName + name.substring(oldName.length()));
+ }
+ }
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.seam.internal.core.refactoring.SeamProjectChange#isRelevant()
*/
@@ -81,21 +102,9 @@
pm.beginTask(getName(), 1);
IEclipsePreferences ps = getSeamPreferences();
- for (Integer index: relevantPropertyIndexes) {
- String sourceFolderProperty = ps.get(SOURCE_NAME_PROPERTIES[index], null);
- if(!source.getResource().getFullPath().toString().equals(sourceFolderProperty)) {
- continue;
- }
- String packageProperty = PACKAGE_NAME_PROPERTIES[index];
- String name = ps.get(packageProperty, null);
- if(name==null) {
- continue;
- }
- if(oldName.equals(name)) {
- ps.put(packageProperty, newName);
- } else if(name.startsWith(oldName + ".")) {
- ps.put(packageProperty, newName + name.substring(oldName.length()));
- }
+
+ for(String key : preferences.keySet()){
+ ps.put(key, preferences.get(key));
}
try {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamProjectChange.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamProjectChange.java 2010-10-12
05:18:16 UTC (rev 25740)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamProjectChange.java 2010-10-12
07:26:41 UTC (rev 25741)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.refactoring;
+import java.util.HashMap;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
@@ -94,4 +96,16 @@
IScopeContext projectScope = new ProjectScope(project);
return projectScope.getNode(SeamCorePlugin.PLUGIN_ID);
}
+
+ protected HashMap<String, String> preferences = new HashMap<String,
String>();
+
+ /**
+ * for test purpose
+ * @return
+ */
+ public HashMap<String, String> getPreferencesForTest(){
+ return preferences;
+ }
+
+
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamProjectRenameChange.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamProjectRenameChange.java 2010-10-12
05:18:16 UTC (rev 25740)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamProjectRenameChange.java 2010-10-12
07:26:41 UTC (rev 25741)
@@ -54,7 +54,23 @@
relevantSourceFolderProperties.add(FOLDER_PROPERTIES[i]);
}
}
+ findPreferences(ps);
}
+
+ private void findPreferences(IEclipsePreferences ps){
+ for (String property: relevantProjectNameProperties) {
+ if(oldName.equals(ps.get(property, null))) {
+ preferences.put(property, newName);
+ }
+ }
+ String oldPrefix = "/" + oldName + "/";
+ for (String property: relevantSourceFolderProperties) {
+ String oldProperty = ps.get(property, "");
+ if(oldProperty.startsWith(oldPrefix) &&
oldProperty.length()>oldPrefix.length()) {
+ preferences.put(property, "/" + newName + "/" +
oldProperty.substring(oldPrefix.length()));
+ }
+ }
+ }
/*
* (non-Javadoc)
@@ -84,18 +100,10 @@
}
}
IEclipsePreferences ps = getSeamPreferences();
- for (String property: relevantProjectNameProperties) {
- if(oldName.equals(ps.get(property, null))) {
- ps.put(property, newName);
- }
+
+ for(String key : preferences.keySet()){
+ ps.put(key, preferences.get(key));
}
- String oldPrefix = "/" + oldName + "/";
- for (String property: relevantSourceFolderProperties) {
- String oldProperty = ps.get(property, "");
- if(oldProperty.startsWith(oldPrefix) &&
oldProperty.length()>oldPrefix.length()) {
- ps.put(property, "/" + newName + "/" +
oldProperty.substring(oldPrefix.length()));
- }
- }
try {
ps.flush();