[jboss-cvs] jbosside/ejb3/plugins/org.jboss.ide.eclipse.ejb3.wizards.ui/src/main/org/jboss/ide/eclipse/ejb3/ui/wizards ...

Robert Stryker rawblem at gmail.com
Fri Feb 9 15:11:05 EST 2007


  User: rawb    
  Date: 07/02/09 15:11:05

  Added:       ejb3/plugins/org.jboss.ide.eclipse.ejb3.wizards.ui/src/main/org/jboss/ide/eclipse/ejb3/ui/wizards     
                        Ejb30ProjectWizard.java NewSessionBeanWizard.java
                        NewMessageDrivenBeanWizard.java
                        NewEJB3ProjectWizard.java
                        Ejb30ProjectFirstPage.java
  Log:
  Recomit all? 
  
  Revision  Changes    Path
  1.5       +0 -0      jbosside/ejb3/plugins/org.jboss.ide.eclipse.ejb3.wizards.ui/src/main/org/jboss/ide/eclipse/ejb3/ui/wizards/Ejb30ProjectWizard.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Ejb30ProjectWizard.java
  ===================================================================
  RCS file: Ejb30ProjectWizard.java
  diff -N Ejb30ProjectWizard.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ Ejb30ProjectWizard.java	9 Feb 2007 20:11:05 -0000	1.5
  @@ -0,0 +1,54 @@
  +package org.jboss.ide.eclipse.ejb3.ui.wizards;
  +
  +import java.net.URL;
  +
  +import org.eclipse.core.runtime.Platform;
  +import org.eclipse.jface.resource.ImageDescriptor;
  +import org.eclipse.jface.wizard.IWizardPage;
  +import org.eclipse.ui.INewWizard;
  +import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
  +import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
  +import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
  +import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
  +import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
  +import org.jboss.ide.eclipse.ejb3.core.facet.Ejb30FacetProjectCreationDataModelProvider;
  +import org.osgi.framework.Bundle;
  +
  +public class Ejb30ProjectWizard extends NewProjectDataModelFacetWizard
  +		implements INewWizard {
  +
  +	public Ejb30ProjectWizard(IDataModel model){
  +		super(model);
  +		setWindowTitle("Create a EJB3 Project");
  +	}
  +	
  +	public Ejb30ProjectWizard(){
  +		super();
  +		setWindowTitle("Create a EJB3 Project");
  +	}
  +	
  +	protected IDataModel createDataModel() {
  +		return DataModelFactory.createDataModel(new Ejb30FacetProjectCreationDataModelProvider());
  +	}
  +
  +	protected IFacetedProjectTemplate getTemplate() {
  +		return ProjectFacetsManager.getTemplate("template.jbide.ejb30"); //$NON-NLS-1$
  +	}
  +
  +	protected IWizardPage createFirstPage() {
  +		return new Ejb30ProjectFirstPage(model, "first.page"); //$NON-NLS-1$
  +	}
  +	
  +	// TODO: change
  +	protected ImageDescriptor getDefaultPageImageDescriptor() {
  +		final Bundle bundle = Platform.getBundle("org.eclipse.jst.ejb.ui"); //$NON-NLS-1$
  +		final URL url = bundle.getEntry("icons/full/wizban/ejbproject_wiz.gif"); //$NON-NLS-1$
  +		return ImageDescriptor.createFromURL(url);
  +	}
  +	
  +	// Let's you switch to another perspective
  +	protected String getFinalPerspectiveID() {
  +		return null;
  +	}
  +
  +}
  
  
  
  1.3       +0 -0      jbosside/ejb3/plugins/org.jboss.ide.eclipse.ejb3.wizards.ui/src/main/org/jboss/ide/eclipse/ejb3/ui/wizards/NewSessionBeanWizard.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NewSessionBeanWizard.java
  ===================================================================
  RCS file: NewSessionBeanWizard.java
  diff -N NewSessionBeanWizard.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ NewSessionBeanWizard.java	9 Feb 2007 20:11:05 -0000	1.3
  @@ -0,0 +1,93 @@
  +/*
  + * JBoss, a division of Red Hat
  + * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
  + * by the @authors tag. See the copyright.txt in the distribution for a
  + * full listing of individual contributors.
  + *
  + * This is free software; you can redistribute it and/or modify it
  + * under the terms of the GNU Lesser General Public License as
  + * published by the Free Software Foundation; either version 2.1 of
  + * the License, or (at your option) any later version.
  + *
  + * This software is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this software; if not, write to the Free
  + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  + */
  +package org.jboss.ide.eclipse.ejb3.ui.wizards;
  +
  +import org.eclipse.core.resources.IFile;
  +import org.eclipse.core.resources.IResource;
  +import org.eclipse.core.runtime.CoreException;
  +import org.eclipse.core.runtime.IProgressMonitor;
  +import org.eclipse.jdt.core.IJavaElement;
  +import org.eclipse.jdt.internal.ui.JavaPluginImages;
  +import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
  +import org.eclipse.jdt.ui.ISharedImages;
  +import org.eclipse.jdt.ui.JavaUI;
  +import org.eclipse.jface.viewers.IStructuredSelection;
  +import org.eclipse.ui.IWorkbench;
  +import org.jboss.ide.eclipse.ejb3.ui.wizards.pages.NewSessionBeanWizardPage;
  +
  +/**
  + * @author Marshall
  + */
  +public class NewSessionBeanWizard extends NewElementWizard
  +{
  +
  +   NewSessionBeanWizardPage page;
  +
  +   private IStructuredSelection selection;
  +
  +   public NewSessionBeanWizard ()
  +   {
  +	   super();
  +	   setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWCLASS);
  +	   setWindowTitle("New Session Bean");
  +   }
  +   
  +   public void init(IWorkbench workbench, IStructuredSelection selection)
  +   {
  +      page = new NewSessionBeanWizardPage();
  +      this.selection = selection;
  +      
  +      super.init(workbench, selection);
  +   }
  +
  +   public boolean performFinish()
  +   {
  +      warnAboutTypeCommentDeprecation();
  +      boolean res = super.performFinish();
  +      if (res)
  +      {
  +         IResource resource = page.getModifiedResource();
  +         if (resource != null)
  +         {
  +            selectAndReveal(resource);
  +            openResource((IFile) resource);
  +         }
  +      }
  +      return true;
  +   }
  +
  +   public void addPages()
  +   {
  +      addPage(page);
  +      page.init(selection);
  +   }
  +
  +   protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException
  +   {
  +      page.createType(monitor);
  +   }
  +
  +   public IJavaElement getCreatedElement()
  +   {
  +      return page.getCreatedType();
  +   }
  +}
  
  
  
  1.3       +0 -0      jbosside/ejb3/plugins/org.jboss.ide.eclipse.ejb3.wizards.ui/src/main/org/jboss/ide/eclipse/ejb3/ui/wizards/NewMessageDrivenBeanWizard.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NewMessageDrivenBeanWizard.java
  ===================================================================
  RCS file: NewMessageDrivenBeanWizard.java
  diff -N NewMessageDrivenBeanWizard.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ NewMessageDrivenBeanWizard.java	9 Feb 2007 20:11:05 -0000	1.3
  @@ -0,0 +1,87 @@
  +/*
  + * JBoss, a division of Red Hat
  + * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
  + * by the @authors tag. See the copyright.txt in the distribution for a
  + * full listing of individual contributors.
  + *
  + * This is free software; you can redistribute it and/or modify it
  + * under the terms of the GNU Lesser General Public License as
  + * published by the Free Software Foundation; either version 2.1 of
  + * the License, or (at your option) any later version.
  + *
  + * This software is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this software; if not, write to the Free
  + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  + */
  +package org.jboss.ide.eclipse.ejb3.ui.wizards;
  +
  +import org.eclipse.core.resources.IFile;
  +import org.eclipse.core.resources.IResource;
  +import org.eclipse.core.runtime.CoreException;
  +import org.eclipse.core.runtime.IProgressMonitor;
  +import org.eclipse.jdt.core.IJavaElement;
  +import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;
  +import org.eclipse.jface.viewers.IStructuredSelection;
  +import org.eclipse.ui.IWorkbench;
  +import org.jboss.ide.eclipse.ejb3.ui.wizards.pages.NewMessageDrivenBeanWizardPage;
  +
  +/**
  + * @author Marshall
  + *
  + * TODO To change the template for this generated type comment go to
  + * Window - Preferences - Java - Code Style - Code Templates
  + */
  +public class NewMessageDrivenBeanWizard extends NewElementWizard
  +{
  +
  +   NewMessageDrivenBeanWizardPage page;
  +
  +   private IStructuredSelection selection;
  +
  +   public void init(IWorkbench workbench, IStructuredSelection selection)
  +   {
  +      page = new NewMessageDrivenBeanWizardPage();
  +      this.selection = selection;
  +
  +      super.init(workbench, selection);
  +   }
  +
  +   public boolean performFinish()
  +   {
  +      warnAboutTypeCommentDeprecation();
  +      boolean res = super.performFinish();
  +      if (res)
  +      {
  +         IResource resource = page.getModifiedResource();
  +         if (resource != null)
  +         {
  +            selectAndReveal(resource);
  +            openResource((IFile) resource);
  +         }
  +      }
  +      return true;
  +   }
  +
  +   public void addPages()
  +   {
  +      addPage(page);
  +      page.init(selection);
  +   }
  +
  +   protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException
  +   {
  +      page.createType(monitor);
  +   }
  +
  +   public IJavaElement getCreatedElement()
  +   {
  +      return page.getCreatedType();
  +   }
  +
  +}
  
  
  
  1.3       +0 -0      jbosside/ejb3/plugins/org.jboss.ide.eclipse.ejb3.wizards.ui/src/main/org/jboss/ide/eclipse/ejb3/ui/wizards/NewEJB3ProjectWizard.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: NewEJB3ProjectWizard.java
  ===================================================================
  RCS file: NewEJB3ProjectWizard.java
  diff -N NewEJB3ProjectWizard.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ NewEJB3ProjectWizard.java	9 Feb 2007 20:11:05 -0000	1.3
  @@ -0,0 +1,372 @@
  +/*
  + * JBoss, a division of Red Hat
  + * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
  + * by the @authors tag. See the copyright.txt in the distribution for a
  + * full listing of individual contributors.
  + *
  + * This is free software; you can redistribute it and/or modify it
  + * under the terms of the GNU Lesser General Public License as
  + * published by the Free Software Foundation; either version 2.1 of
  + * the License, or (at your option) any later version.
  + *
  + * This software is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this software; if not, write to the Free
  + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  + */
  +package org.jboss.ide.eclipse.ejb3.ui.wizards;
  +
  +import java.io.ByteArrayInputStream;
  +import java.io.File;
  +import java.io.FileFilter;
  +import java.lang.reflect.InvocationTargetException;
  +import java.util.ArrayList;
  +import java.util.Iterator;
  +
  +import org.eclipse.core.internal.resources.ResourceException;
  +import org.eclipse.core.resources.IFile;
  +import org.eclipse.core.resources.IFolder;
  +import org.eclipse.core.resources.IProject;
  +import org.eclipse.core.resources.IResource;
  +import org.eclipse.core.resources.IResourceVisitor;
  +import org.eclipse.core.resources.ResourcesPlugin;
  +import org.eclipse.core.runtime.CoreException;
  +import org.eclipse.core.runtime.IPath;
  +import org.eclipse.core.runtime.IProgressMonitor;
  +import org.eclipse.core.runtime.NullProgressMonitor;
  +import org.eclipse.core.runtime.Path;
  +import org.eclipse.jdt.core.IClasspathEntry;
  +import org.eclipse.jdt.core.IJavaProject;
  +import org.eclipse.jdt.core.JavaCore;
  +import org.eclipse.jdt.core.JavaModelException;
  +import org.eclipse.jdt.internal.ui.util.CoreUtility;
  +import org.eclipse.jdt.internal.ui.wizards.JavaProjectWizardSecondPage;
  +import org.eclipse.jdt.launching.JavaRuntime;
  +import org.eclipse.jface.dialogs.ProgressMonitorDialog;
  +import org.eclipse.jface.operation.IRunnableWithProgress;
  +import org.eclipse.jface.viewers.IStructuredSelection;
  +import org.eclipse.jface.wizard.Wizard;
  +import org.eclipse.ui.INewWizard;
  +import org.eclipse.ui.IWorkbench;
  +import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
  +import org.jboss.ide.eclipse.ejb3.core.classpath.EJB3ClasspathContainer;
  +import org.jboss.ide.eclipse.ejb3.ui.EJB3WizardsUIPlugin;
  +import org.jboss.ide.eclipse.ejb3.ui.wizards.pages.JBossEJB3LibrariesPage;
  +import org.jboss.ide.eclipse.jdt.aop.core.AopCorePlugin;
  +import org.jboss.ide.eclipse.jdt.aop.core.classpath.AopJdk15ClasspathContainer;
  +
  +/**
  + * @author Marshall
  + */
  +public class NewEJB3ProjectWizard extends Wizard implements INewWizard
  +{
  +
  +   protected WizardNewProjectCreationPage page1;
  +
  +   protected JBossEJB3LibrariesPage page2;
  +
  +   public void addPages()
  +   {
  +      page1 = new WizardNewProjectCreationPage("EJB3 Project Wizard");
  +      page1.setDescription("Create a EJB 3.0 Project in the workspace or in an external location.");
  +      page1.setTitle("Create a EJB3 Project");
  +
  +      page2 = new JBossEJB3LibrariesPage();
  +      page2.setDescription("Select a JBoss configuration that has the JBoss EJB3 container installed.");
  +      page2.setTitle("Select a JBoss configuration");
  +      addPage(page1);
  +      addPage(page2);
  +   }
  +
  +   private ArrayList findSourcePaths(IProject project) throws CoreException
  +   {
  +      final ArrayList sourcePaths = new ArrayList();
  +      project.accept(new IResourceVisitor()
  +      {
  +         public boolean visit(IResource resource) throws CoreException
  +         {
  +            if (resource.getType() == IResource.FILE && resource.getFileExtension().equals("java"))
  +            {
  +               IPath dir = resource.getFullPath().removeLastSegments(1);
  +
  +               for (int i = 0; i < dir.segmentCount(); i++)
  +               {
  +                  if (dir.segment(i).equalsIgnoreCase("org") || dir.segment(i).equalsIgnoreCase("net")
  +                        || dir.segment(i).equalsIgnoreCase("com") || dir.segment(i).equalsIgnoreCase("edu"))
  +                  {
  +                     dir = dir.uptoSegment(i - 1);
  +                     break;
  +                  }
  +               }
  +               if (!sourcePaths.contains(dir))
  +               {
  +                  sourcePaths.add(dir);
  +               }
  +            }
  +            return true;
  +         }
  +      });
  +
  +      return sourcePaths;
  +   }
  +
  +   private class OutputLocationFinder implements IResourceVisitor
  +   {
  +      private IPath outputLocation;
  +
  +      public OutputLocationFinder()
  +      {
  +         outputLocation = null;
  +      }
  +
  +      public IPath getOuptutLocation()
  +      {
  +         return outputLocation;
  +      }
  +
  +      public boolean visit(IResource resource) throws CoreException
  +      {
  +         if (resource.getType() == IResource.FILE && resource.getFileExtension().equals("class"))
  +         {
  +            outputLocation = resource.getFullPath().removeLastSegments(1);
  +            return false;
  +         }
  +         return true;
  +      }
  +   }
  +
  +   private IPath findOutputLocation(IProject project) throws CoreException
  +   {
  +      OutputLocationFinder finder = new OutputLocationFinder();
  +      project.accept(finder);
  +
  +      return finder.getOuptutLocation();
  +   }
  +
  +   private void createSrcAndBin(IJavaProject project, IProgressMonitor monitor) throws CoreException
  +   {
  +      IPath srcLocation = project.getProject().getFullPath().append(new Path("/src"));
  +      IPath outputLocation = project.getProject().getFullPath().append(new Path("/bin"));
  +
  +      createFolder(srcLocation, monitor);
  +      createFolder(outputLocation, monitor);
  +
  +      ArrayList entries = new ArrayList();
  +      entries.add(JavaCore.newSourceEntry(srcLocation));
  +
  +      createJndiProperties(srcLocation);
  +      project.setRawClasspath(configureClasspathEntries(entries), outputLocation, monitor);
  +   }
  +
  +   private void createFolder(IPath location, IProgressMonitor monitor) throws CoreException
  +   {
  +      if (!ResourcesPlugin.getWorkspace().getRoot().exists(location))
  +      {
  +         IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(location);
  +         try
  +         {
  +            CoreUtility.createFolder(folder, true, true, monitor);
  +         }
  +         catch (ResourceException e)
  +         {
  +
  +         }
  +      }
  +   }
  +
  +   private IClasspathEntry[] getDefaultClasspathEntries() throws CoreException
  +   {
  +      return new IClasspathEntry[]
  +      {JavaRuntime.getDefaultJREContainerEntry()};
  +   }
  +
  +   private IClasspathEntry[] configureClasspathEntries(ArrayList classpathEntries) throws CoreException
  +   {
  +      IClasspathEntry defaultEntries[] = getDefaultClasspathEntries();
  +      for (int i = 0; i < defaultEntries.length; i++)
  +      {
  +         classpathEntries.add(defaultEntries[i]);
  +      }
  +
  +      classpathEntries.add(JavaCore.newContainerEntry(new Path(AopJdk15ClasspathContainer.CONTAINER_ID)));
  +      classpathEntries.add(JavaCore.newContainerEntry(new Path(EJB3ClasspathContainer.CONTAINER_ID).append(page2
  +            .getServer().getServer().getName())));
  +
  +      return (IClasspathEntry[]) classpathEntries.toArray(new IClasspathEntry[classpathEntries.size()]);
  +   }
  +
  +   private void createJndiProperties(IPath srcPath) throws CoreException
  +   {
  +      IPath jndiPath = srcPath.append("jndi.properties");
  +      IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(jndiPath);
  +
  +      String jndiProps = "java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory\n"
  +            + "java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces\n"
  +            + "java.naming.provider.url=localhost:1099\n";
  +
  +      file.create(new ByteArrayInputStream(jndiProps.getBytes()), true, new NullProgressMonitor());
  +   }
  +
  +   private class JndiPropertiesFileFilter implements FileFilter
  +   {
  +      public boolean accept(File file)
  +      {
  +         return (file.getName().equals("jndi.properties"));
  +      }
  +   }
  +
  +   private boolean is15Classpath(IJavaProject javaProject)
  +   {
  +      try
  +      {
  +         return javaProject.findType("java.lang.Enum") != null; //$NON-NLS-1$
  +      }
  +      catch (JavaModelException e)
  +      {
  +         // ignore
  +         return false;
  +      }
  +   }
  +
  +   public boolean performFinish()
  +   {
  +      IRunnableWithProgress op = new IRunnableWithProgress()
  +      {
  +         public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
  +         {
  +            try
  +            {
  +               monitor.beginTask("Configuring EJB3 Classpath...", 1);
  +               boolean page2Finished = page2.finish();
  +
  +               if (!page2Finished)
  +               {
  +                  throw new InterruptedException();
  +               }
  +
  +               monitor.worked(1);
  +
  +               monitor.beginTask("Applying natures..", 2);
  +               IProject project = page1.getProjectHandle();
  +
  +               JavaProjectWizardSecondPage.createProject(project, page1.getLocationPath(), monitor);
  +               AopCorePlugin.addProjectNature(project, JavaCore.NATURE_ID);
  +               monitor.worked(1);
  +
  +               IJavaProject javaProject = JavaCore.create(project);
  +               javaProject.setRawClasspath(getDefaultClasspathEntries(), monitor);
  +               monitor.worked(1);
  +
  +               if (!is15Classpath(javaProject))
  +               {
  +                  EJB3WizardsUIPlugin
  +                        .warn("EJB3 Projects require a 5.0 JRE to compile. "
  +                              + "Since a 5.0 JRE isn't available, a simple java project will be created with your current default JRE. "
  +                              + "After you have installed a 5.0 JRE you can add JBoss EJB3 Libraries to your Java Project under "
  +                              + "Project Properties > Java Build Path > Libraries > Add Library.");
  +
  +                  return;
  +               }
  +
  +               //EJB3ProjectNature.ensureAopProjectNature(javaProject);
  +               AopCorePlugin.getDefault().setJava50CompilerCompliance(javaProject);
  +
  +               ArrayList sourcePaths = findSourcePaths(project);
  +               IPath outputLocation = findOutputLocation(project);
  +
  +               if (sourcePaths.size() > 0)
  +               {
  +                  ArrayList cpEntries = new ArrayList();
  +                  boolean jndiPropertiesExists = false;
  +                  JndiPropertiesFileFilter jndiFilter = new JndiPropertiesFileFilter();
  +
  +                  for (Iterator iter = sourcePaths.iterator(); iter.hasNext();)
  +                  {
  +                     IPath sourcePath = (IPath) iter.next();
  +                     cpEntries.add(JavaCore.newSourceEntry(sourcePath));
  +
  +                     if (!jndiPropertiesExists)
  +                     {
  +                        File propFiles[] = sourcePath.toFile().listFiles(jndiFilter);
  +                        if (propFiles != null && propFiles.length > 0)
  +                        {
  +                           jndiPropertiesExists = true;
  +                        }
  +                     }
  +                  }
  +
  +                  if (!jndiPropertiesExists)
  +                  {
  +                     IPath sourcePath = (IPath) sourcePaths.iterator().next();
  +                     try
  +                     {
  +                        createJndiProperties(sourcePath);
  +                     }
  +                     catch (Exception e)
  +                     {
  +
  +                     }
  +                  }
  +
  +                  if (outputLocation == null)
  +                  {
  +                     EJB3WizardsUIPlugin.alert("While importing existing source, JBossIDE was unable to find"
  +                           + " a location to place compiled java class files. The directory \"bin\" will"
  +                           + " be created under the project directory and used as an output location instead.");
  +
  +                     outputLocation = project.getProject().getFullPath().append(new Path("/bin"));
  +                     createFolder(outputLocation, monitor);
  +                  }
  +
  +                  javaProject.getProject().getPersistentProperty(EJB3ClasspathContainer.JBOSS_EJB3_CONFIGURATION);
  +                  javaProject.setRawClasspath(configureClasspathEntries(cpEntries), outputLocation, monitor);
  +
  +               }
  +               else
  +               {
  +                  createSrcAndBin(javaProject, monitor);
  +               }
  +            }
  +            catch (CoreException e)
  +            {
  +               e.printStackTrace();
  +            }
  +
  +            monitor.done();
  +         }
  +      };
  +
  +      try
  +      {
  +         new ProgressMonitorDialog(getShell()).run(false, true, op);
  +      }
  +      catch (InterruptedException e)
  +      {
  +         return false;
  +      }
  +      catch (Exception e)
  +      {
  +         e.printStackTrace();
  +      }
  +
  +      return true;
  +   }
  +
  +   public void init(IWorkbench workbench, IStructuredSelection selection)
  +   {
  +   }
  +
  +   public boolean canFinish()
  +   {
  +      if (page2 == null)
  +         return false;
  +
  +      return page2.getServer() != null;
  +   }
  +
  +}
  
  
  
  1.5       +0 -0      jbosside/ejb3/plugins/org.jboss.ide.eclipse.ejb3.wizards.ui/src/main/org/jboss/ide/eclipse/ejb3/ui/wizards/Ejb30ProjectFirstPage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Ejb30ProjectFirstPage.java
  ===================================================================
  RCS file: Ejb30ProjectFirstPage.java
  diff -N Ejb30ProjectFirstPage.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ Ejb30ProjectFirstPage.java	9 Feb 2007 20:11:05 -0000	1.5
  @@ -0,0 +1,128 @@
  +package org.jboss.ide.eclipse.ejb3.ui.wizards;
  +
  +import java.util.ArrayList;
  +import java.util.Arrays;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Set;
  +
  +import org.eclipse.jface.dialogs.IDialogSettings;
  +import org.eclipse.jst.j2ee.internal.wizard.J2EEComponentFacetCreationWizardPage;
  +import org.eclipse.swt.SWT;
  +import org.eclipse.swt.events.SelectionAdapter;
  +import org.eclipse.swt.events.SelectionEvent;
  +import org.eclipse.swt.layout.GridLayout;
  +import org.eclipse.swt.widgets.Button;
  +import org.eclipse.swt.widgets.Combo;
  +import org.eclipse.swt.widgets.Composite;
  +import org.eclipse.swt.widgets.Control;
  +import org.eclipse.swt.widgets.Display;
  +import org.eclipse.swt.widgets.Group;
  +import org.eclipse.swt.widgets.Label;
  +import org.eclipse.swt.widgets.Shell;
  +import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
  +import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
  +import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
  +import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
  +import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
  +import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
  +import org.eclipse.wst.common.project.facet.core.runtime.internal.RuntimeComponent;
  +import org.eclipse.wst.common.project.facet.core.runtime.internal.RuntimeManagerImpl;
  +import org.eclipse.wst.project.facet.ProductManager;
  +import org.eclipse.wst.web.internal.ResourceHandler;
  +import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage;
  +
  +public class Ejb30ProjectFirstPage extends J2EEComponentFacetCreationWizardPage {
  +	public static final String EJB30_FACET_ID = "jbide.ejb30";
  +
  +	protected String getModuleFacetID() {
  +		return EJB30_FACET_ID;
  +	}
  +	protected String getModuleTypeID() {
  +		return null;
  +	}
  +
  +	public Ejb30ProjectFirstPage(IDataModel model, String pageName) {
  +		super(model, pageName);
  +		setTitle("Create a EJB3 Project");
  +		setDescription("Create a EJB3 Project in the workspace");
  +	}
  +	
  +	
  +	public void restoreDefaultSettings() {
  +		IDialogSettings settings = getDialogSettings();
  +		//restoreRuntimeSettings2(settings, model);
  +	}
  +
  +	private static String NULL_RUNTIME = "NULL_RUNTIME"; //$NON-NLS-1$
  +	private static String MRU_RUNTIME_STORE = "MRU_RUNTIME_STORE"; //$NON-NLS-1$
  +
  +	private void restoreRuntimeSettings2(IDialogSettings settings, IDataModel model){
  +		if (settings != null) {
  +			if (!model.isPropertySet(IFacetProjectCreationDataModelProperties.FACET_RUNTIME)) {
  +				boolean runtimeSet = false;
  +				String[] mruRuntimeArray = settings.getArray(MRU_RUNTIME_STORE);
  +				DataModelPropertyDescriptor[] descriptors = model.getValidPropertyDescriptors(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
  +				List mruRuntimes = new ArrayList();
  +				if (mruRuntimeArray == null) {
  +					List defRuntimes = ProductManager.getDefaultRuntimes();
  +					for (Iterator iter = defRuntimes.iterator(); iter.hasNext();)
  +						mruRuntimes.add(((IRuntime) iter.next()).getName());
  +				} else {
  +					mruRuntimes.addAll(Arrays.asList(mruRuntimeArray));
  +				}
  +				if (!mruRuntimes.isEmpty()) {
  +					for (int i = 0; i < mruRuntimes.size() && !runtimeSet; i++) {
  +						for (int j = 0; j < descriptors.length-1 && !runtimeSet; j++) {
  +							if (mruRuntimes.get(i).equals(descriptors[j].getPropertyDescription())) {
  +								model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[j].getPropertyValue());
  +								runtimeSet = true;
  +							}
  +						}
  +						if(!runtimeSet && mruRuntimes.get(i).equals(NULL_RUNTIME) && descriptors.length != 0){
  +							model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[descriptors.length -1].getPropertyValue());
  +							runtimeSet = true;
  +						}
  +					}
  +				}
  +				if (!runtimeSet && descriptors.length > 0) {
  +					model.setProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME, descriptors[0].getPropertyValue());
  +				}
  +			}
  +		}
  +	}
  +
  +	
  +	/*
  +	 * Coppied from superclass and added merely a label
  +	 * (non-Javadoc)
  +	 * @see org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage#createServerTargetComposite(org.eclipse.swt.widgets.Composite)
  +	 */
  +	protected void createServerTargetComposite(Composite parent) {
  +        Group group = new Group(parent, SWT.NONE);
  +        group.setText(ResourceHandler.TargetRuntime);
  +        group.setLayoutData(gdhfill());
  +        group.setLayout(new GridLayout(2, false));
  +		serverTargetCombo = new Combo(group, SWT.BORDER | SWT.READ_ONLY);
  +		serverTargetCombo.setLayoutData(gdhfill());
  +		Button newServerTargetButton = new Button(group, SWT.NONE);
  +		newServerTargetButton.setText(ResourceHandler.NewDotDotDot);
  +		newServerTargetButton.addSelectionListener(new SelectionAdapter() {
  +			public void widgetSelected(SelectionEvent e) {
  +				if (!internalLaunchNewRuntimeWizard(getShell(), model)) {
  +					//Bugzilla 135288
  +					//setErrorMessage(ResourceHandler.InvalidServerTarget);
  +				}
  +			}
  +		});
  +		
  +		Label label = new Label(group, SWT.NONE);
  +		label.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
  +		label.setText("Warning: Make sure you're creating a runtime that supports ejb3.0.");
  +		
  +		Control[] deps = new Control[]{newServerTargetButton};
  +		synchHelper.synchCombo(serverTargetCombo, FACET_RUNTIME, deps);
  +		if (serverTargetCombo.getSelectionIndex() == -1 && serverTargetCombo.getVisibleItemCount() != 0)
  +			serverTargetCombo.select(0);
  +	}
  +}
  \ No newline at end of file
  
  
  



More information about the jboss-cvs-commits mailing list