### Eclipse Workspace Patch 1.0 #P org.eclipse.jst.jee.ui Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/META-INF/MANIFEST.MF,v retrieving revision 1.27 diff -u -r1.27 MANIFEST.MF --- META-INF/MANIFEST.MF 1 Oct 2009 13:31:12 -0000 1.27 +++ META-INF/MANIFEST.MF 26 Feb 2010 14:58:14 -0000 @@ -37,7 +37,8 @@ org.eclipse.jst.server.core;bundle-version="[1.0.102,2.0.0)", org.eclipse.jst.common.frameworks;bundle-version="[1.1.0,2.0.0)", org.eclipse.jst.j2ee.jca;bundle-version="[1.1.0,2.0.0)", - org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)" + org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", + org.eclipse.jst.ejb.ui;bundle-version="[1.1.0, 2.0.0)" Eclipse-LazyStart: true Bundle-Localization: plugin Bundle-Vendor: %Bundle-Vendor.0 Index: plugin.xml =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/plugin.xml,v retrieving revision 1.35 diff -u -r1.35 plugin.xml --- plugin.xml 16 Feb 2010 15:21:57 -0000 1.35 +++ plugin.xml 26 Feb 2010 14:58:14 -0000 @@ -1353,6 +1353,13 @@ type="org.eclipse.jst.jee.ui.internal.navigator.ejb.BeanNode"> + + + + + Index: src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/NoBeansQuickFixer.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/NoBeansQuickFixer.java diff -N src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/NoBeansQuickFixer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/NoBeansQuickFixer.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,21 @@ +package org.eclipse.jst.jee.ui.internal.quickfixes.ejb; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.ui.IMarkerResolution; +import org.eclipse.ui.IMarkerResolutionGenerator2; + +public class NoBeansQuickFixer implements IMarkerResolutionGenerator2 { + + public IMarkerResolution[] getResolutions(IMarker marker) { + return new IMarkerResolution[] { + new CreateBeanQuickFix(CreateBeanQuickFix.BEAN_TYPE.SESSION, (IProject)marker.getResource()), + new CreateBeanQuickFix(CreateBeanQuickFix.BEAN_TYPE.MESSAGE_DRIVEN, (IProject)marker.getResource()) + }; + } + + public boolean hasResolutions(IMarker marker) { + return true; + } + +} Index: src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/messages.properties =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/messages.properties diff -N src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/messages.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/messages.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,3 @@ +CREATE_NEW_SESSION_BEAN=Create new session bean +CREATE_NEW_MDB=Create new message driven bean + Index: src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/Messages.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/Messages.java diff -N src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/Messages.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/Messages.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2003, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jst.jee.ui.internal.quickfixes.ejb; + +import org.eclipse.osgi.util.NLS; + + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.jst.jee.ui.internal.quickfixes.ejb.messages"; //$NON-NLS-1$ + + + private Messages() { + // Do not instantiate + } + + public static String CREATE_NEW_SESSION_BEAN; + public static String CREATE_NEW_MDB; + + static { + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } +} Index: src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/CreateBeanQuickFix.java =================================================================== RCS file: src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/CreateBeanQuickFix.java diff -N src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/CreateBeanQuickFix.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/jst/jee/ui/internal/quickfixes/ejb/CreateBeanQuickFix.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,57 @@ +package org.eclipse.jst.jee.ui.internal.quickfixes.ejb; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.jst.ejb.ui.internal.wizard.AddMessageDrivenBeanWizard; +import org.eclipse.jst.ejb.ui.internal.wizard.AddSessionBeanWizard; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IMarkerResolution; +import org.eclipse.ui.IWorkbenchWizard; +import org.eclipse.ui.PlatformUI; +import org.eclipse.wst.common.componentcore.internal.operation.IArtifactEditOperationDataModelProperties; +import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard; + +@SuppressWarnings("restriction") +public class CreateBeanQuickFix implements IMarkerResolution { + + public static enum BEAN_TYPE { + SESSION, + MESSAGE_DRIVEN + } + + private BEAN_TYPE beanType; + private IProject project; + + public CreateBeanQuickFix(BEAN_TYPE bType, IProject proj) { + this.beanType = bType; + this.project = proj; + } + + public String getLabel() { + return (beanType == BEAN_TYPE.SESSION) ? + Messages.CREATE_NEW_SESSION_BEAN : + Messages.CREATE_NEW_MDB; + } + + public void run(IMarker marker) { + Runnable r = new Runnable() { + public void run() { + openNewBeanWizard(); + } + }; + Display.getDefault().asyncExec(r); + } + + private void openNewBeanWizard() { + DataModelWizard wizard = (beanType == BEAN_TYPE.SESSION) ? + new AddSessionBeanWizard() : + new AddMessageDrivenBeanWizard(); + wizard.getDataModel().setStringProperty(IArtifactEditOperationDataModelProperties.COMPONENT_NAME, project.getName()); + ((IWorkbenchWizard) wizard).init(PlatformUI.getWorkbench(), new StructuredSelection(project)); + WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); + dialog.open(); + } + +} #P org.eclipse.jst.jee.ejb Index: plugin.properties =================================================================== RCS file: /cvsroot/webtools/ejbtools/plugins/org.eclipse.jst.jee.ejb/plugin.properties,v retrieving revision 1.2 diff -u -r1.2 plugin.properties --- plugin.properties 7 Jun 2007 19:32:48 -0000 1.2 +++ plugin.properties 26 Feb 2010 14:58:17 -0000 @@ -10,4 +10,7 @@ ############################################################################### # properties file for org.eclipse.jst.jee.ejb Bundle-Name.0 = JEE Ejb Plug-in -Bundle-Vendor.0 = Eclipse.org \ No newline at end of file +Bundle-Vendor.0 = Eclipse.org +org.eclipse.jst.jee.ejb3.nobeans.marker.type = EJB Problem +org.eclipse.jst.jee.ejb3.validator.name = EJB 3.x Validator +org.eclipse.jst.jee.ejb3.nobeansmessage.label = No enterprise bean in the EJB project \ No newline at end of file Index: plugin.xml =================================================================== RCS file: /cvsroot/webtools/ejbtools/plugins/org.eclipse.jst.jee.ejb/plugin.xml,v retrieving revision 1.15 diff -u -r1.15 plugin.xml --- plugin.xml 16 Oct 2009 19:04:18 -0000 1.15 +++ plugin.xml 26 Feb 2010 14:58:17 -0000 @@ -13,5 +13,38 @@ - + + + + + + + + + + + + + + + + + + Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/webtools/ejbtools/plugins/org.eclipse.jst.jee.ejb/META-INF/MANIFEST.MF,v retrieving revision 1.18 diff -u -r1.18 MANIFEST.MF --- META-INF/MANIFEST.MF 1 Oct 2009 13:31:23 -0000 1.18 +++ META-INF/MANIFEST.MF 26 Feb 2010 14:58:17 -0000 @@ -22,7 +22,8 @@ org.eclipse.emf.ecore.xmi;bundle-version="[2.2.0,3.0.0)", org.eclipse.jst.j2ee.ejb;bundle-version="[1.1.0,1.2.0)", org.eclipse.wst.common.emf;bundle-version="[1.1.0,2.0.0)", - org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.0,2.0.0)" + org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.0,2.0.0)", + org.eclipse.wst.validation;bundle-version="[1.2.0,2.0.0)" Eclipse-LazyStart: true Bundle-Localization: plugin Bundle-Vendor: %Bundle-Vendor.0 Index: ejb/org/eclipse/jst/jee/ejb/validation/internal/Messages.java =================================================================== RCS file: ejb/org/eclipse/jst/jee/ejb/validation/internal/Messages.java diff -N ejb/org/eclipse/jst/jee/ejb/validation/internal/Messages.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ejb/org/eclipse/jst/jee/ejb/validation/internal/Messages.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2003, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jst.jee.ejb.validation.internal; + +import org.eclipse.osgi.util.NLS; + + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.jst.jee.ejb.validation.internal.messages"; //$NON-NLS-1$ + + + private Messages() { + // Do not instantiate + } + + public static String NO_BEANS_ERROR; + public static String NO_BEANS_ERROR_LOCATION; + + static { + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } +} Index: ejb/org/eclipse/jst/jee/ejb/validation/internal/UIEJB3Validator.java =================================================================== RCS file: ejb/org/eclipse/jst/jee/ejb/validation/internal/UIEJB3Validator.java diff -N ejb/org/eclipse/jst/jee/ejb/validation/internal/UIEJB3Validator.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ejb/org/eclipse/jst/jee/ejb/validation/internal/UIEJB3Validator.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,81 @@ +package org.eclipse.jst.jee.ejb.validation.internal; + +import java.text.MessageFormat; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jst.j2ee.model.ModelProviderManager; +import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; +import org.eclipse.jst.javaee.ejb.EJBJar; +import org.eclipse.jst.javaee.ejb.EnterpriseBeans; +import org.eclipse.jst.jee.ejb.Activator; +import org.eclipse.wst.validation.AbstractValidator; +import org.eclipse.wst.validation.ValidationEvent; +import org.eclipse.wst.validation.ValidationResult; +import org.eclipse.wst.validation.ValidationState; +import org.eclipse.wst.validation.Validator; +import org.eclipse.wst.validation.ValidatorMessage; +import org.eclipse.wst.validation.internal.MarkerManager; +import org.eclipse.wst.validation.internal.ValManager; +import org.eclipse.wst.validation.internal.ValOperation; + +@SuppressWarnings("restriction") +public class UIEJB3Validator extends AbstractValidator { + + public static String ID = "org.eclipse.jst.jee.ejb3.validator"; //$NON-NLS-1$ + public static String MARKER_ID_NO_BEANS = "org.eclipse.jst.jee.ejb3.nobeans"; //$NON-NLS-1$ + + @Override + public void validationStarting(IProject project, ValidationState state, IProgressMonitor monitor){ + Validator v = ValManager.getDefault().getValidator(UIEJB3Validator.ID, project); + if (project != null) + ValManager.getDefault().validate(v, new ValOperation(), project, IResourceDelta.NO_CHANGE, new NullProgressMonitor(), null); + } + + @Override + public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) { + if ((resource == null) || !IProject.class.isInstance(resource)) + return null; + IProject proj = (IProject)resource; + try { + MarkerManager.getDefault().clearMarker(proj, getParent()); + } catch (CoreException e) { + Activator.logError(e); + } + if (!JavaEEProjectUtilities.isEJBProject(proj)) + return null; + EJBJar ejbJar = (EJBJar)ModelProviderManager.getModelProvider(proj).getModelObject(); + EnterpriseBeans ebs = ejbJar.getEnterpriseBeans(); + if (ebs.getSessionBeans().size() + ebs.getMessageDrivenBeans().size() == 0) { + ValidationResult vRes = new ValidationResult(); + ValidatorMessage vMsg = createValidatorMessage(Messages.NO_BEANS_ERROR, proj, IMarker.SEVERITY_ERROR, IMarker.PRIORITY_HIGH); + vRes.add(vMsg); + return vRes; + } + return null; + } + + @Override + public ValidationResult validate(ValidationEvent event, ValidationState state, IProgressMonitor monitor){ + IResource res = event.getResource(); + return validate(res, 0, state, monitor); + } + + private static ValidatorMessage createValidatorMessage(String txt, + IResource res, + int severity, + int priority) { + ValidatorMessage msg = ValidatorMessage.create(txt, res); + msg.setAttribute(IMarker.SEVERITY, severity); + msg.setAttribute(IMarker.PRIORITY, priority); + msg.setAttribute(IMarker.LOCATION, MessageFormat.format(Messages.NO_BEANS_ERROR_LOCATION, new Object[] { res.getName() })); + msg.setType(MARKER_ID_NO_BEANS); + return msg; + } + +} Index: ejb/org/eclipse/jst/jee/ejb/validation/internal/messages.properties =================================================================== RCS file: ejb/org/eclipse/jst/jee/ejb/validation/internal/messages.properties diff -N ejb/org/eclipse/jst/jee/ejb/validation/internal/messages.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ejb/org/eclipse/jst/jee/ejb/validation/internal/messages.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,2 @@ +NO_BEANS_ERROR=An EJB module must contain one or more enterprise beans. +NO_BEANS_ERROR_LOCATION={0} project