Author: dgeraskov
Date: 2008-06-05 03:20:39 -0400 (Thu, 05 Jun 2008)
New Revision: 8557
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/LaunchConfigurationResourceNameChange.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2250
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/LaunchConfigurationResourceNameChange.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/LaunchConfigurationResourceNameChange.java 2008-06-05
06:46:49 UTC (rev 8556)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/core/refactoring/LaunchConfigurationResourceNameChange.java 2008-06-05
07:20:39 UTC (rev 8557)
@@ -10,10 +10,15 @@
******************************************************************************/
package org.hibernate.eclipse.launch.core.refactoring;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
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.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
@@ -71,6 +76,24 @@
* @see
org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
*/
public Change perform(IProgressMonitor pm) throws CoreException {
+ if (!fLaunchConfiguration.exists()){
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ IPath rootLoacation = root.getLocation();
+ IPath oldConfigLocation = fLaunchConfiguration.getLocation();
+ int matchSegment = oldConfigLocation.matchingFirstSegments(rootLoacation);
+ IPath relativePath = oldConfigLocation.removeFirstSegments(matchSegment);
+ relativePath = relativePath.setDevice(null).makeAbsolute();
+
+ if (HibernateRefactoringUtil.isAttributeChanged(relativePath.toOSString(),
fOldPath)){
+ matchSegment = relativePath.matchingFirstSegments(fOldPath);
+ IPath newLaunchPath =
fNewPath.append(relativePath.removeFirstSegments(matchSegment));
+ IFile[] files = root.findFilesForLocation(rootLoacation.append(newLaunchPath));
+ if (files.length > 0){
+ fLaunchConfiguration =
DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(files[0]);
+ }
+ }
+ }
fLaunchConfiguration =
HibernateRefactoringUtil.updateLaunchConfig(fLaunchConfiguration, fOldPath, fNewPath);
return new LaunchConfigurationResourceNameChange(fLaunchConfiguration, fNewPath,
fOldPath);
}