Author: akazakov
Date: 2007-08-29 13:50:24 -0400 (Wed, 29 Aug 2007)
New Revision: 3406
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java
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/widget/editor/ComboFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedComboFieldEditor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/ComboBoxField.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-769 Added Generate Seam Entities Wizard
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-08-29 16:14:41
UTC (rev 3405)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/META-INF/MANIFEST.MF 2007-08-29 17:50:24
UTC (rev 3406)
@@ -47,7 +47,8 @@
org.eclipse.datatools.connectivity.ui.dse,
org.eclipse.datatools.connectivity.db.generic.ui,
org.eclipse.datatools.connectivity.db.generic,
- org.jboss.tools.common.model.ui
+ org.jboss.tools.common.model.ui,
+ org.hibernate.eclipse
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-08-29
16:14:41 UTC (rev 3405)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2007-08-29
17:50:24 UTC (rev 3406)
@@ -13,7 +13,13 @@
public static String CREATE_NEW_SEAM_PROJECT;
public static String GENERATE_SEAM_ENTITIES_WIZARD_TITLE;
- public static String GENERATE_SEAM_ENTITIES_WIZARD_PAGE1_MESSAGE;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_PAGE_MESSAGE;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_LABEL;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_MESSAGE;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_ERROR;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_GROUP_LABEL;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL;
+ public static String GENERATE_SEAM_ENTITIES_WIZARD_EXISTING_ENTITIES_LABEL;
static {
// load message values from bundle file
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-08-29
16:14:41 UTC (rev 3405)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2007-08-29
17:50:24 UTC (rev 3406)
@@ -1,3 +1,9 @@
CREATE_NEW_SEAM_PROJECT = Create New Seam Project
GENERATE_SEAM_ENTITIES_WIZARD_TITLE = Generate Seam Entities
-GENERATE_SEAM_ENTITIES_WIZARD_PAGE1_MESSAGE = Select seam project
\ No newline at end of file
+GENERATE_SEAM_ENTITIES_WIZARD_PAGE_MESSAGE = Select Seam project
+GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_LABEL = Hibernate Console
Configuration:
+GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_MESSAGE = Select Hibernate Console
Configuration
+GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_ERROR = Hibernate console
configuration name is empty
+GENERATE_SEAM_ENTITIES_WIZARD_GROUP_LABEL = Generation Mode
+GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL = Reverse Engineer from data base
+GENERATE_SEAM_ENTITIES_WIZARD_EXISTING_ENTITIES_LABEL = Use existing entities
\ No newline at end of file
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 2007-08-29
16:14:41 UTC (rev 3405)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/ComboFieldEditor.java 2007-08-29
17:50:24 UTC (rev 3406)
@@ -16,8 +16,6 @@
import java.util.List;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.jboss.tools.seam.ui.widget.field.ComboBoxField;
@@ -92,5 +90,14 @@
// TODO Auto-generated method stub
return 1;
}
-
-}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ super.setEditable(ediatble);
+ comboField.setEditable(ediatble);
+ }
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedComboFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedComboFieldEditor.java 2007-08-29
16:14:41 UTC (rev 3405)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedComboFieldEditor.java 2007-08-29
17:50:24 UTC (rev 3406)
@@ -14,9 +14,7 @@
import java.util.Collections;
import java.util.List;
-import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
public class TaggedComboFieldEditor extends CompositeEditor implements
ITaggedFieldEditor, PropertyChangeListener{
@@ -25,7 +23,7 @@
boolean floatStyle = true;
ComboFieldEditor combo = null;
- public TaggedComboFieldEditor(String name, String label, List values,Object
defaultValue, boolean floatStyle) {
+ public TaggedComboFieldEditor(String name, String label, List values, Object
defaultValue, boolean floatStyle) {
super(name, label, defaultValue);
this.values = Collections.unmodifiableList(values);
this.floatStyle = floatStyle;
@@ -48,4 +46,21 @@
combo.setTags(tags);
}
-}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ combo.setEditable(ediatble);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#isEditable()
+ */
+ @Override
+ public boolean isEditable() {
+ return combo.isEditable();
+ }
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/ComboBoxField.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/ComboBoxField.java 2007-08-29
16:14:41 UTC (rev 3405)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/ComboBoxField.java 2007-08-29
17:50:24 UTC (rev 3406)
@@ -23,13 +23,14 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
/**
* @author eskimo
@@ -43,13 +44,14 @@
public ComboBoxField(Composite parent,List values, ILabelProvider labelProvider,
Object value, boolean floatStyle) {
this(parent, values, value, floatStyle);
-
comboControl.setLabelProvider(labelProvider);
}
+
public ComboBoxField(Composite parent,List values, Object value, boolean floatStyle) {
this.values = values;
- comboControl = new ComboViewer(parent,floatStyle?SWT.FLAT:SWT.READ_ONLY);
-
+ CCombo ccombo = new CCombo(parent, SWT.BORDER);
+ ccombo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+ comboControl = new ComboViewer(ccombo);
comboControl.setContentProvider(new IStructuredContentProvider() {
public void dispose() {
@@ -62,18 +64,14 @@
public Object[] getElements(Object inputElement) {
return ComboBoxField.this.values.toArray();
}
-
-
});
comboControl.addSelectionChangedListener(this);
- comboControl.getCombo().addModifyListener(new ModifyListener() {
-
+ comboControl.getCCombo().addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
- firePropertyChange(new Object(), comboControl.getCombo().getText());
+ firePropertyChange(new Object(), comboControl.getCCombo().getText());
}});
comboControl.setLabelProvider(new ILabelProvider() {
-
public void addListener(ILabelProviderListener listener) {
}
@@ -94,34 +92,32 @@
public String getText(Object element) {
return element.toString();
}
-
});
comboControl.setInput(values);
comboControl.setSelection(new StructuredSelection(value), true);
-
-
}
+
public void widgetDefaultSelected(SelectionEvent e) {
}
public void selectionChanged(SelectionChangedEvent event) {
firePropertyChange("",
((StructuredSelection)event.getSelection()).getFirstElement());
}
-
- public Combo getComboControl() {
- return comboControl.getCombo();
+
+ public CCombo getComboControl() {
+ return comboControl.getCCombo();
}
@Override
public Control getControl() {
return getComboControl();
}
-
+
public void setValue(Object newValue) {
comboControl.setSelection(new StructuredSelection(newValue));
- comboControl.getCombo().setText(newValue.toString());
+ comboControl.getCCombo().setText(newValue.toString());
}
-
+
public void setTags(String[] tags,String value) {
values = Arrays.asList(tags);
comboControl.removeSelectionChangedListener(this);
@@ -129,4 +125,8 @@
comboControl.addPostSelectionChangedListener(this);
comboControl.setSelection(new StructuredSelection(value));
}
-}
+
+ public void setEditable(boolean ediatble) {
+ comboControl.getCCombo().setEditable(ediatble);
+ }
+}
\ No newline at end of file
Added:
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
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java 2007-08-29
17:50:24 UTC (rev 3406)
@@ -0,0 +1,84 @@
+ /*******************************************************************************
+ * 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.widget.field;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * A group of labels and radio buttons.
+ * @author Alexey Kazakov
+ */
+public class RadioField extends BaseField implements SelectionListener {
+
+ private Composite topComposite;
+ private Button[] radios;
+ private Object value;
+
+ public RadioField(Composite parent, List<String> labels, List<Object>
values, Object defaultValue) {
+ topComposite = new Composite(parent, SWT.NONE);
+ topComposite.setLayout(new GridLayout(1, false));
+ topComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ radios = new Button[values.size()];
+ if(defaultValue==null && values.size()>0) {
+ defaultValue = values.get(0);
+ }
+ for (int i = 0; i < radios.length; i++) {
+ radios[i] = new Button(topComposite, SWT.RADIO);
+ radios[i].setText(labels.get(i));
+ radios[i].addSelectionListener(this);
+ Object value = values.get(i);
+ radios[i].setData(value);
+ if(value==defaultValue) {
+ radios[i].setSelection(true);
+ this.value = value;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.field.BaseField#getControl()
+ */
+ @Override
+ public Control getControl() {
+ return topComposite;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent event) {
+ value = event.widget.getData();
+ firePropertyChange("", value);
+ }
+
+ /**
+ * @return Value of selected button
+ */
+ public Object getValue() {
+ return value;
+ }
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java 2007-08-29
16:14:41 UTC (rev 3405)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/IParameter.java 2007-08-29
17:50:24 UTC (rev 3406)
@@ -27,6 +27,7 @@
public static String SEAM_ENTITY_CLASS_NAME = "entity.name";
public static String SEAM_PROJECT_LOCATION_PATH = "seam.project.location";
public static String SEAM_PROJECT_WEBCONTENT_PATH =
"seam.project.webcontent";
+ public static String HIBERNATE_CONFIGURATION_NAME =
"hibernate.configuratrion.name";
public static String SEAM_EAR_PROJECT_LOCATION_PATH =
"seam.ear.project.location";
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java 2007-08-29
16:14:41 UTC (rev 3405)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEnitiesWizardPage.java 2007-08-29
17:50:24 UTC (rev 3406)
@@ -10,36 +10,124 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Map;
+
import org.eclipse.jface.wizard.WizardPage;
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.ui.PlatformUI;
+import org.eclipse.swt.widgets.Group;
import org.jboss.tools.seam.ui.SeamUIMessages;
-import org.jboss.tools.seam.ui.widget.editor.LabelFieldEditor;
+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.field.RadioField;
/**
* @author Alexey Kazakov
*/
-public class SeamGenerateEnitiesWizardPage extends WizardPage {
+public class SeamGenerateEnitiesWizardPage extends WizardPage implements
PropertyChangeListener {
+ private IFieldEditor projectEditor;
+ private IFieldEditor configEditor;
+ private RadioField radios;
+
public SeamGenerateEnitiesWizardPage() {
super("seam.generate.entities.page",
SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_TITLE, null);
- setMessage(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_PAGE1_MESSAGE);
+ setMessage(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_PAGE_MESSAGE);
}
/* (non-Javadoc)
* @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
- Composite top = new Composite(parent, SWT.NONE);
- top.setLayout(new GridLayout());
- top.setLayoutData(new GridData(GridData.FILL_BOTH));
+ setPageComplete(true);
+ String projectName = SeamWizardUtils.getSelectedProjectName();
+ projectEditor = SeamWizardFactory.createSeamProjectSelectionFieldEditor(projectName);
+ projectEditor.addPropertyChangeListener(this);
+ if(projectName!=null && projectName.length()>0) {
+ Map<String, String> errors =
ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(projectEditor.getValue(), null);
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ } else {
+ setMessage(null);
+ }
+ }
- LabelFieldEditor label = new LabelFieldEditor("test", "test");
- label.createLabelControl(top);
- setPageComplete(false);
+ Composite top = new GridLayoutComposite(parent);
+ Composite projectComposite = new GridLayoutComposite(top, SWT.NONE, 3);
+
+ projectEditor.doFillIntoGrid(projectComposite);
+
+ configEditor =
SeamWizardFactory.createHibernateConsoleConfigurationSelectionFieldEditor(null);
+ configEditor.addPropertyChangeListener(this);
+ configEditor.doFillIntoGrid(projectComposite);
+ configEditor.setEditable(false);
+
+ String config = (String)configEditor.getValue();
+ if(config==null && config.length()==0) {
+ setMessage(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_MESSAGE);
+ setPageComplete(false);
+ }
+
+ Composite groupComposite = new GridLayoutComposite(top);
+ Group group = new Group(groupComposite, SWT.NONE);
+ group.setText(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_GROUP_LABEL);
+ group.setLayout(new GridLayout(1, false));
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Composite radioComposite = new GridLayoutComposite(group, SWT.NONE, 2);
+ ArrayList<Object> values = new ArrayList<Object>();
+ values.add("reverse");
+ values.add("existing");
+ ArrayList<String> labels = new ArrayList<String>();
+ labels.add(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL);
+ labels.add(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_EXISTING_ENTITIES_LABEL);
+ radios = new RadioField(radioComposite, labels, values, null);
+ radios.addPropertyChangeListener(this);
+
setControl(top);
}
+
+ public static class GridLayoutComposite extends Composite {
+
+ public GridLayoutComposite(Composite parent, int style, int columnNumber) {
+ super(parent, style);
+ GridLayout gl = new GridLayout(columnNumber, false);
+ setLayout(gl);
+ setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ public GridLayoutComposite(Composite parent) {
+ this(parent, SWT.NONE, 1);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ Map<String, String> errors =
ValidatorFactory.SEAM_PROJECT_NAME_VALIDATOR.validate(projectEditor.getValue(), null);
+
+ if(errors.size()>0) {
+ setErrorMessage(errors.get(IValidator.DEFAULT_ERROR).toString());
+ setPageComplete(false);
+ return;
+ }
+ String config = (String)configEditor.getValue();
+ if(config==null && config.length()==0) {
+ setErrorMessage(SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_ERROR);
+ setPageComplete(false);
+ return;
+ }
+
+ setErrorMessage(null);
+ setMessage(null);
+ setPageComplete(true);
+ }
}
\ 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 2007-08-29
16:14:41 UTC (rev 3405)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java 2007-08-29
17:50:24 UTC (rev 3406)
@@ -11,6 +11,12 @@
package org.jboss.tools.seam.ui.wizard;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.jboss.tools.seam.ui.SeamUIMessages;
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.SwtFieldEditorFactory;
@@ -97,4 +103,25 @@
return SwtFieldEditorFactory.INSTANCE.createTextEditor(
IParameter.SEAM_ENTITY_CLASS_NAME, "Seam entity class name:",
"");
}
-}
+
+ /**
+ * @param defaultSelection if "null" sets first configuration as default
+ * @return
+ */
+ public static IFieldEditor
createHibernateConsoleConfigurationSelectionFieldEditor(String defaultSelection) {
+ ConsoleConfiguration[] configs =
KnownConfigurations.getInstance().getConfigurations();
+ List<String> configurationNames = new ArrayList<String>();
+ for (int i = 0; i < configs.length; i++) {
+ configurationNames.add(configs[i].getName());
+ }
+ if(defaultSelection==null) {
+ if(configurationNames.size()>0) {
+ defaultSelection = configurationNames.get(0);
+ } else {
+ defaultSelection = "";
+ }
+ }
+ IFieldEditor editor =
SwtFieldEditorFactory.INSTANCE.createComboEditor(IParameter.HIBERNATE_CONFIGURATION_NAME,
SeamUIMessages.GENERATE_SEAM_ENTITIES_WIZARD_HIBERNATE_CONFIGURATION_LABEL,
configurationNames, defaultSelection);
+ return editor;
+ }
+}
\ No newline at end of file