Author: scabanovich
Date: 2007-11-01 13:37:17 -0400 (Thu, 01 Nov 2007)
New Revision: 4639
Added:
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/TaggedRadioFieldEditor.java
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/widget/editor/IFieldEditorFactory.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
Log:
JBIDE-1220
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 2007-11-01
17:30:07 UTC (rev 4638)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/internal/project/facet/SeamInstallWizardPage.java 2007-11-01
17:37:17 UTC (rev 4639)
@@ -97,10 +97,12 @@
true, new NewSeamRuntimeAction(), (IValidator)null);
private IFieldEditor jBossAsDeployAsEditor = IFieldEditorFactory.INSTANCE
- .createComboEditor(
+ .createRadioEditor(
ISeamFacetDataModelProperties.JBOSS_AS_DEPLOY_AS,
- SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DEPLOY_AS, Arrays.asList(new String[] {
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_WAR, SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EAR
}),
- getDeployAsDefaultValue(), false);
+ SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_DEPLOY_AS,
+ Arrays.asList(new String[] { SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_WAR,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EAR }),
+ Arrays.asList(new Object[] { SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_WAR,
SeamUIMessages.SEAM_INSTALL_WIZARD_PAGE_EAR }),
+ getDeployAsDefaultValue());
String lastCreatedCPName = ""; //$NON-NLS-1$
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 2007-11-01
17:30:07 UTC (rev 4638)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java 2007-11-01
17:37:17 UTC (rev 4639)
@@ -52,6 +52,18 @@
*/
ITaggedFieldEditor createComboEditor(String name, String label,
List values, Object defaultValue, boolean flat);
+
+ /**
+ *
+ * @param name
+ * @param label
+ * @param labels
+ * @param values
+ * @param defaultValue
+ * @return
+ */
+ public ITaggedFieldEditor createRadioEditor(String name, String label,
+ List<String> labels, List values, Object defaultValue);
/**
*
Added:
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
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/RadioFieldEditor.java 2007-11-01
17:37:17 UTC (rev 4639)
@@ -0,0 +1,108 @@
+ /*******************************************************************************
+ * 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.editor;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.seam.ui.widget.field.RadioField;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class RadioFieldEditor extends BaseFieldEditor implements
ITaggedFieldEditor,PropertyChangeListener{
+ List values = null;
+ List<String> labels;
+
+ RadioField radioField;
+
+ public RadioFieldEditor(String name, String label, List<String> labels, List
values,Object defaultValue) {
+ super(name, label, defaultValue);
+ this.labels = labels;
+ this.values = Collections.unmodifiableList(values);
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ return new Control[] {getComboControl((Composite)composite)};
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ }
+
+ public Control getComboControl(Composite composite) {
+ if(radioField == null) {
+ radioField = new RadioField(composite,labels, values,getValue());
+ radioField.addPropertyChangeListener(this);
+ } else if(composite!=null) {
+ Assert.isTrue(radioField.getControl().getParent()==composite);
+ }
+ return radioField.getControl();
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ return null;
+ }
+
+ public void save(Object object) {
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ setValue(evt.getNewValue());
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#getTags()
+ */
+ public String[] getTags() {
+ String[] result = new String[values.size()];
+ for (int i = 0; i < result.length; i++) result[i] = values.get(0).toString();
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#setTags(java.lang.String[])
+ */
+ public void setTags(String[] tags) {
+ values.clear();
+ for (int i = 0; i < tags.length; i++) values.add(tags[i]);
+ //TODO
+// radioField.setTags(tags,getValueAsString());
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.BaseFieldEditor#getNumberOfControls()
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ public void setValue(Object newValue) {
+ if(newValue==null) {
+ return;
+ }
+ super.setValue(newValue);
+ if(radioField!=null) {
+ radioField.removePropertyChangeListener(this);
+ radioField.setValue(newValue.toString());
+ radioField.addPropertyChangeListener(this);
+ }
+ }
+}
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 2007-11-01
17:30:07 UTC (rev 4638)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java 2007-11-01
17:37:17 UTC (rev 4639)
@@ -58,6 +58,12 @@
return editor;
}
+ public ITaggedFieldEditor createRadioEditor(String name, String label,
+ List<String> labels, List values, Object defaultValue) {
+ TaggedRadioFieldEditor editor = new TaggedRadioFieldEditor(name,label, labels, values,
defaultValue);
+ return editor;
+ }
+
/**
*
*/
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedRadioFieldEditor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedRadioFieldEditor.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/TaggedRadioFieldEditor.java 2007-11-01
17:37:17 UTC (rev 4639)
@@ -0,0 +1,68 @@
+ /*******************************************************************************
+ * 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.editor;
+
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class TaggedRadioFieldEditor extends CompositeEditor implements
ITaggedFieldEditor, PropertyChangeListener{
+
+ List values = null;
+ RadioFieldEditor radios = null;
+
+ public TaggedRadioFieldEditor(String name, String label, List<String> labels, List
values,
+ Object defaultValue) {
+
+ super(name, label, defaultValue==null?"":defaultValue.toString());
//$NON-NLS-1$
+ this.values = Collections.unmodifiableList(values);
+ radios = new RadioFieldEditor(
+ name,label,labels, values,getValue());
+ addFieldEditors(new IFieldEditor[]{new LabelFieldEditor(name,label),
+ radios});
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#getTags()
+ */
+ public String[] getTags() {
+ return radios.getTags();
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.ui.widget.editor.ITaggedFieldEditor#setTags(java.lang.String[])
+ */
+ public void setTags(String[] tags) {
+ radios.setTags(tags);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#setEditable(boolean)
+ */
+ @Override
+ public void setEditable(boolean ediatble) {
+ radios.setEditable(ediatble);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.widget.editor.CompositeEditor#isEditable()
+ */
+ @Override
+ public boolean isEditable() {
+ return radios.isEditable();
+ }
+}
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 2007-11-01
17:30:07 UTC (rev 4638)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/field/RadioField.java 2007-11-01
17:37:17 UTC (rev 4639)
@@ -44,9 +44,10 @@
radios[i] = new Button(topComposite, SWT.RADIO);
radios[i].setText(labels.get(i));
radios[i].addSelectionListener(this);
+ radios[i].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Object value = values.get(i);
radios[i].setData(value);
- if(value==defaultValue) {
+ if(value != null && value.equals(defaultValue)) {
radios[i].setSelection(true);
this.value = value;
}
@@ -81,4 +82,16 @@
public Object getValue() {
return value;
}
-}
\ No newline at end of file
+
+ public void setValue(String value) {
+ this.value = value;
+ for (int i = 0; i < radios.length; i++) {
+ if(value.equals(radios[i].getData())) {
+ radios[i].setSelection(true);
+ } else {
+ radios[i].setSelection(false);
+ }
+ }
+ }
+
+}