You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2008/11/08 21:42:39 UTC

svn commit: r712429 - in /openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main: java/org/apache/openejb/helper/annotation/wizards/ resources/org/apache/openejb/helper/annotation/wizards/

Author: jgallimore
Date: Sat Nov  8 12:42:38 2008
New Revision: 712429

URL: http://svn.apache.org/viewvc?rev=712429&view=rev
Log:
OEP-9 allow entity manager code generation to be switched on and off

Modified:
    openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBJarSelectionPage.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages.properties
    openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages_de.properties

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBJarSelectionPage.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBJarSelectionPage.java?rev=712429&r1=712428&r2=712429&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBJarSelectionPage.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBJarSelectionPage.java Sat Nov  8 12:42:38 2008
@@ -52,6 +52,7 @@
 	private Button ejb3Interfaces;
 	private Button remoteAndRemoteHomeAnnotations;
 	private Button convertEntityBeansToPojos;
+	private Button generateEntityManagerCode;
 	
 	@Override
 	public void performHelp() {
@@ -142,7 +143,7 @@
 		remoteAndRemoteHomeAnnotations = new Button(container, SWT.CHECK);
 		remoteAndRemoteHomeAnnotations.setLayoutData(checkData);
 		remoteAndRemoteHomeAnnotations.setText(Messages.getString("org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.addRemoteAnnotations")); //$NON-NLS-1$
-		remoteAndRemoteHomeAnnotations.setSelection(false);
+		remoteAndRemoteHomeAnnotations.setSelection(true);
 		remoteAndRemoteHomeAnnotations.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
@@ -163,6 +164,18 @@
 			}
 		});
 		
+		generateEntityManagerCode = new Button(container, SWT.CHECK);
+		generateEntityManagerCode.setLayoutData(checkData);
+		generateEntityManagerCode.setText(Messages.getString("org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.generateEntityFactoryCode")); //$NON-NLS-1$
+		generateEntityManagerCode.setSelection(true);
+		generateEntityManagerCode.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				super.widgetSelected(e);
+				checkPage();
+			}
+		});
+		
 		setControl(container);
 		checkPage();
 	}
@@ -216,11 +229,19 @@
 		String ejbJarXmlFile = ejbJarXmlText.getText();
 		String openEjbJarXmlFile = openEjbJarXmlText.getText();
 		
+		if (convertEntityBeansToPojos.getSelection() == false) {
+			generateEntityManagerCode.setSelection(false);
+			generateEntityManagerCode.setEnabled(false);
+		} else {
+			generateEntityManagerCode.setEnabled(true);
+		}
+		
 		refactoring.setEjbJarXmlFile(ejbJarXmlFile);
 		refactoring.setOpenEjbJarXmlFile(openEjbJarXmlFile);
 		refactoring.setConvertEntityBeansToPojos(convertEntityBeansToPojos.getSelection());
 		refactoring.setEjb3Interfaces(ejb3Interfaces.getSelection());
 		refactoring.setRemoteAndRemoteHomeAnnotations(remoteAndRemoteHomeAnnotations.getSelection());
+		refactoring.setGenerateEntityManagerCode(generateEntityManagerCode.getSelection());
 		
 		if (refactoring.getProject() == null) {
 			setErrorMessage(null);

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java?rev=712429&r1=712428&r2=712429&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/java/org/apache/openejb/helper/annotation/wizards/EJBMigrationRefactoring.java Sat Nov  8 12:42:38 2008
@@ -37,6 +37,7 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.NullChange;
 import org.eclipse.ltk.core.refactoring.Refactoring;
 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
 import org.xml.sax.InputSource;
@@ -51,6 +52,7 @@
 	protected boolean ejb3Interfaces;
 	protected boolean remoteAndRemoteHomeAnnotations;
 	protected boolean convertEntityBeansToPojos;
+	protected boolean generateEntityManagerCode;
 	
 	public EJBMigrationRefactoring(IWorkspaceRoot workspaceRoot) {
 		this.workspaceRoot = workspaceRoot;
@@ -81,10 +83,10 @@
 
 	@Override
 	public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+		InputSource ejbJarInputSource = null;
+		InputSource openEjbJarInputSource = null;
+		
 		try {
-			InputSource ejbJarInputSource = null;
-			InputSource openEjbJarInputSource = null;
-			
 			if (ejbJarXmlFile != null && ejbJarXmlFile.length() > 0) {
 				IFile ejbJarFile = project.getFile(ejbJarXmlFile);
 				if (!(ejbJarFile.exists())) {
@@ -100,7 +102,12 @@
 					openEjbJarInputSource = new InputSource(openEjbJarFile.getContents());
 				}
 			}
-			
+		} catch (Exception e) {
+			status.addFatalError(Messages.getString("org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.fatalError.parse"));
+			return new NullChange();
+		}
+		
+		try {
 			JDTFacade jdtFacade = new JDTFacade(project);
 			
 			List<Converter> converterList = new ArrayList<Converter>();
@@ -118,6 +125,9 @@
 			
 			if (convertEntityBeansToPojos) {
 				converterList.add(new EntityBeanPojoConverter(jdtFacade));
+			}
+			
+			if (generateEntityManagerCode) {
 				converterList.add(new EntityBeanUsageConverter(jdtFacade));
 			}
 			
@@ -135,7 +145,7 @@
 
 		} catch (Exception e) {
 			status.addFatalError(Messages.getString("org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.fatalError") + ":" + e.getLocalizedMessage());
-			return null;
+			return new NullChange();
 		}
 	}
 
@@ -201,4 +211,12 @@
 	public void setConvertEntityBeansToPojos(boolean convertEntityBeansToPojos) {
 		this.convertEntityBeansToPojos = convertEntityBeansToPojos;
 	}
+
+	public boolean isGenerateEntityManagerCode() {
+		return generateEntityManagerCode;
+	}
+
+	public void setGenerateEntityManagerCode(boolean generateEntityManagerCode) {
+		this.generateEntityManagerCode = generateEntityManagerCode;
+	}
 }

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages.properties?rev=712429&r1=712428&r2=712429&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages.properties (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages.properties Sat Nov  8 12:42:38 2008
@@ -13,10 +13,11 @@
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.alterSessionBeanIface=Alter session bean interfaces
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.addRemoteAnnotations=Add @Remote and @RemoteHome annotations
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.convertEntityBeans=Convert entity beans to POJOs
+org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.generateEntityFactoryCode=Generate entity manager code
 org.apache.openejb.helper.annotation.wizards.projectSelectionWzd.pageErrorMsg.1=Please select a project
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.pageDescription=This wizard analyzes ejb-jar.xml and openejb-jar.xml and adds EJB 3.0 annotations to your source
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.pageErrorMsg.1=Please select an ejb-jar.xml file
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.pageErrorMsg.2=Please select a valid openejb-jar.xml file
 org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.refactoringName=EJB 3.0 Annotation Migration Refactoring Wizard
 org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.fatalError=A fatal error occurred
-
+org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.fatalError.parse=Unable to parse ejb-jar.xml / openejb-jar.xml (perhaps they are not up to date?)

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages_de.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages_de.properties?rev=712429&r1=712428&r2=712429&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages_de.properties (original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.helper.annotation/src/main/resources/org/apache/openejb/helper/annotation/wizards/messages_de.properties Sat Nov  8 12:42:38 2008
@@ -13,9 +13,11 @@
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.alterSessionBeanIface=Modifiziere Session Bean Schnittstellen
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.addRemoteAnnotations=@Remote und @RemoteHome Annotationen hinzuf\u00fcgen
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.convertEntityBeans=Entity Beans in POJOs umwandeln
+org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.button.generateEntityFactoryCode=Unternehmen generieren Manager-Code
 org.apache.openejb.helper.annotation.wizards.projectSelectionWzd.pageErrorMsg.1=Bitte w\u00e4hlen Sie ein Projekt aus
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.pageDescription=Dieser Wizard analzsiert die Datei ejb-jar.xml und openejb-jar.xml und f\u00fcgt EJB 3.0 Annotationen den Java-Quelldateien hinzu
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.pageErrorMsg.1=Bitte w\u00e4hlen Sie eine ejb-jar.xml Datei aus
 org.apache.openejb.helper.annotation.wizards.ejbJarSelectionWzd.pageErrorMsg.2=Bitte w\u00e4hlen Sie eine g\u00fcltige openejb-jar.xml Datei aus
 org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.refactoringName=EJB 3.0 Annotation-Migrations- und Refactoring-Wizard
 org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.fatalError=Ein fataler Fehler ist aufgetreten
+org.apache.openejb.helper.annotation.wizards.ejbMigrationWzd.fatalError.parse=Nicht in der Lage zu analysieren ejb-jar.xml / OpenEJB-jar.xml (vielleicht sind sie nicht auf dem neuesten Stand?)
\ No newline at end of file