Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2008-05-16 21:40:45 -0400
committerpelder2008-05-16 21:40:45 -0400
commit3e99a8f723c17ca6b094c09613ee293f66b29425 (patch)
tree1b7a3c6118b2b1911e40a0d8568eadecff179346
parentae4936eea89ad05886359dfaab416bc745ba2b5c (diff)
downloadorg.eclipse.jet-3e99a8f723c17ca6b094c09613ee293f66b29425.tar.gz
org.eclipse.jet-3e99a8f723c17ca6b094c09613ee293f66b29425.tar.xz
org.eclipse.jet-3e99a8f723c17ca6b094c09613ee293f66b29425.zip
[232583] JET New project wizard does not validate all fields
-rw-r--r--plugins/org.eclipse.jet.ui/NewJETProject.p1.wzPage.xml8
-rw-r--r--plugins/org.eclipse.jet.ui/NewJETProject.p2.wzPage.xml6
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/Messages.java1
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1.java62
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1Controls.java67
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2.java53
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2Controls.java42
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/messages.properties1
8 files changed, 222 insertions, 18 deletions
diff --git a/plugins/org.eclipse.jet.ui/NewJETProject.p1.wzPage.xml b/plugins/org.eclipse.jet.ui/NewJETProject.p1.wzPage.xml
index 0fabb3d..00ba758 100644
--- a/plugins/org.eclipse.jet.ui/NewJETProject.p1.wzPage.xml
+++ b/plugins/org.eclipse.jet.ui/NewJETProject.p1.wzPage.xml
@@ -11,7 +11,7 @@
</control>
<control parentID="gProjSet" id="txtTemplateFolder">
<var name="txtTemplateFolder"/>
- <type><text multi="false" readOnly="false"></text></type>
+ <type><text multi="false" readOnly="false"><modify/></text></type>
<gridData><hAlign value="FILL"/><hGrabExcessSpace/></gridData>
</control>
<control parentID="gProjSet" id="lblJETOutput">
@@ -19,7 +19,7 @@
</control>
<control parentID="gProjSet" id="txtJETOutput">
<var name="txtJETOutput"/>
- <type><text multi="false" readOnly="false"></text></type>
+ <type><text multi="false" readOnly="false"><modify/></text></type>
<gridData><hAlign value="FILL"/><hGrabExcessSpace/></gridData>
</control>
<control parentID="gProjSet" id="lblJavaOutput">
@@ -27,7 +27,7 @@
</control>
<control parentID="gProjSet" id="txtJavaOutput">
<var name="txtJavaOutput"/>
- <type><text multi="false" readOnly="false"></text></type>
+ <type><text multi="false" readOnly="false"><modify/></text></type>
<gridData><hAlign value="FILL"/><hGrabExcessSpace/></gridData>
</control>
<control parentID="gProjSet" id="lblDefJavaPackage">
@@ -35,7 +35,7 @@
</control>
<control parentID="gProjSet" id="txtDefJavaPackage">
<var name="txtDefJavaPackage"/>
- <type><text multi="false" readOnly="false"></text></type>
+ <type><text multi="false" readOnly="false"><modify/></text></type>
<gridData><hAlign value="FILL"/><hGrabExcessSpace/></gridData>
</control>
</wizardPage>
diff --git a/plugins/org.eclipse.jet.ui/NewJETProject.p2.wzPage.xml b/plugins/org.eclipse.jet.ui/NewJETProject.p2.wzPage.xml
index 11c7b0f..08aa1d2 100644
--- a/plugins/org.eclipse.jet.ui/NewJETProject.p2.wzPage.xml
+++ b/plugins/org.eclipse.jet.ui/NewJETProject.p2.wzPage.xml
@@ -15,7 +15,7 @@
</control>
<control parentID="grpTransProps" id="txtID">
<var name="txtID"/>
- <type><text multi="false" readOnly="false"></text></type>
+ <type><text multi="false" readOnly="false"><modify/></text></type>
<gridData><hAlign value="FILL"/><hGrabExcessSpace/></gridData>
</control>
@@ -43,7 +43,7 @@
</control>
<control parentID="grpTransProps" id="txtTemplateLoader">
<var name="txtTemplateLoader"/>
- <type><text multi="false" readOnly="false"></text></type>
+ <type><text multi="false" readOnly="false"><modify/></text></type>
<gridData><hAlign value="FILL"/><hGrabExcessSpace/></gridData>
</control>
@@ -65,7 +65,7 @@
</control>
<control parentID="grpExtensions" id="ddlBaseTx">
<var name="ddlBaseTx"/>
- <type><combo dropDown="true" readOnly="true"></combo></type>
+ <type><combo dropDown="true" readOnly="true"><modify/></combo></type>
<gridData><hAlign value="FILL"/><hGrabExcessSpace/></gridData>
</control>
</wizardPage>
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/Messages.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/Messages.java
index 3d39729..890484c 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/Messages.java
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/Messages.java
@@ -17,6 +17,7 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.jet.ui.newproject.messages"; //$NON-NLS-1$
public static String NewJETProjectPage2_description;
+ public static String NewJETProjectPage2_InvalidID;
public static String NewJETProjectPage2_title;
public static String NewJETProjectPage2Controls__groupgrpTransProps_text;
public static String NewJETProjectPage2Controls__labellblID_text;
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1.java
index b91fa59..adc382d 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1.java
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1.java
@@ -1,14 +1,23 @@
package org.eclipse.jet.ui.newproject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jet.core.compiler.JETCompilerOptions;
import org.eclipse.jet.ui.Activator;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
public class NewJETProjectPage1 extends NewJETProjectPage1Controls {
+ private String lastBaseID = null;
+
public NewJETProjectPage1(String pageName) {
super(pageName);
}
@@ -27,21 +36,68 @@ public class NewJETProjectPage1 extends NewJETProjectPage1Controls {
}
+ protected void txtTemplateFolder_modify(ModifyEvent e) {
+ validatePage();
+ }
+
+ protected void txtJETOutput_modify(ModifyEvent e) {
+ validatePage();
+ }
+
+ protected void txtJavaOutput_modify(ModifyEvent e) {
+ validatePage();
+ }
+
+ protected void txtDefJavaPackage_modify(ModifyEvent e) {
+ validatePage();
+ }
+
protected boolean validatePage() {
// TODO Auto-generated method stub
final boolean parentValid = super.validatePage();
if(!parentValid) {
return false;
}
-
+
final String id = getBaseID();
+ if(!id.equals(lastBaseID)) {
+ txtDefJavaPackage.setText(id + ".compiled"); //$NON-NLS-1$
+ lastBaseID = id;
+ }
- txtDefJavaPackage.setText(id + ".compiled"); //$NON-NLS-1$
-
+ if(!validateFolder(txtTemplateFolder)) {
+ return false;
+ }
+ if(!validateFolder(txtJavaOutput)) {
+ return false;
+ }
+ if(!validateFolder(txtJETOutput)) {
+ return false;
+ }
+ final String defaultJavaPackage = getDefaultJavaPackage();
+ IStatus status = JavaConventions.validatePackageName(defaultJavaPackage);
+ if(!status.isOK()) {
+ setErrorMessage(status.getMessage());
+ return false;
+ }
return true;
}
/**
+ * @param folderField
+ */
+ private boolean validateFolder(final Text folderField) {
+ final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ final IStatus status = workspace.validatePath("/" + getProjectName() + "/" + folderField.getText().trim(), IResource.FOLDER); //$NON-NLS-1$ //$NON-NLS-2$
+ if(!status.isOK()) {
+ setErrorMessage(status.getMessage());
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
* @return
*/
String getBaseID() {
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1Controls.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1Controls.java
index 7c2dbe4..95abe98 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1Controls.java
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage1Controls.java
@@ -1,13 +1,10 @@
package org.eclipse.jet.ui.newproject;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
public abstract class NewJETProjectPage1Controls
extends WizardNewProjectCreationPage {
@@ -69,6 +66,11 @@ public abstract class NewJETProjectPage1Controls
_gd.horizontalAlignment = GridData.FILL;
_gd.grabExcessHorizontalSpace = true;
txtTemplateFolder.setLayoutData(_gd);
+ // register event handlers for txtTemplateFolder
+ txtTemplateFolder.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ txtTemplateFolder_modify(e);
+ }});
Label _labellblJETOutput;
_labellblJETOutput = new Label(_groupgProjSet, SWT.NONE);
@@ -86,6 +88,11 @@ public abstract class NewJETProjectPage1Controls
_gd.horizontalAlignment = GridData.FILL;
_gd.grabExcessHorizontalSpace = true;
txtJETOutput.setLayoutData(_gd);
+ // register event handlers for txtJETOutput
+ txtJETOutput.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ txtJETOutput_modify(e);
+ }});
Label _labellblJavaOutput;
_labellblJavaOutput = new Label(_groupgProjSet, SWT.NONE);
@@ -103,6 +110,11 @@ public abstract class NewJETProjectPage1Controls
_gd.horizontalAlignment = GridData.FILL;
_gd.grabExcessHorizontalSpace = true;
txtJavaOutput.setLayoutData(_gd);
+ // register event handlers for txtJavaOutput
+ txtJavaOutput.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ txtJavaOutput_modify(e);
+ }});
Label _labellblDefJavaPackage;
_labellblDefJavaPackage = new Label(_groupgProjSet, SWT.NONE);
@@ -120,11 +132,52 @@ public abstract class NewJETProjectPage1Controls
_gd.horizontalAlignment = GridData.FILL;
_gd.grabExcessHorizontalSpace = true;
txtDefJavaPackage.setLayoutData(_gd);
+ // register event handlers for txtDefJavaPackage
+ txtDefJavaPackage.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ txtDefJavaPackage_modify(e);
+ }});
}
+ /**
+ * Modify event handler for {@link #txtTemplateFolder}.
+ *
+ * @param e the Modify Event
+ * @see ModifyListener
+ * @see ModifyListener#modifyText(ModifyEvent)
+ */
+ protected abstract void txtTemplateFolder_modify(ModifyEvent e);
+
+ /**
+ * Modify event handler for {@link #txtJETOutput}.
+ *
+ * @param e the Modify Event
+ * @see ModifyListener
+ * @see ModifyListener#modifyText(ModifyEvent)
+ */
+ protected abstract void txtJETOutput_modify(ModifyEvent e);
+
+ /**
+ * Modify event handler for {@link #txtJavaOutput}.
+ *
+ * @param e the Modify Event
+ * @see ModifyListener
+ * @see ModifyListener#modifyText(ModifyEvent)
+ */
+ protected abstract void txtJavaOutput_modify(ModifyEvent e);
+
+ /**
+ * Modify event handler for {@link #txtDefJavaPackage}.
+ *
+ * @param e the Modify Event
+ * @see ModifyListener
+ * @see ModifyListener#modifyText(ModifyEvent)
+ */
+ protected abstract void txtDefJavaPackage_modify(ModifyEvent e);
+
}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2.java
index 5819213..d44983b 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2.java
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2.java
@@ -13,7 +13,10 @@
package org.eclipse.jet.ui.newproject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jet.JET2Platform;
+import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
@@ -49,10 +52,53 @@ public class NewJETProjectPage2 extends NewJETProjectPage2Controls {
cbxExtends.setVisible(visible);
lblBaseTx.setVisible(visible);
}
+
+ setPageComplete(validatePage());
}
+ private boolean validatePage() {
+ if(!validateTranformID()) {
+ return false;
+ }
+ if(!validateTemplateLoader()) {
+ return false;
+ }
+ if(cbxExtends.getSelection() && cbxExtends.isVisible() && ddlBaseTx.getText().trim().length() == 0) {
+ return false;
+ }
+
+ setMessage(null);
+ setErrorMessage(null);
+ return true;
+ }
+
+ private boolean validateTemplateLoader() {
+ final IStatus status = JavaConventions.validateJavaTypeName(getTemplateLoader());
+ if(status.getSeverity() == IStatus.ERROR) {
+ setErrorMessage(status.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ private boolean validateTranformID() {
+ final String transformID = getTransformID();
+ if(!transformID.matches("[a-zA-Z0-9\\._]*")) { //$NON-NLS-1$
+ setErrorMessage(Messages.NewJETProjectPage2_InvalidID);
+ return false;
+ }
+ return true;
+ }
+
+ protected void txtID_modify(ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+
+ protected void txtTemplateLoader_modify(ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+
private void setExtends(boolean setExtends) {
- // TODO Auto-generated method stub
if(setExtends != cbxExtends.getSelection()) {
cbxExtends.setSelection(setExtends);
}
@@ -74,10 +120,15 @@ public class NewJETProjectPage2 extends NewJETProjectPage2Controls {
if(selected) {
ddlBaseTx.setFocus();
}
+ setPageComplete(validatePage());
getContainer().updateButtons();
}
+ protected void ddlBaseTx_modify(ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+
public void setVisible(boolean visible) {
super.setVisible(visible);
if(visible && page1 != null) {
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2Controls.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2Controls.java
index 0b7e8d8..5e25d74 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2Controls.java
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewJETProjectPage2Controls.java
@@ -98,6 +98,11 @@ public abstract class NewJETProjectPage2Controls
_gd.horizontalAlignment = GridData.FILL;
_gd.grabExcessHorizontalSpace = true;
txtID.setLayoutData(_gd);
+ // register event handlers for txtID
+ txtID.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ txtID_modify(e);
+ }});
Label _labellblName;
_labellblName = new Label(_groupgrpTransProps, SWT.NONE);
@@ -149,6 +154,11 @@ public abstract class NewJETProjectPage2Controls
_gd.horizontalAlignment = GridData.FILL;
_gd.grabExcessHorizontalSpace = true;
txtTemplateLoader.setLayoutData(_gd);
+ // register event handlers for txtTemplateLoader
+ txtTemplateLoader.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ txtTemplateLoader_modify(e);
+ }});
grpExtensions = new Group(_compositetop, SWT.NONE);
grpExtensions.setText(Messages.NewJETProjectPage2Controls_grpExtensions_text);
@@ -205,12 +215,35 @@ public abstract class NewJETProjectPage2Controls
_gd.horizontalAlignment = GridData.FILL;
_gd.grabExcessHorizontalSpace = true;
ddlBaseTx.setLayoutData(_gd);
+ // register event handlers for ddlBaseTx
+ ddlBaseTx.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ ddlBaseTx_modify(e);
+ }});
}
/**
+ * Modify event handler for {@link #txtID}.
+ *
+ * @param e the Modify Event
+ * @see ModifyListener
+ * @see ModifyListener#modifyText(ModifyEvent)
+ */
+ protected abstract void txtID_modify(ModifyEvent e);
+
+ /**
+ * Modify event handler for {@link #txtTemplateLoader}.
+ *
+ * @param e the Modify Event
+ * @see ModifyListener
+ * @see ModifyListener#modifyText(ModifyEvent)
+ */
+ protected abstract void txtTemplateLoader_modify(ModifyEvent e);
+
+ /**
* Selection event handler for {@link #cbxExtends}.
* @param e an event containing information on the selection
* @see SelectionListener
@@ -218,6 +251,15 @@ public abstract class NewJETProjectPage2Controls
*/
protected abstract void cbxExtends_selection(SelectionEvent e);
+ /**
+ * Modify event handler for {@link #ddlBaseTx}.
+ *
+ * @param e the Modify Event
+ * @see ModifyListener
+ * @see ModifyListener#modifyText(ModifyEvent)
+ */
+ protected abstract void ddlBaseTx_modify(ModifyEvent e);
+
}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/messages.properties b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/messages.properties
index 319d003..6a49c18 100644
--- a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/messages.properties
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/messages.properties
@@ -15,4 +15,5 @@ NewJETProjectPage2Controls_cbxExtends_text=E&xtend an existing JET Transformatio
NewJETProjectPage2Controls_lblBaseTx_text=Base &transformation:
NewJETProjectPage2_description=Enter the data required to generate the JET transformation
+NewJETProjectPage2_InvalidID=Invalid ID. Legal characters are A-Z a-z 0-9 . _
NewJETProjectPage2_title=JET Transformation Properties

Back to the top