Author: vrubezhny
Date: 2007-10-15 08:33:29 -0400 (Mon, 15 Oct 2007)
New Revision: 4179
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
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/messages.properties
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-926 DataSourceXMLDeployer chooses first server
that matches runtime when several may match
The server selection combo and "New..." Server dialog are added to the first
wizard page
ISeamFacetDataModelProperties.JBOSS_AS_TARGET_SERVER (String) property now contains a name
for the server selected
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-10-15 12:33:13
UTC (rev 4178)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-10-15 12:33:29
UTC (rev 4179)
@@ -48,7 +48,9 @@
org.eclipse.datatools.connectivity.db.generic.ui,
org.eclipse.datatools.connectivity.db.generic,
org.jboss.tools.common.model.ui,
- org.hibernate.eclipse
+ org.hibernate.eclipse,
+ org.eclipse.wst.server.core,
+ org.eclipse.wst.server.ui
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.seam.ui,
org.jboss.tools.seam.ui.actions,
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 2007-10-15
12:33:13 UTC (rev 4178)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2007-10-15
12:33:29 UTC (rev 4179)
@@ -343,6 +343,8 @@
public static String VALIDATOR_FACTORY_SELECTED_PROJECT;
+ public static String SEAM_TARGET_RUNTIME;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, SeamUIMessages.class);
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 2007-10-15
12:33:13 UTC (rev 4178)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-10-15
12:33:29 UTC (rev 4179)
@@ -168,3 +168,4 @@
SEAM_RUNTIME_LIST_FIELD_EDITOR_THE_SELECTED_SEAM_APPEARS_TO_BE_OF_INCOMATIBLE_VERSION=The
selected seam appears to be of an incompatible version '
SEAM_GENERATE_ENTITIES_WIZARD_THIS_METHOD_IS_NOT_RELEVANT_IN_GENERATING_SEAM_ENTITIES=This
method is not relevant in generating seam entities.
SEAM_FORM_WIZARD_PAGE1_JAVA_INTERFACE_SLSB_AND_KEY_SEAMEJB3_ANNOTATIONS_WILL_BE_CREATED=Java
Interface, SLSB and key Seam/EJB3 annotations will be created.
+SEAM_TARGET_RUNTIME=Target Server
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2007-10-15
12:33:13 UTC (rev 4178)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2007-10-15
12:33:29 UTC (rev 4179)
@@ -10,15 +10,37 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jst.servlet.ui.project.facet.WebProjectFirstPage;
import org.eclipse.jst.servlet.ui.project.facet.WebProjectWizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
+import org.eclipse.wst.server.ui.ServerUIUtil;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.project.facet.SeamFacetPreference;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import
org.jboss.tools.seam.internal.core.project.facet.SeamFacetProjectCreationDataModelProvider;
import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.internal.project.facet.SeamInstallWizardPage;
@@ -40,9 +62,16 @@
setWindowTitle(SeamUIMessages.SEAM_PROJECT_WIZARD_NEW_SEAM_PROJECT);
}
+ protected IDataModel createDataModel() {
+ return DataModelFactory.createDataModel(new
SeamFacetProjectCreationDataModelProvider());
+ }
+
@Override
protected IWizardPage createFirstPage() {
- IWizardPage page = super.createFirstPage();
+// IWizardPage page = super.createFirstPage();
+
+ IWizardPage page = new SeamWebProjectFirstPage(model, "first.page");
//$NON-NLS-1$
+
page.setImageDescriptor(ImageDescriptor.createFromFile(SeamFormWizard.class,
"SeamWebProjectWizBan.png")); //$NON-NLS-1$
page.setTitle(SeamUIMessages.SEAM_PROJECT_WIZARD_SEAM_WEB_PROJECT);
page.setDescription(SeamUIMessages.SEAM_PROJECT_WIZARD_CREATE_STANDALONE_SEAM_WEB_PROJECT);
@@ -53,7 +82,8 @@
public void createPageControls(Composite container) {
super.createPageControls(container);
Control control = findGroupByText(getShell(),
SeamUIMessages.SEAM_PROJECT_WIZARD_EAR_MEMBERSHIP);
- control.setVisible(false);
+ if (control != null)
+ control.setVisible(false);
}
@@ -89,7 +119,6 @@
return "org.jboss.tools.seam.ui.SeamPerspective"; //$NON-NLS-1$
}
- @Override
protected IFacetedProjectTemplate getTemplate() {
return ProjectFacetsManager.getTemplate("template.jst.seam"); //$NON-NLS-1$
}
@@ -103,4 +132,136 @@
page.finishPressed();
return super.performFinish();
}
+
+ class SeamWebProjectFirstPage extends WebProjectFirstPage {
+
+ public SeamWebProjectFirstPage(IDataModel model, String pageName ) {
+ super(model, pageName);
+ }
+
+ protected Combo matchedServerTargetCombo;
+
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite top = new Composite(parent, SWT.NONE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(top, getInfopopID());
+ top.setLayout(new GridLayout());
+ top.setLayoutData(new GridData(GridData.FILL_BOTH));
+ createProjectGroup(top);
+ createServerTargetComposite(top);
+ createSeamServerTargetComposite(top);
+ createPresetPanel(top);
+ return top;
+ }
+
+
+ protected void createSeamServerTargetComposite(Composite parent) {
+// super.createServerTargetComposite(parent);
+ Group group = new Group(parent, SWT.NONE);
+ group.setText(SeamUIMessages.SEAM_TARGET_RUNTIME);
+ group.setLayoutData(gdhfill());
+ group.setLayout(new GridLayout(2, false));
+
+ matchedServerTargetCombo = new Combo(group, SWT.BORDER | SWT.READ_ONLY);
+ matchedServerTargetCombo.setLayoutData(gdhfill());
+ Button newMatchedServerTargetButton = new Button(group, SWT.NONE);
+ newMatchedServerTargetButton.setText(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_NEW);
+ newMatchedServerTargetButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (!SeamWebProjectFirstPage.this.internalLaunchNewServerWizard(getShell(), model))
{
+ //Bugzilla 135288
+ //setErrorMessage(ResourceHandler.InvalidServerTarget);
+ }
+ }
+ });
+ Control[] depsMatched = new Control[]{serverTargetCombo,
newMatchedServerTargetButton};
+ synchHelper.synchCombo(matchedServerTargetCombo,
ISeamFacetDataModelProperties.JBOSS_AS_TARGET_SERVER, depsMatched);
+ if (matchedServerTargetCombo.getSelectionIndex() == -1 &&
matchedServerTargetCombo.getVisibleItemCount() != 0)
+ matchedServerTargetCombo.select(0);
+ }
+
+ protected String[] getValidationPropertyNames() {
+ String[] superProperties = super.getValidationPropertyNames();
+ List list = Arrays.asList(superProperties);
+ ArrayList arrayList = new ArrayList();
+ arrayList.addAll( list );
+ arrayList.add( ISeamFacetDataModelProperties.JBOSS_AS_TARGET_RUNTIME);
+ arrayList.add( ISeamFacetDataModelProperties.JBOSS_AS_TARGET_SERVER);
+ return (String[])arrayList.toArray( new String[0] );
+ }
+
+ public boolean launchNewServerWizard(Shell shell, IDataModel model) {
+ return launchNewServerWizard(shell, model, null);
+ }
+
+ public boolean launchNewServerWizard(Shell shell, IDataModel model, String
serverTypeID) {
+ DataModelPropertyDescriptor[] preAdditionDescriptors =
model.getValidPropertyDescriptors(ISeamFacetDataModelProperties.JBOSS_AS_TARGET_SERVER);
+ IRuntime rt =
(IRuntime)model.getProperty(ISeamFacetDataModelProperties.JBOSS_AS_TARGET_RUNTIME);
+
+ boolean isOK = ServerUIUtil.showNewServerWizard(shell, serverTypeID, null, (rt == null
? null : null));
+ if (isOK && model != null) {
+
+ DataModelPropertyDescriptor[] postAdditionDescriptors =
model.getValidPropertyDescriptors(ISeamFacetDataModelProperties.JBOSS_AS_TARGET_SERVER);
+ Object[] preAddition = new Object[preAdditionDescriptors.length];
+ for (int i = 0; i < preAddition.length; i++) {
+ preAddition[i] = preAdditionDescriptors[i].getPropertyValue();
+ }
+ Object[] postAddition = new Object[postAdditionDescriptors.length];
+ for (int i = 0; i < postAddition.length; i++) {
+ postAddition[i] = postAdditionDescriptors[i].getPropertyValue();
+ }
+ Object newAddition = null;
+
+ if (preAddition != null && postAddition != null && preAddition.length
< postAddition.length) {
+ for (int i = 0; i < postAddition.length; i++) {
+ boolean found = false;
+ Object object = postAddition[i];
+ for (int j = 0; j < preAddition.length; j++) {
+ if (preAddition[j] == object) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ newAddition = object;
+ }
+ }
+ }
+ if (preAddition == null && postAddition != null &&
postAddition.length == 1)
+ newAddition = postAddition[0];
+
+ model.notifyPropertyChange(ISeamFacetDataModelProperties.JBOSS_AS_TARGET_SERVER,
IDataModel.VALID_VALUES_CHG);
+ if (newAddition != null)
+ model.setProperty(ISeamFacetDataModelProperties.JBOSS_AS_TARGET_SERVER,
newAddition);
+ else
+ return false;
+ }
+ return isOK;
+ }
+
+ public boolean internalLaunchNewServerWizard(Shell shell, IDataModel model) {
+ return launchNewServerWizard(shell, model, getModuleTypeID());
+ }
+
+ public void restoreDefaultSettings() {
+ super.restoreDefaultSettings();
+
+ String lastServerName = SeamFacetPreference
+ .getStringPreference(SeamFacetPreference.SEAM_LAST_SERVER_NAME);
+
+ if (lastServerName != null && lastServerName.length() > 0) {
+ SeamFacetProjectCreationDataModelProvider.setServerName(model,lastServerName);
+ }
+ }
+
+ public void storeDefaultSettings() {
+ super.storeDefaultSettings();
+ String serverName =
SeamFacetProjectCreationDataModelProvider.getServerName(model);
+ if (serverName != null && serverName.length() > 0) {
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamFacetPreference.SEAM_LAST_SERVER_NAME,
+ serverName);
+ }
+ }
+
+ }
}
\ No newline at end of file