diff --git a/src/main/java/org/gcube/portlets/user/td/rulewidget/client/multicolumn/RuleOnTableApplyMapColumnCard.java b/src/main/java/org/gcube/portlets/user/td/rulewidget/client/multicolumn/RuleOnTableApplyMapColumnCard.java index 85b3911..be42079 100644 --- a/src/main/java/org/gcube/portlets/user/td/rulewidget/client/multicolumn/RuleOnTableApplyMapColumnCard.java +++ b/src/main/java/org/gcube/portlets/user/td/rulewidget/client/multicolumn/RuleOnTableApplyMapColumnCard.java @@ -17,6 +17,7 @@ import org.gcube.portlets.user.td.rulewidget.client.multicolumn.data.MapPlaceHol import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData; +import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; @@ -49,6 +50,7 @@ import com.sencha.gxt.widget.core.client.form.FormPanel; import com.sencha.gxt.widget.core.client.grid.ColumnConfig; import com.sencha.gxt.widget.core.client.grid.ColumnModel; import com.sencha.gxt.widget.core.client.grid.Grid; +import com.sencha.gxt.widget.core.client.grid.Grid.GridCell; import com.sencha.gxt.widget.core.client.grid.GridSelectionModel; import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing; @@ -66,6 +68,7 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard { private ListStore store; private ArrayList rows; private ArrayList columns; + private ListStore storeComboColumnData; public RuleOnTableApplyMapColumnCard( ApplyTableRuleSession applyTableRuleSession) { @@ -177,9 +180,9 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard { ColumnDataPropertiesCombo columnDataPropertiesCombo = GWT .create(ColumnDataPropertiesCombo.class); - ListStore storeComboColumnData = new ListStore( + storeComboColumnData = new ListStore( columnDataPropertiesCombo.id()); - storeComboColumnData.addAll(columns); + ComboBox comboColumnData = new ComboBox( storeComboColumnData, columnDataPropertiesCombo.label()); @@ -198,6 +201,25 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard { public void onBeforeStartEdit( BeforeStartEditEvent event) { setEnableNextButton(false); + GridCell cell=event.getEditCell(); + int rowIndex=cell.getRow(); + MapPlaceHolderToColumnRow row=store.get(rowIndex); + RuleColumnPlaceHolderDescriptor descriptor=row.getRuleColumnPlaceHolderDescriptor(); + ColumnDataType columnDataType=descriptor.getColumnDataType(); + ArrayList usableColumns=new ArrayList(); + for(ColumnData column:columns){ + ColumnDataType cdt=ColumnDataType.getColumnDataTypeFromId(column.getDataTypeName()); + if(column.getDataTypeName()!=null && cdt.compareTo(columnDataType)==0){ + usableColumns.add(column); + } + } + + storeComboColumnData.clear(); + storeComboColumnData.commitChanges(); + storeComboColumnData.addAll(usableColumns); + storeComboColumnData.commitChanges(); + + } }); @@ -207,7 +229,7 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard { public void onCancelEdit( CancelEditEvent event) { store.rejectChanges(); - setEnableNextButton(true); + checkAllFill(); } @@ -221,19 +243,7 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard { try { store.commitChanges(); - boolean fillAll = true; - for (MapPlaceHolderToColumnRow row : store.getAll()) { - if (row.getColumn() == null) { - fillAll = false; - break; - } - } - - if (fillAll) { - setEnableNextButton(true); - } else { - setEnableNextButton(false); - } + checkAllFill(); } catch (Throwable e) { Log.error("Error in RuleOnTableNewDefinitionCard: " @@ -241,6 +251,8 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard { e.printStackTrace(); } } + + }); // @@ -249,6 +261,23 @@ public class RuleOnTableApplyMapColumnCard extends WizardCard { forceLayout(); return; } + + protected void checkAllFill() { + boolean fillAll = true; + for (MapPlaceHolderToColumnRow row : store.getAll()) { + if (row.getColumn() == null) { + fillAll = false; + break; + } + } + + if (fillAll) { + setEnableNextButton(true); + } else { + setEnableNextButton(false); + } + } + protected void retrieveColumns() { TDGWTServiceAsync.INSTANCE.getColumns(applyTableRuleSession.getTrId(), diff --git a/src/main/java/org/gcube/portlets/user/td/rulewidget/client/multicolumn/RuleOnTableApplySelectRuleCard.java b/src/main/java/org/gcube/portlets/user/td/rulewidget/client/multicolumn/RuleOnTableApplySelectRuleCard.java index cbaecbe..b770afb 100644 --- a/src/main/java/org/gcube/portlets/user/td/rulewidget/client/multicolumn/RuleOnTableApplySelectRuleCard.java +++ b/src/main/java/org/gcube/portlets/user/td/rulewidget/client/multicolumn/RuleOnTableApplySelectRuleCard.java @@ -7,17 +7,12 @@ import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceA import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyTableRuleSession; -import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleColumnPlaceHolderDescriptor; import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType; import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData; -import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleTableType; -import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleType; import org.gcube.portlets.user.td.rulewidget.client.RuleInfoDialog; import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; -import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; -import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3; @@ -381,9 +376,10 @@ public class RuleOnTableApplySelectRuleCard extends WizardCard { }; - //TODO - //ruleDescriptionData = getSelectedItem(); - ArrayList ruleColumnPlaceHolderDescriptors=new ArrayList(); + + ruleDescriptionData = getSelectedItem(); + //TODO x Test + /*ArrayList ruleColumnPlaceHolderDescriptors=new ArrayList(); RuleColumnPlaceHolderDescriptor r1=new RuleColumnPlaceHolderDescriptor("Test1", "Test1", ColumnDataType.Text); RuleColumnPlaceHolderDescriptor r2=new RuleColumnPlaceHolderDescriptor("Test2", "Test2", ColumnDataType.Integer); ruleColumnPlaceHolderDescriptors.add(r1); @@ -392,7 +388,7 @@ public class RuleOnTableApplySelectRuleCard extends WizardCard { ruleDescriptionData =new RuleDescriptionData(1, "Test", "Test Description", "2015-01-01 18:45", null, null, RuleScopeType.TABLE, new C_Expression(), tdRuleType); - + */ if (ruleDescriptionData == null) { AlertMessageBox d = new AlertMessageBox("Attention", "Select one rule!");