[jbosstools-commits] JBoss Tools SVN: r6792 - in trunk/seam/plugins: org.jboss.tools.seam.core/src/org/jboss/tools/seam/core and 6 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Mar 7 16:10:15 EST 2008


Author: akazakov
Date: 2008-03-07 16:10:15 -0500 (Fri, 07 Mar 2008)
New Revision: 6792

Modified:
   trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectSeamProjectAction.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1322

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/META-INF/MANIFEST.MF	2008-03-07 21:10:15 UTC (rev 6792)
@@ -51,14 +51,15 @@
  org.jboss.tools.seam.internal.core.refactoring
 Bundle-Version: 2.0.0
 Export-Package: org.jboss.tools.seam.core,
+ org.jboss.tools.seam.core.commands,
  org.jboss.tools.seam.core.event,
  org.jboss.tools.seam.core.project.facet,
  org.jboss.tools.seam.internal.core,
  org.jboss.tools.seam.internal.core.el,
  org.jboss.tools.seam.internal.core.project.facet,
+ org.jboss.tools.seam.internal.core.refactoring,
  org.jboss.tools.seam.internal.core.scanner,
  org.jboss.tools.seam.internal.core.scanner.java,
  org.jboss.tools.seam.internal.core.scanner.lib,
  org.jboss.tools.seam.internal.core.scanner.xml,
- org.jboss.tools.seam.internal.core.validation,
- org.jboss.tools.seam.internal.core.refactoring
+ org.jboss.tools.seam.internal.core.validation

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamProjectsSet.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -79,10 +79,7 @@
 		if(prefs==null) {
 			return false;
 		}
-		return prefs.get(
-				ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, 
-				ISeamFacetDataModelProperties.DEPLOY_AS_WAR)
-					.equals(ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
+		return prefs.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, ISeamFacetDataModelProperties.DEPLOY_AS_WAR).equals(ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
 	}
 
 	/**
@@ -122,11 +119,14 @@
 	 * @return the action folder (this folder is not guaranteed to exist!)
 	 */	
 	public IFolder getActionFolder() {
-		if(prefs==null) {
+		String folderPath = null;
+		if(prefs!=null) {
+			folderPath = prefs.get(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER, null);
+		}
+		if(folderPath==null) {
 			return getSourceFolder();
 		}
 
-		String folderPath = prefs.get(ISeamFacetDataModelProperties.SESSION_BEAN_SOURCE_FOLDER, null);
 		return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
 	}
 
@@ -135,11 +135,14 @@
 	 * @return the model folder if exists (this folder is not guaranteed to exist!)
 	 */
 	public IFolder getModelFolder() {
-		if(prefs==null) {
+		String folderPath = null;
+		if(prefs!=null) {
+			folderPath = prefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, null);
+		}
+		if(folderPath==null) {
 			return getSourceFolder();
 		}
 
-		String folderPath = prefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, null);
 		return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
 	}
 
@@ -167,7 +170,11 @@
 	 * @return
 	 */
 	public IFolder getViewsFolder() {
-		if(prefs==null) {
+		String folderPath = null;
+		if(prefs!=null) {
+			folderPath = prefs.get(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, null);
+		}
+		if(folderPath==null) {
 			IVirtualComponent com = ComponentCore.createComponent(war);
 			if(com!=null) {
 				IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/")); //$NON-NLS-1$
@@ -178,7 +185,6 @@
 			return null;
 		}
 
-		String folderPath = prefs.get(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, null);
 		return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
 	}
 
@@ -187,15 +193,21 @@
 	 * @return
 	 */
 	public IFolder getTestsFolder() {
-		if(prefs==null) {
+		String folderPath = null;
+		if(prefs!=null) {
+			folderPath = prefs.get(ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER, null);
+		}
+		if(folderPath==null) {
 			return getSourceFolder();
 		}
 
-		String folderPath = prefs.get(ISeamFacetDataModelProperties.TEST_SOURCE_FOLDER, null);
 		return (IFolder)ResourcesPlugin.getWorkspace().getRoot().findMember(folderPath);
 	}
 
 	public String getEntityPackage(){
+		if(prefs==null) {
+			return "entity";
+		}
 		return prefs.get(ISeamFacetDataModelProperties.ENTITY_BEAN_PACKAGE_NAME, "entity"); //$NON-NLS-1$
 	}
 

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -305,8 +305,6 @@
 
 	public static String SEAM_WIZARD_FACTORY_SEAM_PROJECT;
 
-	public static String SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT;
-
 	public static String SELECT_SEAM_PROJECT_ACTION_BROWSE;
 
 	public static String SWT_FIELD_EDITOR_FACTORY_BROWS;
@@ -412,6 +410,8 @@
 	public static String RUNTIME_DELETE_NOT_USED_CONFIRM;
 
 	public static String RUNTIME_DELETE_USED_CONFIRM;
+
+	public static String VIEW_FOLDER_FILED_EDITOR;
 	
 	public static String FIND_DECLARATIONS_ACTION_ACTION_NAME;
 	public static String FIND_DECLARATIONS_ACTION_DESCRIPTION;
@@ -423,6 +423,9 @@
 	public static String FIND_REFERENCES_ACTION_MESSAGE;
 	public static String FIND_REFERENCES_ACTION_TOOL_TIP;
 
+	public static String SELECT_WORKSPACE_FOLDER_DIALOG_TITLE;
+	public static String SELECT_WORKSPACE_FOLDER_DIALOG_MESSAGE;
+	
 	public static String SeamSearchQuery_task_label;
 	public static String SeamSearchQuery_label;
 	public static String SeamSearchQuery_error_unsupported_pattern;

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -18,28 +18,20 @@
 import java.util.Map;
 
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.datatools.connectivity.ConnectionProfileException;
 import org.eclipse.datatools.connectivity.IConnectionProfile;
-import org.eclipse.datatools.connectivity.IProfileListener;
 import org.eclipse.datatools.connectivity.ProfileManager;
-import org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard;
-import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizard;
-import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizardCategoryFilter;
 import org.eclipse.jdt.core.JavaConventions;
 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
 import org.eclipse.osgi.util.NLS;
 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.Display;
 import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.internal.dialogs.PropertyDialog;
 import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
 import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
 import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
@@ -62,7 +54,6 @@
 import org.jboss.tools.seam.core.project.facet.SeamVersion;
 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.ButtonFieldEditor;
 import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
 import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
 import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
@@ -81,8 +72,6 @@
 
 	private static final DriverClassHelpers HIBERNATE_HELPER = new DriverClassHelpers();
 
-	private static final List<String> DIALECT_CLASSES = getDialectClasses();
-
 	private IDataModel model = null;
 
 	private DataModelValidatorDelegate validatorDelegate;
@@ -97,18 +86,13 @@
 					Arrays.asList(new Object[] { ISeamFacetDataModelProperties.DEPLOY_AS_WAR, ISeamFacetDataModelProperties.DEPLOY_AS_EAR }),
 					getDeployAsDefaultValue());
 
-	String lastCreatedCPName = ""; //$NON-NLS-1$
-
 	// Database group
-	private IFieldEditor connProfileSelEditor = IFieldEditorFactory.INSTANCE
-			.createComboWithTwoButtons(
-					ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
-					SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_CONNECTION_PROFILE,
-					getProfileNameList(),
-					getConnectionProfileDefaultValue(),
-					false, new EditConnectionProfileAction(),
-					new NewConnectionProfileAction(),
-					ValidatorFactory.NO_ERRORS_VALIDATOR);
+	private IFieldEditor connProfileSelEditor = SeamWizardFactory.createConnectionProfileSelectionFieldEditor(getConnectionProfileDefaultValue(), new IValidator() {
+		public Map<String, String> validate(Object value, Object context) {
+			SeamInstallWizardPage.this.validate();
+			return ValidatorFactory.NO_ERRORS;
+		}
+	});
 
 	private IFieldEditor jBossHibernateDbTypeEditor = IFieldEditorFactory.INSTANCE
 			.createComboEditor(ISeamFacetDataModelProperties.DB_TYPE,
@@ -163,17 +147,6 @@
 	/**
 	 * @return
 	 */
-	private static List<String> getDialectClasses() {
-		List<String> dialects = new ArrayList<String>();
-		for (String dialectName : HIBERNATE_HELPER.getDialectNames()) {
-			dialects.add(HIBERNATE_HELPER.getDialectClass(dialectName));
-		}
-		return dialects;
-	}
-
-	/**
-	 * @return
-	 */
 	private String getDefaultDbType() {
 		return SeamProjectPreferences.getStringPreference(
 				SeamProjectPreferences.HIBERNATE_DEFAULT_DB_TYPE);
@@ -193,9 +166,19 @@
 	private Object getConnectionProfileDefaultValue() {
 		String defaultDs = SeamProjectPreferences.getStringPreference(
 				SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE);
-		return getProfileNameList().contains(defaultDs)?defaultDs:""; //$NON-NLS-1$
+		return getConnectionProfileNameList().contains(defaultDs)?defaultDs:""; //$NON-NLS-1$
 	}
 
+	private static List<String> getConnectionProfileNameList() {
+		IConnectionProfile[] profiles = ProfileManager.getInstance()
+				.getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
+		List<String> names = new ArrayList<String>();
+		for (IConnectionProfile connectionProfile : profiles) {
+			names.add(connectionProfile.getName());
+		}
+		return names;
+	}
+
 	/**
 	 * 
 	 * @return
@@ -395,109 +378,7 @@
 		}
 	}
 
-	private List<String> getProfileNameList() {
-		IConnectionProfile[] profiles = ProfileManager.getInstance()
-				.getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
-		List<String> names = new ArrayList<String>();
-		for (IConnectionProfile connectionProfile : profiles) {
-			names.add(connectionProfile.getName());
-		}
-		return names;
-	}
-
 	/**
-	 * 
-	 */
-	public class EditConnectionProfileAction extends
-			ButtonFieldEditor.ButtonPressedAction {
-
-		/**
-		 * @param label
-		 */
-		public EditConnectionProfileAction() {
-			super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EDIT);
-		}
-
-		/**
-		 * 
-		 */
-		@Override
-		public void run() {
-			IConnectionProfile selectedProfile = ProfileManager.getInstance()
-					.getProfileByName(getFieldEditor().getValue().toString());
-			String oldName = getFieldEditor().getValue().toString();
-
-			if (selectedProfile == null)
-				return;
-			PropertyDialog
-					.createDialogOn(
-							Display.getCurrent().getActiveShell(),
-							"org.eclipse.datatools.connectivity.db.generic.profileProperties", //$NON-NLS-1$
-							selectedProfile).open();
-
-			if (!oldName.equals(selectedProfile.getName())) {
-				getFieldEditor().setValue(selectedProfile.getName());
-				((ITaggedFieldEditor) ((CompositeEditor) connProfileSelEditor)
-						.getEditors().get(1)).setTags(getProfileNameList()
-						.toArray(new String[0]));
-				oldName = selectedProfile.getName();
-			}
-			validate();
-		}
-	};
-
-	/**
-	 * Handler for ButtonFieldEditor that shows Property Editor dialog for
-	 * selected ConnectionProfile
-	 * 
-	 * @author eskimo
-	 */
-	public class NewConnectionProfileAction extends
-			ButtonFieldEditor.ButtonPressedAction {
-		/**
-		 * @param label
-		 */
-		public NewConnectionProfileAction() {
-			super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_NEW);
-		}
-
-		@Override
-		public void run() {
-			IProfileListener listener = new ConnectionProfileChangeListener();
-
-			ProfileManager.getInstance().addProfileListener(listener);
-			NewCPWizardCategoryFilter filter = new NewCPWizardCategoryFilter("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
-			NewCPWizard wizard = new NewCPWizard(filter, null);
-			new NewConnectionProfileWizard() {
-				public boolean performFinish() {
-					// create profile only
-					try {
-						ProfileManager.getInstance().createProfile(
-								getProfileName() == null ? "" //$NON-NLS-1$
-										: getProfileName(),
-								getProfileDescription() == null ? "" //$NON-NLS-1$
-										: getProfileDescription(),
-								mProviderID,
-								getProfileProperties(),
-								mProfilePage.getRepository() == null ? "" //$NON-NLS-1$
-										: mProfilePage.getRepository()
-												.getName(), false);
-						lastCreatedCPName = getProfileName();
-					} catch (ConnectionProfileException e) {
-						SeamCorePlugin.getPluginLog().logError(e);
-					}
-
-					return true;
-				}
-			};
-			WizardDialog wizardDialog = new WizardDialog(Display.getCurrent()
-					.getActiveShell(), wizard);
-			wizardDialog.open();
-			ProfileManager.getInstance().removeProfileListener(listener);
-		}
-	}
-
-	/**
 	 * It is overridden to fill Code Generation group with the default package
 	 * names
 	 */
@@ -704,34 +585,6 @@
 		}
 	}
 
-	public class ConnectionProfileChangeListener implements IProfileListener {
-		/* (non-Javadoc)
-		 * @see org.eclipse.datatools.connectivity.IProfileListener#profileAdded(org.eclipse.datatools.connectivity.IConnectionProfile)
-		 */
-		public void profileAdded(IConnectionProfile profile) {
-			connProfileSelEditor.setValue(profile.getName());
-			((ITaggedFieldEditor) ((CompositeEditor) connProfileSelEditor)
-					.getEditors().get(1)).setTags(getProfileNameList()
-					.toArray(new String[0]));
-			validate();
-		
-		}
-
-		/* (non-Javadoc)
-		 * @see org.eclipse.datatools.connectivity.IProfileListener#profileChanged(org.eclipse.datatools.connectivity.IConnectionProfile)
-		 */
-		public void profileChanged(IConnectionProfile profile) {
-			profileAdded(profile);
-		}
-
-		/* (non-Javadoc)
-		 * @see org.eclipse.datatools.connectivity.IProfileListener#profileDeleted(org.eclipse.datatools.connectivity.IConnectionProfile)
-		 */
-		public void profileDeleted(IConnectionProfile profile) {
-			// this event never happens
-		}
-	}
-
 	/**
 	 * 
 	 */

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties	2008-03-07 21:10:15 UTC (rev 6792)
@@ -202,7 +202,6 @@
 OPEN_SEAM_COMPONENT_ACTION_MESSAGE=Enter seam component name prefix or pattern (? = any character, * = any string):
 OPEN_SEAM_COMPONENT_DIALOG_LOADING=Seam components loading
 OPEN_SEAM_COMPONENT_DIALOG_NAME=OpenSeamComponentDialog
-SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT=Main Seam Project:
 FIND_DECLARATIONS_ACTION_ACTION_NAME=Find Seam Declarations
 FIND_DECLARATIONS_ACTION_DESCRIPTION=Find Seam Declarations
 FIND_DECLARATIONS_ACTION_TOOL_TIP=Find Seam Declarations
@@ -211,6 +210,9 @@
 FIND_REFERENCES_ACTION_DESCRIPTION=Find Seam References
 FIND_REFERENCES_ACTION_TOOL_TIP=Find Seam References
 FIND_REFERENCES_ACTION_MESSAGE=&Choose a name of the seam variable or pattern (? = any character, * = any string):
+VIEW_FOLDER_FILED_EDITOR=View Folder:
+SELECT_WORKSPACE_FOLDER_DIALOG_TITLE=Folder Selection
+SELECT_WORKSPACE_FOLDER_DIALOG_MESSAGE=&Chose a folder
 SeamSearchQuery_task_label=Searching for ''{0}''...
 SeamSearchQuery_label=Seam {0} Search
 SeamSearchQuery_error_unsupported_pattern=Unsupported search pattern: "{0}"

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -18,7 +18,25 @@
  */
 public class SeamPreferencesMessages extends NLS {
 	private static final String BUNDLE_NAME = "org.jboss.tools.seam.ui.preferences.SeamPreferencesMessages"; //$NON-NLS-1$
-	
+
+	public static String SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT;
+
+	public static String SEAM_SETTINGS_PREFERENCES_PAGE_EJB_PROJECT;
+
+	public static String SEAM_SETTINGS_PREFERENCES_PAGE_DEPLOYMENT;
+
+	public static String SEAM_SETTINGS_PREFERENCES_PAGE_VIEW;
+
+	public static String SEAM_SETTINGS_PREFERENCES_PAGE_MODEL;
+
+	public static String SEAM_SETTINGS_PREFERENCES_PAGE_ACTION;
+
+	public static String SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER;
+
+	public static String SEAM_SETTINGS_PREFERENCES_PAGE_PACKAGE;
+
+	public static String SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT;
+
 	public static String SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES;
 
 	public static String SEAM_SETTINGS_PREFERENCE_PAGE_ADD;
@@ -29,8 +47,6 @@
 
 	public static String SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED;
 
-	public static String SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT;
-
 	public static String SEAM_VALIDATOR_CONFIGURATION_BLOCK_ERROR;
 
 	public static String SEAM_VALIDATOR_CONFIGURATION_BLOCK_IGNORE;

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamPreferencesMessages.properties	2008-03-07 21:10:15 UTC (rev 6792)
@@ -62,12 +62,23 @@
 SeamValidatorConfigurationBlock_pb_unpairedGetterOrSetter_label=Unpaired Getter/Setter:
 SEAM_VALIDATOR_CONFIGURATION_BLOCK_SEAM_VALIDATOR_CONFIGURATION_BLOCK=SeamValidatorConfigurationBlock
 SEAM_VALIDATOR_CONFIGURATION_BLOCK_ERROR=Error
-SEAM_SETTINGS_PREFERENCE_PAGE_RUNTIME=Runtime
 SEAM_VALIDATOR_CONFIGURATION_BLOCK_WARNING=Warning
-SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT=Seam support
+
 SEAM_VALIDATOR_PREFERENCE_PAGE_SEAM_VALIDATOR=Seam Validator
 SEAM_VALIDATOR_CONFIGURATION_BLOCK_IGNORE=Ignore
+
+SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT=Main Seam Project:
+SEAM_SETTINGS_PREFERENCES_PAGE_EJB_PROJECT=Seam EJB Project:
+SEAM_SETTINGS_PREFERENCES_PAGE_DEPLOYMENT=Deployment
+SEAM_SETTINGS_PREFERENCES_PAGE_VIEW=View
+SEAM_SETTINGS_PREFERENCES_PAGE_MODEL=Model
+SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER=Source Folder:
+SEAM_SETTINGS_PREFERENCES_PAGE_PACKAGE=Package:
+SEAM_SETTINGS_PREFERENCES_PAGE_ACTION=Action/Form/Conversation
+SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT=Seam support:
+
+SEAM_SETTINGS_PREFERENCE_PAGE_RUNTIME=Runtime
 SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED=Seam runtime is not selected
 SEAM_SETTINGS_PREFERENCE_PAGE_ADD=Add
 SEAM_PREFERENCE_PAGE_SEAM_RUNTIMES=Seam Runtimes
-SEAM_SETTINGS_PREFERENCE_PAGE_INSTALLED_RUNTIMES=Installed Runtimes
+SEAM_SETTINGS_PREFERENCE_PAGE_INSTALLED_RUNTIMES=Installed Runtimes
\ No newline at end of file

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -12,54 +12,58 @@
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.io.File;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
-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.preferences.IEclipsePreferences;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.ProfileManager;
 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.Control;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.ui.dialogs.PropertyPage;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
 import org.jboss.tools.seam.core.ISeamProject;
 import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.SeamProjectsSet;
+import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
 import org.jboss.tools.seam.core.project.facet.SeamVersion;
 import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
 import org.jboss.tools.seam.ui.SeamGuiPlugin;
 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;
 import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
-import org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor;
 import org.jboss.tools.seam.ui.wizard.IParameter;
 import org.jboss.tools.seam.ui.wizard.SeamWizardFactory;
 import org.jboss.tools.seam.ui.wizard.SeamWizardUtils;
 import org.osgi.service.prefs.BackingStoreException;
 
 /**
+ * Seam Settings Preference Page
  * @author Alexey Kazakov
  */
 public class SeamSettingsPreferencePageNew extends PropertyPage implements PropertyChangeListener {
 
 	private Map<String,IFieldEditor> editorRegistry = new HashMap<String,IFieldEditor>();
-	private List<IFieldEditor> editorOrder = new ArrayList<IFieldEditor>();
 	private IProject project;
 	private IProject warProject;
 	private IEclipsePreferences preferences;
 	private ISeamProject warSeamProject;
+	private boolean suportSeam;
+	private boolean runtimeIsSelected;
+	private List<Group> groups = new ArrayList<Group>();
 
 	/*
 	 * (non-Javadoc)
@@ -73,6 +77,8 @@
 		if(warProject!=null) {
 			preferences = SeamCorePlugin.getSeamPreferences(warProject);
 			warSeamProject = SeamCorePlugin.getSeamProject(warProject, false);
+		} else {
+			preferences = SeamCorePlugin.getSeamPreferences(project);
 		}
 	}
 
@@ -81,17 +87,197 @@
 	 */
 	@Override
 	protected Control createContents(Composite parent) {
-		IFieldEditor projectNameEditor = IFieldEditorFactory.INSTANCE.createUneditableTextEditor(IParameter.SEAM_PROJECT_NAME, SeamUIMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT, getSeamProjectName());
-		addEditor(projectNameEditor);
+		Composite root = new Composite(parent, SWT.NONE);
+		GridData gd = new GridData();
 
+		gd.horizontalSpan = 1;
+		gd.horizontalAlignment = GridData.FILL;
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = false;
+
+		GridLayout gridLayout = new GridLayout(1, false);
+		root.setLayout(gridLayout);
+		Composite generalGroup = new Composite(root, SWT.NONE);
+		generalGroup.setLayoutData(gd);
+		gridLayout = new GridLayout(4, false);
+
+		generalGroup.setLayout(gridLayout);
+
+		IFieldEditor seamSupportCheckBox = IFieldEditorFactory.INSTANCE.createCheckboxEditor(
+				SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT, SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT, warSeamProject!=null);
+		seamSupportCheckBox.addPropertyChangeListener(new PropertyChangeListener() {
+			public void propertyChange(PropertyChangeEvent evt) {
+				Object value = evt.getNewValue();
+				if (value instanceof Boolean) {
+					boolean v = ((Boolean) value).booleanValue();
+					setEnabledSeamSuport(v);
+					validate();
+				}
+			}
+		});
+		registerEditor(seamSupportCheckBox, generalGroup);
+
 		IFieldEditor seamRuntimeEditor = SeamWizardFactory.createSeamRuntimeSelectionFieldEditor(getSeamVersions(), getSeamRuntimeName());
-		addEditor(seamRuntimeEditor);
+		seamRuntimeEditor.addPropertyChangeListener(new PropertyChangeListener() {
+			public void propertyChange(PropertyChangeEvent evt) {
+				Object value = evt.getNewValue();
+				if(value.toString().length()>0) {
+					setRuntimeIsSelected(true);
+				} else {
+					setRuntimeIsSelected(false);
+				}
+				validate();
+			}
+		});
+		registerEditor(seamRuntimeEditor, generalGroup);
 
-		Control control = new GridLayoutComposite(parent);
+		IFieldEditor projectNameEditor = IFieldEditorFactory.INSTANCE.createUneditableTextEditor(IParameter.SEAM_PROJECT_NAME, SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SEAM_PROJECT, getSeamProjectName());
+		registerEditor(projectNameEditor, generalGroup);
 
-		return control;
+		IFieldEditor connProfileEditor = SeamWizardFactory.createConnectionProfileSelectionFieldEditor(getConnectionProfile(), new IValidator() {
+			public Map<String, String> validate(Object value, Object context) {
+				SeamSettingsPreferencePageNew.this.validate();
+				return ValidatorFactory.NO_ERRORS;
+			}
+		});
+		registerEditor(connProfileEditor, generalGroup);
+
+		gd = new GridData();
+		gd.horizontalSpan = 1;
+		gd.horizontalAlignment = GridData.FILL;
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = false;
+
+		Group deploymentGroup = new Group(root, SWT.NONE);
+		groups.add(deploymentGroup);
+		deploymentGroup.setLayoutData(gd);
+		deploymentGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_DEPLOYMENT);
+		gridLayout = new GridLayout(4, false);
+		deploymentGroup.setLayout(gridLayout);
+
+		IFieldEditor deployTypeEditor = IFieldEditorFactory.INSTANCE.createRadioEditor(
+				ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
+				SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DEPLOY_AS, 
+				Arrays.asList(new String[] {ISeamFacetDataModelProperties.DEPLOY_AS_WAR.toUpperCase(), ISeamFacetDataModelProperties.DEPLOY_AS_EAR.toUpperCase()}),
+				Arrays.asList(new Object[] {ISeamFacetDataModelProperties.DEPLOY_AS_WAR, ISeamFacetDataModelProperties.DEPLOY_AS_EAR}),
+				getDeployAsValue());
+
+		registerEditor(deployTypeEditor, deploymentGroup);
+
+		IFieldEditor ejbProjectEditor = SeamWizardFactory.createSeamProjectSelectionFieldEditor(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_EJB_PROJECT, getEjbProjectName(), true);
+		registerEditor(ejbProjectEditor, deploymentGroup);
+
+		Group viewGroup = new Group(root, SWT.NONE);
+		groups.add(viewGroup);
+		gd = new GridData();
+		gd.horizontalSpan = 1;
+		gd.horizontalAlignment = GridData.FILL;
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = false;
+
+		viewGroup.setLayoutData(gd);
+		viewGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_VIEW);
+		gridLayout = new GridLayout(3, false);
+		viewGroup.setLayout(gridLayout);
+
+		IFieldEditor viewFolderEditor = SeamWizardFactory.createViewFolderFieldEditor(getViewFolder());
+		registerEditor(viewFolderEditor, viewGroup);
+
+		Group modelGroup = new Group(root, SWT.NONE);
+		groups.add(modelGroup);
+		gd = new GridData();
+		gd.horizontalSpan = 1;
+		gd.horizontalAlignment = GridData.FILL;
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = false;
+
+		modelGroup.setLayoutData(gd);
+		modelGroup.setText(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_MODEL);
+		gridLayout = new GridLayout(3, false);
+		modelGroup.setLayout(gridLayout);
+
+		IFieldEditor modelSourceFolderEditor = IFieldEditorFactory.INSTANCE.createBrowseSourceFolderEditor(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCES_PAGE_SOURCE_FOLDER, getModelSourceFolder());
+		registerEditor(modelSourceFolderEditor, modelGroup);
+
+		setEnabledSeamSuport(warSeamProject!=null);
+		setRuntimeIsSelected(getSeamRuntimeName().length()>0);
+
+		return root;
 	}
 
+	private String getModelSourceFolder() {
+		String folder = null;
+		if(preferences!=null) {
+			folder = preferences.get(ISeamFacetDataModelProperties.ENTITY_BEAN_SOURCE_FOLDER, null);
+		}
+		if(folder==null) {
+			SeamProjectsSet set = new SeamProjectsSet(project);
+			IFolder f = set.getModelFolder();
+			folder = f!=null?f.getFullPath().toString():"";
+		}
+		return folder;
+	}
+
+	private String getViewFolder() {
+		String folder = null;
+		if(preferences!=null) {
+			folder = preferences.get(ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER, null);
+		}
+		if(folder==null) {
+			SeamProjectsSet set = new SeamProjectsSet(project);
+			IFolder f = set.getViewsFolder();
+			folder = f!=null?f.getFullPath().toString():"";
+		}
+		return folder;
+	}
+
+	private List<String> getProfileNameList() {
+		IConnectionProfile[] profiles = ProfileManager.getInstance()
+				.getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
+		List<String> names = new ArrayList<String>();
+		for (IConnectionProfile connectionProfile : profiles) {
+			names.add(connectionProfile.getName());
+		}
+		return names;
+	}
+
+	private String getConnectionProfile() {
+		String defaultDs = SeamProjectPreferences.getStringPreference(
+				SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE);
+		return getProfileNameList().contains(defaultDs)?defaultDs:""; //$NON-NLS-1$
+	}
+
+	private String getEjbProjectName() {
+		if(preferences!=null) {
+			return preferences.get(ISeamFacetDataModelProperties.SEAM_EJB_PROJECT, project.getName());
+		}
+		return project.getName();
+	}
+
+	private Object getDeployAsValue() {
+		if(preferences!=null) {
+			return preferences.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, ISeamFacetDataModelProperties.DEPLOY_AS_WAR);
+		}
+		return ISeamFacetDataModelProperties.DEPLOY_AS_WAR;
+	}
+
+	private void validate() {
+//		if(getSeamSupport() && (runtime.getValue()== null || "".equals(runtime.getValue()))) { //$NON-NLS-1$
+////			setValid(false);
+//			setMessage(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED, IMessageProvider.WARNING);
+////			setErrorMessage(SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_RUNTIME_IS_NOT_SELECTED);
+//		} else {
+//			setValid(true);
+//			String value = runtime.getValueAsString();
+//			if(Boolean.TRUE.equals(seamEnablement.getValue()) && SeamRuntimeManager.getInstance().findRuntimeByName(value) == null) {
+//				setErrorMessage("Runtime " + value + " does not exist.");
+//			} else {
+//				setErrorMessage(null);
+//				setMessage(null, IMessageProvider.WARNING);
+//			}
+//		}
+	}
+
 	private String getSeamRuntimeName() {
 		if(preferences!=null) {
 			return preferences.get(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME, "");
@@ -109,15 +295,9 @@
 	public void propertyChange(PropertyChangeEvent evt) {
 	}
 
-	/**
-	 * 
-	 * @param id
-	 * @param editor
-	 */
-	public void addEditor(IFieldEditor editor) {
+	private void registerEditor(IFieldEditor editor, Composite parent) {
 		editorRegistry.put(editor.getName(), editor);
-		editorOrder.add(editor);
-		editor.addPropertyChangeListener(this);
+		editor.doFillIntoGrid(parent);
 	}
 
 	/*
@@ -146,10 +326,38 @@
 	}
 
 	private boolean isSeamSupported() {
-		//TODO
-		return true;
+		return suportSeam;
 	}
 
+	private void setEnabledSeamSuport(boolean enabled) {
+		suportSeam = enabled;
+		for (String key : editorRegistry.keySet()) {
+			if(key!=SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT) {
+				editorRegistry.get(key).setEnabled(enabled && runtimeIsSelected);
+			}
+			if(key==ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME) {
+				editorRegistry.get(key).setEnabled(enabled);
+			}
+		}
+		setEnabledGroups(enabled && runtimeIsSelected);
+	}
+
+	private void setEnabledGroups(boolean enabled) {
+		for (Group group : groups) {
+			group.setEnabled(enabled);
+		}
+	}
+
+	private void setRuntimeIsSelected(boolean selected) {
+		runtimeIsSelected = selected;
+		for (String key : editorRegistry.keySet()) {
+			if(key!=SeamPreferencesMessages.SEAM_SETTINGS_PREFERENCE_PAGE_SEAM_SUPPORT && key!=ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME) {
+				editorRegistry.get(key).setEnabled(selected);
+			}
+		}
+		setEnabledGroups(selected);
+	}
+
 	private void removeSeamSupport() {
 		try {
 			EclipseResourceUtil.removeNatureFromProject(project,
@@ -185,7 +393,7 @@
 //		}
 		return SeamVersion.ALL_VERSIONS;
 	}
-
+/*
 	private SeamVersion findMatchingVersion(String vs) {
 		if(vs == null) return null;
 		if(vs.matches(SeamVersion.SEAM_1_2.toString().replace(".", "\\.") + ".*")) {
@@ -217,29 +425,5 @@
 		}
 		return null;
 	}
-
-	public class GridLayoutComposite extends Composite {
-
-		public GridLayoutComposite(Composite parent, int style) {
-			super(parent, style);
-			int columnNumber = 1;
-			for (IFieldEditor fieldEditor : editorOrder) {
-				if(fieldEditor.getNumberOfControls()>columnNumber)
-					columnNumber=fieldEditor.getNumberOfControls();
-			}
-			GridLayout gl = new GridLayout(columnNumber, false);
-			gl.verticalSpacing = 5;
-			gl.marginTop = 3;
-			gl.marginLeft = 3;
-			gl.marginRight = 3;
-			setLayout(gl);
-			for (IFieldEditor fieldEditor : editorOrder) {
-				fieldEditor.doFillIntoGrid(this);
-			}
-		}
-
-		public GridLayoutComposite(Composite parent) {
-			this(parent, SWT.NONE);
-		}
-	}
+*/
 }
\ No newline at end of file

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/BaseFieldEditor.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -170,9 +170,23 @@
 		for(int i=0;i<controls.length;i++) {
 			Control control = controls[i];
 			control.setEnabled(enabled);
+			if(control instanceof Composite) {
+				setEnabled((Composite)control, enabled);
+			}
 		}
 	}
 
+	private void setEnabled(Composite composite, boolean enabled) {
+		Control[] controls = composite.getChildren();
+		for(int i=0;i<controls.length;i++) {
+			Control control = controls[i];
+			control.setEnabled(enabled);
+			if(control instanceof Composite) {
+				setEnabled((Composite)control, enabled);
+			}
+		}
+	}
+
 	/**
 	 * 
 	 */

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -55,7 +55,7 @@
 
 	@Override
 	public Object[] getEditorControls() {
-		return null;
+		return new Control[]{comboField.getControl()};
 	}
 
 	public void save(Object object) {

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/CompositeEditor.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -15,7 +15,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 
 import org.eclipse.core.runtime.Assert;

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -83,8 +83,7 @@
 	 * @param defaultValue
 	 * @return
 	 */
-	IFieldEditor createBrowseFolderEditor(String name, String label,
-			String defaultValue);
+	IFieldEditor createBrowseFolderEditor(String name, String label, String defaultValue);
 
 	/**
 	 * 
@@ -93,6 +92,24 @@
 	 * @param defaultValue
 	 * @return
 	 */
+	IFieldEditor createBrowseWorkspaceFolderEditor(String name, String label, String defaultValue);
+
+	/**
+	 * 
+	 * @param name
+	 * @param label
+	 * @param defaultValue
+	 * @return
+	 */
+	IFieldEditor createBrowseSourceFolderEditor(String name, String label, String defaultValue);
+
+	/**
+	 * 
+	 * @param name
+	 * @param label
+	 * @param defaultValue
+	 * @return
+	 */
 	IFieldEditor createBrowseFileEditor(String name, String label,
 			String defaultValue);
 

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -57,7 +57,7 @@
 
 	@Override
 	public Object[] getEditorControls() {
-		return null;
+		return new Control[]{radioField.getControl()};
 	}
 
 	public void save(Object object) {

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -10,12 +10,37 @@
  ******************************************************************************/ 
 package org.jboss.tools.seam.ui.widget.editor;
 
+import java.util.ArrayList;
 import java.util.List;
 
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
 import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.DirectoryDialog;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.internal.util.Util;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
 import org.jboss.tools.seam.ui.SeamUIMessages;
 import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
 import org.jboss.tools.seam.ui.widget.editor.ButtonFieldEditor.ButtonPressedAction;
@@ -78,7 +103,7 @@
 	 * 
 	 */
 	public IFieldEditor createUneditableTextEditor(String name, String label, String defaultValue) {
-		CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+		CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
 		editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
 				new TextFieldEditor(name,label, defaultValue,false)});
 		return editor;
@@ -88,7 +113,7 @@
 	 * 
 	 */
 	public IFieldEditor createBrowseFolderEditor(String name, String label, String defaultValue) {
-		CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+		CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
 		editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
 				new TextFieldEditor(name,label, defaultValue),
 				new ButtonFieldEditor(name,createSelectFolderAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS),defaultValue)});
@@ -98,8 +123,178 @@
 	/**
 	 * 
 	 */
+	public IFieldEditor createBrowseWorkspaceFolderEditor(String name, String label, String defaultValue) {
+		ButtonFieldEditor.ButtonPressedAction action = createSelectWorkspaceFolderAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS, defaultValue);
+		CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
+		editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
+				new TextFieldEditor(name,label, defaultValue),
+				new ButtonFieldEditor(name, action, defaultValue)});
+		action.setFieldEditor(editor);
+		return editor;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory#createBrowseSourceFolderEditor(java.lang.String, java.lang.String, java.lang.String)
+	 */
+	public IFieldEditor createBrowseSourceFolderEditor(String name,	String label, String defaultValue) {
+		ButtonFieldEditor.ButtonPressedAction action = createSelectSourceFolderAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS, defaultValue);
+		CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
+		editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name, label),
+				new TextFieldEditor(name, label, defaultValue),
+				new ButtonFieldEditor(name, action, defaultValue)});
+		action.setFieldEditor(editor);
+		return editor;
+	}
+
+	/**
+	 * @param buttonName
+	 * @return
+	 */
+	public ButtonFieldEditor.ButtonPressedAction createSelectSourceFolderAction(String buttonName, final String initPath) {
+		ButtonFieldEditor.ButtonPressedAction action = new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+			private String inerInitPath;
+
+			/*
+			 * (non-Javadoc)
+			 * @see org.eclipse.jface.action.Action#run()
+			 */
+			@Override
+			public void run() {
+				final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+						Display.getCurrent().getActiveShell(),
+						new JavaElementLabelProvider(), new JavaSourceContentProvider());
+				dialog.setInput(ResourcesPlugin.getWorkspace());
+				String path = inerInitPath!=null?inerInitPath:initPath;
+				IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+				if (resource!=null) {
+					IProject project = resource.getProject();
+					if (project.getProject().isOpen()) {
+						IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
+						try {
+							IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots();
+							for (int i= 0; i < roots.length; i++) {
+								if (roots[i].getKind() == IPackageFragmentRoot.K_SOURCE && roots[i].getResource().equals(resource)) {
+									dialog.setInitialSelection(roots[i]);
+									break;
+								}
+							}
+						} catch (JavaModelException e) {
+							SeamGuiPlugin.getPluginLog().logError(e);
+						}
+					}
+				}
+				dialog.setValidator(new ISelectionStatusValidator(){
+					public IStatus validate(Object[] selection) {
+						if(selection.length>0) {
+							if(selection[0] instanceof IPackageFragmentRoot) {
+								return new Status(IStatus.OK, SeamGuiPlugin.PLUGIN_ID, IStatus.OK, null, null);
+							}
+						}
+						return new Status(IStatus.ERROR, SeamGuiPlugin.PLUGIN_ID, IStatus.ERROR, null, null);
+					}
+				});
+				dialog.setAllowMultiple(false);
+				dialog.setTitle(SeamUIMessages.SELECT_WORKSPACE_FOLDER_DIALOG_TITLE); 
+				dialog.setMessage(SeamUIMessages.SELECT_WORKSPACE_FOLDER_DIALOG_MESSAGE); 
+				if (dialog.open() == Window.OK) {
+					IPackageFragmentRoot pack = (IPackageFragmentRoot) dialog.getFirstResult();
+					IPath newPath = pack.getResource().getFullPath();
+					String value = newPath.toString();
+					inerInitPath = value;
+					getFieldEditor().setValue(value);
+				}
+			}
+		};
+		return action;
+	}
+
+	/**
+	 * @author Alexey Kazakov
+	 */
+	private static class JavaSourceContentProvider extends StandardJavaElementContentProvider {
+
+		/*
+		 * (non-Javadoc)
+		 * @see org.eclipse.jdt.ui.StandardJavaElementContentProvider#hasChildren(java.lang.Object)
+		 */
+		@Override
+		public boolean hasChildren(Object element) {
+			if (element instanceof IPackageFragmentRoot) {
+				return false;
+			}
+			return true;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * @see org.eclipse.jdt.ui.StandardJavaElementContentProvider#getChildren(java.lang.Object)
+		 */
+		@Override
+		public Object[] getChildren(Object element) {
+			if (!exists(element)) {
+				return NO_CHILDREN;
+			}
+
+			if (element instanceof IWorkspace) {
+		        IWorkbenchAdapter adapter = (IWorkbenchAdapter)Util.getAdapter(element, IWorkbenchAdapter.class);
+		        if (adapter != null) {
+		        	Object[] children = adapter.getChildren(element);
+		        	List<Object> result = new ArrayList<Object>();
+		        	for (int i = 0; i < children.length; i++) {
+		        		if(children[i] instanceof IProject) {
+		        			if(EclipseResourceUtil.getJavaProject((IProject)children[i])!=null) {
+		        				result.add(children[i]);
+		        			}
+		        		}
+					}
+		            return result.toArray(new Object[]{});
+		        }
+		        return new Object[0];
+			}
+
+			if (element instanceof IProject) {
+				element = EclipseResourceUtil.getJavaProject((IProject)element);
+				if(element==null) {
+					return NO_CHILDREN;
+				}
+			}
+
+			if (element instanceof IJavaProject) {
+				try {
+					return getPackageFragmentRoots((IJavaProject)element);
+				} catch (JavaModelException e) {
+					SeamGuiPlugin.getPluginLog().logError(e);
+					return NO_CHILDREN;
+				}
+			}
+			if (element instanceof IPackageFragmentRoot) {
+				return NO_CHILDREN;
+			}
+
+			return super.getChildren(element);
+		}
+
+		protected Object[] getPackageFragmentRoots(IJavaProject project) throws JavaModelException {
+			if (!project.getProject().isOpen()) {
+				return NO_CHILDREN;
+			}
+			IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
+			List<IPackageFragmentRoot> list= new ArrayList<IPackageFragmentRoot>(roots.length);
+			for (int i= 0; i < roots.length; i++) {
+				IPackageFragmentRoot root = roots[i];
+				if (!isProjectPackageFragmentRoot(root) && root.getKind() == IPackageFragmentRoot.K_SOURCE) {
+					list.add(root);
+				}
+			}
+			return list.toArray();
+		}
+	}
+
+	/**
+	 * 
+	 */
 	public IFieldEditor createBrowseFileEditor(String name, String label, String defaultValue) {
-		CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+		CompositeEditor editor = new CompositeEditor(name, label, defaultValue);
 		editor.addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
 				new TextFieldEditor(name,label, defaultValue),
 				new ButtonFieldEditor(name,createSelectFileAction(SeamUIMessages.SWT_FIELD_EDITOR_FACTORY_BROWS),defaultValue)});
@@ -135,6 +330,53 @@
 	}
 
 	/**
+	 * @param buttonName
+	 * @return
+	 */
+	public ButtonFieldEditor.ButtonPressedAction createSelectWorkspaceFolderAction(String buttonName, final String initPath) {
+		ButtonFieldEditor.ButtonPressedAction action = new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+
+			private String inerInitPath;
+
+			/*
+			 * (non-Javadoc)
+			 * @see org.eclipse.jface.action.Action#run()
+			 */
+			@Override
+			public void run() {
+				ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
+						Display.getCurrent().getActiveShell(),
+						new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+				dialog.setInput(ResourcesPlugin.getWorkspace());
+				String path = inerInitPath!=null?inerInitPath:initPath;
+				IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+				if (resource!=null) {
+					dialog.setInitialSelection(resource);
+				}
+				dialog.addFilter(new ViewerFilter() {
+					public boolean select(Viewer viewer, Object parentElement, Object element) {
+						if (element instanceof IFolder || element instanceof IProject) {
+							return true;
+						}
+						return false;
+					}
+				});
+				dialog.setAllowMultiple(false);
+				dialog.setTitle(SeamUIMessages.SELECT_WORKSPACE_FOLDER_DIALOG_TITLE); 
+				dialog.setMessage(SeamUIMessages.SELECT_WORKSPACE_FOLDER_DIALOG_MESSAGE); 
+				if (dialog.open() == Window.OK) {
+					IResource res = (IResource) dialog.getFirstResult();
+					IPath newPath = res.getFullPath();
+					String value = newPath.toString();
+					inerInitPath = value;
+					getFieldEditor().setValue(value);
+				}
+			}
+		};
+		return action;
+	}
+
+	/**
 	 * 
 	 * @param buttonName
 	 * @return

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -84,7 +84,11 @@
 	public Object getValue() {
 		return value;
 	}
-	
+
+	/**
+	 * 
+	 * @param value
+	 */
 	public void setValue(String value) {
 		this.value = value;
 		for (int i = 0; i < radios.length; i++) {
@@ -95,5 +99,4 @@
 			}
 		}
 	}
-
-}
+}
\ No newline at end of file

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -28,8 +28,6 @@
 import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
 import org.jboss.tools.seam.core.ISeamProject;
 import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.core.project.facet.SeamProjectPreferences;
-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;
 
@@ -41,8 +39,9 @@
 
 	/**
 	 * @param parent
+	 * @param allowAllProjects If "false" show only projects with seam nature.
 	 */
-	public SeamProjectSelectionDialog(Shell parent) {
+	public SeamProjectSelectionDialog(Shell parent, final boolean allowAllProjects) {
 		super(parent);
 		setTitle(SeamUIMessages.SEAM_PROJECT_SELECTION_DIALOG_SEAM_WEB_PROJECT);
 		setMessage(SeamUIMessages.SEAM_PROJECT_SELECTION_DIALOG_SELECT_SEAM_WEB_PROJECT);
@@ -53,11 +52,11 @@
 				ArrayList<IProject> seamProjects = new ArrayList<IProject>();
 				for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
 					try {
-						if(project.hasNature(ISeamProject.NATURE_ID) 
+						if(allowAllProjects || (project.hasNature(ISeamProject.NATURE_ID) 
 								&& SeamCorePlugin.getSeamPreferences(project)!=null
 								&& project.getAdapter(IFacetedProject.class)!=null
 								&& ((IFacetedProject)project.getAdapter(IFacetedProject.class)).hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.web"))
-								&& !"".equals(SeamCorePlugin.getSeamPreferences(project).get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, ""))) { //$NON-NLS-1$
+								&& !"".equals(SeamCorePlugin.getSeamPreferences(project).get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS, "")))) { //$NON-NLS-1$
 							seamProjects.add(project);
 						}
 					} catch (CoreException e) {
@@ -73,8 +72,15 @@
 			}
 		});
 	}
-	
+
 	/**
+	 * @param parent
+	 */
+	public SeamProjectSelectionDialog(Shell parent) {
+		this(parent, false);
+	}
+
+	/**
 	 * 
 	 */
 	@Override
@@ -90,4 +96,4 @@
 	public void selectionChanged(SelectionChangedEvent event) {
 		getOkButton().setEnabled(!event.getSelection().isEmpty());
 	}
-}
+}
\ No newline at end of file

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -15,12 +15,21 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.eclipse.datatools.connectivity.ConnectionProfileException;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.IProfileListener;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.datatools.connectivity.db.generic.ui.NewConnectionProfileWizard;
+import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizard;
+import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizardCategoryFilter;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.internal.dialogs.PropertyDialog;
 import org.hibernate.console.ConsoleConfiguration;
 import org.hibernate.console.KnownConfigurations;
 import org.hibernate.eclipse.console.HibernateConsolePlugin;
+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;
@@ -40,11 +49,25 @@
  *
  */
 public class SeamWizardFactory {
+
+	/**
+	 * @param defaultSelection
+	 * @param allowAllProjects If "false" show only projects with seam nature.
+	 * @return
+	 */
+	public static IFieldEditor createSeamProjectSelectionFieldEditor(String name, String label, String defaultSelection, boolean allowAllProjects) {
+		return IFieldEditorFactory.INSTANCE.createButtonFieldEditor(
+				name, label, defaultSelection, 
+				 new SelectSeamProjectAction(allowAllProjects), ValidatorFactory.NO_ERRORS_VALIDATOR);
+	}
+
+	/**
+	 * @param defaultSelection
+	 * @return
+	 */
 	public static IFieldEditor createSeamProjectSelectionFieldEditor(
 			String defaultSelection) {
-		return IFieldEditorFactory.INSTANCE.createButtonFieldEditor(
-				IParameter.SEAM_PROJECT_NAME, SeamUIMessages.SEAM_WIZARD_FACTORY_SEAM_PROJECT, defaultSelection, 
-				 new SelectSeamProjectAction(), ValidatorFactory.NO_ERRORS_VALIDATOR);
+		return createSeamProjectSelectionFieldEditor(IParameter.SEAM_PROJECT_NAME, SeamUIMessages.SEAM_WIZARD_FACTORY_SEAM_PROJECT, defaultSelection, false);
 	}
 
 	/**
@@ -86,7 +109,11 @@
 		return IFieldEditorFactory.INSTANCE.createTextEditor(
 				IParameter.SEAM_MASTER_PAGE_NAME, SeamUIMessages.SEAM_WIZARD_FACTORY_MASTER_PAGE_NAME, ""); //$NON-NLS-1$
 	}
-	
+
+	/**
+	 * @param defaultSelection
+	 * @return
+	 */
 	public static final IFieldEditor[] createBaseFormFieldEditors(String defaultSelection) {
 		return new IFieldEditor[]{
 			SeamWizardFactory.createSeamProjectSelectionFieldEditor(defaultSelection),
@@ -126,6 +153,179 @@
 	}
 
 	/**
+	 * Creates Selection Field of Connection Profiles
+	 * @param defaultValue
+	 * @return
+	 */
+	public static IFieldEditor createConnectionProfileSelectionFieldEditor(Object defaultValue, IValidator validator) {
+		EditConnectionProfileAction editAction = new EditConnectionProfileAction(validator);
+		NewConnectionProfileAction newAction = new NewConnectionProfileAction(validator);
+		IFieldEditor connProfileSelEditor = IFieldEditorFactory.INSTANCE.createComboWithTwoButtons(
+				ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE,
+				SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_CONNECTION_PROFILE,
+				getConnectionProfileNameList(),
+				defaultValue,
+				false, editAction,
+				newAction,
+				ValidatorFactory.NO_ERRORS_VALIDATOR);
+		editAction.setEditor(connProfileSelEditor);
+		newAction.setEditor(connProfileSelEditor);
+		return connProfileSelEditor;
+	}
+
+	private static class EditConnectionProfileAction extends ButtonFieldEditor.ButtonPressedAction {
+
+		private IValidator validator;
+		private IFieldEditor connProfileSelEditor;
+
+		/**
+		 * @param validator
+		 */
+		public EditConnectionProfileAction(IValidator validator) {
+			super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EDIT);
+			this.validator = validator;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * @see org.eclipse.jface.action.Action#run()
+		 */
+		@Override
+		public void run() {
+			IConnectionProfile selectedProfile = ProfileManager.getInstance()
+					.getProfileByName(getFieldEditor().getValue().toString());
+			String oldName = getFieldEditor().getValue().toString();
+
+			if (selectedProfile == null) {
+				return;
+			}
+			PropertyDialog.createDialogOn(Display.getCurrent().getActiveShell(),
+							"org.eclipse.datatools.connectivity.db.generic.profileProperties", //$NON-NLS-1$
+							selectedProfile).open();
+			if (!oldName.equals(selectedProfile.getName())) {
+				getFieldEditor().setValue(selectedProfile.getName());
+				((ITaggedFieldEditor) ((CompositeEditor) connProfileSelEditor)
+						.getEditors().get(1)).setTags(getConnectionProfileNameList()
+						.toArray(new String[0]));
+				oldName = selectedProfile.getName();
+			}
+			validator.validate(selectedProfile.getName(), null);
+		}
+
+		public void setEditor(IFieldEditor connProfileSelEditor) {
+			this.connProfileSelEditor = connProfileSelEditor; 
+		}
+	};
+
+	/**
+	 * Handler for ButtonFieldEditor that shows Property Editor dialog for
+	 * selected ConnectionProfile
+	 * 
+	 * @author eskimo
+	 */
+	private static class NewConnectionProfileAction extends	ButtonFieldEditor.ButtonPressedAction {
+
+		private IValidator validator;
+		private IFieldEditor connProfileSelEditor;
+
+		public NewConnectionProfileAction(IValidator validator) {
+			super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_NEW);
+			this.validator = validator;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * @see org.eclipse.jface.action.Action#run()
+		 */
+		@Override
+		public void run() {
+			IProfileListener listener = new ConnectionProfileChangeListener(validator, connProfileSelEditor);
+
+			ProfileManager.getInstance().addProfileListener(listener);
+			NewCPWizardCategoryFilter filter = new NewCPWizardCategoryFilter("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
+			NewCPWizard wizard = new NewCPWizard(filter, null);
+			new NewConnectionProfileWizard() {
+				public boolean performFinish() {
+					// create profile only
+					try {
+						ProfileManager.getInstance().createProfile(
+								getProfileName() == null ? "" //$NON-NLS-1$
+										: getProfileName(),
+								getProfileDescription() == null ? "" //$NON-NLS-1$
+										: getProfileDescription(),
+								mProviderID,
+								getProfileProperties(),
+								mProfilePage.getRepository() == null ? "" //$NON-NLS-1$
+										: mProfilePage.getRepository()
+												.getName(), false);
+					} catch (ConnectionProfileException e) {
+						SeamCorePlugin.getPluginLog().logError(e);
+					}
+
+					return true;
+				}
+			};
+			WizardDialog wizardDialog = new WizardDialog(Display.getCurrent()
+					.getActiveShell(), wizard);
+			wizardDialog.open();
+			ProfileManager.getInstance().removeProfileListener(listener);
+		}
+
+		public void setEditor(IFieldEditor connProfileSelEditor) {
+			this.connProfileSelEditor = connProfileSelEditor; 
+		}
+	}
+
+	private static class ConnectionProfileChangeListener implements IProfileListener {
+
+		private IFieldEditor connProfileSelEditor;
+		private IValidator validator;
+
+		/**
+		 * @param validator
+		 */
+		public ConnectionProfileChangeListener(IValidator validator, IFieldEditor connProfileSelEditor) {
+			this.validator = validator;
+			this.connProfileSelEditor = connProfileSelEditor;
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.datatools.connectivity.IProfileListener#profileAdded(org.eclipse.datatools.connectivity.IConnectionProfile)
+		 */
+		public void profileAdded(IConnectionProfile profile) {
+			connProfileSelEditor.setValue(profile.getName());
+			((ITaggedFieldEditor) ((CompositeEditor) connProfileSelEditor)
+					.getEditors().get(1)).setTags(getConnectionProfileNameList()
+					.toArray(new String[0]));
+			validator.validate(profile.getName(), null);
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.datatools.connectivity.IProfileListener#profileChanged(org.eclipse.datatools.connectivity.IConnectionProfile)
+		 */
+		public void profileChanged(IConnectionProfile profile) {
+			profileAdded(profile);
+		}
+
+		/* (non-Javadoc)
+		 * @see org.eclipse.datatools.connectivity.IProfileListener#profileDeleted(org.eclipse.datatools.connectivity.IConnectionProfile)
+		 */
+		public void profileDeleted(IConnectionProfile profile) {
+			// this event never happens
+		}
+	}
+
+	private static List<String> getConnectionProfileNameList() {
+		IConnectionProfile[] profiles = ProfileManager.getInstance()
+				.getProfilesByCategory("org.eclipse.datatools.connectivity.db.category"); //$NON-NLS-1$
+		List<String> names = new ArrayList<String>();
+		for (IConnectionProfile connectionProfile : profiles) {
+			names.add(connectionProfile.getName());
+		}
+		return names;
+	}
+
+	/**
 	 * @param seamVersions Array of seam runtime versions. If length == 0 then use all versions
 	 * @param defaultSelection
 	 * @return Editor to select seam runtime
@@ -277,4 +477,16 @@
 				configurationNames, defaultSelection);
 		return editor;
 	}
+
+	/**
+	 * @param defaultSelection full path of resource
+	 * @return
+	 */
+	public static IFieldEditor createViewFolderFieldEditor(String defaultSelection) {
+		IFieldEditor viewDirEditor = IFieldEditorFactory.INSTANCE.createBrowseWorkspaceFolderEditor(
+				ISeamFacetDataModelProperties.WEB_CONTENTS_FOLDER,
+				SeamUIMessages.VIEW_FOLDER_FILED_EDITOR,
+				defaultSelection); 
+		return viewDirEditor;
+	}
 }
\ No newline at end of file

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectSeamProjectAction.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectSeamProjectAction.java	2008-03-07 20:58:26 UTC (rev 6791)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SelectSeamProjectAction.java	2008-03-07 21:10:15 UTC (rev 6792)
@@ -21,17 +21,27 @@
 
 public class SelectSeamProjectAction extends ButtonFieldEditor.ButtonPressedAction {
 
+	private boolean allowAllProjects;
+
 	/**
-	 * @param label
+	 * @param allowAllProjects If "false" show only projects with seam nature.
 	 */
-	public SelectSeamProjectAction() {
+	public SelectSeamProjectAction(boolean allowAllProjects) {
 		super(SeamUIMessages.SELECT_SEAM_PROJECT_ACTION_BROWSE);
+		this.allowAllProjects = allowAllProjects;
 	}
 
+	/**
+	 * 
+	 */
+	public SelectSeamProjectAction() {
+		this(false);
+	}
+
 	@Override
 	public void run() {
 		ListDialog dialog = new SeamProjectSelectionDialog(
-				Display.getCurrent().getActiveShell());
+				Display.getCurrent().getActiveShell(), allowAllProjects);
 		if(!"".equals(this.getFieldEditor().getValueAsString())) //$NON-NLS-1$
 			dialog.setInitialSelections(new Object[] {
 				ResourcesPlugin.getWorkspace().getRoot().getProject(this.getFieldEditor().getValueAsString())});




More information about the jbosstools-commits mailing list