From 96443d562937184827bbc0de66c073acee55abbb Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 13 Apr 2015 17:02:34 +0000 Subject: [PATCH] Updated Rule git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@113988 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/ColumnExpressionPanel.java | 209 ++++++++++++++---- .../expressionwidget/client/RuleDialog.java | 9 +- 2 files changed, 168 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionPanel.java index 5e171fc..aca85c6 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionPanel.java @@ -36,6 +36,8 @@ import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionHandler; +import com.google.gwt.event.logical.shared.ValueChangeEvent; +import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.web.bindery.event.shared.EventBus; @@ -75,6 +77,7 @@ public class ColumnExpressionPanel extends FramedPanel { private static final String HEIGHT_MULTI = "290px"; private static final String WIDTH = "648px"; private static final String HEIGHT = "364px"; + private static final String RULE_HEIGHT = "388px"; private ColumnExpressionPanelType type; private EventBus eventBus; @@ -94,13 +97,14 @@ public class ColumnExpressionPanel extends FramedPanel { private ConditionWidget conditionWidget; private ComboBox comboCols; private RuleDialog parentRuleDialog; - + private TextField columnTag; private ComboBox comboColumnTypeCode; private ComboBox comboMeasureType; private ComboBox comboAttributeType; private ListStore storeComboLocaleType; private ComboBox comboLocaleType; + private FieldLabel comboColumnTypeCodeLabel; private FieldLabel comboLocaleTypeLabel; private FieldLabel comboAttributeTypeLabel; private FieldLabel comboMeasureTypeLabel; @@ -161,7 +165,7 @@ public class ColumnExpressionPanel extends FramedPanel { ColumnData column, ArrayList columns, EventBus eventBus) { super(); setWidth(WIDTH); - setHeight(HEIGHT); + setHeight(RULE_HEIGHT); type = ColumnExpressionPanelType.RowDeleteByExpression; this.parentRowsDeleteByExpressionDialog = parentRowsDeleteByExpressionDialog; this.column = column; @@ -246,14 +250,14 @@ public class ColumnExpressionPanel extends FramedPanel { Log.debug("ConditionWidget" + conditionWidget); conditionsField.add(conditionWidget); - btnApply = new TextButton("Apply"); - btnApply.setIcon(ExpressionResources.INSTANCE.apply()); + btnApply = new TextButton("Save"); + btnApply.setIcon(ExpressionResources.INSTANCE.rule()); btnApply.setIconAlign(IconAlign.RIGHT); - btnApply.setToolTip("Apply rule"); + btnApply.setToolTip("Save rule"); btnApply.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { - Log.debug("Pressed Apply"); + Log.debug("Pressed Save"); applySeleceted(); } @@ -288,10 +292,21 @@ public class ColumnExpressionPanel extends FramedPanel { // TODO private void createColumnMockUp(VerticalLayoutContainer propertiesLayout) { columnTag = new TextField(); - columnTag.setToolTip("Label"); - FieldLabel columnLabel=new FieldLabel(columnTag, "Column Label"); - - //combo TypeCode + columnTag.setToolTip("Column Label"); + columnTag.addValueChangeHandler(new ValueChangeHandler() { + + @Override + public void onValueChange(ValueChangeEvent event) { + updateColumnTag(event.getValue()); + + } + + + }); + + FieldLabel columnLabel = new FieldLabel(columnTag, "Column Label"); + + // combo TypeCode ColumnTypeCodeProperties propsColumnTypeCode = GWT .create(ColumnTypeCodeProperties.class); ListStore storeComboTypeCode = new ListStore( @@ -309,7 +324,9 @@ public class ColumnExpressionPanel extends FramedPanel { comboColumnTypeCode.setWidth(191); comboColumnTypeCode.setTypeAhead(true); comboColumnTypeCode.setTriggerAction(TriggerAction.ALL); - + + comboColumnTypeCodeLabel=new FieldLabel(comboColumnTypeCode, "Column Type"); + // comboMeasureType ColumnDataTypeProperties propsMeasureType = GWT .create(ColumnDataTypeProperties.class); @@ -379,29 +396,26 @@ public class ColumnExpressionPanel extends FramedPanel { comboLocaleType.setTriggerAction(TriggerAction.ALL); comboLocaleTypeLabel = new FieldLabel(comboLocaleType, "Locale"); - - - propertiesLayout.add(columnLabel, - new VerticalLayoutData(1, -1, new Margins(0))); - propertiesLayout.add(new FieldLabel(comboColumnTypeCode, "Column Type"), - new VerticalLayoutData(1, -1, new Margins(0))); - propertiesLayout.add(comboLocaleTypeLabel, new VerticalLayoutData(1, -1, + + propertiesLayout.add(columnLabel, new VerticalLayoutData(1, -1, new Margins(0))); - propertiesLayout.add(comboMeasureTypeLabel, new VerticalLayoutData(1, -1, new Margins( - 0))); - propertiesLayout.add(comboAttributeTypeLabel, new VerticalLayoutData(1, -1, - new Margins(0))); - - + propertiesLayout.add( + comboColumnTypeCodeLabel, + new VerticalLayoutData(1, -1, new Margins(0))); + propertiesLayout.add(comboLocaleTypeLabel, new VerticalLayoutData(1, + -1, new Margins(0))); + propertiesLayout.add(comboMeasureTypeLabel, new VerticalLayoutData(1, + -1, new Margins(0))); + propertiesLayout.add(comboAttributeTypeLabel, new VerticalLayoutData(1, + -1, new Margins(0))); + + comboColumnTypeCodeLabel.setVisible(false); comboMeasureTypeLabel.setVisible(false); comboAttributeTypeLabel.setVisible(false); comboLocaleTypeLabel.setVisible(false); - - } - - + protected void addHandlersForComboColumnTypeCode( final LabelProvider labelProvider) { comboColumnTypeCode @@ -492,8 +506,32 @@ public class ColumnExpressionPanel extends FramedPanel { }); } - + protected void updateColumnTag(String value) { + if(value==null|| value.isEmpty()){ + comboColumnTypeCodeLabel.setVisible(false); + comboMeasureTypeLabel.setVisible(false); + comboAttributeTypeLabel.setVisible(false); + comboLocaleTypeLabel.setVisible(false); + + } else { + comboColumnTypeCodeLabel.setVisible(true); + comboMeasureTypeLabel.setVisible(false); + comboAttributeTypeLabel.setVisible(false); + comboLocaleTypeLabel.setVisible(false); + + } + + comboColumnTypeCode.reset(); + comboMeasureType.reset(); + comboAttributeType.reset(); + comboLocaleType.reset(); + updateCondition(); + forceLayout(); + + } + + protected void updateColumnType(ColumnTypeCode type) { Log.debug("Update ColumnTypeCode " + type.toString()); switch (type) { @@ -520,30 +558,120 @@ public class ColumnExpressionPanel extends FramedPanel { comboAttributeTypeLabel.setVisible(false); break; } - + + updateCondition(); forceLayout(); } + protected void updateCondition() { + ColumnMockUp columnMockUp = retrieveColumnMockUp(); + if (columnMockUp != null) { + column = new ColumnData(); + column.setColumnId(columnMockUp.getColumnId()); + column.setLabel(columnMockUp.getLabel()); + column.setDataTypeName(columnMockUp.getColumnDataType().toString()); + column.setTypeCode(columnMockUp.getColumnType().toString()); + conditionWidget.update(column); + conditionWidget.enable(); + } else { + conditionWidget.disable(); + } + forceLayout(); + } + + protected ColumnMockUp retrieveColumnMockUp() { + ColumnMockUp columnMockUp = null; + + String labelS = columnTag.getCurrentValue(); + + if (labelS != null && !labelS.isEmpty()) { + ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode + .getCurrentValue(); + if (columnTypeCodeElement != null) { + ColumnTypeCode type = columnTypeCodeElement.getCode(); + ColumnDataTypeElement columnDataTypeElement; + switch (type) { + case MEASURE: + columnDataTypeElement = comboMeasureType.getCurrentValue(); + if (columnDataTypeElement != null) { + ColumnDataType dataType = columnDataTypeElement + .getType(); + if (dataType != null) { + columnMockUp = new ColumnMockUp(null, labelS, + labelS, type, dataType, ""); + } else { + + } + + } else { + + } + break; + case ATTRIBUTE: + columnDataTypeElement = comboAttributeType + .getCurrentValue(); + if (columnDataTypeElement != null) { + ColumnDataType dataType = columnDataTypeElement + .getType(); + if (dataType != null) { + columnMockUp = new ColumnMockUp(null, labelS, + labelS, type, dataType, ""); + + } else { + } + } else { + + } + break; + case CODE: + case CODEDESCRIPTION: + case ANNOTATION: + columnMockUp = new ColumnMockUp(null, labelS, labelS, type, + ""); + break; + + case CODENAME: + LocaleTypeElement locale = comboLocaleType + .getCurrentValue(); + if (locale != null) { + columnMockUp = new ColumnMockUp(null, labelS, labelS, + type, locale.getLocaleName(), ""); + + } else { + + } + break; + default: + break; + } + } else { + + } + } else { + + } + return columnMockUp; + + } + protected void updateMeasureType(ColumnDataType type) { Log.debug("Update ColumnTypeCode " + type); + updateCondition(); - forceLayout(); } protected void updateAttributeType(ColumnDataType type) { Log.debug("Update ColumnTypeCode " + type); + updateCondition(); - forceLayout(); } protected void updateLocaleType(LocaleTypeElement type) { Log.debug("Update LocalType" + type); - + updateCondition(); } - - protected void retrieveLocales() { TDGWTServiceAsync.INSTANCE .getLocales(new AsyncCallback>() { @@ -589,8 +717,7 @@ public class ColumnExpressionPanel extends FramedPanel { }); } - - + protected void createOnTemplate() { // Important: fixed rendering of widgets forceLayoutOnResize = true; @@ -1071,14 +1198,6 @@ public class ColumnExpressionPanel extends FramedPanel { } - protected void saveRule() { - - } - - protected void searchRule() { - - } - protected void close() { switch (type) { case Template: diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleDialog.java index 99f25e4..36e5afd 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RuleDialog.java @@ -18,7 +18,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; */ public class RuleDialog extends Window { private static final String WIDTH = "660px"; - private static final String HEIGHT = "426px"; + private static final String HEIGHT = "460px"; private ColumnExpressionPanel columnExpressionPanel; private EventBus eventBus; @@ -30,14 +30,13 @@ public class RuleDialog extends Window { */ public RuleDialog(EventBus eventBus) { initWindow(); - this.eventBus = eventBus; - + this.eventBus = eventBus; create(); } - + protected void initWindow() { setWidth(WIDTH); setHeight(HEIGHT); @@ -90,7 +89,7 @@ public class RuleDialog extends Window { public void addRule(ExpressionWrapper exWrapper) { Log.debug("ExpressionWrapper: "+exWrapper); - + close(); }