[jboss-cvs] jboss-seam-ide/src/org/jboss/seam/ide/wizard ...
Thomas Heute
theute at belmont.prod.atl2.jboss.com
Wed Aug 30 07:46:17 EDT 2006
User: theute
Date: 06/08/30 07:46:17
Modified: src/org/jboss/seam/ide/wizard
NewSeamProjectWizardPage.java
NewSeamProjectWizard.java
Added: src/org/jboss/seam/ide/wizard WebProjectWizardPage.java
Log:
New wizard page to configure the webapp
Revision Changes Path
1.3 +19 -15 jboss-seam-ide/src/org/jboss/seam/ide/wizard/NewSeamProjectWizardPage.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NewSeamProjectWizardPage.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam-ide/src/org/jboss/seam/ide/wizard/NewSeamProjectWizardPage.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- NewSeamProjectWizardPage.java 29 Aug 2006 13:05:49 -0000 1.2
+++ NewSeamProjectWizardPage.java 30 Aug 2006 11:46:17 -0000 1.3
@@ -44,7 +44,7 @@
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version <tt>$Revision: 1.2 $</tt>
+ * @version <tt>$Revision: 1.3 $</tt>
*/
public class NewSeamProjectWizardPage extends WizardPage
{
@@ -62,8 +62,6 @@
private Button testSupportButton;
- private Button faceletsSupportButton;
-
public NewSeamProjectWizardPage()
{
super("seamWizardPage");
@@ -128,10 +126,6 @@
});
- faceletsSupportButton = new Button(container, SWT.CHECK);
- faceletsSupportButton.setText("Facelets support");
- faceletsSupportButton.setLayoutData(span3);
-
label = new Label(container, SWT.NULL);
label.setText("JBoss Seam location:");
@@ -182,6 +176,7 @@
setEnabledExampleConfigurationGoup(false);
}
}
+ checkValidity();
}
});
@@ -204,12 +199,26 @@
exampleSrcPackageText = new Text(exampleConfigurationGroup, SWT.BORDER | SWT.SINGLE);
exampleSrcPackageText.setLayoutData(groupItemGridData);
+ exampleSrcPackageText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ checkValidity();
+ }
+ });
label = new Label(exampleConfigurationGroup, SWT.NULL);
label.setText("Example test sources package:");
exampleTestPackageText = new Text(exampleConfigurationGroup, SWT.BORDER | SWT.SINGLE);
exampleTestPackageText.setLayoutData(groupItemGridData);
+ exampleTestPackageText.addModifyListener(new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ checkValidity();
+ }
+ });
initialize();
checkValidity();
@@ -240,7 +249,7 @@
}
if (!Pattern.matches("[a-zA-Z0-9_-]+", projectNameText.getText()))
{
- updateStatus("The project main only contains alphanumerical characters, - and _");
+ updateStatus("The project name may only contains alphanumerical characters, - and _");
return false;
}
@@ -254,14 +263,14 @@
}
// Check src package
- if (!Pattern.matches("[a-zA-Z0-9._]+", exampleSrcPackageText.getText()))
+ if (exampleSrcPackageText.getEnabled() && !Pattern.matches("[a-zA-Z0-9._]*", exampleSrcPackageText.getText()))
{
updateStatus("The example src package can only contain alphanumerical characters, . and _");
return false;
}
// Check test package
- if (!Pattern.matches("[a-zA-Z0-9._]+", exampleTestPackageText.getText()))
+ if (exampleTestPackageText.getEnabled() && !Pattern.matches("[a-zA-Z0-9._]*", exampleTestPackageText.getText()))
{
updateStatus("The example test package can only contain alphanumerical characters, . and _");
return false;
@@ -311,11 +320,6 @@
return exampleProjectButton.getSelection();
}
- public boolean getFaceletsSupport()
- {
- return faceletsSupportButton.getSelection();
- }
-
public boolean getTestSupport()
{
return testSupportButton.getSelection();
1.3 +50 -52 jboss-seam-ide/src/org/jboss/seam/ide/wizard/NewSeamProjectWizard.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NewSeamProjectWizard.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam-ide/src/org/jboss/seam/ide/wizard/NewSeamProjectWizard.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- NewSeamProjectWizard.java 29 Aug 2006 13:05:49 -0000 1.2
+++ NewSeamProjectWizard.java 30 Aug 2006 11:46:17 -0000 1.3
@@ -48,13 +48,15 @@
/**
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version <tt>$Revision: 1.2 $</tt>
+ * @version <tt>$Revision: 1.3 $</tt>
*/
public class NewSeamProjectWizard extends Wizard implements INewWizard
{
private NewSeamProjectWizardPage seamPage;
+ private WebProjectWizardPage webPage;
+
/**
* Constructor for NewSeamProjectWizard.
*/
@@ -71,19 +73,55 @@
public void addPages()
{
seamPage = new NewSeamProjectWizardPage();
+ webPage = new WebProjectWizardPage(seamPage);
addPage(seamPage);
+ addPage(webPage);
}
public boolean performFinish()
{
- final String projectName = seamPage.getProjectName();
- final boolean exampleProject = seamPage.getExampleProject();
- final String seamLocation = seamPage.getSeamLocation();
- final String exampleSrcPackage = seamPage.getExampleSrcPackage();
- final String exampleTestPackage = seamPage.getExampleTestPackage();
- final boolean faceletsSupport = seamPage.getFaceletsSupport();
- final boolean testSupport = seamPage.getTestSupport();
+ String projectName = seamPage.getProjectName();
+
+ final Context context = new Context();
+ context.setProjectName(projectName);
+ context.setIsolationClassLoadingName("seam.jboss.org:loader=" + projectName);
+ context.setSeamLocation(seamPage.getSeamLocation());
+ context.setEclipseSupport(true);
+ context.setBasicProject(seamPage.getExampleProject());
+ context.setTestSupport(seamPage.getTestSupport());
+ context.setSrcPackage(seamPage.getExampleSrcPackage());
+ context.setTestPackage(seamPage.getExampleTestPackage());
+ context.setFaceletsSupport(webPage.getFaceletsSupport());
+
+ final EarContext earContext = new EarContext();
+ earContext.setProjectName(projectName + "-ear");
+ earContext.setDisplayName(projectName);
+ earContext.setFilename(projectName + ".ear");
+ earContext.setContentDirectory("src");
+
+ final EjbContext ejbContext = new EjbContext();
+ ejbContext.setFilename(projectName + "-ejb.jar");
+ ejbContext.setProjectName(projectName + "-ejb");
+ ejbContext.setId(projectName + "-ejb");
+ ejbContext.setContentDirectory("src");
+ ejbContext.setJtaDataSource("DefaultDS");
+ ejbContext.setPersistenceUnitName(projectName + "Database");
+
+ final WebContext webContext = new WebContext();
+ webContext.setProjectName(webPage.getProjectName());
+ webContext.setFilename(webPage.getFilename());
+ webContext.setContextRoot(webPage.getContextRoot());
+ webContext.setId(webPage.getProjectName());
+ webContext.setContentDirectory(webPage.getContentDirectory());
+ if (context.isFaceletsSupport())
+ {
+ webContext.setJsfExtension(webPage.getJsfExtension());
+ }
+ else
+ {
+ webContext.setJsfExtension("jsp");
+ }
IRunnableWithProgress op = new IRunnableWithProgress()
{
@@ -91,8 +129,7 @@
{
try
{
- createProjects(projectName, exampleProject, faceletsSupport, testSupport, seamLocation,
- exampleSrcPackage, exampleTestPackage, monitor);
+ createProjects(context, earContext, webContext, ejbContext, monitor);
}
catch (Exception e)
{
@@ -122,58 +159,19 @@
return true;
}
- public void createProjects(String projectName, boolean exampleProject, boolean faceletsSupport, boolean testSupport,
- String seamLocation, String exampleSrcPackage, String exampleTestPackage, IProgressMonitor monitor)
- throws IOException, CoreException
+ public void createProjects(Context context, EarContext earContext, WebContext webContext, EjbContext ejbContext,
+ IProgressMonitor monitor) throws IOException, CoreException
{
- monitor.beginTask("Creating " + projectName, 5);
+ monitor.beginTask("Creating " + context.getProjectName(), 5);
- Context context = new Context();
- context.setProjectName(projectName);
- context.setIsolationClassLoadingName("seam.jboss.org:loader=" + projectName);
- context.setSeamLocation(seamLocation);
- context.setEclipseSupport(true);
- context.setBasicProject(exampleProject);
- context.setTestSupport(testSupport);
- context.setSrcPackage(exampleSrcPackage);
- context.setTestPackage(exampleTestPackage);
- context.setFaceletsSupport(faceletsSupport);
-
- EarContext earContext = new EarContext();
- earContext.setProjectName(projectName + "-ear");
- earContext.setDisplayName(projectName);
- earContext.setFilename(projectName + ".ear");
- earContext.setContentDirectory("src");
WTPEarProjectExporter wtpEarExporter = new WTPEarProjectExporter(context);
wtpEarExporter.setEarContext(earContext);
- EjbContext ejbContext = new EjbContext();
- ejbContext.setFilename(projectName + "-ejb.jar");
- ejbContext.setProjectName(projectName + "-ejb");
- ejbContext.setId(projectName + "-ejb");
- ejbContext.setContentDirectory("src");
- ejbContext.setJtaDataSource("DefaultDS");
- ejbContext.setPersistenceUnitName(projectName + "Database");
-
WTPEjbProjectExporter wtpEjbExporter = new WTPEjbProjectExporter(context);
wtpEjbExporter.setEjbContext(ejbContext);
List ejbExporters = new ArrayList();
ejbExporters.add(wtpEjbExporter);
- WebContext webContext = new WebContext();
- webContext.setProjectName(projectName + "-web");
- webContext.setFilename(projectName + "-web.war");
- webContext.setContextRoot(projectName);
- webContext.setId(projectName + "-web.war");
- webContext.setContentDirectory("web");
- if (context.isFaceletsSupport())
- {
- webContext.setJsfExtension("xhtml");
- }
- else
- {
- webContext.setJsfExtension("jsp");
- }
WTPWebProjectExporter wtpWebExporter = new WTPWebProjectExporter(context);
wtpWebExporter.setWebContext(webContext);
List webExporters = new ArrayList();
1.1 date: 2006/08/30 11:46:17; author: theute; state: Exp;jboss-seam-ide/src/org/jboss/seam/ide/wizard/WebProjectWizardPage.java
Index: WebProjectWizardPage.java
===================================================================
package org.jboss.seam.ide.wizard;
import java.util.regex.Pattern;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class WebProjectWizardPage extends WizardPage
{
private Text projectNameText;
private Text filenameText;
private Text contextRootText;
private Text contentDirectoryText;
private Text jsfExtensionText;
private Button faceletsSupportButton;
private NewSeamProjectWizardPage seamPage;
protected WebProjectWizardPage(NewSeamProjectWizardPage seamPage)
{
super("webWizardPage");
setTitle("Seam Web project wizard");
setDescription("This page helps you define your web application, default values are usually acceptable");
this.seamPage = seamPage;
}
public void createControl(Composite parent)
{
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 3;
layout.verticalSpacing = 9;
GridData span3 = new GridData(GridData.FILL_HORIZONTAL);
span3.horizontalSpan = 3;
Button defaultButton = new Button(container, SWT.PUSH);
defaultButton.setText("Use default values");
defaultButton.setLayoutData(span3);
defaultButton.addSelectionListener(new SelectionListener()
{
public void widgetDefaultSelected(SelectionEvent e)
{
// TODO Auto-generated method stub
}
public void widgetSelected(SelectionEvent e)
{
projectNameText.setText(seamPage.getProjectName() + "-web");
filenameText.setText(seamPage.getProjectName() + ".war");
contextRootText.setText(seamPage.getProjectName());
contentDirectoryText.setText("web");
jsfExtensionText.setText("xhtml");
}
});
Label label = new Label(container, SWT.NULL);
label.setText("Project name:");
projectNameText = new Text(container, SWT.BORDER | SWT.SINGLE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
projectNameText.setLayoutData(gd);
projectNameText.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
checkValidity();
}
});
label = new Label(container, SWT.NULL);
label.setText("Web application Filename:");
filenameText = new Text(container, SWT.BORDER | SWT.SINGLE);
filenameText.setLayoutData(gd);
filenameText.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
checkValidity();
}
});
label = new Label(container, SWT.NULL);
label.setText("Context root:");
contextRootText = new Text(container, SWT.BORDER | SWT.SINGLE);
contextRootText.setLayoutData(gd);
contextRootText.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
checkValidity();
}
});
label = new Label(container, SWT.NULL);
label.setText("Content directory:");
contentDirectoryText = new Text(container, SWT.BORDER | SWT.SINGLE);
contentDirectoryText.setLayoutData(gd);
contentDirectoryText.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
checkValidity();
}
});
faceletsSupportButton = new Button(container, SWT.CHECK);
faceletsSupportButton.setText("Facelets support");
faceletsSupportButton.setLayoutData(span3);
faceletsSupportButton.addSelectionListener(new SelectionListener()
{
public void widgetDefaultSelected(SelectionEvent e)
{
}
public void widgetSelected(SelectionEvent e)
{
if (faceletsSupportButton.getSelection())
{
jsfExtensionText.setEnabled(true);
}
else
{
jsfExtensionText.setEnabled(false);
}
}
});
label = new Label(container, SWT.NULL);
label.setText("JSF extension:");
jsfExtensionText = new Text(container, SWT.BORDER | SWT.SINGLE);
jsfExtensionText.setLayoutData(gd);
jsfExtensionText.addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
checkValidity();
}
});
initialize();
checkValidity();
setControl(container);
}
private void initialize()
{
faceletsSupportButton.setSelection(true);
}
private void updateStatus(String message)
{
setErrorMessage(message);
setPageComplete(message == null);
}
private boolean checkValidity()
{
// check projectNameText
if ("".equals(projectNameText.getText()))
{
updateStatus("The project name cannot be empty");
return false;
}
if (!Pattern.matches("[a-zA-Z0-9_-]+", projectNameText.getText()))
{
updateStatus("The project name may only contains alphanumerical characters, - and _");
return false;
}
// check filenameText
if ("".equals(filenameText.getText()))
{
updateStatus("The filename cannot be empty");
return false;
}
if (!filenameText.getText().endsWith(".war"))
{
updateStatus("The filename must end with \".war\"");
return false;
}
if (!Pattern.matches("[a-zA-Z0-9_-]+.war", filenameText.getText()))
{
updateStatus("The filename is not valid");
return false;
}
// check contextRoot
if ("".equals(contextRootText.getText()))
{
updateStatus("The context root cannot be empty");
return false;
}
if (!Pattern.matches("[a-zA-Z0-9_-]+", contextRootText.getText()))
{
updateStatus("The context root is not valid");
return false;
}
// check contentDirectory
if ("".equals(contentDirectoryText.getText()))
{
updateStatus("The content directory cannot be empty");
return false;
}
// check faceletsExtension
if (faceletsSupportButton.getSelection() && "".equals(jsfExtensionText.getText()))
{
updateStatus("The jsf extension cannot be empty");
return false;
}
if (!Pattern.matches("[a-zA-Z0-9]+", jsfExtensionText.getText()))
{
updateStatus("The jsf extension is not valid");
return false;
}
updateStatus(null);
return true;
}
public boolean getFaceletsSupport()
{
return faceletsSupportButton.getSelection();
}
public String getProjectName()
{
return projectNameText.getText();
}
public String getFilename()
{
return filenameText.getText();
}
public String getContextRoot()
{
return contextRootText.getText();
}
public String getContentDirectory()
{
return contentDirectoryText.getText();
}
public String getJsfExtension()
{
return jsfExtensionText.getText();
}
}
More information about the jboss-cvs-commits
mailing list