[jboss-cvs] jboss-seam-ide/src/org/jboss/seam/ide/wizard ...
Thomas Heute
theute at jboss.com
Tue Aug 29 09:05:49 EDT 2006
User: theute
Date: 06/08/29 09:05:49
Modified: src/org/jboss/seam/ide/wizard
NewSeamProjectWizardPage.java
NewSeamProjectWizard.java
Log:
re-formatted with headers
Revision Changes Path
1.2 +312 -221 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.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- NewSeamProjectWizardPage.java 15 Aug 2006 10:14:37 -0000 1.1
+++ NewSeamProjectWizardPage.java 29 Aug 2006 13:05:49 -0000 1.2
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.seam.ide.wizard;
import java.io.File;
@@ -22,9 +43,11 @@
import org.eclipse.swt.widgets.Text;
/**
- *
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version <tt>$Revision: 1.2 $</tt>
*/
-public class NewSeamProjectWizardPage extends WizardPage {
+public class NewSeamProjectWizardPage extends WizardPage
+{
private Text projectNameText;
private Text seamLocationText;
@@ -41,7 +64,8 @@
private Button faceletsSupportButton;
- public NewSeamProjectWizardPage() {
+ public NewSeamProjectWizardPage()
+ {
super("seamWizardPage");
setTitle("New Seam project wizard");
setDescription("This wizard creates a new Seam project composed of an EAR application, an EJB3 application and a WAR application.");
@@ -50,7 +74,8 @@
/**
* @see IDialogPage#createControl(Composite)
*/
- public void createControl(Composite parent) {
+ public void createControl(Composite parent)
+ {
Composite container = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
@@ -65,9 +90,11 @@
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
projectNameText.setLayoutData(gd);
- projectNameText.addModifyListener(new ModifyListener() {
+ projectNameText.addModifyListener(new ModifyListener()
+ {
- public void modifyText(ModifyEvent e) {
+ public void modifyText(ModifyEvent e)
+ {
checkValidity();
}
@@ -79,6 +106,27 @@
testSupportButton = new Button(container, SWT.CHECK);
testSupportButton.setText("Create test environment");
testSupportButton.setLayoutData(span3);
+ testSupportButton.addSelectionListener(new SelectionListener()
+ {
+
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+
+ }
+
+ public void widgetSelected(SelectionEvent e)
+ {
+ if (exampleProjectButton.getSelection() && testSupportButton.getSelection())
+ {
+ exampleTestPackageText.setEnabled(true);
+ }
+ else
+ {
+ exampleTestPackageText.setEnabled(false);
+ }
+ }
+
+ });
faceletsSupportButton = new Button(container, SWT.CHECK);
faceletsSupportButton.setText("Facelets support");
@@ -90,9 +138,11 @@
seamLocationText = new Text(container, SWT.BORDER | SWT.SINGLE);
GridData seamLocationGd = new GridData(GridData.FILL_HORIZONTAL);
seamLocationText.setLayoutData(seamLocationGd);
- seamLocationText.addModifyListener(new ModifyListener() {
+ seamLocationText.addModifyListener(new ModifyListener()
+ {
- public void modifyText(ModifyEvent e) {
+ public void modifyText(ModifyEvent e)
+ {
checkValidity();
}
@@ -100,8 +150,10 @@
Button button = new Button(container, SWT.PUSH);
button.setText("Browse...");
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
+ button.addSelectionListener(new SelectionAdapter()
+ {
+ public void widgetSelected(SelectionEvent e)
+ {
handleBrowse();
}
});
@@ -109,13 +161,16 @@
exampleProjectButton = new Button(container, SWT.CHECK);
exampleProjectButton.setText("Example project");
exampleProjectButton.setLayoutData(span3);
- exampleProjectButton.addSelectionListener(new SelectionListener() {
+ exampleProjectButton.addSelectionListener(new SelectionListener()
+ {
- public void widgetDefaultSelected(SelectionEvent e) {
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
}
- public void widgetSelected(SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e)
+ {
if (exampleConfigurationGroup != null)
{
if (exampleProjectButton.getSelection())
@@ -124,7 +179,8 @@
}
else
{
- setEnabledExampleConfigurationGoup(false); }
+ setEnabledExampleConfigurationGoup(false);
+ }
}
}
@@ -160,12 +216,14 @@
setControl(container);
}
- private void initialize() {
+ private void initialize()
+ {
exampleProjectButton.setSelection(false);
setEnabledExampleConfigurationGoup(false);
}
- private void handleBrowse() {
+ private void handleBrowse()
+ {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setMessage("Select the directory where you installed JBoss Seam");
String seamPath = dialog.open();
@@ -180,7 +238,7 @@
updateStatus("The project name cannot be empty");
return false;
}
- if ( ! Pattern.matches("[a-zA-Z0-9_-]+", projectNameText.getText()))
+ if (!Pattern.matches("[a-zA-Z0-9_-]+", projectNameText.getText()))
{
updateStatus("The project main only contains alphanumerical characters, - and _");
return false;
@@ -195,23 +253,51 @@
return false;
}
+ // Check src package
+ if (!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()))
+ {
+ updateStatus("The example test package can only contain alphanumerical characters, . and _");
+ return false;
+ }
+
updateStatus(null);
return true;
}
- private void updateStatus(String message) {
+ private void updateStatus(String message)
+ {
setErrorMessage(message);
setPageComplete(message == null);
}
-
public void setEnabledExampleConfigurationGoup(boolean enabled)
{
exampleConfigurationGroup.setEnabled(enabled);
Control[] controls = exampleConfigurationGroup.getChildren();
- for (int i=0; i<controls.length; i++)
+ for (int i = 0; i < controls.length; i++)
+ {
+ if (controls[i] == exampleTestPackageText)
+ {
+ if (enabled && testSupportButton.getSelection())
{
- ((Control)controls[i]).setEnabled(enabled);
+ exampleTestPackageText.setEnabled(true);
+ }
+ else
+ {
+ exampleTestPackageText.setEnabled(false);
+ }
+ }
+ else
+ {
+ ((Control) controls[i]).setEnabled(enabled);
+ }
}
}
@@ -220,29 +306,34 @@
return projectNameText.getText();
}
- public boolean getExampleProject() {
+ public boolean getExampleProject()
+ {
return exampleProjectButton.getSelection();
}
- public boolean getFaceletsSupport() {
+ public boolean getFaceletsSupport()
+ {
return faceletsSupportButton.getSelection();
}
- public boolean getTestSupport() {
+ public boolean getTestSupport()
+ {
return testSupportButton.getSelection();
}
- public String getSeamLocation() {
+ public String getSeamLocation()
+ {
return seamLocationText.getText();
}
- public String getExampleSrcPackage() {
+ public String getExampleSrcPackage()
+ {
return exampleSrcPackageText.getText();
}
- public String getExampleTestPackage() {
+ public String getExampleTestPackage()
+ {
return exampleTestPackageText.getText();
}
}
-
1.2 +262 -232 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.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- NewSeamProjectWizard.java 15 Aug 2006 10:14:37 -0000 1.1
+++ NewSeamProjectWizard.java 29 Aug 2006 13:05:49 -0000 1.2
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., 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.seam.ide.wizard;
import java.io.IOException;
@@ -26,24 +47,19 @@
import org.jboss.seam.tools.exporter.wtp.WTPWebProjectExporter;
/**
- * This is a sample new wizard. Its role is to create a new file
- * resource in the provided container. If the container resource
- * (a folder or a project) is selected in the workspace
- * when the wizard is opened, it will accept it as the target
- * container. The wizard creates one file with the extension
- * "mpe". If a sample multi-page editor (also available
- * as a template) is registered for the same extension, it will
- * be able to open it.
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @version <tt>$Revision: 1.2 $</tt>
*/
-
-public class NewSeamProjectWizard extends Wizard implements INewWizard {
+public class NewSeamProjectWizard extends Wizard implements INewWizard
+{
private NewSeamProjectWizardPage seamPage;
/**
* Constructor for NewSeamProjectWizard.
*/
- public NewSeamProjectWizard() {
+ public NewSeamProjectWizard()
+ {
super();
setNeedsProgressMonitor(true);
}
@@ -52,12 +68,14 @@
* Adding the page to the wizard.
*/
- public void addPages() {
+ public void addPages()
+ {
seamPage = new NewSeamProjectWizardPage();
addPage(seamPage);
}
- public boolean performFinish() {
+ public boolean performFinish()
+ {
final String projectName = seamPage.getProjectName();
final boolean exampleProject = seamPage.getExampleProject();
@@ -67,23 +85,36 @@
final boolean faceletsSupport = seamPage.getFaceletsSupport();
final boolean testSupport = seamPage.getTestSupport();
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- createProjects(projectName, exampleProject, faceletsSupport, testSupport, seamLocation, exampleSrcPackage, exampleTestPackage, monitor);
- } catch (Exception e) {
+ IRunnableWithProgress op = new IRunnableWithProgress()
+ {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException
+ {
+ try
+ {
+ createProjects(projectName, exampleProject, faceletsSupport, testSupport, seamLocation,
+ exampleSrcPackage, exampleTestPackage, monitor);
+ }
+ catch (Exception e)
+ {
e.printStackTrace();
throw new InvocationTargetException(e);
- } finally {
+ }
+ finally
+ {
monitor.done();
}
}
};
- try {
+ try
+ {
getContainer().run(true, false, op);
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
return false;
- } catch (InvocationTargetException e) {
+ }
+ catch (InvocationTargetException e)
+ {
Throwable realException = e.getTargetException();
realException.printStackTrace();
return false;
@@ -91,7 +122,9 @@
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(String projectName, boolean exampleProject, boolean faceletsSupport, boolean testSupport,
+ String seamLocation, String exampleSrcPackage, String exampleTestPackage, IProgressMonitor monitor)
+ throws IOException, CoreException
{
monitor.beginTask("Creating " + projectName, 5);
@@ -106,7 +139,6 @@
context.setTestPackage(exampleTestPackage);
context.setFaceletsSupport(faceletsSupport);
-
EarContext earContext = new EarContext();
earContext.setProjectName(projectName + "-ear");
earContext.setDisplayName(projectName);
@@ -115,7 +147,6 @@
WTPEarProjectExporter wtpEarExporter = new WTPEarProjectExporter(context);
wtpEarExporter.setEarContext(earContext);
-
EjbContext ejbContext = new EjbContext();
ejbContext.setFilename(projectName + "-ejb.jar");
ejbContext.setProjectName(projectName + "-ejb");
@@ -148,14 +179,11 @@
List webExporters = new ArrayList();
webExporters.add(wtpWebExporter);
-
WTPSeamExporter seamWTPExporter = new WTPSeamExporter(wtpEarExporter, ejbExporters, webExporters);
seamWTPExporter.setOutputDirectory(ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toFile());
seamWTPExporter.start();
-
-
/*
WTPRootProject seamProject = new WTPRootProject();
@@ -218,47 +246,49 @@
context.setTestPackage(exampleTestPackage);
seamProject.generate(context);
-*/
+ */
monitor.worked(2);
IProjectDescription descr;
// Load and open the Web project
- descr = ResourcesPlugin.getWorkspace().loadProjectDescription(ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(webContext.getProjectName()).append(".project"));
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- webContext.getProjectName());
+ descr = ResourcesPlugin.getWorkspace().loadProjectDescription(
+ ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(webContext.getProjectName()).append(
+ ".project"));
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(webContext.getProjectName());
project.create(descr, monitor);
project.open(monitor);
monitor.worked(1);
// Load and open the Ejb project
- descr = ResourcesPlugin.getWorkspace().loadProjectDescription(ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(ejbContext.getProjectName()).append(".project"));
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- ejbContext.getProjectName());
+ descr = ResourcesPlugin.getWorkspace().loadProjectDescription(
+ ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(ejbContext.getProjectName()).append(
+ ".project"));
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(ejbContext.getProjectName());
project.create(descr, monitor);
project.open(monitor);
monitor.worked(1);
// Load and open the Ear project
- descr = ResourcesPlugin.getWorkspace().loadProjectDescription(ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(earContext.getProjectName()).append(".project"));
- project = ResourcesPlugin.getWorkspace().getRoot().getProject(
- earContext.getProjectName());
+ descr = ResourcesPlugin.getWorkspace().loadProjectDescription(
+ ResourcesPlugin.getWorkspace().getRoot().getRawLocation().append(earContext.getProjectName()).append(
+ ".project"));
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(earContext.getProjectName());
project.create(descr, monitor);
project.open(monitor);
monitor.worked(1);
}
-
-
/**
* We will accept the selection in the workbench to see if
* we can initialize from it.
* @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
*/
- public void init(IWorkbench workbench, IStructuredSelection selection) {
-// this.selection = selection;
+ public void init(IWorkbench workbench, IStructuredSelection selection)
+ {
+ // this.selection = selection;
}
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list