[jboss-cvs] jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards ...

Max Rydahl Andersen mandersen at jboss.com
Thu Dec 14 06:52:54 EST 2006


  User: mandersen
  Date: 06/12/14 06:52:54

  Modified:    hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards  
                        ConsoleConfigurationWizardPage.java
                        ConsoleConfigurationCreationWizard.java
  Log:
  HBX-839: Support persistence unit name in eclipse 
  HBX-840: Support namingstrategy in eclipse 
  
  Revision  Changes    Path
  1.27      +56 -24    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.26
  retrieving revision 1.27
  diff -u -b -r1.26 -r1.27
  --- ConsoleConfigurationWizardPage.java	10 Dec 2006 01:59:03 -0000	1.26
  +++ ConsoleConfigurationWizardPage.java	14 Dec 2006 11:52:54 -0000	1.27
  @@ -72,6 +72,7 @@
   import org.eclipse.swt.widgets.Table;
   import org.eclipse.swt.widgets.TableItem;
   import org.eclipse.swt.widgets.Text;
  +import org.hibernate.cfg.NamingStrategy;
   import org.hibernate.console.KnownConfigurations;
   import org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
   import org.hibernate.eclipse.console.EclipseConsoleConfiguration;
  @@ -82,6 +83,7 @@
   import org.hibernate.util.StringHelper;
   import org.xml.sax.EntityResolver;
   
  +
   /**
    * @author max
    *
  @@ -93,6 +95,9 @@
   	private Text configurationFileText;
   	private Text configurationNameText;
   	private Text projectNameText;
  +	private Text persistenceUnitNameText;
  +	
  +	
   	private EclipseConsoleConfiguration oldConfiguaration = null;
   	//private Button enableAnnotations;
   	Button coreMode;
  @@ -100,6 +105,7 @@
   	Button annotationsMode;
   	
   	private Text entityResolverClassNameText;
  +	private Text namingStrategyClassNameText;
   	
   	private ISelection selection;
   	private UpDownListComposite mappingFilesViewer;
  @@ -108,6 +114,7 @@
   	private Button confbutton;
   	private Button entbutton;
   	private Button useProjectClassPath;
  +	private Button nambutton;
   	
   	/**
   	 * Constructor for SampleNewWizardPage.
  @@ -235,6 +242,32 @@
   		});
   		
   		label = new Label(container, SWT.NULL);
  +		label.setText("&Persistence unit:");
  +		
  +		persistenceUnitNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
  +		gd = new GridData(GridData.FILL_HORIZONTAL);
  +		gd.horizontalSpan = 2;
  +		persistenceUnitNameText.setLayoutData(gd);
  +		persistenceUnitNameText.addModifyListener(modifyListener);
  +		
  +		label = new Label(container, SWT.NULL);
  +		label.setText("&Naming strategy:");
  +		
  +		namingStrategyClassNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
  +		gd = new GridData(GridData.FILL_HORIZONTAL);
  +		gd.horizontalSpan = 1;
  +		namingStrategyClassNameText.setLayoutData(gd);		
  +		namingStrategyClassNameText.addModifyListener(modifyListener);
  +		
  +		nambutton = new Button(container, SWT.PUSH);
  +		nambutton.setText("Browse...");
  +		nambutton.addSelectionListener(new SelectionAdapter() {
  +			public void widgetSelected(SelectionEvent e) {
  +				handleNamingStrategyBrowse();
  +			}
  +		});
  +	
  +		label = new Label(container, SWT.NULL);
   		label.setText("&Entity resolver:");
   		
   		entityResolverClassNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
  @@ -251,23 +284,11 @@
   			}
   		});
   						
  -		//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() {
  -		
  -			public void widgetDefaultSelected(SelectionEvent e) {
  -				dialogChanged();
  -			}
  -		
  -			public void widgetSelected(SelectionEvent e) {
  -				dialogChanged();		
  -			}
  -		});*/
   		
   		return container;
   	}
   
  +	
   	private void createConfigurationMode(Composite container) {
   		SelectionListener sl = new SelectionAdapter() {
   			public void widgetSelected(SelectionEvent e) {
  @@ -300,14 +321,11 @@
   		}
   	}
   
  -	
  -	private GridData createGridData() {
  -		GridData gd;
  -		gd = new GridData(GridData.FILL_HORIZONTAL);
  -		
  -		gd.horizontalSpan = 3;
  -		gd.verticalSpan = 1;
  -		return gd;
  +	protected void handleNamingStrategyBrowse() {
  +		String string = DialogSelectionHelper.chooseImplementation(NamingStrategy.class.getName(), namingStrategyClassNameText.getText(), "Select naming strategy class", getShell());
  +		if(string!=null) {
  +			namingStrategyClassNameText.setText(string);
  +		}		
   	}
   	
   	
  @@ -523,6 +541,8 @@
   				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());
  +				if(prefs.getNamingStrategy() !=null) namingStrategyClassNameText.setText(prefs.getNamingStrategy());
  +				if(prefs.getPersistenceUnitName()!=null) persistenceUnitNameText.setText( prefs.getPersistenceUnitName() );
   				jpaMode.setSelection( prefs.getConfigurationMode().equals( ConfigurationMode.JPA ) );
   				coreMode.setSelection( prefs.getConfigurationMode().equals( ConfigurationMode.CORE ) );
   				annotationsMode.setSelection( prefs.getConfigurationMode().equals( ConfigurationMode.ANNOTATIONS ) );
  @@ -643,6 +663,8 @@
   		configurationFileText.setEnabled( !configurationFileWillBeCreated && !getConfigurationMode().equals( ConfigurationMode.JPA ) );
   		confbutton.setEnabled( !getConfigurationMode().equals( ConfigurationMode.JPA ) );
   		
  +		persistenceUnitNameText.setEnabled( getConfigurationMode().equals( ConfigurationMode.JPA) );
  +		
   		if(getConfigurationName()==null || getConfigurationName().trim().length() == 0) {
   			updateStatus("A name must be specified");
   			return;
  @@ -776,6 +798,16 @@
   		}
   	}
   
  +	public String getNamingStrategy() {
  +		return namingStrategyClassNameText.getText();
  +	}
  +
  +	public String getPersistenceUnitName() {
  +		return persistenceUnitNameText.getText();
  +	}
  +	
  +	
  +
   }
   
   
  
  
  
  1.13      +8 -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.12
  retrieving revision 1.13
  diff -u -b -r1.12 -r1.13
  --- ConsoleConfigurationCreationWizard.java	17 Nov 2006 19:57:32 -0000	1.12
  +++ ConsoleConfigurationCreationWizard.java	14 Dec 2006 11:52:54 -0000	1.13
  @@ -96,10 +96,12 @@
   		final IPath[] classpaths = confPage.getClassPath();
   		final boolean useProjectClasspath = confPage.useProjectClassPath();
   		final String projectName = confPage.getProjectName();
  +		final String namingStrategy = confPage.getNamingStrategy();
  +		final String persistenceUnitName = confPage.getPersistenceUnitName();
   		IRunnableWithProgress op = new IRunnableWithProgress() {
   			public void run(IProgressMonitor monitor) throws InvocationTargetException {
   				try {
  -					createConsoleConfiguration(confPage.getOldConfiguration(), configName, annotations, projectName, useProjectClasspath, entityResolver, propertyFile, fileName, mappings, classpaths, monitor);
  +					createConsoleConfiguration(confPage.getOldConfiguration(), configName, annotations, projectName, useProjectClasspath, entityResolver, propertyFile, fileName, mappings, classpaths, persistenceUnitName, namingStrategy, monitor);
   				} catch (CoreException e) {
   					throw new InvocationTargetException(e);
   				} finally {
  @@ -131,12 +133,15 @@
   			EclipseConsoleConfiguration oldConfig,
   			String configName,
   			ConfigurationMode cmode, String projectName, boolean useProjectClasspath, String entityResolver, IPath propertyFilename,
  -			IPath cfgFile, IPath[] mappings, IPath[] classpaths, IProgressMonitor monitor)
  +			IPath cfgFile, IPath[] mappings, IPath[] classpaths, String persistenceUnitName, String namingStrategy, IProgressMonitor monitor)
   		throws CoreException {
   
   		monitor.beginTask("Configuring Hibernate Console" + propertyFilename, IProgressMonitor.UNKNOWN);
   								
  -		ConsoleConfigurationPreferences ccp = new EclipseConsoleConfigurationPreferences(configName, cmode, projectName, useProjectClasspath, entityResolver, cfgFile, propertyFilename, mappings, classpaths);
  +		ConsoleConfigurationPreferences ccp = new EclipseConsoleConfigurationPreferences(
  +				configName, cmode, projectName, useProjectClasspath,
  +				entityResolver, cfgFile, propertyFilename, mappings, classpaths,
  +				persistenceUnitName, namingStrategy);
   		
   		
   		final ConsoleConfiguration cfg = new EclipseConsoleConfiguration(ccp);
  
  
  



More information about the jboss-cvs-commits mailing list