Author: dgeraskov
Date: 2008-10-16 10:02:38 -0400 (Thu, 16 Oct 2008)
New Revision: 10886
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/TableFilterView.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1178
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/TableFilterView.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/TableFilterView.java 2008-10-16
14:02:28 UTC (rev 10885)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/TableFilterView.java 2008-10-16
14:02:38 UTC (rev 10886)
@@ -21,17 +21,12 @@
*/
package org.hibernate.eclipse.console.wizards;
-import java.util.ArrayList;
import java.util.Iterator;
-import java.util.List;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.CheckboxCellEditor;
-import org.eclipse.jface.viewers.ICellEditorListener;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
@@ -45,7 +40,6 @@
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.model.IReverseEngineeringDefinition;
import org.hibernate.eclipse.console.model.ITableFilter;
-import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.hibernate.eclipse.console.workbench.DeferredContentProvider;
import org.hibernate.eclipse.console.workbench.LazyDatabaseSchema;
import org.hibernate.eclipse.console.workbench.TableContainer;
@@ -60,11 +54,19 @@
private TableViewer tableViewer;
- private IReverseEngineeringDefinition revEngDef;
+ protected IReverseEngineeringDefinition revEngDef;
public TableFilterView(Composite parent, int style) {
- super( parent, style );
+ super( parent, style );
+ }
+ protected TreeViewer createTreeViewer() {
+ TreeViewer viewer = new TreeViewer( tree );
+ viewer.setLabelProvider( new AnyAdaptableLabelProvider() );
+ viewer.setContentProvider( new DeferredContentProvider() );
+
+ viewer.setInput( null );
+ return viewer;
}
public void setModel(IReverseEngineeringDefinition revEngDef) {
@@ -75,13 +77,7 @@
protected void initialize() {
super.initialize();
tableViewer = createTableFilterViewer();
-
- viewer = new TreeViewer( tree );
- viewer.setLabelProvider( new AnyAdaptableLabelProvider() );
- viewer.setContentProvider( new DeferredContentProvider() );
-
- viewer.setInput( null );
-
+ viewer = createTreeViewer();
}
private TableViewer createTableFilterViewer() {
@@ -133,7 +129,7 @@
return revEngDef.getTableFilters();
}
- private void toggle(boolean exclude) {
+ protected void toggle(boolean exclude) {
ISelection selection = viewer.getSelection();
if ( !selection.isEmpty() ) {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-10-16
14:02:28 UTC (rev 10885)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-10-16
14:02:38 UTC (rev 10886)
@@ -21,6 +21,7 @@
*/
package org.hibernate.eclipse.launch;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.lang.reflect.Constructor;
import java.util.HashSet;
@@ -65,6 +66,7 @@
import org.hibernate.cfg.reveng.OverrideRepository;
import org.hibernate.cfg.reveng.ReverseEngineeringSettings;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
+import org.hibernate.cfg.reveng.TableFilter;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.HibernateConsoleRuntimeException;
import org.hibernate.console.KnownConfigurations;
@@ -264,7 +266,8 @@
final String reverseEngineeringStrategy = attributes.getRevengStrategy();
final boolean preferBasicCompositeids = attributes.isPreferBasicCompositeIds();
final IResource revengres = PathHelper.findMember( root,
attributes.getRevengSettings());
-
+ final String revengTables = attributes.getRevengTables();
+
if(reveng) {
Configuration configuration = null;
if(cc.hasConfiguration()) {
@@ -282,20 +285,24 @@
cc.execute(new Command() { // need to execute in the consoleconfiguration to let it
handle classpath stuff!
- public Object execute() {
+ public Object execute() {
+ //todo: factor this setup of revengstrategy to core
+ ReverseEngineeringStrategy res = new DefaultReverseEngineeringStrategy();
-
- //todo: factor this setup of revengstrategy to core
- DefaultReverseEngineeringStrategy configurableNamingStrategy = new
DefaultReverseEngineeringStrategy();
- //configurableNamingStrategy.setSettings(qqsettings);
-
- ReverseEngineeringStrategy res = configurableNamingStrategy;
- if(revengres!=null) {
+ OverrideRepository repository = null;
+
+ if (revengTables != null){
+ repository = new OverrideRepository();
+ repository.addInputStream(new ByteArrayInputStream(revengTables.getBytes()));
+ } else if(revengres!=null) {
/*Configuration configuration = cc.buildWith(new Configuration(), false);*/
/*Settings settings = cc.getSettings(configuration);*/
File file = PathHelper.getLocation( revengres ).toFile();
- OverrideRepository repository = new
OverrideRepository();///*settings.getDefaultCatalogName(),settings.getDefaultSchemaName()*/);
- repository.addFile(file);
+ repository = new OverrideRepository();
+ repository.addFile(file);
+ }
+
+ if (repository != null){
res = repository.getReverseEngineeringStrategy(res);
}
@@ -308,7 +315,6 @@
.setDetectManyToMany( attributes.detectManyToMany() )
.setDetectOptimisticLock( attributes.detectOptimisticLock() );
- configurableNamingStrategy.setSettings( qqsettings );
res.setSettings(qqsettings);
cfg.setReverseEngineeringStrategy( res );
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2008-10-16
14:02:28 UTC (rev 10885)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java 2008-10-16
14:02:38 UTC (rev 10886)
@@ -46,6 +46,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.StringTokenizer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
@@ -58,6 +59,7 @@
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.model.impl.ExporterDefinition;
import org.hibernate.eclipse.console.model.impl.ExporterFactory;
+import org.hibernate.mapping.Table;
// This class was created to centralize launch configuration attribute loading/saving
// (and also to clean up CodeGenerationLaunchDelegate considerably)
@@ -71,8 +73,10 @@
private String outputPath;
private String templatePath;
private List exporterFactories;
-private boolean autoManyToManyDetection;
-private boolean autoVersioning;
+ // if set then build reveng strategy relying on the list of tables
+ private String revengTables;
+ private boolean autoManyToManyDetection;
+ private boolean autoVersioning;
public ExporterAttributes () { }
@@ -106,8 +110,8 @@
}
exporterFactories = readExporterFactories(configuration);
-
- } catch (CoreException e) {
+ revengTables =
configuration.getAttribute(HibernateLaunchConstants.ATTR_REVENG_TABLES, (String)null);
+ } catch (CoreException e) {
throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
}
}
@@ -351,7 +355,11 @@
return autoVersioning;
}
+ public String getRevengTables() {
+ return revengTables;
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java 2008-10-16
14:02:28 UTC (rev 10885)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/HibernateLaunchConstants.java 2008-10-16
14:02:38 UTC (rev 10886)
@@ -61,5 +61,6 @@
public static final String ATTR_PREFER_BASIC_COMPOSITE_IDS = ATTR_PREFIX +
"prefercompositeids"; //$NON-NLS-1$
public static final String ATTR_AUTOMATIC_MANY_TO_MANY = ATTR_PREFIX +
"reveng.detect_many_to_many"; //$NON-NLS-1$
public static final String ATTR_AUTOMATIC_VERSIONING = ATTR_PREFIX +
"reveng.detect_optimistc_lock"; //$NON-NLS-1$
+ public static final String ATTR_REVENG_TABLES = ATTR_PREFIX +
"reveng.tables";//$NON-NLS-1$
}