Author: akazakov
Date: 2007-10-22 12:39:55 -0400 (Mon, 22 Oct 2007)
New Revision: 4414
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ButtonFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
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/SelectJavaPackageAction.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1037
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2007-10-22
15:56:28 UTC (rev 4413)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/ValidatorFactory.java 2007-10-22
16:39:55 UTC (rev 4414)
@@ -11,11 +11,11 @@
package org.jboss.tools.seam.ui.internal.project.facet;
import java.io.File;
-import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -30,7 +30,9 @@
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.corext.util.Messages;
+import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
@@ -38,8 +40,6 @@
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.project.facet.SeamRuntime;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
-import org.jboss.tools.seam.core.project.facet.SeamVersion;
-import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamUIMessages;
@@ -67,7 +67,6 @@
*/
static public IValidator NO_ERRORS_VALIDATOR = new IValidator() {
public Map<String, String> validate(Object value, Object context) {
- // TODO Auto-generated method stub
return NO_ERRORS;
}
};
@@ -112,7 +111,7 @@
map.put(propertyName, text);
return map;
}
-
+
/**
*
*/
@@ -149,7 +148,7 @@
return errors;
}
String version = (String) context;
-
+
if(version.startsWith("2.0")) {
File seamJarFile = new File(value.toString(), "lib/jboss-seam.jar");
//$NON-NLS-1$
if (!seamJarFile.isFile()) {
@@ -167,7 +166,7 @@
SeamUIMessages.VALIDATOR_FACTORY_LOCATION_THAT_DOES_NOT_LOOK_LIKE_SEAM_HOME_FOLDER);
}
}
-
+
return errors;
}
};
@@ -216,6 +215,19 @@
}
};
+ public static final IValidator PACKAGE_NAME_VALIDATOR = new IValidator() {
+ public Map<String, String> validate(Object value, Object context) {
+ IStatus status = JavaConventions.validatePackageName(value
+ .toString(), CompilerOptions.VERSION_1_5,
+ CompilerOptions.VERSION_1_5);
+ if (status.getSeverity() == IStatus.ERROR) {
+ return
createErrormessage((Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName,
status.getMessage())));
+ }
+
+ return ValidatorFactory.NO_ERRORS;
+ }
+ };
+
/**
*
*/
@@ -225,7 +237,7 @@
return ValidatorFactory.NO_ERRORS;
};
};
-
+
/**
*
* @author eskimo
@@ -257,7 +269,7 @@
throw new IllegalArgumentException(
"Context parameter should be instance of Object[]"); //$NON-NLS-1$
}
-
+
Object[] contextArray = ((Object[]) context);
IProject project = (IProject) contextArray[1];
@@ -292,7 +304,7 @@
CompilationUnit compilationUnit = createCompilationUnit(
"class ClassName {public void " //$NON-NLS-1$
+ value.toString() + "() {}}",project); //$NON-NLS-1$
-
+
IProblem[] problems = compilationUnit.getProblems();
if (problems.length > 0) {
@@ -378,7 +390,7 @@
return NO_ERRORS;
}
};
-
+
public static final IValidator SEAM_RUNTIME_NAME_VALIDATOR = new IValidator() {
public Map<String, String> validate(Object value, Object context) {
@@ -418,13 +430,13 @@
return errors;
}
};
-
+
public static final IValidator SEAM_RUNTIME_VALIDATOR = new IValidator() {
public java.util.Map<String, String> validate(Object value,
Object context) {
Map<String,String> errors = NO_ERRORS;
String rtName = value.toString();
-
+
if(value==null || "".equals(value)) { //$NON-NLS-1$
errors =
createErrormessage(SeamUIMessages.VALIDATOR_FACTORY_SEAM_RT_NOT_CONFIGURED);
} else {
@@ -462,4 +474,4 @@
.createAST(null);
return compilationUnit;
}
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ButtonFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ButtonFieldEditor.java 2007-10-22
15:56:28 UTC (rev 4413)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ButtonFieldEditor.java 2007-10-22
16:39:55 UTC (rev 4414)
@@ -49,7 +49,7 @@
@Override
public Object[] getEditorControls() {
- return null;
+ return new Control[]{button.getControl()};
}
@Override
@@ -63,7 +63,7 @@
@Override
public void setEditable(boolean ediatble) {
}
-
+
@Override
public Object[] getEditorControls(Object composite) {
if(button==null && composite!=null) {
@@ -75,11 +75,11 @@
public ButtonPressedAction getButtonaction() {
return buttonAction;
}
-
+
public static class ButtonPressedAction extends Action implements SelectionListener{
-
+
private IFieldEditor editor = null;
-
+
public ButtonPressedAction(String label) {
super(label);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2007-10-22
15:56:28 UTC (rev 4413)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2007-10-22
16:39:55 UTC (rev 4414)
@@ -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;
/**
*
@@ -99,5 +101,14 @@
"${" + IParameter.SEAM_TEST_PROJECT_LOCATION_PATH +
"}/test-src/${" + ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH +
"}/${"+ IParameter.SEAM_LOCAL_INTERFACE_NAME +"}Test.xml"});
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
ACTION_EAR_MAPPING.add(ACTION_WAR_MAPPING.get(3));
}
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.wizard.SeamBaseOperation#getSessionBeanPackageName(org.eclipse.core.runtime.preferences.IEclipsePreferences,
java.util.Map)
+ */
+ @Override
+ protected String getSessionBeanPackageName(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/SeamActionWizardPage1.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java 2007-10-22
15:56:28 UTC (rev 4413)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizardPage1.java 2007-10-22
16:39:55 UTC (rev 4414)
@@ -28,8 +28,16 @@
super("seam.new.action.page1",
SeamUIMessages.SEAM_ACTION_WIZARD_PAGE1_SEAM_ACTION, null, is); //$NON-NLS-1$
setMessage(getDefaultMessageText());
}
-
+ @Override
+ protected void createEditors() {
+ super.createEditors();
+ String selectedProject = SeamWizardUtils.getRootSeamProjectName(initialSelection);
+ String packageName = getDefaultPackageName(selectedProject);
+ addEditor(SeamWizardFactory.createSeamJavaPackageSelectionFieldEditor(packageName));
+ setSeamProjectNameData(selectedProject);
+ }
+
/* (non-Javadoc)
* @see org.jboss.tools.seam.ui.wizard.SeamBaseWizardPage#getDefaultMessageText()
*/
@@ -37,4 +45,4 @@
public String getDefaultMessageText() {
return "Create a new Seam action";
}
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2007-10-22
15:56:28 UTC (rev 4413)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2007-10-22
16:39:55 UTC (rev 4414)
@@ -11,10 +11,8 @@
package org.jboss.tools.seam.ui.wizard;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -27,12 +25,9 @@
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
@@ -47,7 +42,6 @@
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.SeamProjectsSet;
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
-import org.jboss.tools.seam.internal.core.project.facet.AntCopyUtils;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.internal.core.project.facet.SeamFacetFilterSetFactory;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
@@ -65,7 +59,6 @@
*/
public SeamBaseOperation(String label) {
super(label);
- // TODO Auto-generated constructor stub
}
/**
@@ -95,10 +88,14 @@
loadCustomVariables(vars);
- String actionFolder =
vars.get(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString();
- String entityFolder =
vars.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME).toString();
- String testFolder =
vars.get(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME).toString();
+// String actionFolder =
vars.get(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME).toString();
+// String entityFolder =
vars.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME).toString();
+// String testFolder =
vars.get(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME).toString();
+ String actionFolder = getSessionBeanPackageName(seamFacetPrefs, params);
+ String entityFolder = getEntityBeanPackageName(seamFacetPrefs, params);
+ String testFolder = getTestCasesPackageName(seamFacetPrefs, params);
+
IVirtualComponent com = ComponentCore.createComponent(project);
IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/"));
//$NON-NLS-1$
IContainer webRootContainer = webRootFolder.getUnderlyingFolder();
@@ -133,7 +130,6 @@
* @see java.lang.Runnable#run()
*/
public void run() {
- // TODO Auto-generated method stub
if(file.length > 0){
IFile iFile = project.getWorkspace().getRoot().getFileForLocation(new
Path(file[0].getAbsolutePath()));
try {
@@ -154,6 +150,18 @@
return result;
}
+ protected String getSessionBeanPackageName(IEclipsePreferences seamFacetPrefs,
Map<String, INamedElement> wizardParams) {
+ return seamFacetPrefs.get(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME,
"");
+ }
+
+ protected String getEntityBeanPackageName(IEclipsePreferences seamFacetPrefs,
Map<String, INamedElement> wizardParams) {
+ return seamFacetPrefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME,
"");
+ }
+
+ protected String getTestCasesPackageName(IEclipsePreferences seamFacetPrefs,
Map<String, INamedElement> wizardParams) {
+ return seamFacetPrefs.get(ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_NAME,
"");
+ }
+
/**
* @param fileMapping
* @param vars
@@ -194,7 +202,7 @@
public FilterSetCollection getFilterSetCollection(Map vars) {
return new
FilterSetCollection(SeamFacetFilterSetFactory.createFiltersFilterSet(vars));
}
-
+
/* (non-Javadoc)
* @see
org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor,
org.eclipse.core.runtime.IAdaptable)
*/
@@ -222,12 +230,11 @@
public boolean canUndo() {
return false;
}
-
+
public File getSeamFolder(Map<String, Object> vars) {
return new
File(vars.get(ISeamFacetDataModelProperties.JBOSS_SEAM_HOME).toString(),"seam-gen");
//$NON-NLS-1$
}
-
+
protected void loadCustomVariables(Map<String, Object> vars) {
-
}
-}
+}
\ No newline at end of file
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
15:56:28 UTC (rev 4413)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseWizardPage.java 2007-10-22
16:39:55 UTC (rev 4414)
@@ -22,6 +22,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -45,7 +46,7 @@
*/
public abstract class SeamBaseWizardPage extends WizardPage implements IAdaptable,
PropertyChangeListener {
- private final IStructuredSelection initialSelection;
+ protected final IStructuredSelection initialSelection;
/**
*
@@ -72,21 +73,21 @@
protected void createEditors() {
addEditors(SeamWizardFactory.createBaseFormFieldEditors(SeamWizardUtils.getRootSeamProjectName(initialSelection)));
}
-
+
Map<String,IFieldEditor> editorRegistry = new
HashMap<String,IFieldEditor>();
-
+
List<IFieldEditor> editorOrder = new ArrayList<IFieldEditor>();
-
+
/**
* @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
setControl(new GridLayoutComposite(parent));
-
+
if (!"".equals(editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValue())){
//$NON-NLS-1$
Map errors = ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(
getEditor(IParameter.SEAM_PROJECT_NAME).getValue(), null);
-
+
if(errors.size()>0) {
setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
getEditor(IParameter.SEAM_BEAN_NAME).setEnabled(false);
@@ -117,7 +118,7 @@
return editorRegistry;
return null;
}
-
+
/**
*
* @param id
@@ -128,7 +129,7 @@
editorOrder.add(editor);
editor.addPropertyChangeListener(this);
}
-
+
/**
*
* @param id
@@ -139,7 +140,7 @@
addEditor(fieldEditor);
}
}
-
+
/**
*
* @param name
@@ -148,18 +149,16 @@
public IFieldEditor getEditor(String name) {
return editorRegistry.get(name);
}
-
-
+
public void setDefaultValue(String name, Object value) {
IFieldEditor editor = getEditor(name);
editor.removePropertyChangeListener(this);
editor.setValue(value);
editor.addPropertyChangeListener(this);
}
+
/**
- *
* @author eskimo
- *
*/
public class GridLayoutComposite extends Composite {
@@ -180,12 +179,12 @@
fieldEditor2.doFillIntoGrid(this);
}
}
-
+
public GridLayoutComposite(Composite parent) {
this(parent, SWT.NONE);
}
}
-
+
/* (non-Javadoc)
* @see
java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@@ -199,67 +198,81 @@
*/
protected void doValidate(PropertyChangeEvent event) {
if(!isValidProjectSelected()) return;
-
+
IProject project = getSelectedProject();
- getEditor(IParameter.SEAM_BEAN_NAME).setEnabled(!isWar());
+ boolean isWar = isWar();
+ getEditor(IParameter.SEAM_BEAN_NAME).setEnabled(!isWar);
+ IFieldEditor packageEditor = getEditor(IParameter.SEAM_PACKAGE_NAME);
+ if(packageEditor!=null) {
+ packageEditor.setEnabled(!isWar);
+ }
if(!isValidRuntimeConfigured(project)) return;
-
+
LabelFieldEditor label =
(LabelFieldEditor)((CompositeEditor)getEditor(IParameter.SEAM_LOCAL_INTERFACE_NAME)).getEditors().get(0);
- label.getLabelControl().setText(isWar()?SeamUIMessages.SEAM_BASE_WIZARD_PAGE_POJO_CLASS_NAME:
SeamUIMessages.SEAM_BASE_WIZARD_PAGE_LOCAL_CLASS_NAME);
-
+ label.getLabelControl().setText(isWar?SeamUIMessages.SEAM_BASE_WIZARD_PAGE_POJO_CLASS_NAME:
SeamUIMessages.SEAM_BASE_WIZARD_PAGE_LOCAL_CLASS_NAME);
+
Map errors = ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_COMPONENT_NAME).getValue(), null);
-
+
if(errors.size()>0) {
setErrorMessage(NLS.bind(errors.get(IValidator.DEFAULT_ERROR).toString(),SeamUIMessages.SEAM_BASE_WIZARD_PAGE_SEAM_COMPONENTS));
setPageComplete(false);
return;
}
-
+
errors = ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_LOCAL_INTERFACE_NAME).getValue(), null);
-
+
if(errors.size()>0) {
setErrorMessage(NLS.bind(errors.get(IValidator.DEFAULT_ERROR).toString(),SeamUIMessages.SEAM_BASE_WIZARD_PAGE_LOCAL_INTERFACE));
setPageComplete(false);
return;
}
- if(!isWar()) {
+ if(!isWar) {
errors = ValidatorFactory.SEAM_COMPONENT_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_BEAN_NAME).getValue(), null);
-
+
if(errors.size()>0) {
setErrorMessage(NLS.bind(errors.get(IValidator.DEFAULT_ERROR).toString(),"Bean"));
//$NON-NLS-1$
setPageComplete(false);
return;
}
- } else {
-
}
-
+
+ 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.SEAM_METHOD_NAME_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_METHOD_NAME).getValue(), new
Object[]{"Method",project}); //$NON-NLS-1$
-
+
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[]{"Page",project}); //$NON-NLS-1$
-
+
if(errors.size()>0) {
setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
setPageComplete(false);
return;
}
-
+
errors = ValidatorFactory.SEAM_JAVA_INTEFACE_NAME_CONVENTION_VALIDATOR.validate(
editorRegistry.get(IParameter.SEAM_LOCAL_INTERFACE_NAME).getValue(), new
Object[]{SeamUIMessages.SEAM_BASE_WIZARD_PAGE_LOCAL_INTERFACE,project});
-
+
if(errors.size()>0) {
setErrorMessage(null);
setMessage(errors.get(IValidator.DEFAULT_ERROR).toString(),IMessageProvider.WARNING);
@@ -290,16 +303,20 @@
protected boolean isValidProjectSelected() {
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);
getEditor(IParameter.SEAM_BEAN_NAME).setEnabled(false);
+ IFieldEditor packageEditor = getEditor(IParameter.SEAM_PACKAGE_NAME);
+ if(packageEditor!=null) {
+ packageEditor.setEnabled(false);
+ }
return false;
- }
+ }
return true;
}
-
+
/**
*
*/
@@ -322,13 +339,36 @@
}
}
if(event.getPropertyName().equals(IParameter.SEAM_PROJECT_NAME)) {
- IFieldEditor editor = getEditor(IParameter.SEAM_PACKAGE_NAME);
- if(editor!=null) {
- editor.setData(IParameter.SEAM_PROJECT_NAME, event.getNewValue());
+ String selectedProject = event.getNewValue().toString();
+ setSeamProjectNameData(selectedProject);
+ setDefaultValue(IParameter.SEAM_PACKAGE_NAME,
getDefaultPackageName(selectedProject));
+ }
+ }
+
+ protected String getDefaultPackageName(String selectedProject) {
+ String packageName = "";
+ if(selectedProject!=null && selectedProject.length()>0) {
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(selectedProject);
+ if(project!=null) {
+ IEclipsePreferences seamFacetPrefs = SeamCorePlugin.getSeamPreferences(project);
+ packageName = getDefaultPackageName(seamFacetPrefs);
}
}
+
+ return packageName;
}
+ protected String getDefaultPackageName(IEclipsePreferences seamFacetPrefs) {
+ return seamFacetPrefs.get(ISeamFacetDataModelProperties.SESION_BEAN_PACKAGE_NAME,
"");
+ }
+
+ protected void setSeamProjectNameData(String projectName) {
+ IFieldEditor editor = getEditor(IParameter.SEAM_PACKAGE_NAME);
+ if(editor!=null) {
+ editor.setData(IParameter.SEAM_PROJECT_NAME, projectName);
+ }
+ }
+
/**
* @return
*/
@@ -337,12 +377,12 @@
editorRegistry.get(IParameter.SEAM_PROJECT_NAME).getValueAsString());
return (IProject)project;
}
-
+
public boolean isWar() {
if(getSelectedProject()==null ||
SeamCorePlugin.getSeamPreferences(getSelectedProject().getProject())==null) return
true;
return
"war".equals(SeamCorePlugin.getSeamPreferences(getSelectedProject().getProject()).get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,"war"));
//$NON-NLS-1$ //$NON-NLS-2$
}
-
+
public abstract String getDefaultMessageText();
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectJavaPackageAction.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectJavaPackageAction.java 2007-10-22
15:56:28 UTC (rev 4413)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectJavaPackageAction.java 2007-10-22
16:39:55 UTC (rev 4414)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.util.ArrayList;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jdt.core.IJavaElement;
@@ -40,6 +42,9 @@
@Override
public void run() {
String projectName = (String)getFieldEditor().getData(IParameter.SEAM_PROJECT_NAME);
+ if(projectName == null) {
+ return;
+ }
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if(project == null) {
SeamGuiPlugin.getPluginLog().logError("Can't find java project with name:
" + projectName);
@@ -85,12 +90,29 @@
packages = new IJavaElement[0];
}
+ String initialValue = getFieldEditor().getValue().toString();
+ IJavaElement initialElement = null;
+ ArrayList packagesWithouDefaultPackage = new ArrayList();
+ for (IJavaElement packageElement : packages) {
+ String packageName = packageElement.getElementName();
+ if(packageName.length()>0) {
+ packagesWithouDefaultPackage.add(packageElement);
+ if(packageName.equals(initialValue)) {
+ initialElement = packageElement;
+ }
+ }
+ }
+
+ packages = (IJavaElement[])packagesWithouDefaultPackage.toArray(new
IJavaElement[packagesWithouDefaultPackage.size()]);
ElementListSelectionDialog dialog = new
ElementListSelectionDialog(Display.getCurrent().getActiveShell(), new
JavaElementLabelProvider(
JavaElementLabelProvider.SHOW_DEFAULT));
dialog.setTitle(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_TITLE);
dialog.setMessage(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_DESC);
dialog.setEmptyListMessage(J2EEUIMessages.PACKAGE_SELECTION_DIALOG_MSG_NONE);
dialog.setElements(packages);
+ if(initialElement!=null) {
+ dialog.setInitialSelections(new Object[]{initialElement});
+ }
if (dialog.open() == Window.OK) {
IPackageFragment fragment = (IPackageFragment) dialog.getFirstResult();
if (fragment != null) {