Author: akazakov
Date: 2008-03-06 12:31:03 -0500 (Thu, 06 Mar 2008)
New Revision: 6712
Added:
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/wizard/SeamActionCreateOperation.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardCustomizationPage.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
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/widget/editor/IFieldEditorFactory.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/SeamWizardUtils.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1322
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java 2008-03-06
16:54:55 UTC (rev 6711)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -45,6 +45,8 @@
return version;
}
+ public static SeamVersion[] ALL_VERSIONS = new SeamVersion[]{SEAM_1_2, SEAM_2_0};
+
/**
* Get enumeration by string
* TODO support for compatible version? should 1.2.1 return SEAM_1_2?
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2008-03-06 16:54:55 UTC (rev
6711)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2008-03-06 17:31:03 UTC (rev
6712)
@@ -400,7 +400,7 @@
<page
name="Seam Settings"
-
class="org.jboss.tools.seam.ui.preferences.SeamSettingsPreferencePage"
+
class="org.jboss.tools.seam.ui.preferences.SeamSettingsPreferencePageNew"
id="org.jboss.tools.seam.ui.propertyPages.SeamSettingsPreferencePage">
<enabledWhen>
<adapt type="org.eclipse.core.resources.IProject">
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-06
16:54:55 UTC (rev 6711)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -305,6 +305,8 @@
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;
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-06
16:54:55 UTC (rev 6711)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -30,7 +30,6 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jst.j2ee.project.facet.IJ2EEModuleFacetInstallDataModelProperties;
import org.eclipse.osgi.util.NLS;
@@ -68,8 +67,8 @@
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.ITaggedFieldEditor;
-import
org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor.SeamRuntimeNewWizard;
import org.jboss.tools.seam.ui.wizard.SeamFormWizard;
+import org.jboss.tools.seam.ui.wizard.SeamWizardFactory;
/**
* @author eskimo
@@ -280,24 +279,11 @@
return result;
}
- public List<String> getRuntimeNames() {
- SeamRuntime[] rts =
SeamRuntimeManager.getInstance().getRuntimes(/*SeamVersion.SEAM_1_2*/);
- List<String> result = new ArrayList<String>();
- for(SeamRuntime seamRuntime : rts) {
- result.add(seamRuntime.getName());
- }
- return result;
- }
-
/**
* Creates Seam Facet Wizard Page contents
*/
public void createControl(Composite parent) {
- jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
- .createComboWithButton(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_RUNTIME, getRuntimeNames(),
- getSeamRuntimeDefaultValue(),
- true, new NewSeamRuntimeAction(), (IValidator)null);
+ jBossSeamHomeEditor = SeamWizardFactory.createSeamRuntimeSelectionFieldEditor(new
SeamVersion[0], getSeamRuntimeDefaultValue().toString(), new NewSeamRuntimeAction());
initializeDialogUnits(parent);
@@ -699,36 +685,22 @@
}
}
- public class NewSeamRuntimeAction extends
- ButtonFieldEditor.ButtonPressedAction {
- /**
- * @param label
- */
- public NewSeamRuntimeAction() {
- super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_ADD);
+ private class NewSeamRuntimeAction extends SeamWizardFactory.NewSeamRuntimeAction {
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.wizard.SeamWizardFactory.NewSeamRuntimeAction#getRuntimeSelectionEditor()
+ */
+ @Override
+ protected IFieldEditor getRuntimeSelectionEditor() {
+ return jBossSeamHomeEditor;
}
- public void run() {
- List<SeamRuntime> added = new ArrayList<SeamRuntime>();
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.wizard.SeamWizardFactory.NewSeamRuntimeAction#getSeamVersions()
+ */
+ @Override
+ protected SeamVersion[] getSeamVersions() {
String seamVersion =
model.getProperty(IFacetDataModelProperties.FACET_VERSION_STR).toString();
- List<SeamVersion> versians = new ArrayList<SeamVersion>(1);
- versians.add(SeamVersion.parseFromString(seamVersion));
- Wizard wiz = new SeamRuntimeNewWizard((List<SeamRuntime>)
- new
ArrayList<SeamRuntime>(Arrays.asList(SeamRuntimeManager.getInstance().getRuntimes()))
- , added, versians);
- WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wiz);
- dialog.open();
-
- if (added.size()>0) {
- SeamRuntimeManager.getInstance().addRuntime(added.get(0));
-
- List<String> runtimes = getRuntimeNames(seamVersion);
- SeamRuntime newRuntime = added.get(0);
- if(seamVersion.equals(newRuntime.getVersion().toString())) {
- getFieldEditor().setValue(added.get(0).getName());
- }
- ((ITaggedFieldEditor) ((CompositeEditor)
jBossSeamHomeEditor).getEditors().get(1)).setTags(runtimes.toArray(new String[0]));
- }
+ return new SeamVersion[]{SeamVersion.parseFromString(seamVersion)};
}
}
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-06
16:54:55 UTC (rev 6711)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-03-06
17:31:03 UTC (rev 6712)
@@ -202,3 +202,4 @@
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:
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/preferences/SeamSettingsPreferencePageNew.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -0,0 +1,177 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.preferences;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+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.ui.SeamGuiPlugin;
+import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
+import org.jboss.tools.seam.ui.widget.editor.IFieldEditorFactory;
+import org.jboss.tools.seam.ui.wizard.IParameter;
+import org.jboss.tools.seam.ui.wizard.SeamWizardUtils;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * @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;
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.ui.dialogs.PropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ public void setElement(IAdaptable element) {
+ super.setElement(element);
+ project = (IProject) getElement().getAdapter(IProject.class);
+ warProject = SeamWizardUtils.getRootSeamProject(project);
+ if(warProject!=null) {
+ preferences = SeamCorePlugin.getSeamPreferences(warProject);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @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);
+
+// IFieldEditor jBossSeamHomeEditor = IFieldEditorFactory.INSTANCE
+// .createComboWithButton(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+// SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_RUNTIME, getRuntimeNames(),
+// getSeamRuntimeDefaultValue(),
+// true, new NewSeamRuntimeAction(), (IValidator)null);
+
+ Control control = new GridLayoutComposite(parent);
+// projectNameEditor.setEnabled(false);
+
+ return control;
+ }
+
+ private String getSeamProjectName() {
+ return warProject!=null ? warProject.getName() : project.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see
java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ }
+
+ /**
+ *
+ * @param id
+ * @param editor
+ */
+ public void addEditor(IFieldEditor editor) {
+ editorRegistry.put(editor.getName(), editor);
+ editorOrder.add(editor);
+ editor.addPropertyChangeListener(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ if (isSeamSupported()) {
+ addSeamSupport();
+ storeSettigs();
+ } else {
+ removeSeamSupport();
+ }
+ return true;
+ }
+
+ private void storeSettigs() {
+ //TODO
+// pref.put("test", "blah-blah-blah");
+ try {
+ preferences.flush();
+ } catch (BackingStoreException e) {
+ SeamGuiPlugin.getPluginLog().logError(e);
+ }
+ }
+
+ private boolean isSeamSupported() {
+ //TODO
+ return true;
+ }
+
+ private void removeSeamSupport() {
+ try {
+ EclipseResourceUtil.removeNatureFromProject(project,
+ ISeamProject.NATURE_ID);
+ } catch (CoreException e) {
+ SeamGuiPlugin.getPluginLog().logError(e);
+ }
+ }
+
+ private void addSeamSupport() {
+ try {
+ EclipseResourceUtil.addNatureToProject(project, ISeamProject.NATURE_ID);
+ } catch (CoreException e) {
+ SeamGuiPlugin.getPluginLog().logError(e);
+ }
+ }
+
+ 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/IFieldEditorFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2008-03-06
16:54:55 UTC (rev 6711)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -97,13 +97,14 @@
String defaultValue);
/**
- * @param jdbcDriverClassName
- * @param string
- * @param string2
+ *
+ * @param name
+ * @param label
+ * @param defaultValue
* @return
*/
- IFieldEditor createUneditableTextEditor(String jdbcDriverClassName,
- String string, String string2);
+ IFieldEditor createUneditableTextEditor(String name,
+ String label, String defaultValue);
/**
*
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionCreateOperation.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionCreateOperation.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionCreateOperation.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -0,0 +1,76 @@
+package org.jboss.tools.seam.ui.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+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;
+
+/**
+ *
+ * TODO move operations to core plugin
+ */
+public class SeamActionCreateOperation extends SeamBaseOperation{
+
+ /**
+ * @param label
+ */
+ public SeamActionCreateOperation() {
+ super((SeamUIMessages.SEAM_ACTION_WIZARD_ACTION_CREATING_OPERATION));
+ }
+
+ @Override
+ public List<String[]> getFileMappings(Map<String, Object> vars) {
+ if("war".equals(vars.get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS)))
//$NON-NLS-1$
+ return ACTION_WAR_MAPPING;
+ else
+ return ACTION_EAR_MAPPING;
+ }
+
+ public static final List<String[]> ACTION_WAR_MAPPING = new
ArrayList<String[]>();
+
+ public static final List<String[]> ACTION_EAR_MAPPING = new
ArrayList<String[]>();
+
+ static {
+ // initialize war files mapping
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/src/ActionJavaBean.java", //$NON-NLS-1$ //$NON-NLS-2$
+ "${" + IParameter.SEAM_PROJECT_SRC_ACTION + "}/${" +
ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_PATH + "}/${" +
IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"}); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/test/ActionTest.java", //$NON-NLS-1$ //$NON-NLS-2$
+ "${" + IParameter.SEAM_TEST_PROJECT_LOCATION_PATH +
"}/test-src/${" + ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH +
"}/${"+ IParameter.SEAM_LOCAL_INTERFACE_NAME +"}Test.java"});
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ ACTION_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/test/testng.xml", //$NON-NLS-1$ //$NON-NLS-2$
+ "${" + 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_WAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/view/action.xhtml", //$NON-NLS-1$ //$NON-NLS-2$
+ "${" + IParameter.SEAM_PROJECT_WEBCONTENT_PATH + "}/${" +
IParameter.SEAM_PAGE_NAME +"}.xhtml"}); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
+
+ // initialize ear files mapping
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/src/ActionBean.java", //$NON-NLS-1$ //$NON-NLS-2$
+ "${" + IParameter.SEAM_PROJECT_SRC_ACTION + "}/${" +
ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_PATH + "}/${" +
IParameter.SEAM_BEAN_NAME +"}.java"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/src/Action.java", //$NON-NLS-1$ //$NON-NLS-2$
+ "${" + IParameter.SEAM_PROJECT_SRC_ACTION + "}/${" +
ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_PATH + "}/${" +
IParameter.SEAM_LOCAL_INTERFACE_NAME +"}.java"}); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/test/ActionTest.java", //$NON-NLS-1$ //$NON-NLS-2$
+ "${" + IParameter.SEAM_TEST_PROJECT_LOCATION_PATH +
"}/test-src/${" + ISeamFacetDataModelProperties.TEST_CASES_PACKAGE_PATH +
"}/${"+ IParameter.SEAM_LOCAL_INTERFACE_NAME +"}Test.java"});
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ ACTION_EAR_MAPPING.add(new String[]{
+ "${" + ISeamFacetDataModelProperties.JBOSS_SEAM_HOME +
"}/seam-gen/test/testng.xml", //$NON-NLS-1$ //$NON-NLS-2$
+ "${" + 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
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardCustomizationPage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardCustomizationPage.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardCustomizationPage.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -0,0 +1,71 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.ui.wizard;
+
+import java.beans.PropertyChangeListener;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
+
+/**
+ * @author Alexey Kazakov
+ */
+public abstract class SeamWizardCustomizationPage extends SeamBaseWizardPage implements
IAdaptable, PropertyChangeListener {
+
+ /**
+ * @param pageName
+ * @param title
+ * @param titleImage
+ */
+ public SeamWizardCustomizationPage(String pageName, String title,
+ ImageDescriptor titleImage, IStructuredSelection initialSelection) {
+ super(pageName, title, titleImage, initialSelection);
+ }
+
+ /**
+ * @param pageName
+ */
+ public SeamWizardCustomizationPage(String pageName, IStructuredSelection initSelection)
{
+ super(pageName, initSelection);
+ }
+
+ protected void createEditors() {
+ String selectedProject = SeamWizardUtils.getRootSeamProjectName(initialSelection);
+ String packageName = getDefaultPackageName(selectedProject);
+ addEditor(SeamWizardFactory.createSeamJavaPackageSelectionFieldEditor(packageName));
+ setSeamProjectNameData(selectedProject);
+ String projectName = SeamWizardUtils.getRootSeamProjectName(initialSelection);
+ addEditor(SeamWizardFactory.createSeamProjectSelectionFieldEditor(projectName));
+ }
+
+ /**
+ * @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);
+ }
+
+ String selectedProject = getEditor(IParameter.SEAM_PROJECT_NAME).getValueAsString();
+
+ if(selectedProject!=null && !"".equals(selectedProject) &&
isValidProjectSelected()) {
+ isValidRuntimeConfigured(getSelectedProject());
+ }
+ setPageComplete(false);
+ }
+}
\ 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-06
16:54:55 UTC (rev 6711)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -12,15 +12,28 @@
package org.jboss.tools.seam.ui.wizard;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Display;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+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.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.internal.project.facet.IValidator;
import org.jboss.tools.seam.ui.internal.project.facet.ValidatorFactory;
+import org.jboss.tools.seam.ui.widget.editor.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;
+import org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor;
+import
org.jboss.tools.seam.ui.widget.editor.SeamRuntimeListFieldEditor.SeamRuntimeNewWizard;
/**
* @author eskimo
@@ -95,6 +108,133 @@
}
/**
+ * @param seamVersions Array of seam runtime versions. If length == 0 then use all
versions
+ * @param defaultSelection
+ * @param action
+ * @return Editor to select seam runtime
+ */
+ public static IFieldEditor createSeamRuntimeSelectionFieldEditor(SeamVersion[]
seamVersions, String defaultValue, NewSeamRuntimeAction action) {
+ IFieldEditor jBossSeamRuntimeEditor = IFieldEditorFactory.INSTANCE
+ .createComboWithButton(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME,
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_SEAM_RUNTIME, getRuntimeNames(seamVersions),
+ defaultValue,
+ true, action, (IValidator)null);
+ return jBossSeamRuntimeEditor;
+ }
+
+ /**
+ * @param seamVersions Array of seam runtime versions. If length == 0 then use all
versions
+ * @param defaultSelection
+ * @return Editor to select seam runtime
+ */
+ public static IFieldEditor createSeamRuntimeSelectionFieldEditor(SeamVersion[]
seamVersions, String defaultValue) {
+ DefaultNewSeamRuntimeAction action = new DefaultNewSeamRuntimeAction(seamVersions);
+ IFieldEditor jBossSeamRuntimeEditor =
createSeamRuntimeSelectionFieldEditor(seamVersions, defaultValue, action);
+ action.setRuntimeSelectionEditor(jBossSeamRuntimeEditor);
+ return jBossSeamRuntimeEditor;
+ }
+
+ /**
+ * @param defaultSelection
+ * @return Editor to select seam runtime of all versions
+ */
+ public static IFieldEditor createSeamRuntimeSelectionFieldEditor(String defaultValue) {
+ DefaultNewSeamRuntimeAction action = new DefaultNewSeamRuntimeAction(new
SeamVersion[0]);
+ IFieldEditor jBossSeamRuntimeEditor = createSeamRuntimeSelectionFieldEditor(new
SeamVersion[0], defaultValue, action);
+ action.setRuntimeSelectionEditor(jBossSeamRuntimeEditor);
+ return jBossSeamRuntimeEditor;
+ }
+
+ private static List<String> getRuntimeNames(SeamVersion[] seamVersions) {
+ List<String> rtStrings = new ArrayList<String>();
+ for (int i = 0; i < seamVersions.length; i++) {
+ SeamRuntime[] rts = SeamRuntimeManager.getInstance().getRuntimes(seamVersions[i]);
+ for(SeamRuntime seamRuntime : rts) {
+ rtStrings.add(seamRuntime.getName());
+ }
+ }
+ return rtStrings;
+ }
+
+ public static abstract class NewSeamRuntimeAction extends
ButtonFieldEditor.ButtonPressedAction {
+
+ public NewSeamRuntimeAction() {
+ super(SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_ADD);
+ }
+
+ abstract protected SeamVersion[] getSeamVersions();
+
+ abstract protected IFieldEditor getRuntimeSelectionEditor();
+
+ public void run() {
+ List<SeamRuntime> added = new ArrayList<SeamRuntime>();
+
+ List<SeamVersion> versions = new ArrayList<SeamVersion>(1);
+ SeamVersion[] sv = getSeamVersions();
+ for (int i = 0; i < sv.length; i++) {
+ versions.add(sv[i]);
+ }
+ if(versions.isEmpty()) {
+ SeamVersion[] allVersions = SeamVersion.ALL_VERSIONS;
+ for (int i = 0; i < allVersions.length; i++) {
+ versions.add(allVersions[i]);
+ }
+ }
+ Wizard wiz = new SeamRuntimeNewWizard(
+ (List<SeamRuntime>) new ArrayList<SeamRuntime>(Arrays
+ .asList(SeamRuntimeManager.getInstance()
+ .getRuntimes())), added, versions);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+
+ if (added.size() > 0) {
+ SeamRuntimeManager.getInstance().addRuntime(added.get(0));
+ List<String> runtimes = getRuntimeNames(sv);
+ getFieldEditor().setValue(added.get(0).getName());
+ ((ITaggedFieldEditor) ((CompositeEditor) getRuntimeSelectionEditor())
+ .getEditors().get(1)).setTags(runtimes
+ .toArray(new String[0]));
+ }
+ }
+
+ }
+
+ /**
+ * Default Action for creating new Seam runtime.
+ * @author Alexey Kazakov
+ */
+ private static class DefaultNewSeamRuntimeAction extends NewSeamRuntimeAction {
+
+ private SeamVersion[] seamVersions;
+ private IFieldEditor runtimeSelectionEditor;
+
+ public DefaultNewSeamRuntimeAction() {
+ super();
+ }
+
+ /**
+ * @param seamVersions
+ */
+ public DefaultNewSeamRuntimeAction(SeamVersion[] seamVersions) {
+ this();
+ this.seamVersions = seamVersions;
+ }
+
+ void setRuntimeSelectionEditor(IFieldEditor runtimeSelectionEditor) {
+ this.runtimeSelectionEditor = runtimeSelectionEditor;
+ }
+
+ protected SeamVersion[] getSeamVersions() {
+ return seamVersions;
+ }
+
+ protected IFieldEditor getRuntimeSelectionEditor() {
+ return runtimeSelectionEditor;
+ }
+ }
+
+ /**
* @return
*/
public static IFieldEditor createSeamComponentNameFieldEditor() {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardUtils.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardUtils.java 2008-03-06
16:54:55 UTC (rev 6711)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardUtils.java 2008-03-06
17:31:03 UTC (rev 6712)
@@ -48,38 +48,40 @@
return getRootSeamProjectName(sel);
}
- public static String getRootSeamProjectName(ISelection sel) {
- IProject project = getInitialProject(sel);
+ public static IProject getRootSeamProject(IProject project) {
if (project != null) {
- ISeamProject seamProject = SeamCorePlugin.getSeamProject(project,
- false);
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
if (seamProject == null) {
- return "";
+ return null;
}
-
-
+
String parentProjectName = seamProject.getParentProjectName();
-
+
IProject targetProject = null;
if (parentProjectName == null) {
- targetProject =
ResourcesPlugin.getWorkspace().getRoot().getProject(project.getName());
+ targetProject = project;
} else {
targetProject =
ResourcesPlugin.getWorkspace().getRoot().getProject(parentProjectName);
}
-
+
if(targetProject.exists()) {
if("".equals(SeamCorePlugin.getSeamPreferences(targetProject).get(ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
""))) {
- return "";
+ return null;
} else {
- return targetProject.getName();
+ return targetProject;
}
}
}
- return "";
+ return null;
}
- static private IProject getInitialProject(ISelection simpleSelection) {
+ public static String getRootSeamProjectName(ISelection sel) {
+ IProject project = getRootSeamProject(getInitialProject(sel));
+ return project == null ? "" : project.getName();
+ }
+ public static IProject getInitialProject(ISelection simpleSelection) {
+
IProject project = null;
if (simpleSelection != null && !simpleSelection.isEmpty()
&& simpleSelection instanceof IStructuredSelection) {