Skip to contentSkip to conversation

Adjust project location for non-default location

PATCH New Ioana Grigoropol 1 participant 1 message Jul 29, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Adjust project location for non-default location

---
 .../ide/dialogs/ProjectContentsLocationArea.java   |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectContentsLocationArea.java +19 -0
index 35cd387..7de5255 100644
@@ -23,7 +23,9 @@ import org.eclipse.core.filesystem.IFileInfo;
 import org.eclipse.core.filesystem.URIUtil;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.osgi.util.TextProcessor;
@@ -471,10 +473,27 @@ public class ProjectContentsLocationArea {
 	 *            existing project name.
 	 */
 	public void updateProjectName(String newName) {
+		boolean append = false;
+		if (projectName.isEmpty())
+			append = true;
 		projectName = newName;
 		if (isDefault()) {
 			locationPathField.setText(TextProcessor
 					.process(getDefaultPathDisplayString()));
+		} else {
+			try {
+				URI uri = new URI(locationPathField.getText());
+				IPath path = new Path(uri.getPath());
+				if (!append)
+					path = path.removeLastSegments(1);
+				path = path.addTrailingSeparator();
+				path = path.append(projectName);
+			    URI newURI = new URI(uri.getScheme(), uri.getAuthority(), path.toPortableString(), uri.getQuery(), uri.getFragment());
+				locationPathField.setText(TextProcessor
+						.process(newURI.toString()));
+			} catch (URISyntaxException e) {
+				e.printStackTrace();
+			}
 		}
 
 	}
Signature · 1 line
1.7.9.5