Start ColumnMapping dev
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@97811 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -0,0 +1,4 @@
|
|||
<!-- file: ./IconButton.html -->
|
||||
<div class="{style.iconButton}">
|
||||
<div class="{style.iconButtonImage}"></div>
|
||||
</div>
|
|
@ -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"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface IconButtonAppearance {
|
||||
void render(SafeHtmlBuilder sb);
|
||||
void onUpdateIcon(XElement parent, ImageResource icon);
|
||||
}
|
||||
|
|
@ -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"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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));
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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 + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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<ColumnMappingListener> 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<ColumnMappingListener>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ColumnMappingList implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 733237646914552402L;
|
||||
|
||||
protected ArrayList<DimensionRow> mapping;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ColumnMappingList(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mapping
|
||||
*/
|
||||
public ColumnMappingList(ArrayList<DimensionRow> mapping){
|
||||
this.mapping=mapping;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<DimensionRow> getMapping() {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
public void setMapping(ArrayList<DimensionRow> mapping) {
|
||||
this.mapping = mapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ColumnMappingList [mapping=" + mapping + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.mapping;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
}
|
|
@ -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: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 660 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 614 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 660 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 614 B |
After Width: | Height: | Size: 1.3 KiB |