From 41eb61a1eea62431c29e36bec638adffee3d485d Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 4 Apr 2014 18:26:43 +0000 Subject: [PATCH] Update Batch Replace git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@94401 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/batch/ReplaceBatchPanel.java | 88 +++++++++++++++++-- .../ShowOccurrencesTypeProperties.java | 26 ++++++ .../store/ShowOccurrencesTypeElement.java | 53 +++++++++++ .../store/ShowOccurrencesTypeStore.java | 75 ++++++++++++++++ 4 files changed, 235 insertions(+), 7 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/td/columnwidget/client/properties/ShowOccurrencesTypeProperties.java create mode 100644 src/main/java/org/gcube/portlets/user/td/columnwidget/client/store/ShowOccurrencesTypeElement.java create mode 100644 src/main/java/org/gcube/portlets/user/td/columnwidget/client/store/ShowOccurrencesTypeStore.java diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/ReplaceBatchPanel.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/ReplaceBatchPanel.java index 5e1c7ab..e0e7191 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/ReplaceBatchPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/batch/ReplaceBatchPanel.java @@ -6,7 +6,10 @@ import java.util.List; import org.gcube.portlets.user.td.columnwidget.client.custom.ActionButtonCell; import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionDialog; import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener; +import org.gcube.portlets.user.td.columnwidget.client.properties.ShowOccurrencesTypeProperties; import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle; +import org.gcube.portlets.user.td.columnwidget.client.store.ShowOccurrencesTypeElement; +import org.gcube.portlets.user.td.columnwidget.client.store.ShowOccurrencesTypeStore; import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; @@ -24,18 +27,22 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.logical.shared.SelectionEvent; +import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.safecss.shared.SafeStylesBuilder; import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; +import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction; import com.sencha.gxt.core.client.IdentityValueProvider; import com.sencha.gxt.core.client.Style.SelectionMode; import com.sencha.gxt.core.client.resources.ThemeStyles; import com.sencha.gxt.core.client.util.Format; import com.sencha.gxt.core.client.util.Margins; import com.sencha.gxt.data.client.loader.RpcProxy; +import com.sencha.gxt.data.shared.LabelProvider; import com.sencha.gxt.data.shared.ListStore; import com.sencha.gxt.data.shared.event.StoreDataChangeEvent; import com.sencha.gxt.data.shared.event.StoreDataChangeEvent.StoreDataChangeHandler; @@ -54,12 +61,16 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; +import com.sencha.gxt.widget.core.client.form.ComboBox; +import com.sencha.gxt.widget.core.client.form.FieldLabel; import com.sencha.gxt.widget.core.client.form.TextField; import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel; 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.RowNumberer; +import com.sencha.gxt.widget.core.client.info.Info; +import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; import com.sencha.gxt.widget.core.client.toolbar.ToolBar; /** @@ -87,21 +98,21 @@ public class ReplaceBatchPanel extends FramedPanel implements private TextButton btnSave; private TextButton btnClose; + private ComboBox comboShowOccurrencesType = null; + private FieldLabel comboShowOccurencesTypeLabel; protected ListLoader> loader; protected Grid grid; protected ListStore store; protected HTML info; - - - + public ReplaceBatchPanel(ReplaceBatchDialog parent, TRId trId, String columnName, EventBus eventBus) { this.parent = parent; this.trId = trId; this.columnName = columnName; this.eventBus = eventBus; - hasValidationColumns=false; + hasValidationColumns = false; Log.debug("Create BatchReplacePanel(): [" + trId.toString() + " , columnName:" + columnName + "]"); init(); @@ -117,7 +128,39 @@ public class ReplaceBatchPanel extends FramedPanel implements } protected void create() { + ToolBar toolBarHead = new ToolBar(); + toolBarHead.add(new LabelToolItem("Show: ")); + + + // Create Combo Show + ShowOccurrencesTypeProperties propsShowOccurrencesType = GWT + .create(ShowOccurrencesTypeProperties.class); + ListStore storeShowOccurrencesType = new ListStore( + propsShowOccurrencesType.id()); + storeShowOccurrencesType.addAll(ShowOccurrencesTypeStore + .getShowOccurrencesType()); + comboShowOccurrencesType = new ComboBox( + storeShowOccurrencesType, propsShowOccurrencesType.type()); + Log.trace("ComboMeasureType created"); + + addHandlersForShowOccurrencesType(propsShowOccurrencesType.type()); + + comboShowOccurrencesType.setEmptyText("Select a show type..."); + comboShowOccurrencesType.setWidth(100); + comboShowOccurrencesType.setTypeAhead(true); + comboShowOccurrencesType.setEditable(false); + comboShowOccurrencesType.setTriggerAction(TriggerAction.ALL); + comboShowOccurrencesType.setValue(ShowOccurrencesTypeStore.onlyErrorsElement); + + toolBarHead.add(comboShowOccurrencesType); + + /*comboShowOccurencesTypeLabel = new FieldLabel(comboShowOccurrencesType, + "Show"); + */ + + + // Create Grid IdentityValueProvider identity = new IdentityValueProvider(); CheckBoxSelectionModel sm = new CheckBoxSelectionModel( identity); @@ -233,7 +276,7 @@ public class ReplaceBatchPanel extends FramedPanel implements number.initPlugin(grid); // grid.getView().setAutoExpandColumn(labelCol); // grid.setHeight(360); - grid.setHeight("418px"); + grid.setHeight("388px"); grid.getView().setStripeRows(true); grid.getView().setColumnLines(true); grid.getView().setAutoFill(true); @@ -284,6 +327,8 @@ public class ReplaceBatchPanel extends FramedPanel implements flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4))); VerticalLayoutContainer v = new VerticalLayoutContainer(); + //v.add(comboShowOccurencesTypeLabel,new VerticalLayoutData(-1, -1, new Margins(0,0,2,0))); + v.add(toolBarHead,new VerticalLayoutData(1, -1, new Margins(0))); v.add(grid, new VerticalLayoutData(-1, -1, new Margins(0))); v.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0))); v.add(flowButton, new VerticalLayoutData(-1, 36, @@ -329,14 +374,14 @@ public class ReplaceBatchPanel extends FramedPanel implements Log.debug("Validation Columns: " + result.size()); ArrayList validationColumnReferences = new ArrayList(); if (result.size() > 0) { - hasValidationColumns=true; + hasValidationColumns = true; for (ColumnData columnData : result) { validationColumnReferences.add(columnData .getColumnId()); } column.setValidationColumnReferences(validationColumnReferences); } else { - hasValidationColumns=false; + hasValidationColumns = false; } create(); } @@ -344,6 +389,35 @@ public class ReplaceBatchPanel extends FramedPanel implements }); } + + protected void addHandlersForShowOccurrencesType( + final LabelProvider labelProvider) { + comboShowOccurrencesType + .addSelectionHandler(new SelectionHandler() { + public void onSelection( + SelectionEvent event) { + Info.display( + "Show Type Selected", + "You selected " + + (event.getSelectedItem() == null ? "nothing" + : labelProvider.getLabel(event + .getSelectedItem()) + + "!")); + Log.debug("ComboShowOccurrencesType selected: " + + event.getSelectedItem()); + ShowOccurrencesTypeElement showType = event + .getSelectedItem(); + updateShowType(showType.getType()); + } + + }); + } + + protected void updateShowType(String type){ + + } + + protected void loadData(ListLoadConfig loadConfig, final AsyncCallback> callback) { diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/properties/ShowOccurrencesTypeProperties.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/properties/ShowOccurrencesTypeProperties.java new file mode 100644 index 0000000..d827c02 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/properties/ShowOccurrencesTypeProperties.java @@ -0,0 +1,26 @@ +package org.gcube.portlets.user.td.columnwidget.client.properties; + +import org.gcube.portlets.user.td.columnwidget.client.store.ShowOccurrencesTypeElement; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; + +import com.google.gwt.editor.client.Editor.Path; +import com.sencha.gxt.data.shared.LabelProvider; +import com.sencha.gxt.data.shared.ModelKeyProvider; +import com.sencha.gxt.data.shared.PropertyAccess; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface ShowOccurrencesTypeProperties extends + PropertyAccess { + + @Path("id") + ModelKeyProvider id(); + + LabelProvider type(); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/store/ShowOccurrencesTypeElement.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/store/ShowOccurrencesTypeElement.java new file mode 100644 index 0000000..bb35cbc --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/store/ShowOccurrencesTypeElement.java @@ -0,0 +1,53 @@ +package org.gcube.portlets.user.td.columnwidget.client.store; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class ShowOccurrencesTypeElement { + + protected int id; // For insert in table only + protected String type; + + + public ShowOccurrencesTypeElement(int id,String type){ + this.id=id; + this.type=type; + } + + + public int getId() { + return id; + } + + + public void setId(int id) { + this.id = id; + } + + + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + @Override + public String toString() { + return "ShowOccurrencesTypeElement [id=" + id + ", type=" + type + "]"; + } + + + + + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/store/ShowOccurrencesTypeStore.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/store/ShowOccurrencesTypeStore.java new file mode 100644 index 0000000..c959a6a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/store/ShowOccurrencesTypeStore.java @@ -0,0 +1,75 @@ +package org.gcube.portlets.user.td.columnwidget.client.store; + +import java.io.Serializable; +import java.util.ArrayList; + + + + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class ShowOccurrencesTypeStore implements Serializable { + + private static final long serialVersionUID = -1908324094430432681L; + private final static String ONLYERRORS="Only Errors"; + private final static String ALL="All"; + + protected static ArrayList store; + + public static ShowOccurrencesTypeElement onlyErrorsElement=new ShowOccurrencesTypeElement(1,ONLYERRORS); + public static ShowOccurrencesTypeElement allElement=new ShowOccurrencesTypeElement(2,ALL); + + + public static ArrayList getShowOccurrencesType(){ + store=new ArrayList(); + store.add(onlyErrorsElement); + store.add(allElement); + return store; + } + + public static int selectedShowOccurrencesTypePosition(String selected){ + int position=0; + if(selected.compareTo(ONLYERRORS)==0){ + position=1; + } else { + if(selected.compareTo(ALL)==0){ + position=2; + } else { + } + } + return position; + } + + + public static String selectedShowOccurrencesType(String selected){ + if(selected.compareTo(ONLYERRORS)==0){ + return ONLYERRORS; + } else { + if(selected.compareTo(ALL)==0){ + return ALL; + } else { + return null; + } + } + } + + public static ShowOccurrencesTypeElement selectedShowOccurrencesTypeElement(String selected){ + if(selected.compareTo(ONLYERRORS)==0){ + return onlyErrorsElement; + } else { + if(selected.compareTo(ALL)==0){ + return allElement; + } else { + return null; + } + } + } + + + + +}