Author: vyemialyanchyk
Date: 2009-12-21 13:10:08 -0500 (Mon, 21 Dec 2009)
New Revision: 19503
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CompilationUnitCollector.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesSource.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizardDataFactory.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/Utils.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardData.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardParams.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/ResolveAmbiguous.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/AddRemoveTableComposite.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapMockTests.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5330 - update
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -54,6 +54,11 @@
public static String NewHibernateMappingFileWizard_look_for_dependent_cu;
public static String NewHibernateMappingFileWizard_selection_cant_be_empty;
+ public static String EntitiesSource_header;
+ public static String EntitiesSource_description;
+ public static String EntitiesList_header;
+ public static String EntitiesList_description;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, JdtUiMessages.class);
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/JdtUiMessages.properties 2009-12-21
18:10:08 UTC (rev 19503)
@@ -57,3 +57,8 @@
NewHibernateMappingFileWizard_create_empty_xml_mapping_file=Create a new empty XML
Mapping files
NewHibernateMappingFileWizard_look_for_dependent_cu=Search for dependent compilation
units...
NewHibernateMappingFileWizard_selection_cant_be_empty=Selection can't be empty
+
+EntitiesSource_header=Hibernate: add JPA annotations for classes
+EntitiesSource_description=Add classes and packages to proceed with
+EntitiesList_header=Hibernate: add JPA annotations to the related set of entities
+EntitiesList_description=The following classes will be changed
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -12,20 +12,13 @@
import java.lang.reflect.Field;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
import org.eclipse.core.internal.filebuffers.SynchronizableDocument;
-import org.eclipse.core.internal.resources.File;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
@@ -34,11 +27,7 @@
import org.eclipse.jdt.internal.core.ClassFile;
import org.eclipse.jdt.internal.core.ExternalPackageFragmentRoot;
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
-import org.eclipse.jdt.internal.core.JavaElement;
-import org.eclipse.jdt.internal.core.JavaElementInfo;
-import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jdt.internal.core.PackageFragment;
-import org.eclipse.jdt.internal.core.PackageFragmentRoot;
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IDocument;
@@ -54,6 +43,7 @@
import org.hibernate.eclipse.jdt.ui.Activator;
import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.CompilationUnitCollector;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
import org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor;
@@ -80,7 +70,7 @@
* selected compilation units for startup processing,
* result of processing selection
*/
- protected Set<ICompilationUnit> selectionCU = new
HashSet<ICompilationUnit>();
+ protected CompilationUnitCollector compileUnitCollector = new
CompilationUnitCollector();
/**
* responsible to gather information
*/
@@ -109,7 +99,7 @@
* Cleanup collection of selected elements for processing
*/
public void clearSelectionCU() {
- selectionCU.clear();
+ compileUnitCollector.clearSelectionCU();
}
/**
@@ -117,18 +107,7 @@
* @param cu compilation unit
*/
public void addCompilationUnit(ICompilationUnit cu) {
- if (cu != null) {
- IType[] types = null;
- try {
- types = cu.getTypes();
- } catch (JavaModelException e) {
- // just ignore it
- }
- if (types != null) {
-
- }
- selectionCU.add(cu);
- }
+ compileUnitCollector.addCompilationUnit(cu, true);
}
/**
@@ -138,51 +117,30 @@
if (selection != null) {
updateSelectedItems(selection);
selection = null;
- }
- else {
- if (selectionCU.size() == 0) {
+ } else {
+ if (getSelectionCUSize() == 0) {
updateOpen();
return;
}
}
- if (selectionCU.size() == 0) {
- processor.modify(null, new HashMap<String, EntityInfo>(), true);
+ if (getSelectionCUSize() == 0) {
+ processor.modify(new HashMap<String, EntityInfo>(), true,
createSelection2Update());
return;
}
- Iterator<ICompilationUnit> it = selectionCU.iterator();
- Map<IJavaProject, Set<ICompilationUnit>> mapJP_CUSet =
- new HashMap<IJavaProject, Set<ICompilationUnit>>();
+ Iterator<ICompilationUnit> it = compileUnitCollector.setSelectionCUIterator();
+ /**/
while (it.hasNext()) {
ICompilationUnit cu = it.next();
- Set<ICompilationUnit> set = mapJP_CUSet.get(cu.getJavaProject());
- if (set == null) {
- set = new HashSet<ICompilationUnit>();
- mapJP_CUSet.put(cu.getJavaProject(), set);
- }
- set.add(cu);
+ collector.collect(cu);
}
- Iterator<Map.Entry<IJavaProject, Set<ICompilationUnit>>>
- mapIt = mapJP_CUSet.entrySet().iterator();
- while (mapIt.hasNext()) {
- Map.Entry<IJavaProject, Set<ICompilationUnit>>
- entry = mapIt.next();
- IJavaProject javaProject = entry.getKey();
- Iterator<ICompilationUnit> setIt = entry.getValue().iterator();
- collector.initCollector(javaProject);
- while (setIt.hasNext()) {
- ICompilationUnit icu = setIt.next();
- collector.collect(icu);
- }
- collector.resolveRelations();
- if (collector.getNonInterfaceCUNumber() > 0) {
- processor.setAnnotationStylePreference(collector.getAnnotationStylePreference());
- processor.modify(javaProject, collector.getMapCUs_Info(), true);
- }
- else {
- MessageDialog.openInformation(getShell(),
- JdtUiMessages.JPAMapToolActor_message_title,
- JdtUiMessages.JPAMapToolActor_message);
- }
+ collector.resolveRelations();
+ if (collector.getNonInterfaceCUNumber() > 0) {
+ processor.setAnnotationStylePreference(collector.getAnnotationStylePreference());
+ processor.modify(collector.getMapCUs_Info(), true, createSelection2Update());
+ } else {
+ MessageDialog.openInformation(getShell(),
+ JdtUiMessages.JPAMapToolActor_message_title,
+ JdtUiMessages.JPAMapToolActor_message);
}
processor.savePreferences();
}
@@ -216,14 +174,15 @@
CompilationUnitEditor cue = (CompilationUnitEditor)editor;
ICompilationUnit cu = (ICompilationUnit)cue.getViewPartInput();
if (cu != null) {
- IJavaProject javaProject = cu.getJavaProject();
- collector.initCollector(javaProject);
+ //IJavaProject javaProject = cu.getJavaProject();
+ //collector.initCollector(javaProject);
+ collector.initCollector();
collector.collect(cu);
collector.resolveRelations();
if (collector.getNonInterfaceCUNumber() > 0) {
- processor.modify(javaProject, collector.getMapCUs_Info(), true);
- }
- else {
+ //processor.modify(javaProject, collector.getMapCUs_Info(), true,
createSelection2Update());
+ processor.modify(collector.getMapCUs_Info(), true, createSelection2Update());
+ } else {
MessageDialog.openInformation(getShell(),
JdtUiMessages.JPAMapToolActor_message_title,
JdtUiMessages.JPAMapToolActor_message);
@@ -244,11 +203,9 @@
if (selection == null) {
//res = selectionCU.size();
res = 1;
- }
- else if (selection instanceof TextSelection) {
+ } else if (selection instanceof TextSelection) {
res = 1;
- }
- else if (selection instanceof TreeSelection) {
+ } else if (selection instanceof TreeSelection) {
TreeSelection treeSelection = (TreeSelection)selection;
res = treeSelection.size();
Iterator<?> it = treeSelection.iterator();
@@ -295,8 +252,7 @@
if (resultCU != null && resultCU.types().size() > 0 ) {
if (resultCU.getPackage() != null) {
fullyQualifiedName = resultCU.getPackage().getName().getFullyQualifiedName() +
"."; //$NON-NLS-1$
- }
- else {
+ } else {
fullyQualifiedName = ""; //$NON-NLS-1$
}
Object tmp = resultCU.types().get(0);
@@ -321,8 +277,7 @@
ICompilationUnit cu = Utils.findCompilationUnit(fullyQualifiedName);
addCompilationUnit(cu);
}
- }
- else if (sel instanceof TreeSelection) {
+ } else if (sel instanceof TreeSelection) {
clearSelectionCU();
TreeSelection treeSelection = (TreeSelection)sel;
Iterator<?> it = treeSelection.iterator();
@@ -330,8 +285,7 @@
Object obj = it.next();
processJavaElements(obj);
}
- }
- else {
+ } else {
//System.out.println("2 Blah! " + selection); //$NON-NLS-1$
sel = null;
}
@@ -346,11 +300,9 @@
boolean res = false;
if (obj instanceof JarPackageFragmentRoot) {
res = true;
- }
- else if (obj instanceof ClassFile) {
+ } else if (obj instanceof ClassFile) {
res = true;
- }
- else if (obj instanceof PackageFragment) {
+ } else if (obj instanceof PackageFragment) {
PackageFragment pf = (PackageFragment)obj;
try {
if (pf.getKind() == IPackageFragmentRoot.K_BINARY) {
@@ -359,8 +311,7 @@
} catch (JavaModelException e) {
// ignore
}
- }
- else if (obj instanceof ExternalPackageFragmentRoot) {
+ } else if (obj instanceof ExternalPackageFragmentRoot) {
res = true;
}
return res;
@@ -371,78 +322,7 @@
* @param obj
*/
public void processJavaElements(Object obj) {
- if (obj instanceof ICompilationUnit) {
- ICompilationUnit cu = (ICompilationUnit)obj;
- addCompilationUnit(cu);
- }
- else if (obj instanceof File) {
- File file = (File)obj;
- if (file.getProject() != null) {
- IJavaProject javaProject = JavaCore.create(file.getProject());
- ICompilationUnit[] cus = Utils.findCompilationUnits(javaProject,
- file.getFullPath());
- if (cus != null) {
- for (int i = 0; i < cus.length; i++) {
- addCompilationUnit(cus[i]);
- }
- }
- }
- }
- else if (obj instanceof JavaProject) {
- JavaProject javaProject = (JavaProject)obj;
- IPackageFragmentRoot[] pfr = null;
- try {
- pfr = javaProject.getAllPackageFragmentRoots();
- } catch (JavaModelException e) {
- // just ignore it!
- //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
- }
- if (pfr != null) {
- for (int i = 0; i < pfr.length; i++) {
- processJavaElements(pfr[i]);
- }
- }
- }
- else if (obj instanceof PackageFragment) {
- PackageFragment packageFragment = (PackageFragment)obj;
- ICompilationUnit[] cus = null;
- try {
- cus = packageFragment.getCompilationUnits();
- } catch (JavaModelException e) {
- // just ignore it!
- //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
- }
- if (cus != null) {
- for (int i = 0; i < cus.length; i++) {
- addCompilationUnit(cus[i]);
- }
- }
- }
- else if (obj instanceof PackageFragmentRoot) {
- JavaElement javaElement = (JavaElement)obj;
- JavaElementInfo javaElementInfo = null;
- try {
- javaElementInfo = (JavaElementInfo)javaElement.getElementInfo();
- } catch (JavaModelException e) {
- // just ignore it!
- //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
- }
- if (javaElementInfo != null) {
- IJavaElement[] je = javaElementInfo.getChildren();
- for (int i = 0; i < je.length; i++) {
- processJavaElements(je[i]);
- }
- }
- }
- else if (obj instanceof JavaElement) {
- JavaElement javaElement = (JavaElement)obj;
- ICompilationUnit cu = javaElement.getCompilationUnit();
- addCompilationUnit(cu);
- }
- else {
- // ignore
- //System.out.println("1 Blah! " + selection); //$NON-NLS-1$
- }
+ compileUnitCollector.processJavaElements(obj, true);
}
/**
@@ -451,6 +331,7 @@
*/
synchronized public void setSelection(ISelection selection) {
//System.out.println("Blah! " + selection); //$NON-NLS-1$
+ compileUnitCollector.clearSelection2UpdateList();
if (selection instanceof StructuredSelection && selection.isEmpty()) {
//System.out.println("This! " + this.selection); //$NON-NLS-1$
clearSelectionCU();
@@ -460,6 +341,10 @@
this.selection = selection;
}
+ public StructuredSelection createSelection2Update() {
+ return compileUnitCollector.createSelection2Update();
+ }
+
// setters for testing
public void setAllEntitiesInfoCollector(AllEntitiesInfoCollector collector) {
@@ -471,10 +356,10 @@
}
public void setSelectionCU(Set<ICompilationUnit> selectionCU) {
- this.selectionCU = selectionCU;
+ compileUnitCollector.setSelectionCU(selectionCU);
}
public int getSelectionCUSize() {
- return selectionCU.size();
+ return compileUnitCollector.getSelectionCUSize();
}
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -36,12 +36,8 @@
public class AllEntitiesInfoCollector {
/**
- * place to search compilation units
- */
- protected IJavaProject javaProject;
- /**
* map:
- * fullyQualifiedName entity name -> EntityInfo
+ * javaProjectName + "/" + fullyQualifiedName entity name -> EntityInfo
* this collection of processed entities
*/
protected Map<String, EntityInfo> mapCUs_Info = new TreeMap<String,
EntityInfo>();
@@ -50,11 +46,9 @@
*/
protected AnnotStyle annotationStylePreference = AnnotStyle.FIELDS;
- public void initCollector(IJavaProject javaProject) {
- // setup java project
- this.javaProject = javaProject;
+ public void initCollector() {
// clear collection
- mapCUs_Info = new TreeMap<String, EntityInfo>();
+ mapCUs_Info.clear();
}
/**
@@ -108,8 +102,9 @@
// entry.getKey() - fully qualified name
// entry.getValue() - EntityInfo
EntityInfo entryInfo = entry.getValue();
- assert(entry.getKey().equals(entryInfo.getFullyQualifiedName()));
String fullyQualifiedName = entryInfo.getFullyQualifiedName();
+ String javaProjectName = entryInfo.getJavaProjectName();
+ assert(entry.getKey().equals(javaProjectName + "/" + fullyQualifiedName));
//$NON-NLS-1$
// get references map:
// * field id -> RefEntityInfo
Iterator<Map.Entry<String, RefEntityInfo>> referencesIt =
@@ -121,7 +116,7 @@
pi.fieldId = entry2.getKey();
pi.refEntityInfo = entry2.getValue();
String fullyQualifiedName2 = pi.refEntityInfo.fullyQualifiedName;
- EntityInfo entryInfo2 = mapCUs_Info.get(fullyQualifiedName2);
+ EntityInfo entryInfo2 = mapCUs_Info.get(javaProjectName + "/" +
fullyQualifiedName2); //$NON-NLS-1$
assert(fullyQualifiedName2.equals(entryInfo2.getFullyQualifiedName()));
if (entryInfo2 != null && pi.refEntityInfo != null) {
pi.refEntityInfo2 = null;
@@ -257,8 +252,9 @@
// entry.getKey() - fully qualified name
// entry.getValue() - EntityInfo
EntityInfo entryInfo = entry.getValue();
- assert(entry.getKey().equals(entryInfo.getFullyQualifiedName()));
String fullyQualifiedName = entryInfo.getFullyQualifiedName();
+ String javaProjectName = entryInfo.getJavaProjectName();
+ assert(entry.getKey().equals(javaProjectName + "/" + fullyQualifiedName));
//$NON-NLS-1$
// get references map:
// * field id -> RefEntityInfo
Iterator<Map.Entry<String, RefEntityInfo>> referencesIt =
@@ -270,7 +266,7 @@
pi.fieldId = entry2.getKey();
pi.refEntityInfo = entry2.getValue();
String fullyQualifiedName2 = pi.refEntityInfo.fullyQualifiedName;
- EntityInfo entryInfo2 = mapCUs_Info.get(fullyQualifiedName2);
+ EntityInfo entryInfo2 = mapCUs_Info.get(javaProjectName + "/" +
fullyQualifiedName2); //$NON-NLS-1$
assert(fullyQualifiedName2.equals(entryInfo2.getFullyQualifiedName()));
if (entryInfo2 != null && pi.refEntityInfo != null) {
pi.refEntityInfo2 = null;
@@ -322,11 +318,11 @@
}
}
- public boolean hasMappedSuperclassVersion(String parentName) {
+ public boolean hasMappedSuperclassVersion(String javaProjectName, String parentName) {
if (parentName == null) {
return false;
}
- EntityInfo entryInfoParent = mapCUs_Info.get(parentName);
+ EntityInfo entryInfoParent = mapCUs_Info.get(javaProjectName + "/" +
parentName); //$NON-NLS-1$
if (entryInfoParent == null) {
return false;
}
@@ -351,8 +347,9 @@
while (it.hasNext()) {
Map.Entry<String, EntityInfo> entry = it.next();
EntityInfo entityInfo = entry.getValue();
+ String javaProjectName = entityInfo.getJavaProjectName();
String parentName = entityInfo.getFullyQualifiedParentName();
- if (hasMappedSuperclassVersion(parentName)) {
+ if (hasMappedSuperclassVersion(javaProjectName, parentName)) {
entityInfo.setAddVersionFlag(false);
}
else {
@@ -662,7 +659,7 @@
if (ei == null) {
return;
}
- EntityInfo parentEI = mapCUs_Info.get(ei.getFullyQualifiedParentName());
+ EntityInfo parentEI = mapCUs_Info.get(ei.getJavaProjectName() + "/" +
ei.getFullyQualifiedParentName()); //$NON-NLS-1$
adjustParentId(parentEI);
ei.adjustPrimaryId(parentEI);
}
@@ -673,14 +670,15 @@
* @param fullyQualifiedName of startup point entity fully qualified name
* example:
"org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector"
*/
- public void collect(String fullyQualifiedName) {
+ public void collect(String fullyQualifiedName, String projectName) {
if (fullyQualifiedName == null) {
return;
}
- if (mapCUs_Info.containsKey(fullyQualifiedName)) {
+ if (mapCUs_Info.containsKey(projectName + "/" + fullyQualifiedName)) {
//$NON-NLS-1$
return;
}
+ final IJavaProject javaProject = Utils.findJavaProject(projectName);
ICompilationUnit icu = Utils.findCompilationUnit(javaProject, fullyQualifiedName);
collect(icu);
}
@@ -716,6 +714,8 @@
// ignore EnumDeclaration & AnnotationTypeDeclaration
return;
}
+ IJavaProject javaProject = icu.getJavaProject();
+ String projectName = (javaProject != null) ? javaProject.getProject().getName() :
""; //$NON-NLS-1$
ArrayList<String> fullyQualifiedNames = new ArrayList<String>();
//TODO: should inspect all types in cu? so next method to get fullyQualifiedName:
if (cu.getTypeRoot() == null || cu.getTypeRoot().findPrimaryType() == null) {
@@ -732,17 +732,18 @@
Iterator<String> itFQNames = fullyQualifiedNames.iterator();
while (itFQNames.hasNext()) {
String fullyQualifiedName = itFQNames.next();
- if (!mapCUs_Info.containsKey(fullyQualifiedName)) {
+ if (!mapCUs_Info.containsKey(projectName + "/" + fullyQualifiedName)) {
//$NON-NLS-1$
CollectEntityInfo finder = new CollectEntityInfo(fullyQualifiedName);
cu.accept(finder);
EntityInfo result = finder.getEntityInfo();
if (result != null) {
result.adjustParameters();
- mapCUs_Info.put(fullyQualifiedName, result);
+ result.setJavaProjectName(projectName);
+ mapCUs_Info.put(projectName + "/" + fullyQualifiedName, result);
//$NON-NLS-1$
Iterator<String> itDep = result.getDependences();
while (itDep.hasNext()) {
String fullyQualifiedNameTmp = itDep.next();
- collect(fullyQualifiedNameTmp);
+ collect(fullyQualifiedNameTmp, projectName);
}
}
}
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CompilationUnitCollector.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CompilationUnitCollector.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/CompilationUnitCollector.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.jdt.ui.internal.jpa.collect;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.internal.resources.File;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jdt.internal.core.JavaElementInfo;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jdt.internal.core.PackageFragment;
+import org.eclipse.jdt.internal.core.PackageFragmentRoot;
+import org.eclipse.jdt.internal.core.SourceType;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
+
+/**
+ * @author Vitali
+ */
+@SuppressWarnings("restriction")
+public class CompilationUnitCollector {
+ /**
+ * selection - start point for wizard selection update page
+ */
+ protected List<Object> selection2UpdateList = new ArrayList<Object>();
+ /**
+ * selected compilation units for startup processing,
+ * result of processing selection
+ */
+ protected Set<ICompilationUnit> selectionCU = new
HashSet<ICompilationUnit>();
+
+ /**
+ * Cleanup collection of selected elements for processing
+ */
+ public void clearSelectionCU() {
+ selectionCU.clear();
+ }
+
+ public Iterator<ICompilationUnit> setSelectionCUIterator() {
+ return this.selectionCU.iterator();
+ }
+
+ public void setSelectionCU(Set<ICompilationUnit> selectionCU) {
+ this.selectionCU = selectionCU;
+ }
+
+ public int getSelectionCUSize() {
+ return selectionCU.size();
+ }
+
+ public void clearSelection2UpdateList() {
+ selection2UpdateList.clear();
+ }
+
+ public StructuredSelection createSelection2Update() {
+ return new StructuredSelection(selection2UpdateList);
+ }
+
+ /**
+ * Adds compilation unit into collection of selected elements for processing
+ * @param cu compilation unit
+ */
+ public void addCompilationUnit(ICompilationUnit cu, boolean bCollect) {
+ if (cu != null) {
+ IType[] types = null;
+ try {
+ types = cu.getTypes();
+ } catch (JavaModelException e) {
+ // just ignore it
+ }
+ if (types != null) {
+ if (bCollect) {
+ for (int i = 0; i < types.length; i++) {
+ if (types[i] instanceof SourceType) {
+ selection2UpdateList.add(types[i]);
+ }
+ }
+ bCollect = false;
+ }
+ }
+ selectionCU.add(cu);
+ }
+ }
+
+ /**
+ * Process object - java element to collect all it's children CompilationUnits
+ * @param obj
+ */
+ public void processJavaElements(Object obj, boolean bCollect) {
+ if (obj instanceof ICompilationUnit) {
+ ICompilationUnit cu = (ICompilationUnit)obj;
+ addCompilationUnit(cu, bCollect);
+ } else if (obj instanceof File) {
+ File file = (File)obj;
+ if (file.getProject() != null) {
+ IJavaProject javaProject = JavaCore.create(file.getProject());
+ ICompilationUnit[] cus = Utils.findCompilationUnits(javaProject,
+ file.getFullPath());
+ if (cus != null) {
+ for (int i = 0; i < cus.length; i++) {
+ addCompilationUnit(cus[i], bCollect);
+ }
+ }
+ }
+ } else if (obj instanceof JavaProject) {
+ JavaProject javaProject = (JavaProject)obj;
+ IPackageFragmentRoot[] pfr = null;
+ try {
+ pfr = javaProject.getAllPackageFragmentRoots();
+ } catch (JavaModelException e) {
+ // just ignore it!
+ //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
+ }
+ if (pfr != null) {
+ for (int i = 0; i < pfr.length; i++) {
+ processJavaElements(pfr[i], bCollect);
+ }
+ }
+ } else if (obj instanceof PackageFragment) {
+ PackageFragment packageFragment = (PackageFragment)obj;
+ ICompilationUnit[] cus = null;
+ try {
+ cus = packageFragment.getCompilationUnits();
+ } catch (JavaModelException e) {
+ // just ignore it!
+ //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
+ }
+ if (cus != null && cus.length > 0) {
+ if (bCollect) {
+ selection2UpdateList.add(obj);
+ bCollect = false;
+ }
+ for (int i = 0; i < cus.length; i++) {
+ addCompilationUnit(cus[i], bCollect);
+ }
+ }
+ } else if (obj instanceof PackageFragmentRoot) {
+ JavaElement javaElement = (JavaElement)obj;
+ JavaElementInfo javaElementInfo = null;
+ try {
+ javaElementInfo = (JavaElementInfo)javaElement.getElementInfo();
+ } catch (JavaModelException e) {
+ // just ignore it!
+ //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
+ }
+ if (javaElementInfo != null) {
+ IJavaElement[] je = javaElementInfo.getChildren();
+ for (int i = 0; i < je.length; i++) {
+ processJavaElements(je[i], true);
+ }
+ }
+ } else if (obj instanceof JavaElement) {
+ JavaElement javaElement = (JavaElement)obj;
+ ICompilationUnit cu = javaElement.getCompilationUnit();
+ addCompilationUnit(cu, bCollect);
+ } else if (obj instanceof SourceType) {
+ if (bCollect) {
+ selection2UpdateList.add(obj);
+ bCollect = false;
+ }
+ SourceType sourceType = (SourceType)obj;
+ processJavaElements(sourceType.getJavaModel(), bCollect);
+ } else {
+ // ignore
+ //System.out.println("1 Blah! " + selection); //$NON-NLS-1$
+ }
+ }
+
+ public void collectFromSelection2UpdateList() {
+ clearSelectionCU();
+ Iterator<Object> it = selection2UpdateList.iterator();
+ while (it.hasNext()) {
+ processJavaElements(it.next(), true);
+ }
+ }
+}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/EntityInfo.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -30,6 +30,10 @@
public class EntityInfo {
/*
+ * fully java project name
+ */
+ protected String javaProjectName = ""; //$NON-NLS-1$
+ /*
* fully qualified entity name
*/
protected String fullyQualifiedName = ""; //$NON-NLS-1$
@@ -317,6 +321,14 @@
return ""; //$NON-NLS-1$
}
+ public String getJavaProjectName() {
+ return javaProjectName;
+ }
+
+ public void setJavaProjectName(String javaProjectName) {
+ this.javaProjectName = javaProjectName;
+ }
+
public String getFullyQualifiedName() {
return fullyQualifiedName;
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/Utils.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/Utils.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/common/Utils.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -55,11 +55,13 @@
static public IType findType(IJavaProject javaProject,
String fullyQualifiedName) {
IType lwType = null;
- try {
- lwType = javaProject.findType(fullyQualifiedName);
- } catch (JavaModelException e) {
- // just ignore it!
- //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
+ if (javaProject != null) {
+ try {
+ lwType = javaProject.findType(fullyQualifiedName);
+ } catch (JavaModelException e) {
+ // just ignore it!
+ //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException:
", e); //$NON-NLS-1$
+ }
}
return lwType;
}
@@ -80,6 +82,31 @@
}
return resCompilationUnit;
}
+
+ static public IProject findProject(String projectName) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject[] projects = root.getProjects();
+ IProject res = null;
+ for (int i = 0; i < projects.length && res == null; i++) {
+ if (projects[i].exists() && projects[i].getName().compareTo(projectName) == 0)
{
+ res = projects[i];
+ }
+ }
+ return res;
+ }
+
+ static public IJavaProject findJavaProject(String projectName) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject[] projects = root.getProjects();
+ IJavaProject res = null;
+ for (int i = 0; i < projects.length && res == null; i++) {
+ if (projects[i].exists() && projects[i].getName().compareTo(projectName) == 0)
{
+ IJavaProject javaProject = JavaCore.create(projects[i]);
+ res = javaProject;
+ }
+ }
+ return res;
+ }
static public ICompilationUnit[] findCompilationUnits(IJavaProject javaProject,
IPath path) {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/AllEntitiesProcessor.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -29,6 +29,7 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.text.edits.MalformedTreeException;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.jdt.ui.Activator;
@@ -36,6 +37,7 @@
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfosCollection;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
import org.hibernate.eclipse.jdt.ui.internal.jpa.process.wizard.HibernateJPAWizard;
+import
org.hibernate.eclipse.jdt.ui.internal.jpa.process.wizard.HibernateJPAWizardDataFactory;
import org.hibernate.eclipse.jdt.ui.internal.jpa.process.wizard.IHibernateJPAWizardData;
import
org.hibernate.eclipse.jdt.ui.internal.jpa.process.wizard.IHibernateJPAWizardParams;
@@ -46,10 +48,6 @@
*/
public class AllEntitiesProcessor implements IHibernateJPAWizardParams {
/**
- * place to search compilation units
- */
- protected IJavaProject javaProject = null;
- /**
* place to store default settings
*/
protected IPreferenceStore preferenceStore = null;
@@ -147,13 +145,13 @@
* @param entities - collection
* @param askConfirmation - ask user confirmation (show dialog)
*/
- public void modify(IJavaProject project, Map<String, EntityInfo> entities,
- boolean askConfirmation) {
+ //public void modify(IJavaProject project, Map<String, EntityInfo> entities,
+ public void modify(Map<String, EntityInfo> entities,
+ boolean askConfirmation, IStructuredSelection selection2Update) {
changes.clear();
- setJavaProject(project);
// get the buffer manager
- ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
- /*Iterator<Map.Entry<String, EntityInfo>> it =
entities.entrySet().iterator();
+ /** /
+ Iterator<Map.Entry<String, EntityInfo>> it =
entities.entrySet().iterator();
String outText = ""; //$NON-NLS-1$
String ls = System.getProperties().getProperty("line.separator",
"\n"); //$NON-NLS-1$//$NON-NLS-2$
while (it.hasNext()) {
@@ -165,35 +163,10 @@
// TODO: save entity name as has compiler problems
}
outText += entry.getKey() + (it.hasNext() ? ls : ""); //$NON-NLS-1$
- }*/
+ }
+ /**/
boolean performChange = true;
int res = 0;
- if (askConfirmation) {
- /** /
- final String outText2 = outText;
- MessageDialog dialog = new
MessageDialog(JavaPlugin.getActiveWorkbenchShell(),
- JdtUiMessages.AllEntitiesProcessor_header, null,
- JdtUiMessages.AllEntitiesProcessor_message,
- MessageDialog.QUESTION,
- new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL },
0) {
- protected Control createCustomArea(Composite parent) {
- Text messageText = new Text(parent, SWT.WRAP | SWT.V_SCROLL);
- messageText.setText(outText2);
- messageText.setEditable(false);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL)
- .grab(true, true)
-
.hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
- convertHorizontalDLUsToPixels(2 *
IDialogConstants.BUTTON_BAR_HEIGHT)).applyTo(messageText);
-
- return messageText;
- }
- protected boolean isResizable() {
- return true;
- }
- };
- res = dialog.open();
- /**/
- }
if (res == 0) {
// TODO:
// show warning about abstract classes
@@ -202,29 +175,28 @@
// modify accepted items
if (getAnnotationStyle().equals(AnnotStyle.AUTO)) {
setAnnotationStyle(getAnnotationStylePreference());
- reCollectModification(bufferManager, entities);
+ reCollectModification(entities);
setAnnotationStyle(AnnotStyle.AUTO);
+ } else {
+ reCollectModification(entities);
}
- else {
- reCollectModification(bufferManager, entities);
- }
- }
- else {
+ } else {
performChange = false;
}
//
if (askConfirmation) {
- if (!showRefactoringDialog(entities, bufferManager)) {
+ if (!showRefactoringDialog(entities, selection2Update)) {
performChange = false;
}
}
if (performChange) {
- performCommit(entities, bufferManager);
+ performCommit(entities);
}
- performDisconnect(bufferManager);
+ performDisconnect();
}
- protected void performDisconnect(ITextFileBufferManager bufferManager) {
+ public void performDisconnect() {
+ final ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
for (int i = 0; i < changes.size(); i++) {
ChangeStructure cs = changes.get(i);
try {
@@ -236,9 +208,9 @@
changes.clear();
}
- protected void performCommit(final Map<String, EntityInfo> entities,
- ITextFileBufferManager bufferManager) {
+ protected void performCommit(final Map<String, EntityInfo> entities) {
+ final ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
for (int i = 0; i < changes.size(); i++) {
ChangeStructure cs = changes.get(i);
if (cs.textEdit != null && ((cs.change != null &&
cs.change.isEnabled()) || (cs.change == null))) {
@@ -261,10 +233,10 @@
}
}
- public void reCollectModification(ITextFileBufferManager bufferManager,
- Map<String, EntityInfo> entities) {
+ public void reCollectModification(Map<String, EntityInfo> entities) {
changes.clear();
+ final ITextFileBufferManager bufferManager = FileBuffers.getTextFileBufferManager();
HashMap<IPath, EntityInfosCollection> modifications = new HashMap<IPath,
EntityInfosCollection>();
Iterator<Map.Entry<String, EntityInfo>> it =
entities.entrySet().iterator();
while (it.hasNext()) {
@@ -272,8 +244,13 @@
if (entry.getValue().isInterfaceFlag()) {
continue;
}
- final String fullyQualifiedName = entry.getKey();
+ final String javaProjectName = entry.getValue().getJavaProjectName();
+ final String fullyQualifiedName = entry.getValue().getFullyQualifiedName();
+ IJavaProject javaProject = Utils.findJavaProject(javaProjectName);
ICompilationUnit icu = Utils.findCompilationUnit(javaProject, fullyQualifiedName);
+ if (icu == null) {
+ continue;
+ }
org.eclipse.jdt.core.dom.CompilationUnit cu = Utils.getCompilationUnit(icu, true);
final IPath path = cu.getJavaElement().getPath();
EntityInfosCollection eiCollection = null;
@@ -335,31 +312,15 @@
}
public boolean showRefactoringDialog(final Map<String, EntityInfo> entities,
- final ITextFileBufferManager bufferManager) {
+ final IStructuredSelection selection2Update) {
- IHibernateJPAWizardData data = new IHibernateJPAWizardData() {
-
- public ITextFileBufferManager getBufferManager() {
- return bufferManager;
- }
-
- public Map<String, EntityInfo> getEntities() {
- return entities;
- }
-
- public ArrayList<ChangeStructure> getChanges() {
- return changes;
- }
-
- };
+ IHibernateJPAWizardData data =
+ HibernateJPAWizardDataFactory.createHibernateJPAWizardData(
+ entities, selection2Update, changes);
HibernateJPAWizard wizard = new HibernateJPAWizard(data, this);
return wizard.showWizard();
}
- protected void setJavaProject(IJavaProject project) {
- javaProject = project;
- }
-
public AnnotStyle getAnnotationStyle() {
return annotationStyle;
}
@@ -391,4 +352,8 @@
public void setEnableOptLock(boolean enableOptLock) {
this.enableOptLock = enableOptLock;
}
+
+ public ArrayList<ChangeStructure> getChanges() {
+ return changes;
+ }
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesList.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -31,6 +31,8 @@
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
@@ -43,7 +45,11 @@
*/
@SuppressWarnings("restriction")
public class EntitiesList extends UserInputWizardPage {
+
+ protected final int COLUMN_CLASS = 0;
+ protected TableViewer listViewer;
+
protected IHibernateJPAWizardData data;
protected IHibernateJPAWizardParams params;
@@ -52,8 +58,31 @@
super(name);
this.data = data;
this.params = params;
+ setDescription(JdtUiMessages.EntitiesList_description);
}
+ public IStructuredContentProvider createContentProvider(final IHibernateJPAWizardData
data) {
+ return new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ return data.getEntities().values().toArray();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ };
+ }
+
+ public void setData(final IHibernateJPAWizardData data) {
+ this.data = data;
+ if (listViewer != null) {
+ listViewer.setContentProvider(createContentProvider(data));
+ listViewer.setInput(data.getEntities());
+ }
+ }
+
public void createControl(Composite parent) {
initializeDialogUnits(parent);
Composite container = new Composite(parent, SWT.NULL);
@@ -63,7 +92,7 @@
Label label = new Label(container, SWT.NULL);
label.setText(JdtUiMessages.AllEntitiesProcessor_message);
- TableViewer listViewer = new TableViewer(container, SWT.SINGLE | SWT.H_SCROLL
+ listViewer = new TableViewer(container, SWT.SINGLE | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.BORDER);
//listViewer.setComparator(getViewerComparator());
Control control = listViewer.getControl();
@@ -71,21 +100,7 @@
| GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
gridData.heightHint = convertHeightInCharsToPixels(10);
control.setLayoutData(gridData);
- listViewer.setContentProvider(new IStructuredContentProvider() {
- public Object[] getElements(Object inputElement) {
- return data.getEntities().values().toArray();
- }
-
- public void dispose() {
-
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
-
- }
- });
-
+ listViewer.setContentProvider(createContentProvider(data));
listViewer.setLabelProvider(new LabelProvider() {
private Image classImage;
@@ -113,6 +128,9 @@
});
listViewer.setInput(data.getEntities());
+ listViewer.getTable().setHeaderVisible(true);
+ listViewer.getTable().setLinesVisible(true);
+ createTableColumns(listViewer.getTable());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, true)
.hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
@@ -146,15 +164,15 @@
int idx = ((Combo)e.getSource()).getSelectionIndex();
if (idx == 0 && !params.getAnnotationStyle().equals(AnnotStyle.FIELDS)) {
params.setAnnotationStyle(AnnotStyle.FIELDS);
- params.reCollectModification(data.getBufferManager(), data.getEntities());
+ params.reCollectModification(data.getEntities());
}
else if (idx == 1 && !params.getAnnotationStyle().equals(AnnotStyle.GETTERS))
{
params.setAnnotationStyle(AnnotStyle.GETTERS);
- params.reCollectModification(data.getBufferManager(), data.getEntities());
+ params.reCollectModification(data.getEntities());
}
else if (idx == 2 && !params.getAnnotationStyle().equals(AnnotStyle.AUTO)) {
params.setAnnotationStyle(params.getAnnotationStylePreference());
- params.reCollectModification(data.getBufferManager(), data.getEntities());
+ params.reCollectModification(data.getEntities());
params.setAnnotationStyle(AnnotStyle.AUTO);
}
}
@@ -191,7 +209,7 @@
val = Integer.valueOf(str);
}
params.setDefaultStrLength(val);
- params.reCollectModification(data.getBufferManager(), data.getEntities());
+ params.reCollectModification(data.getEntities());
}
};
@@ -206,7 +224,7 @@
public void handleEvent(Event e) {
params.setEnableOptLock(((Button)e.widget).getSelection());
- params.reCollectModification(data.getBufferManager(), data.getEntities());
+ params.reCollectModification(data.getEntities());
}
};
@@ -214,4 +232,12 @@
setControl(container);
}
+
+ protected void createTableColumns(Table table) {
+ TableColumn column = null;
+
+ column = new TableColumn(table, SWT.LEFT, COLUMN_CLASS);
+ column.setText(JdtUiMessages.ResolveAmbiguous_column_Class);
+ column.setWidth(200);
+ }
}
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesSource.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesSource.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesSource.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.jdt.ui.internal.jpa.process.wizard;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableItem;
+import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
+import org.hibernate.eclipse.jdt.ui.wizards.AddRemoveTableComposite;
+
+/**
+ * @author Vitali
+ */
+public class EntitiesSource extends UserInputWizardPage {
+
+ protected AddRemoveTableComposite addRemoveTableComposite;
+
+ protected IStructuredSelection selection;
+
+ public EntitiesSource(String name, IStructuredSelection selection) {
+ super(name);
+ this.selection = selection;
+ setDescription(JdtUiMessages.EntitiesSource_description);
+ }
+
+ public void createControl(Composite parent) {
+ addRemoveTableComposite = new AddRemoveTableComposite(parent, SWT.NONE) {
+ @Override
+ protected void handleButtonPressed(Button button) {
+ super.handleButtonPressed(button);
+ itemsChanged();
+ }
+ };
+ addRemoveTableComposite.getTableViewer().setInput(selection.toArray());
+ setControl(addRemoveTableComposite);
+ }
+
+ public IStructuredSelection getSelection() {
+ TableItem[] items = addRemoveTableComposite.getTableViewer().getTable().getItems();
+ Object[] data = new Object[items.length];
+ for (int i = 0; i < items.length; i++) {
+ data[i] = items[i].getData();
+ }
+ return new StructuredSelection(data);
+ }
+
+ protected void itemsChanged(){
+ getContainer().updateButtons();
+ }
+
+}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -12,11 +12,20 @@
import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper;
import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
+import org.eclipse.jface.dialogs.IPageChangingListener;
+import org.eclipse.jface.dialogs.PageChangingEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.utils.EclipseImages;
import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
/**
@@ -25,7 +34,7 @@
* @author Vitali
*/
@SuppressWarnings("restriction")
-public class HibernateJPAWizard extends RefactoringWizard {
+public class HibernateJPAWizard extends RefactoringWizard implements
IPageChangingListener {
protected final String wizard_title = JdtUiMessages.AllEntitiesProcessor_header;
@@ -37,14 +46,29 @@
super(new HibernateJPARefactoring(data.getChanges()),
RefactoringWizard.WIZARD_BASED_USER_INTERFACE);
this.data = data;
this.params = params;
+ setDefaultPageImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.NEW_WIZARD));
setWindowTitle(wizard_title);
setDefaultPageTitle(wizard_title);
}
@Override
protected void addUserInputPages() {
- UserInputWizardPage page = new EntitiesList(wizard_title, data, params);
- addPage(page);
+
+ IStructuredSelection selection = null;
+ if (data != null && data.getSelection2Update() != null) {
+ selection = data.getSelection2Update();
+ }
+ if (selection == null) {
+ selection = new StructuredSelection();
+ }
+ String title = JdtUiMessages.EntitiesSource_header;
+ EntitiesSource page0 = new EntitiesSource(title, selection);
+ addPage(page0);
+
+ title = JdtUiMessages.EntitiesList_header;
+ UserInputWizardPage page1 = new EntitiesList(title, data, params);
+ addPage(page1);
+ setDefaultPageTitle(page1.getName());
/** /
UserInputWizardPage page2 = new ResolveAmbiguous(wizard_title, data, params);
addPage(page2);
@@ -64,4 +88,42 @@
return res;
}
+ public IWizardPage getStartingPage() {
+ if (getPages().length <= 0) {
+ return null;
+ }
+ if (getPages().length == 1) {
+ return getPages()[0];
+ }
+ return getPages()[1];
+ }
+
+ @Override
+ public void setContainer(IWizardContainer wizardContainer) {
+ if (getContainer() instanceof WizardDialog) {
+ ((WizardDialog) getContainer()).removePageChangingListener(this);
+ }
+ super.setContainer(wizardContainer);
+ if (getContainer() instanceof WizardDialog) {
+ ((WizardDialog) getContainer()).addPageChangingListener(this);
+ }
+ }
+
+ public void handlePageChanging(PageChangingEvent event) {
+ Object currentPage = event.getCurrentPage();
+ Object targetPage = event.getTargetPage();
+ if (targetPage instanceof IWizardPage) {
+ setDefaultPageTitle(((IWizardPage)targetPage).getName());
+ }
+ if (currentPage instanceof EntitiesSource && targetPage instanceof
EntitiesList){
+ EntitiesSource entitiesSource = (EntitiesSource)currentPage;
+ EntitiesList entitiesList = (EntitiesList)targetPage;
+ final IStructuredSelection selection = entitiesSource.getSelection();
+ IHibernateJPAWizardData data =
+ HibernateJPAWizardDataFactory.createHibernateJPAWizardData(selection,
+ params);
+ entitiesList.setData(data);
+ }
+ }
+
}
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizardDataFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizardDataFactory.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizardDataFactory.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.jdt.ui.internal.jpa.process.wizard;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.CompilationUnitCollector;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure;
+
+/**
+ * @author Vitali
+ */
+public class HibernateJPAWizardDataFactory {
+
+ static public IHibernateJPAWizardData createHibernateJPAWizardData(
+ final Map<String, EntityInfo> entities,
+ final IStructuredSelection selection2Update,
+ final ArrayList<ChangeStructure> changes) {
+
+ IHibernateJPAWizardData data = new IHibernateJPAWizardData() {
+
+ public Map<String, EntityInfo> getEntities() {
+ return entities;
+ }
+
+ public ArrayList<ChangeStructure> getChanges() {
+ return changes;
+ }
+
+ public IStructuredSelection getSelection2Update() {
+ return selection2Update;
+ }
+
+ };
+ return data;
+ }
+
+ @SuppressWarnings("unchecked")
+ static public IHibernateJPAWizardData createHibernateJPAWizardData(
+ final IStructuredSelection selection2Update, IHibernateJPAWizardParams params) {
+
+ CompilationUnitCollector compileUnitCollector = new CompilationUnitCollector();
+ Iterator itSelection2Update = selection2Update.iterator();
+ while (itSelection2Update.hasNext()) {
+ Object obj = itSelection2Update.next();
+ compileUnitCollector.processJavaElements(obj, true);
+ }
+ Iterator<ICompilationUnit> it = compileUnitCollector.setSelectionCUIterator();
+ AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
+ collector.initCollector();
+ while (it.hasNext()) {
+ ICompilationUnit cu = it.next();
+ collector.collect(cu);
+ }
+ collector.resolveRelations();
+ final Map<String, EntityInfo> entities = collector.getMapCUs_Info();
+
+ params.performDisconnect();
+ params.reCollectModification(entities);
+
+ final ArrayList<ChangeStructure> changes = params.getChanges();
+
+ IHibernateJPAWizardData data = new IHibernateJPAWizardData() {
+
+ public Map<String, EntityInfo> getEntities() {
+ return entities;
+ }
+
+ public ArrayList<ChangeStructure> getChanges() {
+ return changes;
+ }
+
+ public IStructuredSelection getSelection2Update() {
+ return selection2Update;
+ }
+
+ };
+ return data;
+ }
+
+}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardData.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardData.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardData.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -13,7 +13,7 @@
import java.util.ArrayList;
import java.util.Map;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
import org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure;
@@ -25,8 +25,8 @@
public interface IHibernateJPAWizardData {
public Map<String, EntityInfo> getEntities();
-
- public ITextFileBufferManager getBufferManager();
public ArrayList<ChangeStructure> getChanges();
+
+ public IStructuredSelection getSelection2Update();
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardParams.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardParams.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/IHibernateJPAWizardParams.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -10,11 +10,12 @@
******************************************************************************/
package org.hibernate.eclipse.jdt.ui.internal.jpa.process.wizard;
+import java.util.ArrayList;
import java.util.Map;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
import org.hibernate.eclipse.jdt.ui.internal.jpa.process.AnnotStyle;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.process.ChangeStructure;
/**
* Hibernate JPA wizard input parameters interface
@@ -41,6 +42,9 @@
public AnnotStyle getAnnotationStylePreference();
- public void reCollectModification(ITextFileBufferManager bufferManager,
- Map<String, EntityInfo> entities);
+ public void reCollectModification(Map<String, EntityInfo> entities);
+
+ public void performDisconnect();
+
+ public ArrayList<ChangeStructure> getChanges();
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/ResolveAmbiguous.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/ResolveAmbiguous.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/ResolveAmbiguous.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -165,7 +165,7 @@
updateEditorOwner(ti);
updateTI(ti);
updateTI(ti2);
- params.reCollectModification(data.getBufferManager(), data.getEntities());
+ params.reCollectModification(data.getEntities());
}
}
}
@@ -238,7 +238,7 @@
updateEditorType(ti);
updateEditorOwner(ti);
updateTI(ti);
- params.reCollectModification(data.getBufferManager(), data.getEntities());
+ params.reCollectModification(data.getEntities());
}
}
}
@@ -292,7 +292,7 @@
updateEditorType(ti);
updateTI(ti);
updateTI(ti2);
- params.reCollectModification(data.getBufferManager(), data.getEntities());
+ params.reCollectModification(data.getEntities());
}
}
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/AddRemoveTableComposite.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/AddRemoveTableComposite.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/AddRemoveTableComposite.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -31,6 +31,8 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.SelectionDialog;
import org.hibernate.eclipse.console.wizards.UpDownListComposite;
@@ -60,6 +62,28 @@
TableColumn column = new TableColumn(table, SWT.NULL);
column.setWidth(350);
}
+
+ public void add(Object[] o, boolean notify) {
+ ArrayList<Object> arr = new ArrayList<Object>();
+ ArrayList<Object> arrSelItems = new ArrayList<Object>();
+ for (int i = 0; i < o.length; i++) {
+ Widget w = getTableViewer().testFindItem(o[i]);
+ if (w == null) {
+ arr.add(o[i]);
+ } else {
+ arrSelItems.add(w);
+ }
+ }
+ super.add(arr.toArray(), notify);
+ for (int i = 0; i < arr.size(); i++) {
+ Widget w = getTableViewer().testFindItem(arr.get(i));
+ if (w != null) {
+ arrSelItems.add(w);
+ }
+ }
+ getTableViewer().getTable().setSelection(arrSelItems.toArray(new TableItem[0]));
+ getTableViewer().setSelection(getTableViewer().getSelection(), false);
+ }
protected Object[] handleAdd(int i) {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -115,7 +115,7 @@
entry = mapIt.next();
IJavaProject javaProject = entry.getKey();
Iterator<ICompilationUnit> setIt = entry.getValue().iterator();
- collector.initCollector(javaProject);
+ collector.initCollector();
while (setIt.hasNext()) {
ICompilationUnit icu = setIt.next();
collector.collect(icu);
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 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -28,14 +28,11 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
@@ -358,7 +355,7 @@
entry = mapIt.next();
IJavaProject javaProject = entry.getKey();
Iterator<ICompilationUnit> setIt = entry.getValue().iterator();
- collector.initCollector(javaProject);
+ collector.initCollector();
while (setIt.hasNext()) {
ICompilationUnit icu = setIt.next();
collector.collect(icu);
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapMockTests.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapMockTests.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapMockTests.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -18,6 +18,8 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.hibernate.eclipse.jdt.ui.internal.jpa.actions.JPAMapToolActor;
import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector;
import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
@@ -35,6 +37,7 @@
*
* @author Vitali Yemialyanchyk
*/
+@SuppressWarnings("restriction")
public class JPAMapMockTests extends TestCase {
@@ -81,8 +84,9 @@
jpaMapToolActor.setAllEntitiesInfoCollector(allEntitiesInfoCollector);
jpaMapToolActor.setSelection(selection);
+ final IStructuredSelection selection2Update = new StructuredSelection();
context.checking(new Expectations() {{
- exactly(1).of(allEntitiesProcessor).modify(null, new HashMap<String,
EntityInfo>(), true);
+ exactly(1).of(allEntitiesProcessor).modify(new HashMap<String,
EntityInfo>(), true, selection2Update);
}});
jpaMapToolActor.updateSelected();
context.assertIsSatisfied();
@@ -98,7 +102,7 @@
inSequence(sequence);
will(returnValue(javaProject));
- allowing(allEntitiesInfoCollector).initCollector(javaProject);
+ allowing(allEntitiesInfoCollector).initCollector();
inSequence(sequence);
allowing(allEntitiesInfoCollector).collect(compilationUnit);
@@ -126,12 +130,14 @@
inSequence(sequence);
will(returnValue(null));
- allowing(allEntitiesProcessor).modify(javaProject, null, true);
+ allowing(allEntitiesProcessor).modify(null, true, null);
inSequence(sequence);
allowing(allEntitiesProcessor).savePreferences();
inSequence(sequence);
- }});
+
+ exactly(1).of(allEntitiesProcessor).modify(null, true, selection2Update);
+ }});
jpaMapToolActor.updateSelected();
context.assertIsSatisfied();
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java 2009-12-21
17:23:58 UTC (rev 19502)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/JPAMapTest.java 2009-12-21
18:10:08 UTC (rev 19503)
@@ -46,6 +46,7 @@
*
* @author Vitali Yemialyanchyk
*/
+@SuppressWarnings("restriction")
public class JPAMapTest extends TestCase {
public static final String PROJECT_NAME = "TestProject"; //$NON-NLS-1$
@@ -128,7 +129,7 @@
assertNotNull(icu2);
assertNotNull(icu3);
assertNotNull(icu4);
- collector.initCollector(javaProject);
+ collector.initCollector();
collector.collect(icu);
collector.collect(icu2);
collector.collect(icu3);
@@ -138,7 +139,7 @@
}
collector.resolveRelations();
processor.setEnableOptLock(true);
- processor.modify(javaProject, collector.getMapCUs_Info(), false);
+ processor.modify(collector.getMapCUs_Info(), false, null);
//
checkItem("DocumentBase"); //$NON-NLS-1$
checkItem("Document"); //$NON-NLS-1$