Author: vyemialyanchyk
Date: 2010-01-05 13:08:29 -0500 (Tue, 05 Jan 2010)
New Revision: 19649
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java
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/process/wizard/EntitiesSource.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/HibernateJPAWizardDataFactory.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/NewHibernateMappingElementsSelectionPage2.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5159 - first step implementation
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionDelegate.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -45,7 +45,7 @@
}
public void run(IAction action) {
- actor.updateSelected();
+ actor.updateSelected(Integer.MAX_VALUE);
//actor.updateOpen();
}
@@ -63,7 +63,7 @@
}
public Object execute(ExecutionEvent event) throws ExecutionException {
- actor.updateSelected();
+ actor.updateSelected(Integer.MAX_VALUE);
//actor.updateOpen();
return null;
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActionPulldownDelegate.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -93,7 +93,7 @@
IAction action = new Action(JdtUiMessages.JPAMapToolActionPulldownDelegate_menu) {
public void run() {
//actor.updateOpen();
- actor.updateSelected();
+ actor.updateSelected(Integer.MAX_VALUE);
}
};
addToMenu(menu, action, -1);
@@ -146,7 +146,7 @@
public void runWithEvent(IAction action, Event event) {
//actor.updateOpen();
- actor.updateSelected();
+ actor.updateSelected(Integer.MAX_VALUE);
}
}
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 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/actions/JPAMapToolActor.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -112,14 +112,15 @@
/**
* updates selected compilation units collection
+ * @param depth - process depth
*/
- public void updateSelected() {
+ public void updateSelected(int depth) {
if (selection != null) {
updateSelectedItems(selection);
selection = null;
} else {
if (getSelectionCUSize() == 0) {
- updateOpen();
+ updateOpen(depth);
return;
}
}
@@ -131,7 +132,7 @@
collector.initCollector();
while (it.hasNext()) {
ICompilationUnit cu = it.next();
- collector.collect(cu);
+ collector.collect(cu, depth);
}
collector.resolveRelations();
if (collector.getNonInterfaceCUNumber() > 0) {
@@ -159,8 +160,9 @@
/**
* update compilation unit of currently opened editor
+ * @param depth - process depth
*/
- public void updateOpen() {
+ public void updateOpen(int depth) {
IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
if (activeWorkbenchWindow == null) {
return;
@@ -177,7 +179,7 @@
//IJavaProject javaProject = cu.getJavaProject();
//collector.initCollector(javaProject);
collector.initCollector();
- collector.collect(cu);
+ collector.collect(cu, depth);
collector.resolveRelations();
if (collector.getNonInterfaceCUNumber() > 0) {
//processor.modify(javaProject, collector.getMapCUs_Info(), true,
createSelection2Update());
@@ -192,7 +194,7 @@
}
public void makePersistent(ICompilationUnit cu) throws CoreException {
- collector.collect(cu);
+ collector.collect(cu, Integer.MAX_VALUE);
}
/**
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 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/collect/AllEntitiesInfoCollector.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -671,9 +671,9 @@
* @param fullyQualifiedName of startup point entity fully qualified name
* example:
"org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector"
*/
- public void collect(String fullyQualifiedName, String projectName) {
+ public void collect(String fullyQualifiedName, String projectName, int depth) {
- if (fullyQualifiedName == null) {
+ if (fullyQualifiedName == null || depth < 0) {
return;
}
if (mapCUs_Info.containsKey(projectName + "/" + fullyQualifiedName)) {
//$NON-NLS-1$
@@ -681,18 +681,19 @@
}
final IJavaProject javaProject = Utils.findJavaProject(projectName);
ICompilationUnit icu = Utils.findCompilationUnit(javaProject, fullyQualifiedName);
- collect(icu);
+ collect(icu, depth);
}
/**
* start to collect information from particular entity class and
* its dependencies
* @param icu - startup point entity compilation unit
+ * @param depth - process depth
*/
@SuppressWarnings("unchecked")
- public void collect(ICompilationUnit icu) {
+ public void collect(ICompilationUnit icu, int depth) {
- if (icu == null) {
+ if (icu == null || depth < 0) {
return;
}
org.eclipse.jdt.core.dom.CompilationUnit cu = Utils.getCompilationUnit(icu, true);
@@ -741,10 +742,12 @@
result.adjustParameters();
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, projectName);
+ if (depth > 0) {
+ Iterator<String> itDep = result.getDependences();
+ while (itDep.hasNext()) {
+ String fullyQualifiedNameTmp = itDep.next();
+ collect(fullyQualifiedNameTmp, projectName, depth - 1);
+ }
}
}
}
Modified:
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 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/EntitiesSource.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -46,6 +46,10 @@
addRemoveTableComposite.getTableViewer().setInput(selection.toArray());
setControl(addRemoveTableComposite);
}
+
+ public int getProcessDepth() {
+ return addRemoveTableComposite.getProcessDepth();
+ }
public IStructuredSelection getSelection() {
TableItem[] items = addRemoveTableComposite.getTableViewer().getTable().getItems();
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 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizard.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -120,8 +120,8 @@
EntitiesList entitiesList = (EntitiesList)targetPage;
final IStructuredSelection selection = entitiesSource.getSelection();
IHibernateJPAWizardData data =
- HibernateJPAWizardDataFactory.createHibernateJPAWizardData(selection,
- params);
+ HibernateJPAWizardDataFactory.createHibernateJPAWizardData(
+ selection, params, entitiesSource.getProcessDepth());
entitiesList.setData(data);
}
}
Modified:
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 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/internal/jpa/process/wizard/HibernateJPAWizardDataFactory.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -51,7 +51,8 @@
@SuppressWarnings("unchecked")
static public IHibernateJPAWizardData createHibernateJPAWizardData(
- final IStructuredSelection selection2Update, IHibernateJPAWizardParams params) {
+ final IStructuredSelection selection2Update,
+ IHibernateJPAWizardParams params, int depth) {
CompilationUnitCollector compileUnitCollector = new CompilationUnitCollector();
Iterator itSelection2Update = selection2Update.iterator();
@@ -64,7 +65,7 @@
collector.initCollector();
while (it.hasNext()) {
ICompilationUnit cu = it.next();
- collector.collect(cu);
+ collector.collect(cu, depth);
}
collector.resolveRelations();
final Map<String, EntityInfo> entities = collector.getMapCUs_Info();
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 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/AddRemoveTableComposite.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -27,6 +27,8 @@
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
@@ -35,6 +37,7 @@
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.SelectionDialog;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.wizards.UpDownListComposite;
import org.hibernate.eclipse.jdt.ui.internal.JdtUiMessages;
@@ -45,6 +48,8 @@
@SuppressWarnings("restriction")
public class AddRemoveTableComposite extends UpDownListComposite {
+ protected Button depthControl;
+
public AddRemoveTableComposite(Composite parent, int style) {
super(parent, style, "", //$NON-NLS-1$
false, new JavaElementLabelProvider(),
@@ -57,6 +62,22 @@
return new String[] { JdtUiMessages.AddRemoveTableComposite_add_class,
JdtUiMessages.AddRemoveTableComposite_add_package};
}
+
+ @Override
+ protected void createAdditionalOptions(Composite parent) {
+ GridData gridData = new org.eclipse.swt.layout.GridData();
+ gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
+ gridData.grabExcessHorizontalSpace = false;
+ gridData.grabExcessVerticalSpace = false;
+ gridData.verticalAlignment = SWT.BOTTOM;
+ depthControl = new Button(parent, SWT.CHECK);
+ depthControl.setText(HibernateConsoleMessages.AddRemoveTableComposite_no_dependencies);
+ depthControl.setLayoutData(gridData);
+ }
+
+ public int getProcessDepth() {
+ return depthControl.getSelection() ? 0 : Integer.MAX_VALUE;
+ }
protected void createColumns(Table table) {
TableColumn column = new TableColumn(table, SWT.NULL);
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 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -87,7 +87,7 @@
*
* @return different configuration for different projects
*/
- public Map<IJavaProject, Configuration> createConfigurations(){
+ public Map<IJavaProject, Configuration> createConfigurations(int processDepth){
Map<IJavaProject, Configuration> configs = new HashMap<IJavaProject,
Configuration>();
if (selectionCU.size() == 0) {
return configs;
@@ -118,7 +118,7 @@
collector.initCollector();
while (setIt.hasNext()) {
ICompilationUnit icu = setIt.next();
- collector.collect(icu);
+ collector.collect(icu, processDepth);
}
collector.resolveRelations();
//I don't check here if any non abstract class selected
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingElementsSelectionPage2.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingElementsSelectionPage2.java 2010-01-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingElementsSelectionPage2.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -55,6 +55,10 @@
return new StructuredSelection(data);
}
+ public int getProcessDepth() {
+ return addRemoveTableComposite.getProcessDepth();
+ }
+
protected void itemsChanged(){
getContainer().updateButtons();
}
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-05
18:07:49 UTC (rev 19648)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java 2010-01-05
18:08:29 UTC (rev 19649)
@@ -87,6 +87,8 @@
private Map<IJavaProject, Collection<EntityInfo>> project_infos = new
HashMap<IJavaProject, Collection<EntityInfo>>();
private IStructuredSelection selection;
+ // process depth of current selection
+ private int processDepth = Integer.MIN_VALUE;
private NewHibernateMappingElementsSelectionPage2 page0 = null;
@@ -360,7 +362,7 @@
collector.initCollector();
while (setIt.hasNext()) {
ICompilationUnit icu = setIt.next();
- collector.collect(icu);
+ collector.collect(icu, processDepth);
}
collector.resolveRelations();
Collection<EntityInfo> c = new ArrayList<EntityInfo>();
@@ -373,16 +375,19 @@
}
}
- protected void processJavaElements(Object obj) {
+ protected void processJavaElements(Object obj, int depth) {
+ if (depth < 0) {
+ return;
+ }
try {
if (obj instanceof ICompilationUnit) {
ICompilationUnit cu = (ICompilationUnit) obj;
selectionCU.add(cu);
- } else if (obj instanceof JavaProject) {
+ } else if (obj instanceof JavaProject && depth > 0) {
JavaProject javaProject = (JavaProject) obj;
IPackageFragmentRoot[] pfr = javaProject.getAllPackageFragmentRoots();
for (IPackageFragmentRoot element : pfr) {
- processJavaElements(element);
+ processJavaElements(element, depth - 1);
}
} else if (obj instanceof PackageFragment) {
PackageFragment packageFragment = (PackageFragment) obj;
@@ -390,12 +395,12 @@
for (ICompilationUnit cu : cus) {
selectionCU.add(cu);
}
- } else if (obj instanceof PackageFragmentRoot) {
+ } else if (obj instanceof PackageFragmentRoot && depth > 0) {
JavaElement javaElement = (JavaElement) obj;
JavaElementInfo javaElementInfo = (JavaElementInfo) javaElement.getElementInfo();
IJavaElement[] je = javaElementInfo.getChildren();
for (IJavaElement element : je) {
- processJavaElements(element);
+ processJavaElements(element, depth - 1);
}
} else if (obj instanceof JavaElement) {
JavaElement javaElement = (JavaElement) obj;
@@ -411,16 +416,18 @@
protected Map<IJavaProject, Configuration> createConfigurations() {
ConfigurationActor actor = new ConfigurationActor(selectionCU);
- Map<IJavaProject, Configuration> configs = actor.createConfigurations();
+ Map<IJavaProject, Configuration> configs =
actor.createConfigurations(processDepth);
return configs;
}
protected void updateCompilationUnits(){
Assert.isNotNull(page0.getSelection(),
JdtUiMessages.NewHibernateMappingFileWizard_selection_cant_be_empty);
- if ((selectionCU == null) || !page0.getSelection().equals(selection)) {
+ if ((selectionCU == null) || !page0.getSelection().equals(selection) ||
+ processDepth != page0.getProcessDepth()) {
selectionCU = new HashSet<ICompilationUnit>();
project_infos.clear();
selection = page0.getSelection();
+ processDepth = page0.getProcessDepth();
try {
getContainer().run(false, false, new IRunnableWithProgress() {
@@ -432,7 +439,7 @@
int done = 1;
while (it.hasNext()) {
Object obj = it.next();
- processJavaElements(obj);
+ processJavaElements(obj, processDepth);
monitor.worked(done++);
}
initEntitiesInfo();