Index: SelectParametersWizardPanel.java
===================================================================
--- SelectParametersWizardPanel.java	(revision 38551)
+++ SelectParametersWizardPanel.java	(revision 38552)
@@ -27,30 +27,51 @@
 
 package org.gvsig.app.join.daltransform;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+
+import javax.swing.JOptionPane;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.gvsig.andami.PluginServices;
+import org.gvsig.app.ApplicationLocator;
+import org.gvsig.app.join.utils.TransformUtils;
 import org.gvsig.daltransform.swing.DataTransformWizardPanel;
 import org.gvsig.daltransform.swing.impl.AbstractDataTransformWizardPanel;
 import org.gvsig.daltransform.swing.impl.components.FeatureTypeAttributesCombo;
 import org.gvsig.daltransform.swing.impl.components.FeatureTypeAttributesList;
 import org.gvsig.fmap.dal.exception.DataException;
+import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
 import org.gvsig.fmap.dal.feature.FeatureStore;
+import org.gvsig.fmap.dal.feature.FeatureType;
+import org.gvsig.i18n.Messages;
 
 
 /**
  * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
  */
-public class SelectParametersWizardPanel extends AbstractDataTransformWizardPanel implements DataTransformWizardPanel{
+public class SelectParametersWizardPanel extends AbstractDataTransformWizardPanel
+implements DataTransformWizardPanel, ActionListener{
+    
+    private static Logger logger =
+        LoggerFactory.getLogger(SelectParametersWizardPanel.class);
+    
 	private javax.swing.JLabel attributesLabel;
 	private FeatureTypeAttributesList attributesList;
 	private javax.swing.JScrollPane attributesScroll;
 	private FeatureTypeAttributesCombo key1Combo;
 	private javax.swing.JLabel key1Label;
-	private FeatureTypeAttributesCombo key2Combo;
+	private FeatureTypeAttributesCombo key2_Combo;
 	private javax.swing.JLabel key2Label;
 	private javax.swing.JLabel prefix1Label;
 	private javax.swing.JTextField prefix1Text;
 	private javax.swing.JLabel prefix2Label;
 	private javax.swing.JTextField prefix2Text; 
+	
+	private FeatureStore secondFeatStore = null;
 
 	/**
 	 * @param featureTransformWizardModel
@@ -73,10 +94,16 @@
 		java.awt.GridBagConstraints gridBagConstraints;
 
 		prefix2Text = new javax.swing.JTextField();
-		key2Combo = new FeatureTypeAttributesCombo();
+		key2_Combo = new FeatureTypeAttributesCombo();
 		prefix1Text = new javax.swing.JTextField();
 		key1Label = new javax.swing.JLabel();
+		
 		key1Combo = new FeatureTypeAttributesCombo();
+		// listen to changes in first combo
+		// we'll update second combo leaving
+		// fields of same type
+		key1Combo.addActionListener(this);
+		
 		key2Label = new javax.swing.JLabel();
 		prefix1Label = new javax.swing.JLabel();
 		prefix2Label = new javax.swing.JLabel();
@@ -99,7 +126,7 @@
 		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
 		gridBagConstraints.weightx = 1.0;
 		gridBagConstraints.insets = new java.awt.Insets(2, 2, 3, 2);
-		add(key2Combo, gridBagConstraints);
+		add(key2_Combo, gridBagConstraints);
 		gridBagConstraints = new java.awt.GridBagConstraints();
 		gridBagConstraints.gridx = 0;
 		gridBagConstraints.gridy = 5;
@@ -179,7 +206,7 @@
 	 * @return
 	 */
 	public String getkeyAtrr2() {
-		return key2Combo.getSelectedFeatureAttributeDescriptor().getName();
+		return key2_Combo.getSelectedFeatureAttributeDescriptor().getName();
 	}
 
 	/**
@@ -208,9 +235,77 @@
 	 * @throws DataException 
 	 */
 	public void updateFeatureStores(FeatureStore selectedFeatureStore) throws DataException {
+	    secondFeatStore = selectedFeatureStore;
 		key1Combo.addFeatureAttributes(getFeatureStore().getDefaultFeatureType());
-		key2Combo.addFeatureAttributes(selectedFeatureStore.getDefaultFeatureType());
 		attributesList.addFeatureAttributes(selectedFeatureStore.getDefaultFeatureType());
+		
+		if (key1Combo.getItemCount() == 0) {
+		    
+            String _msg =
+                Messages.getText("_First_table_has_no_fields");
+            String _tit = Messages.getText("_Join");
+            
+            JOptionPane.showMessageDialog(
+                this, _msg, _tit,
+                JOptionPane.ERROR_MESSAGE);
+            
+		    getDataTransformWizard().setApplicable(false);
+        } else {
+            key1Combo.setSelectedIndex(0);
+		}
 	}
+
+
+	/**
+	 * Listen to changes in first combo box (key1)
+	 */
+    public void actionPerformed(ActionEvent e) {
+        
+        Object src = e.getSource();
+        if (src == key1Combo
+            && key1Combo != null
+            && key2_Combo != null
+            && secondFeatStore != null) {
+            
+            FeatureAttributeDescriptor att =
+                key1Combo.getSelectedFeatureAttributeDescriptor();
+            if (att != null) {
+                
+                int the_type = att.getType();
+                key2_Combo.removeAllItems();
+                FeatureType ft = null;
+                
+                try {
+                    ft = secondFeatStore.getDefaultFeatureType();
+                } catch (DataException de) {
+                    logger.info("While getting feat type: " + de.getMessage());
+                    getDataTransformWizard().setApplicable(false);
+                    ApplicationLocator.getManager().message(
+                        Messages.getText("_Error_getting_attributes"),
+                        JOptionPane.ERROR_MESSAGE);
+                    return;
+                }
+                
+                ArrayList<Integer> comparable_types =
+                    TransformUtils.getComparableDataTypes(ft, the_type);
+                
+                if (key2_Combo.addFeatureAttributes(ft, comparable_types) == 0) {
+                    getDataTransformWizard().setApplicable(false);
+                    
+                    String _msg =
+                        Messages.getText("_No_compatible_field_in_second_table");
+                    String _tit = Messages.getText("_Join");
+                    
+                    JOptionPane.showMessageDialog(
+                        this, _msg, _tit,
+                        JOptionPane.ERROR_MESSAGE);
+                } else {
+                    getDataTransformWizard().setApplicable(true);
+                    // JOptionPane.showMessageDialog(this, "(2) OK !!");
+                }
+            }
+        }
+        
+    }
 }
 
