81: Allow the creation and use of expressions on multi column in TDM portlet

Task-Url: https://support.d4science.org/issues/81

Updated Rule on Table creation

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-rule-widget@114808 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-05-19 16:54:51 +00:00 committed by Giancarlo Panichi
parent 485276fef3
commit 944e3fb32b
11 changed files with 347 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedExcep
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.rule.AppliedRulesResponseData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
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;

View File

@ -13,7 +13,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedExcep
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.rule.AppliedRulesResponseData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyAndDetachColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
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;

View File

@ -5,7 +5,7 @@ import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
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;

View File

@ -6,8 +6,8 @@ import java.util.List;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
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.RuleDescriptionData;
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.rulewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.td.rulewidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle;
import com.sencha.gxt.core.client.util.Margins;

View File

@ -3,7 +3,7 @@ package org.gcube.portlets.user.td.rulewidget.client;
import org.gcube.portlets.user.td.expressionwidget.client.RuleEditDialog;
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleEditDialogNotification;
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleEditDialogNotification.RuleEditDialogNotificationListener;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle;
import com.allen_sauer.gwt.log.client.Log;

View File

@ -6,8 +6,8 @@ import java.util.List;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
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.RuleDescriptionData;
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.rulewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.td.rulewidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.sharewidget.client.RuleShare;

View File

@ -6,8 +6,8 @@ import java.util.List;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
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.RuleDescriptionData;
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.rulewidget.client.RuleDeletePanel.RuleDeleteTemplates;
import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;

View File

@ -0,0 +1,296 @@
package org.gcube.portlets.user.td.rulewidget.client.multicolumn;
import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.client.properties.RuleColumnPlaceHolderDescriptorProperties;
import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleColumnPlaceHolderDescriptor;
import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleTableType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TableType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.sencha.gxt.core.client.util.Padding;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
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;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CreateRuleOnTableDefinitionCard extends WizardCard {
private CreateRuleOnTableDefinitionCard thisCard;
private TDRuleTableType tdRuleTableType;
private Grid<RuleColumnPlaceHolderDescriptor> grid;
public CreateRuleOnTableDefinitionCard() {
super("Columns Definition", "");
this.thisCard = this;
FormPanel panel = createPanel();
setCenterWidget(panel, new MarginData(0));
}
protected FormPanel createPanel() {
FormPanel panel = new FormPanel();
panel.setLabelWidth(90);
panel.getElement().setPadding(new Padding(5));
VerticalLayoutContainer content = new VerticalLayoutContainer();
panel.add(content);
RuleColumnPlaceHolderDescriptorProperties props = GWT
.create(RuleColumnPlaceHolderDescriptorProperties.class);
//
ColumnConfig<RuleColumnPlaceHolderDescriptor, String> labelColumn = new ColumnConfig<RuleColumnPlaceHolderDescriptor, String>(
props.label(), 220, "Label");
ColumnConfig<RuleColumnPlaceHolderDescriptor, ColumnDataType> columnDataTypeColumn = new ColumnConfig<RuleColumnPlaceHolderDescriptor, ColumnDataType>(
props.columnDataType(), 130, "Data Type");
ArrayList<ColumnConfig<RuleColumnPlaceHolderDescriptor, ?>> l = new ArrayList<ColumnConfig<RuleColumnPlaceHolderDescriptor, ?>>();
l.add(labelColumn);
l.add(columnDataTypeColumn);
ColumnModel<RuleColumnPlaceHolderDescriptor> columns = new ColumnModel<RuleColumnPlaceHolderDescriptor>(
l);
final ListStore<RuleColumnPlaceHolderDescriptor> store = new ListStore<RuleColumnPlaceHolderDescriptor>(
props.id());
grid = new Grid<RuleColumnPlaceHolderDescriptor>(store, columns);
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
grid.setBorders(false);
grid.setLoadMask(true);
grid.setColumnReordering(false);
grid.getView().setAutoExpandColumn(labelColumn);
// EDITING //
/*
SimpleComboBox<ColumnDataType> comboColumnDataType = new SimpleComboBox<ColumnDataType>(
new StringLabelProvider<Light>());
comboColumnDataType.setClearValueOnParseError(false);
comboColumnDataType.setPropertyEditor(new PropertyEditor<ColumnDataType>() {
@Override
public Light parse(CharSequence text) throws ParseException {
return Light.parseString(text.toString());
}
@Override
public String render(ColumnDataType object) {
return object == null ? Light.SUNNY.toString() : object
.toString();
}
});
comboColumnDataType.setTriggerAction(TriggerAction.ALL);
comboColumnDataType.add(Light.SUNNY);
comboColumnDataType.add(Light.MOSTLYSUNNY);
comboColumnDataType.add(Light.SUNORSHADE);
comboColumnDataType.add(Light.MOSTLYSHADY);
comboColumnDataType.add(Light.SHADE);
Converter<String, Light> lightConverter = new Converter<String, Light>() {
@Override
public String convertFieldValue(Light object) {
return object == null ? "" : object.toString();
}
@Override
public Light convertModelValue(String object) {
try {
return Light.parseString(object);
} catch (ParseException e) {
return null;
}
}
};
DateTimeFormat dateFormat = DateTimeFormat
.getFormat(PredefinedFormat.DATE_SHORT);
DateField dateField = new DateField(new DateTimePropertyEditor(
dateFormat));
dateField.setClearValueOnParseError(false);
final GridEditing<Plant> editing = createGridEditing(grid);
editing.addEditor(labelColumn, new TextField());
editing.addEditor(columnDataTypeColumn, lightConverter, comboColumnDataType);
// EDITING //
customizeGrid(grid);
TextButton addButton = new TextButton("Add Plant");
addButton.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
Plant plant = new Plant();
plant.setName("New Plant 1");
plant.setLight("Mostly Shady");
plant.setPrice(0);
plant.setAvailable(new DateWrapper().clearTime().asDate());
plant.setIndoor(false);
editing.cancelEditing();
store.add(0, plant);
int row = store.indexOf(plant);
editing.startEditing(new GridCell(row, 0));
}
});
ToolBar toolBar = new ToolBar();
toolBar.add(addButton);
VerticalLayoutContainer verticalLayoutContainer = new VerticalLayoutContainer();
verticalLayoutContainer.setBorders(true);
verticalLayoutContainer.add(toolBar, new VerticalLayoutData(1, -1));
verticalLayoutContainer.add(grid, new VerticalLayoutData(1, 1));
panel = new FramedPanel();
panel.setHeadingText("Editable Grid Example");
panel.setPixelSize(600, 400);
panel.addStyleName("margin-10");
panel.setWidget(verticalLayoutContainer);
panel.setButtonAlign(BoxLayoutPack.CENTER);
panel.addButton(new TextButton("Reset", new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
store.rejectChanges();
}
}));
panel.addButton(new TextButton("Save", new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
store.commitChanges();
}
}));*/
return panel;
}
@Override
public void setup() {
Log.debug("ChartSelectionCard Setup");
Command sayNextCard = new Command() {
public void execute() {
Log.debug("ChartSelectionCard Call sayNextCard");
checkData();
}
};
Command sayPreviousCard = new Command() {
public void execute() {
try {
getWizardWindow().previousCard();
getWizardWindow().removeCard(thisCard);
Log.info("Remove ChartSelectionCard");
} catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
getWizardWindow().setNextButtonCommand(sayNextCard);
setEnableBackButton(false);
setEnableNextButton(true);
}
protected void checkData() {
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false);
HideHandler hideHandler = new HideHandler() {
public void onHide(HideEvent event) {
getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(false);
}
};
/*
if (chartTypeSelected == null) {
AlertMessageBox d = new AlertMessageBox("Attention",
"No chart selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
return;
}
switch (chartTypeSelected) {
case TopRating:
checkTopRating();
break;
default:
AlertMessageBox d = new AlertMessageBox("Attention",
"No chart selected");
d.addHideHandler(hideHandler);
d.setModal(false);
d.show();
break;
}
*/
}
/*
protected void checkTopRating() {
String tableTypeName = chartSession.getTrId().getTableTypeName();
if (tableTypeName.compareTo(TableType.DATASET.toString()) == 0) {
try {
ChartTopRatingSession chartTopRatingSession = new ChartTopRatingSession();
chartTopRatingSession.setTrId(chartSession.getTrId());
TopRatingColumnSelectionCard topRatingColumnSelectionCard = new TopRatingColumnSelectionCard(
chartSession, chartTopRatingSession);
getWizardWindow().addCard(topRatingColumnSelectionCard);
getWizardWindow().nextCard();
} catch (Exception e) {
Log.error("sayNextCard :" + e.getLocalizedMessage());
}
} else {
AlertMessageBox d = new AlertMessageBox("Attention",
"Chart not applicable, table is not a Dataset!");
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(false);
}
});
d.setModal(false);
d.show();
}
}*/
@Override
public void dispose() {
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.user.td.rulewidget.client.multicolumn;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CreateRuleOnTableWizard extends WizardWindow {
/**
*
* @param title
* @param eventBus
*/
public CreateRuleOnTableWizard(EventBus eventBus) {
super("Create Rule On Table",eventBus);
Log.debug("CreateRuleOnMultiColumnWizard");
create();
}
private void create() {
CreateRuleOnTableDefinitionCard createRuleOnTableDefinitionCard=new CreateRuleOnTableDefinitionCard();
addCard(createRuleOnTableDefinitionCard);
createRuleOnTableDefinitionCard.setup();
show();
}
}