Author: vyemialyanchyk
Date: 2010-01-19 13:56:22 -0500 (Tue, 19 Jan 2010)
New Revision: 19819
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/FileUtils.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingPreviewPage.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5408 - use system tmp folder instead of
".settings" and "Finish without Preview changes page" were fixed
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/FileUtils.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/FileUtils.java 2010-01-19
18:13:13 UTC (rev 19818)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/FileUtils.java 2010-01-19
18:56:22 UTC (rev 19819)
@@ -28,7 +28,7 @@
File[] files = path.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
- tmp = delete(files[i]);;
+ tmp = delete(files[i]);
} else {
tmp = deleteFile(files[i]);
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java 2010-01-19
18:13:13 UTC (rev 19818)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java 2010-01-19
18:56:22 UTC (rev 19819)
@@ -260,8 +260,7 @@
}
if (resource != null) {
final IPath projPath = proj.getResource().getLocation();
- IPath place2Gen = projPath.append(".settings"); //$NON-NLS-1$
- place2Gen =
place2Gen.append(NewHibernateMappingPreviewPage.HIBERNATE_NEW_HBM_XML_FOLDER_NAME);
+ IPath place2Gen = previewPage.getRootPlace2Gen().append(proj.getElementName());
//
IPath tmpPath = resource.getLocation();
tmpPath = tmpPath.makeRelativeTo(projPath);
@@ -286,9 +285,8 @@
Configuration config = entry.getValue();
HibernateMappingGlobalSettings hmgs = new HibernateMappingGlobalSettings();
- final IPath projPath = entry.getKey().getProject().getLocation();
- IPath place2Gen = projPath.append(".settings"); //$NON-NLS-1$
- place2Gen =
place2Gen.append(NewHibernateMappingPreviewPage.HIBERNATE_NEW_HBM_XML_FOLDER_NAME);
+ //final IPath projPath = entry.getKey().getProject().getLocation();
+ IPath place2Gen =
previewPage.getRootPlace2Gen().append(entry.getKey().getElementName());
places2Gen.put(entry.getKey(), place2Gen);
File folder2Gen = new File(place2Gen.toOSString());
@@ -315,9 +313,8 @@
Set<IJavaProject> projs = previewPage.getJavaProjects();
for (IJavaProject proj : projs) {
// cleanup gen folder
- final IPath projPath = proj.getProject().getLocation();
- IPath place2Gen = projPath.append(".settings"); //$NON-NLS-1$
- place2Gen =
place2Gen.append(NewHibernateMappingPreviewPage.HIBERNATE_NEW_HBM_XML_FOLDER_NAME);
+ //final IPath projPath = proj.getProject().getLocation();
+ IPath place2Gen = previewPage.getRootPlace2Gen().append(proj.getElementName());
File folder2Gen = new File(place2Gen.toOSString());
FileUtils.delete(folder2Gen);
}
@@ -356,6 +353,10 @@
}
cleanUpGenFolders();
} else {
+ if (previewPage.getChange() == null) {
+ Map<IJavaProject, IPath> places2Gen = getPlaces2Gen();
+ previewPage.setPlaces2Gen(places2Gen);
+ }
previewPage.performFinish();
// refresh
Set<IJavaProject> projs = previewPage.getJavaProjects();
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingPreviewPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingPreviewPage.java 2010-01-19
18:13:13 UTC (rev 19818)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingPreviewPage.java 2010-01-19
18:56:22 UTC (rev 19819)
@@ -18,6 +18,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.UUID;
import java.util.Map.Entry;
import org.eclipse.core.filebuffers.FileBuffers;
@@ -43,6 +44,7 @@
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.utils.FileUtils;
/**
* Preview wizard page for new hibernate mappings.
@@ -54,6 +56,8 @@
public static final String HIBERNATE_NEW_HBM_XML_FOLDER_NAME =
"hibernateNewHbmXml"; //$NON-NLS-1$
+ protected IPath rootPlace2GenBase = null;
+ protected IPath rootPlace2Gen = null;
protected Map<IJavaProject, IPath> places2Gen;
protected Set<IPath> paths2Disconnect = new HashSet<IPath>();
@@ -64,6 +68,11 @@
@Override
public void dispose() {
performDisconnect();
+ IPath place2Gen = getRootPlace2Gen();
+ if (place2Gen != null) {
+ File folder2Gen = new File(place2Gen.toOSString());
+ FileUtils.delete(folder2Gen);
+ }
super.dispose();
}
@@ -166,6 +175,26 @@
}
return str.toString();
}
+
+ public IPath getRootPlace2GenBase() {
+ if (rootPlace2GenBase != null) {
+ return rootPlace2GenBase;
+ }
+ String systemTmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
+ rootPlace2GenBase = new Path(systemTmpDir);
+ rootPlace2GenBase = rootPlace2GenBase.append(HIBERNATE_NEW_HBM_XML_FOLDER_NAME);
+ return rootPlace2GenBase;
+ }
+
+ public IPath getRootPlace2Gen() {
+ if (rootPlace2Gen != null) {
+ return rootPlace2Gen;
+ }
+ rootPlace2Gen = getRootPlace2GenBase();
+ String uuidName = UUID.randomUUID().toString();
+ rootPlace2Gen = rootPlace2Gen.append(uuidName);
+ return rootPlace2Gen;
+ }
/**
* Try to create one change according with input file (fileSrc).
@@ -184,7 +213,7 @@
}
final IPath basePath = proj.getResource().getParent().getLocation();
final IPath projPath = proj.getResource().getLocation();
- final IPath place2Gen =
projPath.append(".settings").append(HIBERNATE_NEW_HBM_XML_FOLDER_NAME);
//$NON-NLS-1$
+ final IPath place2Gen = getRootPlace2Gen().append(proj.getElementName());
IPath filePathFrom = new Path(fileSrc.getPath());
IPath filePathTo = filePathFrom.makeRelativeTo(place2Gen);
filePathTo = projPath.append(filePathTo);