diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButton.html b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButton.html new file mode 100644 index 0000000..9b36b96 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButton.html @@ -0,0 +1,4 @@ + +
+
+
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButton.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButton.java new file mode 100644 index 0000000..04e14a8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButton.java @@ -0,0 +1,47 @@ +package org.gcube.portlets.user.td.columnwidget.client.custom; + + +import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.HasClickHandlers; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.client.Event; +import com.sencha.gxt.core.client.dom.XDOM; +import com.sencha.gxt.widget.core.client.Component; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class IconButton extends Component implements HasClickHandlers { + + private IconButtonAppearance appearance; + + public IconButton() { + this((IconButtonAppearance) GWT.create(IconButtonAppearanceDefault.class)); + } + + public IconButton(IconButtonAppearance appearance) { + this.appearance = appearance; + + SafeHtmlBuilder sb = new SafeHtmlBuilder(); + this.appearance.render(sb); + + setElement(XDOM.create(sb.toSafeHtml())); + sinkEvents(Event.ONCLICK); + } + + public HandlerRegistration addClickHandler(ClickHandler handler) { + return addDomHandler(handler, ClickEvent.getType()); + } + + + public void setIcon(ImageResource icon) { + appearance.onUpdateIcon(getElement(), icon); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonAppearance.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonAppearance.java new file mode 100644 index 0000000..5687497 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonAppearance.java @@ -0,0 +1,17 @@ +package org.gcube.portlets.user.td.columnwidget.client.custom; + +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.sencha.gxt.core.client.dom.XElement; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface IconButtonAppearance { + void render(SafeHtmlBuilder sb); + void onUpdateIcon(XElement parent, ImageResource icon); +} + diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonAppearanceDefault.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonAppearanceDefault.java new file mode 100644 index 0000000..cd7a024 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonAppearanceDefault.java @@ -0,0 +1,75 @@ +package org.gcube.portlets.user.td.columnwidget.client.custom; + + +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Element; +import com.google.gwt.resources.client.ClientBundle; +import com.google.gwt.resources.client.CssResource; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.safehtml.shared.SafeHtml; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.user.client.ui.Image; +import com.sencha.gxt.core.client.XTemplates; +import com.sencha.gxt.core.client.dom.XElement; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class IconButtonAppearanceDefault implements IconButtonAppearance { + + public interface Template extends XTemplates { + @XTemplate(source = "IconButton.html") + SafeHtml template(IconButtonStyle style); + } + + public interface IconButtonStyle extends CssResource { + @ClassName("iconButton") + public String getIconButton(); + + @ClassName("iconButtonImage") + public String getIconButtonImage(); + + @ClassName("iconButtonRef") + public String getIconButtonRef(); + + } + + private final IconButtonStyle style; + private final Template template; + + public interface IconButtonResources extends ClientBundle { + public static final IconButtonResources INSTANCE = GWT.create(IconButtonResources.class); + + @Source("IconButtonStyle.css") + IconButtonStyle style(); + } + + public IconButtonAppearanceDefault() { + this(IconButtonResources.INSTANCE); + } + + public IconButtonAppearanceDefault(IconButtonResources resources) { + this.style = resources.style(); + this.style.ensureInjected(); + + this.template = GWT.create(Template.class); + } + + + + public void onUpdateIcon(XElement parent, ImageResource icon) { + XElement element = parent.selectNode("." + style.getIconButtonImage()); + Image image=new Image(icon); + Element img=image.getElement(); + img.setClassName(style.getIconButtonRef()); + element.appendChild(img); + + } + + public void render(SafeHtmlBuilder sb) { + sb.append(template.template(style)); + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonStyle.css b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonStyle.css new file mode 100644 index 0000000..98ef72c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/custom/IconButtonStyle.css @@ -0,0 +1,17 @@ +@CHARSET "UTF-8"; + +.iconButton { + border: none; + font-size: 12px; + margin: 0px; + padding: 0px; +} + +.iconButton .iconButtonImage { + vertical-align: center; +} + +.iconButtonRef { + vertical-align: center; + cursor: pointer; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingData.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingData.java new file mode 100644 index 0000000..d655b9e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingData.java @@ -0,0 +1,63 @@ +package org.gcube.portlets.user.td.columnwidget.client.mapping; + +import java.io.Serializable; + + +import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow; + +/** + * + * @author "Giancarlo Panichi" + * email: g.panichi@isti.cnr.it + * + */ +public class ColumnMappingData implements Serializable { + + private static final long serialVersionUID = 733237646914552402L; + + protected DimensionRow sourceArg; + protected DimensionRow targetArg; + + /** + * + */ + public ColumnMappingData(){ + + } + + /** + * + * @param sourceArg + * @param targetArg + */ + public ColumnMappingData(DimensionRow sourceArg, DimensionRow targetArg){ + this.sourceArg=sourceArg; + this.targetArg=targetArg; + } + + public DimensionRow getSourceArg() { + return sourceArg; + } + + public void setSourceArg(DimensionRow sourceArg) { + this.sourceArg = sourceArg; + } + + public DimensionRow getTargetArg() { + return targetArg; + } + + public void setTargetArg(DimensionRow targetArg) { + this.targetArg = targetArg; + } + + @Override + public String toString() { + return "ColumnMappingData [sourceArg=" + sourceArg + ", targetArg=" + + targetArg + "]"; + } + + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingDialog.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingDialog.java new file mode 100644 index 0000000..80e0e4c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingDialog.java @@ -0,0 +1,102 @@ +package org.gcube.portlets.user.td.columnwidget.client.mapping; + +import java.util.ArrayList; + +import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.web.bindery.event.shared.EventBus; +import com.sencha.gxt.widget.core.client.Window; +import com.sencha.gxt.widget.core.client.event.SelectEvent; +import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; + +public class ColumnMappingDialog extends Window { + protected String WIDTH = "650px"; + protected String HEIGHT = "530px"; + + protected TRId trId; + protected ColumnData selectedColumn; + protected TabResource dimensionTR; + protected ColumnData columnReference; + protected EventBus eventBus; + + protected ArrayList listeners; + + public ColumnMappingDialog(TRId trId, ColumnData selectedColumn, + TabResource dimensionTR, ColumnData columnReference, + EventBus eventBus) { + this.trId = trId; + this.selectedColumn = selectedColumn; + this.dimensionTR = dimensionTR; + this.columnReference= columnReference; + this.eventBus = eventBus; + Log.debug("ColumnMappingDialog: [trId:" + trId + + ", selectedColumn:" + selectedColumn + ", dimensionTR:" + + dimensionTR + ", columnReference:" + columnReference + + ", eventBus:" + eventBus + + "]"); + listeners=new ArrayList(); + + initWindow(); + ColumnMappingPanel columnMappingPanel = new ColumnMappingPanel(this, + trId, selectedColumn, + dimensionTR, columnReference, + eventBus); + add(columnMappingPanel); + } + + protected void initWindow() { + setWidth(WIDTH); + setHeight(HEIGHT); + setBodyBorder(false); + setResizable(false); + setHeadingText("Column Mapping"); + setClosable(true); + setModal(true); + forceLayoutOnResize = true; + getHeader().setIcon(ResourceBundle.INSTANCE.replaceBatch()); + + } + + /** + * {@inheritDoc} + */ + @Override + protected void initTools() { + super.initTools(); + + closeBtn.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + close(); + } + }); + + } + + protected void close() { + hide(); + + } + + /** + * + * @param listener + */ + public void addColumnMappingListener(ColumnMappingListener listener) { + listeners.add(listener); + } + + /** + * + * @param listener + */ + public void removeColumnMappingListener(ColumnMappingListener listener) { + listeners.remove(listener); + } + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingList.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingList.java new file mode 100644 index 0000000..5d29982 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingList.java @@ -0,0 +1,52 @@ +package org.gcube.portlets.user.td.columnwidget.client.mapping; + +import java.io.Serializable; +import java.util.ArrayList; + +import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow; + +/** + * + * @author "Giancarlo Panichi" + * email: g.panichi@isti.cnr.it + * + */ +public class ColumnMappingList implements Serializable{ + + private static final long serialVersionUID = 733237646914552402L; + + protected ArrayList mapping; + + /** + * + */ + public ColumnMappingList(){ + + } + + /** + * + * @param mapping + */ + public ColumnMappingList(ArrayList mapping){ + this.mapping=mapping; + + } + + public ArrayList getMapping() { + return mapping; + } + + public void setMapping(ArrayList mapping) { + this.mapping = mapping; + } + + @Override + public String toString() { + return "ColumnMappingList [mapping=" + mapping + "]"; + } + + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingListener.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingListener.java new file mode 100644 index 0000000..2761f10 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingListener.java @@ -0,0 +1,32 @@ +package org.gcube.portlets.user.td.columnwidget.client.mapping; + + + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface ColumnMappingListener { + + /** + * Called when created column mapping without errors + */ + public void selectedColumnMappingListener(ColumnMappingList columnMappingData); + + /** + * Called when the column mapping operation is aborted by the user. + */ + public void abortedColumnMapping(); + + /** + * Called when the something in the wizard is failed. + * + * @param reason + * @param detail + */ + public void failedColumnMapping(String reason, String detail); + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingPanel.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingPanel.java new file mode 100644 index 0000000..5316b46 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/mapping/ColumnMappingPanel.java @@ -0,0 +1,164 @@ +package org.gcube.portlets.user.td.columnwidget.client.mapping; + +import org.gcube.portlets.user.td.columnwidget.client.custom.IconButton; +import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener; +import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle; +import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; +import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; +import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; + +import com.allen_sauer.gwt.log.client.Log; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.web.bindery.event.shared.EventBus; +import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode; +import com.sencha.gxt.widget.core.client.FramedPanel; +import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer; +import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; +import com.sencha.gxt.widget.core.client.form.TextField; + +/** + * + * @author "Giancarlo Panichi" + * email: g.panichi@isti.cnr.it + * + */ +public class ColumnMappingPanel extends FramedPanel implements + DimensionRowSelectionListener { + protected String WIDTH = "560px"; + protected String HEIGHT = "520px"; + + protected ColumnMappingPanel thisPanel; + + protected ColumnMappingDialog parent; + protected TRId trId; + protected ColumnData selectedColumn; + protected TabResource dimensionTR; + protected ColumnData columnReference; + protected EventBus eventBus; + + protected VerticalLayoutContainer vert; + protected String itemIdSourceValueArg; + protected String itemIdTargetValueArg; + protected String itemIdBtnAdd; + protected String itemIdBtnDel; + + protected ColumnMappingList columnMappingList; + + /** + * + * + * @param parent + * @param trId + * @param selectedColumn + * @param dimensionTR + * @param columnReference + * @param eventBus + */ + public ColumnMappingPanel(ColumnMappingDialog parent, TRId trId, + ColumnData selectedColumn, TabResource dimensionTR, + ColumnData columnReference, EventBus eventBus) { + this.parent = parent; + this.trId = trId; + this.selectedColumn = selectedColumn; + this.dimensionTR = dimensionTR; + this.columnReference = columnReference; + this.eventBus = eventBus; + thisPanel=this; + Log.debug("ColumnMappingPanel: [parent:" + parent + " , trId:" + trId + + ", selectedColumn:" + selectedColumn + ", dimensionTR:" + + dimensionTR + ", columnReference:" + columnReference + + ", eventBus:" + eventBus + + "]"); + columnMappingList=new ColumnMappingList(); + + + } + + + protected void setup(){ + itemIdSourceValueArg = "SourceArg" + selectedColumn.getName(); + itemIdTargetValueArg = "TargetArg" + selectedColumn.getName(); + + + vert = new VerticalLayoutContainer(); + vert.setScrollMode(ScrollMode.AUTO); + vert.setAdjustForScroll(true); + + final HBoxLayoutContainer horiz = new HBoxLayoutContainer(); + + + + final TextField sourceValueArg = new TextField(); + sourceValueArg.setItemId(itemIdSourceValueArg); + + + final TextField targetValueArg = new TextField(); + targetValueArg.setItemId(itemIdTargetValueArg); + + final IconButton btnAdd = new IconButton(); + btnAdd.setItemId(itemIdBtnAdd); + btnAdd.setIcon(ResourceBundle.INSTANCE.add()); + btnAdd.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + Log.debug("Clicked btnAdd"); + addColumnMappingData(); + thisPanel.forceLayout(); + vert.forceLayout(); + + } + }); + btnAdd.setVisible(false); + + final IconButton btnDel = new IconButton(); + btnDel.setItemId(itemIdBtnDel); + btnDel.setIcon(ResourceBundle.INSTANCE.delete()); + btnDel.addClickHandler(new ClickHandler() { + + public void onClick(ClickEvent event) { + Log.debug("Clicked btnDel"); + vert.remove(horiz); + if (vert.getWidgetCount() == 0) { + setup(); + } else { + + } + thisPanel.forceLayout(); + vert.forceLayout(); + + } + }); + btnDel.setVisible(false); + + + add(vert); + } + + protected void addColumnMappingData(){ + + } + + + @Override + public void selectedDimensionRow(DimensionRow dimensionRow) { + // TODO Auto-generated method stub + + } + + @Override + public void abortedDimensionRowSelection() { + // TODO Auto-generated method stub + + } + + @Override + public void failedDimensionRowSelection(String reason, String detail) { + // TODO Auto-generated method stub + + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/ResourceBundle.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/ResourceBundle.java index ce42270..bbca134 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/ResourceBundle.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/ResourceBundle.java @@ -89,7 +89,17 @@ public interface ResourceBundle extends ClientBundle { @Source("codelist-link-break_32.png") ImageResource codelistLinkBreak32(); + @Source("add.png") + ImageResource add(); + @Source("add_32.png") + ImageResource add32(); + + @Source("delete.png") + ImageResource delete(); + + @Source("delete_32.png") + ImageResource delete32(); } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/add.png b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/add.png new file mode 100644 index 0000000..6b1ab47 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/add.png differ diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/add_32.png b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/add_32.png new file mode 100644 index 0000000..6981821 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/add_32.png differ diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/delete.png b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/delete.png new file mode 100644 index 0000000..b639afd Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/delete.png differ diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/delete_32.png b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/delete_32.png new file mode 100644 index 0000000..020b555 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/resources/delete_32.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/add.png b/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/add.png new file mode 100644 index 0000000..6b1ab47 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/add.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/add_32.png b/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/add_32.png new file mode 100644 index 0000000..6981821 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/add_32.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/delete.png b/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/delete.png new file mode 100644 index 0000000..b639afd Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/delete.png differ diff --git a/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/delete_32.png b/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/delete_32.png new file mode 100644 index 0000000..020b555 Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/columnwidget/client/resources/delete_32.png differ