[jboss-cvs] jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards ...
Max Rydahl Andersen
mandersen at jboss.com
Wed Nov 15 11:12:08 EST 2006
User: mandersen
Date: 06/11/15 11:12:08
Modified: hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards
ConsoleConfigurationWizardPage.java
ConsoleConfigurationCreationWizard.java
Log:
HBX-822 Automatically use Eclipse's project classpath
HBX-821 Support Hibernate EntityManager/JPA
HBX-823 Do not require hibernate.cfg.xml for core configuration to work
Revision Changes Path
1.24 +60 -18 jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConsoleConfigurationWizardPage.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- ConsoleConfigurationWizardPage.java 23 Oct 2006 13:22:55 -0000 1.23
+++ ConsoleConfigurationWizardPage.java 15 Nov 2006 16:12:08 -0000 1.24
@@ -62,8 +62,10 @@
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
@@ -71,6 +73,7 @@
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.hibernate.console.KnownConfigurations;
+import org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
import org.hibernate.eclipse.console.EclipseConsoleConfiguration;
import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
@@ -91,7 +94,10 @@
private Text configurationNameText;
private Text projectNameText;
private EclipseConsoleConfiguration oldConfiguaration = null;
- private Button enableAnnotations;
+ //private Button enableAnnotations;
+ Button coreMode;
+ Button jpaMode;
+ Button annotationsMode;
private Text entityResolverClassNameText;
@@ -183,7 +189,6 @@
projectNameText.setLayoutData(gd);
projectNameText.addModifyListener(modifyListener);
-
button = new Button(container, SWT.PUSH);
button.setText("Browse...");
button.addSelectionListener(new SelectionAdapter() {
@@ -192,6 +197,8 @@
}
});
+ //label = new Label(container, SWT.NULL);
+ createConfigurationMode( container );
label = new Label(container, SWT.NULL);
@@ -244,8 +251,8 @@
}
});
- label = new Label(container, SWT.NULL);
- enableAnnotations = new Button(container, SWT.CHECK);
+ //configurationMode.
+ /*enableAnnotations = new Button(container, SWT.CHECK);
enableAnnotations.setText("Enable hibernate ejb3/annotations (requires running eclipse with a Java 5 runtime)");
enableAnnotations.addSelectionListener(new SelectionListener() {
@@ -256,11 +263,36 @@
public void widgetSelected(SelectionEvent e) {
dialogChanged();
}
- });
+ });*/
return container;
}
+ private void createConfigurationMode(Composite container) {
+ SelectionListener sl = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ dialogChanged();
+ }
+ };
+ new Label(container, SWT.NULL).setText( "Type:" );
+ Group group = new Group( container, SWT.SHADOW_IN);
+ //group.setText("Choose Hibernate configuration");
+ group.setLayout( new RowLayout( SWT.HORIZONTAL ) );
+ coreMode = new Button(group, SWT.RADIO);
+ coreMode.setText("Core");
+ coreMode.addSelectionListener( sl );
+ coreMode.setSelection( true );
+ annotationsMode = new Button(group, SWT.RADIO);
+ annotationsMode.setText("Annotations (jdk 1.5+)");
+ annotationsMode.addSelectionListener( sl );
+ jpaMode = new Button(group, SWT.RADIO);
+ jpaMode.setText("JPA (jdk 1.5+)");
+ jpaMode.addSelectionListener( sl );
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ group.setLayoutData( gd );
+ }
+
protected void handleEntityResolverBrowse() {
String string = DialogSelectionHelper.chooseImplementation(EntityResolver.class.getName(), entityResolverClassNameText.getText(), "Select entity resolver class", getShell());
if(string!=null) {
@@ -475,7 +507,6 @@
if (!v.mappings.isEmpty() ) mappingFilesViewer.add(v.mappings.toArray(), false);
if (!v.classpath.isEmpty() ) classPathViewer.add(v.classpath.toArray(), false);
useProjectClassPath.setSelection( true );
-
//if(v.javaProject!=null) {
//classPathViewer.add(locateTypes(v.javaProject).toArray(), false);
//}
@@ -492,8 +523,9 @@
if(prefs.getMappings()!=null) mappingFilesViewer.add(prefs.getMappings(),false);
if(prefs.getCustomClasspath()!=null) classPathViewer.add(prefs.getCustomClasspath(),false);
if(prefs.getEntityResolverName()!=null) entityResolverClassNameText.setText(prefs.getEntityResolverName());
- enableAnnotations.setSelection(prefs.useAnnotations());
-
+ jpaMode.setSelection( prefs.getConfigurationMode().equals( ConfigurationMode.JPA ) );
+ coreMode.setSelection( prefs.getConfigurationMode().equals( ConfigurationMode.CORE ) );
+ annotationsMode.setSelection( prefs.getConfigurationMode().equals( ConfigurationMode.ANNOTATIONS ) );
oldConfiguaration = cc;
}
@@ -608,6 +640,8 @@
String propertyFilename = propertyFileText.getText();
String configurationFilename = configurationFileText.getText();
+ configurationFileText.setEnabled( !getConfigurationMode().equals( ConfigurationMode.JPA ) );
+ confbutton.setEnabled( !getConfigurationMode().equals( ConfigurationMode.JPA ) );
if(getConfigurationName()==null || getConfigurationName().trim().length() == 0) {
updateStatus("A name must be specified");
@@ -626,10 +660,12 @@
return;
}
}
- if (propertyFilename.length() == 0 && configurationFilename.trim().length() == 0) {
+
+ /* TODO: warn about implicit behavior of loading /hibernate.cfg.xml, /hibernate.properties and /META-INF/persistence.xml
+ * if (propertyFilename.length() == 0 && configurationFilename.trim().length() == 0) {
updateStatus("Property or Configuration file must be specified");
return;
- }
+ } */
if (propertyFilename.length() > 0) {
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(propertyFilename);
@@ -716,14 +752,20 @@
return entityResolverClassNameText.getText();
}
- public boolean useAnnotations() {
- return enableAnnotations.getSelection();
- }
-
public boolean useProjectClassPath() {
return useProjectClassPath.getSelection();
}
+ public ConfigurationMode getConfigurationMode() {
+ if(annotationsMode.getSelection()) {
+ return ConfigurationMode.ANNOTATIONS;
+ } else if(jpaMode.getSelection()) {
+ return ConfigurationMode.JPA;
+ } else {
+ return ConfigurationMode.CORE;
+ }
+ }
+
}
1.11 +4 -3 jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ConsoleConfigurationCreationWizard.java
===================================================================
RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationCreationWizard.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- ConsoleConfigurationCreationWizard.java 23 Oct 2006 13:22:55 -0000 1.10
+++ ConsoleConfigurationCreationWizard.java 15 Nov 2006 16:12:08 -0000 1.11
@@ -42,6 +42,7 @@
import org.hibernate.console.ImageConstants;
import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
+import org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
import org.hibernate.eclipse.console.EclipseConsoleConfiguration;
import org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
@@ -89,7 +90,7 @@
final String entityResolver = confPage.getEntityResolverClassName();
final IPath propertyFile = confPage.getPropertyFilePath();
final IPath fileName = confPage.getConfigurationFilePath();
- final boolean annotations = confPage.useAnnotations();
+ final ConfigurationMode annotations = confPage.getConfigurationMode();
final IPath[] mappings = confPage.getMappingFiles();
final IPath[] classpaths = confPage.getClassPath();
final boolean useProjectClasspath = confPage.useProjectClassPath();
@@ -128,13 +129,13 @@
static private void createConsoleConfiguration(
EclipseConsoleConfiguration oldConfig,
String configName,
- boolean annotations, String projectName, boolean useProjectClasspath, String entityResolver, IPath propertyFilename,
+ ConfigurationMode cmode, String projectName, boolean useProjectClasspath, String entityResolver, IPath propertyFilename,
IPath cfgFile, IPath[] mappings, IPath[] classpaths, IProgressMonitor monitor)
throws CoreException {
monitor.beginTask("Configuring Hibernate Console" + propertyFilename, IProgressMonitor.UNKNOWN);
- ConsoleConfigurationPreferences ccp = new EclipseConsoleConfigurationPreferences(configName, annotations, projectName, useProjectClasspath, entityResolver, cfgFile, propertyFilename, mappings, classpaths);
+ ConsoleConfigurationPreferences ccp = new EclipseConsoleConfigurationPreferences(configName, cmode, projectName, useProjectClasspath, entityResolver, cfgFile, propertyFilename, mappings, classpaths);
final ConsoleConfiguration cfg = new EclipseConsoleConfiguration(ccp);
More information about the jboss-cvs-commits
mailing list