Author: akazakov
Date: 2007-10-22 13:04:29 -0400 (Mon, 22 Oct 2007)
New Revision: 4416
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1037 Package Name for New Entity Wizard
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java 2007-10-22
16:40:13 UTC (rev 4415)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java 2007-10-22
17:04:29 UTC (rev 4416)
@@ -244,7 +244,6 @@
IFieldEditor editor = editorRegistry.get(IParameter.SEAM_PACKAGE_NAME);
if(editor!=null) {
errors = ValidatorFactory.PACKAGE_NAME_VALIDATOR.validate(editor.getValue(), null);
-
if(errors.size()>0) {
setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString()); //$NON-NLS-1$
setPageComplete(false);
@@ -338,7 +337,7 @@
setDefaultValue(IParameter.SEAM_PAGE_NAME, valueL);
}
}
- if(event.getPropertyName().equals(IParameter.SEAM_PROJECT_NAME)) {
+ if(event.getPropertyName().equals(IParameter.SEAM_PROJECT_NAME)&&
getEditor(IParameter.SEAM_PACKAGE_NAME)!=null) {
String selectedProject = event.getNewValue().toString();
setSeamProjectNameData(selectedProject);
setDefaultValue(IParameter.SEAM_PACKAGE_NAME,
getDefaultPackageName(selectedProject));
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2007-10-22
16:40:13 UTC (rev 4415)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2007-10-22
17:04:29 UTC (rev 4416)
@@ -15,10 +15,12 @@
import java.util.Map;
import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.INewWizard;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.widget.editor.INamedElement;
/**
* @author eskimo
@@ -40,7 +42,7 @@
public void addPages() {
addPage(new SeamEntityWizardPage1(getInitialSelection()));
}
-
+
// TODO move operations to core plugin
public static final IUndoableOperation CREATE_SEAM_ENTITY = new
SeamEntityCreateOperation();
/**
@@ -48,7 +50,7 @@
* TODO move operations to core plugin
*/
public static class SeamEntityCreateOperation extends SeamBaseOperation{
-
+
@Override
protected void loadCustomVariables(Map<String, Object> vars) {
String entityClassname = vars.get(IParameter.SEAM_ENTITY_CLASS_NAME).toString();
@@ -70,11 +72,11 @@
else
return ACTION_EAR_MAPPING;
}
-
+
public static final List<String[]> ACTION_WAR_MAPPING = new
ArrayList<String[]>();
-
+
public static final List<String[]> ACTION_EAR_MAPPING = new
ArrayList<String[]>();
-
+
static {
// initialize war files mapping
ACTION_WAR_MAPPING.add(new String[]{
@@ -93,8 +95,7 @@
ACTION_WAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/view/list.xhtml", //$NON-NLS-1$ //$NON-NLS-2$
"${" + IParameter.SEAM_PROJECT_WEBCONTENT_PATH + "}/${" +
IParameter.SEAM_MASTER_PAGE_NAME +"}.xhtml"}); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
-
-
+
ACTION_EAR_MAPPING.add(new String[]{
"${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/src/Entity.java", //$NON-NLS-1$ //$NON-NLS-2$
"${" + IParameter.SEAM_EJB_PROJECT_LOCATION_PATH +
"}/ejbModule/${" + ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_PATH +
"}/${" + IParameter.SEAM_ENTITY_CLASS_NAME +"}.java"}); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -108,6 +109,14 @@
ACTION_EAR_MAPPING.add(ACTION_WAR_MAPPING.get(3));
ACTION_EAR_MAPPING.add(ACTION_WAR_MAPPING.get(4));
}
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.wizard.SeamBaseOperation#getEntityBeanPackageName(org.eclipse.core.runtime.preferences.IEclipsePreferences,
java.util.Map)
+ */
+ @Override
+ protected String getEntityBeanPackageName(IEclipsePreferences seamFacetPrefs,
Map<String, INamedElement> wizardParams) {
+ return wizardParams.get(IParameter.SEAM_PACKAGE_NAME).getValue().toString();
+ }
};
-
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java 2007-10-22
16:40:13 UTC (rev 4415)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizardPage1.java 2007-10-22
17:04:29 UTC (rev 4416)
@@ -15,13 +15,15 @@
import java.util.Map;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
+import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
/**
* @author eskimo
@@ -37,24 +39,30 @@
super("seam.new.entity.page1","Seam Entity", null, is);
setMessage(getDefaultMessageText());
}
-
+
/**
*
*/
@Override
protected void createEditors() {
super.createEditors();
+
+ String selectedProject = SeamWizardUtils.getRootSeamProjectName(initialSelection);
+ String packageName = getDefaultPackageName(selectedProject);
+ addEditor(SeamWizardFactory.createSeamJavaPackageSelectionFieldEditor(packageName));
+ setSeamProjectNameData(selectedProject);
+
addEditor(SeamWizardFactory.createSeamEntityClasNameFieldEditor());
addEditor(SeamWizardFactory.createSeamMasterPageNameFieldEditor());
addEditor(SeamWizardFactory.createSeamPageNameFieldEditor());
}
-
+
@Override
public void createControl(Composite parent) {
setControl(new GridLayoutComposite(parent));
setPageComplete(false);
}
-
+
@Override
public void doFillDefaults(PropertyChangeEvent event) {
if(event.getPropertyName().equals(IParameter.SEAM_ENTITY_CLASS_NAME)) {
@@ -64,50 +72,80 @@
setDefaultValue(IParameter.SEAM_PAGE_NAME, "");
} else {
String value = event.getNewValue().toString();
- String valueU = value.substring(0,1).toUpperCase() + value.substring(1);
String valueL = value.substring(0,1).toLowerCase() + value.substring(1);
setDefaultValue(IParameter.SEAM_MASTER_PAGE_NAME, valueL+"List");
setDefaultValue(IParameter.SEAM_PAGE_NAME, valueL);
}
}
+ if(event.getPropertyName().equals(IParameter.SEAM_PROJECT_NAME)) {
+ String selectedProject = event.getNewValue().toString();
+ setSeamProjectNameData(selectedProject);
+ setDefaultValue(IParameter.SEAM_PACKAGE_NAME,
getDefaultPackageName(selectedProject));
+ }
}
-
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.wizard.SeamBaseWizardPage#getDefaultPackageName(org.eclipse.core.runtime.preferences.IEclipsePreferences)
+ */
@Override
+ protected String getDefaultPackageName(IEclipsePreferences seamFacetPrefs) {
+ return seamFacetPrefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME,
"");
+ }
+
+ @Override
protected void doValidate(PropertyChangeEvent event) {
+ if(!isValidProjectSelected()) return;
+
Map errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValue(), null);
-
+
if(errors.size()>0) {
setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
setPageComplete(false);
return;
}
-
+ getEditor(IParameter.SEAM_BEAN_NAME).setEnabled(true);
+ IFieldEditor packageEditor = getEditor(IParameter.SEAM_PACKAGE_NAME);
+ if(packageEditor!=null) {
+ packageEditor.setEnabled(true);
+ }
+
IProject project = getSelectedProject();
-
+
if(!isValidRuntimeConfigured(project)) return;
errors = ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_ENTITY_CLASS_NAME).getValue(), null);
-
+
if(errors.size()>0) {
setErrorMessage(NLS.bind(errors.get(IValidator.DEFAULT_ERROR).toString(),SeamUIMessages.SEAM_ENTITY_WIZARD_PAGE1_ENTITY_CLASS_NAME));
setPageComplete(false);
return;
}
-
+
+ IFieldEditor editor = editorRegistry.get(IParameter.SEAM_PACKAGE_NAME);
+ if(editor!=null) {
+ errors = ValidatorFactory.PACKAGE_NAME_VALIDATOR.validate(editor.getValue(), null);
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString()); //$NON-NLS-1$
+ setPageComplete(false);
+ return;
+ }
+ }
+
errors = ValidatorFactory.FILE_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_MASTER_PAGE_NAME).getValue(), new
Object[]{SeamUIMessages.SEAM_ENTITY_WIZARD_PAGE1_ENTITY_MASTER_PAGE,project,project});
-
+
if(errors.size()>0) {
setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
setPageComplete(false);
return;
}
-
+
errors = ValidatorFactory.FILE_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_PAGE_NAME).getValue(), new
Object[]{SeamUIMessages.SEAM_ENTITY_WIZARD_PAGE1_PAGE,project});
-
+
if(errors.size()>0) {
setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
setPageComplete(false);
@@ -124,7 +162,6 @@
*/
@Override
public String getDefaultMessageText() {
- // TODO Auto-generated method stub
return "Create a new Entity";
}
-}
+}
\ No newline at end of file