Updated for curation on validations
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@95875 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e1cb9638e2
commit
f584a1cee0
|
@ -0,0 +1,3 @@
|
||||||
|
.image {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
<div class="{style.image}" alt="{alt}" title="{title}">{img}</div>
|
|
@ -0,0 +1,94 @@
|
||||||
|
package org.gcube.portlets.user.td.tablewidget.client.custom;
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gwt.cell.client.ValueUpdater;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.google.gwt.dom.client.NativeEvent;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
|
import com.sencha.gxt.cell.core.client.ResizeCell;
|
||||||
|
import com.sencha.gxt.core.client.dom.XElement;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.BeforeSelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.HasSelectHandlers;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ValidationCell extends ResizeCell<Boolean> implements HasSelectHandlers {
|
||||||
|
|
||||||
|
private final ValidationCellAppearance appearance;
|
||||||
|
private ImageResource trueIcon;
|
||||||
|
private ImageResource falseIcon;
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
public ValidationCell() {
|
||||||
|
this(GWT.<ValidationCellAppearance> create(ValidationCellAppearance.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationCell(ValidationCellAppearance appearance) {
|
||||||
|
super("click");
|
||||||
|
this.appearance = appearance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrueIcon(ImageResource icon) {
|
||||||
|
this.trueIcon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFalseIcon(ImageResource icon) {
|
||||||
|
this.falseIcon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerRegistration addSelectHandler(SelectHandler handler) {
|
||||||
|
return addHandler(handler, SelectEvent.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Context context,
|
||||||
|
Boolean value, SafeHtmlBuilder sb) {
|
||||||
|
this.appearance.trueIcon = trueIcon;
|
||||||
|
this.appearance.falseIcon = falseIcon;
|
||||||
|
if(title==null){
|
||||||
|
title="";
|
||||||
|
}
|
||||||
|
|
||||||
|
this.appearance.title = title;
|
||||||
|
this.appearance.render(sb, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBrowserEvent(Context context,
|
||||||
|
Element parent, Boolean value, NativeEvent event,
|
||||||
|
ValueUpdater<Boolean> valueUpdater) {
|
||||||
|
Element target = event.getEventTarget().cast();
|
||||||
|
// ignore the parent element
|
||||||
|
if (isDisableEvents() || !parent.getFirstChildElement().isOrHasChild(target)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
XElement p = parent.cast();
|
||||||
|
|
||||||
|
String eventType = event.getType();
|
||||||
|
if ("click".equals(eventType)) {
|
||||||
|
onClick(context, p, value, event, valueUpdater);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onClick(Context context, XElement p, Boolean value, NativeEvent event, ValueUpdater<Boolean> valueUpdater) {
|
||||||
|
if (!isDisableEvents() && fireCancellableEvent(context, new BeforeSelectEvent(context))) {
|
||||||
|
fireEvent(context, new SelectEvent(context));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package org.gcube.portlets.user.td.tablewidget.client.custom;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
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.safehtml.shared.SafeHtmlUtils;
|
||||||
|
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||||
|
import com.sencha.gxt.core.client.XTemplates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ValidationCellAppearance {
|
||||||
|
|
||||||
|
public interface Style extends CssResource {
|
||||||
|
String image();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Template extends XTemplates {
|
||||||
|
@XTemplate(source = "ValidationButton.html")
|
||||||
|
SafeHtml template(Style style, SafeHtml img, String title, String alt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Resources extends ClientBundle {
|
||||||
|
@Source("ValidationButton.css")
|
||||||
|
Style style();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Style style;
|
||||||
|
private final Template template;
|
||||||
|
|
||||||
|
public ImageResource trueIcon;
|
||||||
|
public ImageResource falseIcon;
|
||||||
|
|
||||||
|
public String title;
|
||||||
|
|
||||||
|
public ValidationCellAppearance() {
|
||||||
|
this((Resources) GWT.create(Resources.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationCellAppearance(Resources resources) {
|
||||||
|
this.style = resources.style();
|
||||||
|
this.style.ensureInjected();
|
||||||
|
this.template = GWT.create(Template.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render(SafeHtmlBuilder sb, Boolean value) {
|
||||||
|
SafeHtml safeIcon = SafeHtmlUtils.fromString("");
|
||||||
|
String alt = "";
|
||||||
|
if (value != null) {
|
||||||
|
if (value) {
|
||||||
|
safeIcon = makeImage(trueIcon);
|
||||||
|
alt = "true";
|
||||||
|
} else {
|
||||||
|
safeIcon = makeImage(falseIcon);
|
||||||
|
alt = "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append(template.template(style, safeIcon, title, alt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make icons available as SafeHtml to be displayed inside the table
|
||||||
|
*
|
||||||
|
* @param resource
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static SafeHtml makeImage(ImageResource resource) {
|
||||||
|
AbstractImagePrototype proto = AbstractImagePrototype.create(resource);
|
||||||
|
String html = proto.getHTML();
|
||||||
|
return SafeHtmlUtils.fromTrustedString(html);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,16 @@
|
||||||
package org.gcube.portlets.user.td.tablewidget.client.validation;
|
package org.gcube.portlets.user.td.tablewidget.client.validation;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.task.InvocationS;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
|
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
|
||||||
|
import org.gcube.portlets.user.td.tablewidget.client.custom.ValidationCell;
|
||||||
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
|
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
|
||||||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||||
import org.gcube.portlets.user.td.tablewidget.client.validation.tree.BaseDto;
|
import org.gcube.portlets.user.td.tablewidget.client.validation.tree.BaseDto;
|
||||||
|
@ -13,11 +18,15 @@ import org.gcube.portlets.user.td.tablewidget.client.validation.tree.FolderDto;
|
||||||
import org.gcube.portlets.user.td.tablewidget.client.validation.tree.TreeDataGenerator;
|
import org.gcube.portlets.user.td.tablewidget.client.validation.tree.TreeDataGenerator;
|
||||||
import org.gcube.portlets.user.td.tablewidget.client.validation.tree.ValidationDto;
|
import org.gcube.portlets.user.td.tablewidget.client.validation.tree.ValidationDto;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.WidgetRequestEvent;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.WidgetRequestType;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.RequestProperties;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
import com.sencha.gxt.widget.core.client.event.CollapseItemEvent.CollapseItemHandler;
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.cell.client.AbstractCell;
|
import com.google.gwt.cell.client.AbstractCell;
|
||||||
|
import com.google.gwt.cell.client.Cell.Context;
|
||||||
import com.google.gwt.resources.client.ImageResource;
|
import com.google.gwt.resources.client.ImageResource;
|
||||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
||||||
|
@ -35,6 +44,7 @@ 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.container.VerticalLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.event.CollapseItemEvent;
|
import com.sencha.gxt.widget.core.client.event.CollapseItemEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.CollapseItemEvent.CollapseItemHandler;
|
||||||
import com.sencha.gxt.widget.core.client.event.ExpandItemEvent;
|
import com.sencha.gxt.widget.core.client.event.ExpandItemEvent;
|
||||||
import com.sencha.gxt.widget.core.client.event.ExpandItemEvent.ExpandItemHandler;
|
import com.sencha.gxt.widget.core.client.event.ExpandItemEvent.ExpandItemHandler;
|
||||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
@ -63,6 +73,62 @@ public class ValidationsTasksPanel extends FramedPanel {
|
||||||
protected TreeStore<BaseDto> store;
|
protected TreeStore<BaseDto> store;
|
||||||
protected TreeGrid<BaseDto> tree;
|
protected TreeGrid<BaseDto> tree;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected AbstractCell actionButton = new AbstractCell<Boolean>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Context context, Boolean value, SafeHtmlBuilder sb) {
|
||||||
|
|
||||||
|
if (value == null) {
|
||||||
|
sb.appendHtmlConstant("");
|
||||||
|
} else {
|
||||||
|
Log.debug("Context: pos=" + context.getIndex() + ", key="
|
||||||
|
+ context.getKey() + ", column=" + context.getColumn());
|
||||||
|
String key = (String) context.getKey();
|
||||||
|
BaseDto d = store.findModelWithKey(key);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List<BaseDto> list = ;
|
||||||
|
* Log.debug("List: ["+list.toString()+"]"); int i = 0; BaseDto
|
||||||
|
* d=null; for (; i < list.size(); i++) { BaseDto dt =
|
||||||
|
* list.get(i); if (dt.getId().compareTo((String)
|
||||||
|
* context.getKey()) == 0) { d=dt;
|
||||||
|
* Log.debug("Retrieved: "+d+" at pos:"+i); break; } }
|
||||||
|
*/
|
||||||
|
|
||||||
|
String title = "";
|
||||||
|
if (d != null) {
|
||||||
|
Log.debug(d.toString());
|
||||||
|
if (d instanceof ValidationDto) {
|
||||||
|
ValidationDto v = (ValidationDto) d;
|
||||||
|
Log.debug("ValidationDto: [" + v.getId() + ", "
|
||||||
|
+ v.getDescription() + ", " + v.getValid()
|
||||||
|
+ ", " + v.getInvocation() + "]");
|
||||||
|
if (v.getInvocation() != null) {
|
||||||
|
title = v.getInvocation().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
|
||||||
|
sb.appendHtmlConstant("<img src='"
|
||||||
|
+ ResourceBundle.INSTANCE.ok().getSafeUri()
|
||||||
|
.asString() + "' alt='true' title='"
|
||||||
|
+ title + "'>");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
sb.appendHtmlConstant("<img src='"
|
||||||
|
+ ResourceBundle.INSTANCE.exit().getSafeUri()
|
||||||
|
.asString() + "' alt='false' title='"
|
||||||
|
+ title + "'>");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class KeyProvider implements ModelKeyProvider<BaseDto> {
|
class KeyProvider implements ModelKeyProvider<BaseDto> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey(BaseDto item) {
|
public String getKey(BaseDto item) {
|
||||||
|
@ -175,64 +241,23 @@ public class ValidationsTasksPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
}, 38, "Valid");
|
}, 38, "Valid");
|
||||||
cc3.setHeader("Valid");
|
cc3.setHeader("Valid");
|
||||||
cc3.setCell(new AbstractCell<Boolean>() {
|
|
||||||
|
ValidationCell validationButton = new ValidationCell();
|
||||||
|
validationButton.setTrueIcon(ResourceBundle.INSTANCE.ok());
|
||||||
|
validationButton.setFalseIcon(ResourceBundle.INSTANCE.exit());
|
||||||
|
validationButton.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(Context context, Boolean value,
|
public void onSelect(SelectEvent event) {
|
||||||
SafeHtmlBuilder sb) {
|
Log.debug("Button ValidationCell Pressed");
|
||||||
|
Context context = event.getContext();
|
||||||
if (value == null) {
|
requestSolution(context);
|
||||||
sb.appendHtmlConstant("");
|
|
||||||
} else {
|
|
||||||
Log.debug("Context: pos=" + context.getIndex() + ", key="
|
|
||||||
+ context.getKey() + ", column="
|
|
||||||
+ context.getColumn());
|
|
||||||
String key = (String) context.getKey();
|
|
||||||
BaseDto d = store.findModelWithKey(key);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* List<BaseDto> list = ;
|
|
||||||
* Log.debug("List: ["+list.toString()+"]"); int i = 0;
|
|
||||||
* BaseDto d=null; for (; i < list.size(); i++) { BaseDto dt
|
|
||||||
* = list.get(i); if (dt.getId().compareTo((String)
|
|
||||||
* context.getKey()) == 0) { d=dt;
|
|
||||||
* Log.debug("Retrieved: "+d+" at pos:"+i); break; } }
|
|
||||||
*/
|
|
||||||
|
|
||||||
String title = "";
|
|
||||||
if (d != null) {
|
|
||||||
Log.debug(d.toString());
|
|
||||||
if (d instanceof ValidationDto) {
|
|
||||||
ValidationDto v = (ValidationDto) d;
|
|
||||||
Log.debug("ValidationDto: [" + v.getId() + ", "
|
|
||||||
+ v.getDescription() + ", "
|
|
||||||
+ v.getValid() + ", "
|
|
||||||
+ v.getInvocation() + "]");
|
|
||||||
if (v.getInvocation() != null) {
|
|
||||||
title = v.getInvocation().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value) {
|
|
||||||
|
|
||||||
sb.appendHtmlConstant("<img src='"
|
|
||||||
+ ResourceBundle.INSTANCE.ok().getSafeUri()
|
|
||||||
.asString() + "' alt='true' title='"
|
|
||||||
+ title + "'>");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
sb.appendHtmlConstant("<img src='"
|
|
||||||
+ ResourceBundle.INSTANCE.exit().getSafeUri()
|
|
||||||
.asString() + "' alt='false' title='"
|
|
||||||
+ title + "'>");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
cc3.setCell(validationButton);
|
||||||
|
|
||||||
List<ColumnConfig<BaseDto, ?>> l = new ArrayList<ColumnConfig<BaseDto, ?>>();
|
List<ColumnConfig<BaseDto, ?>> l = new ArrayList<ColumnConfig<BaseDto, ?>>();
|
||||||
l.add(cc1);
|
l.add(cc1);
|
||||||
// l.add(cc2);
|
// l.add(cc2);
|
||||||
|
@ -329,6 +354,47 @@ public class ValidationsTasksPanel extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
protected void requestSolution(Context context) {
|
||||||
|
String key = (String) context.getKey();
|
||||||
|
BaseDto d = store.findModelWithKey(key);
|
||||||
|
|
||||||
|
String title = "";
|
||||||
|
if (d != null) {
|
||||||
|
Log.debug(d.toString());
|
||||||
|
if (d instanceof ValidationDto) {
|
||||||
|
ValidationDto v = (ValidationDto) d;
|
||||||
|
Log.debug("ValidationDto: [" + v.getId() + ", "
|
||||||
|
+ v.getDescription() + ", " + v.getValid() + ", "
|
||||||
|
+ v.getInvocation() + "]");
|
||||||
|
if (v.getInvocation() != null) {
|
||||||
|
InvocationS invocationS = v.getInvocation();
|
||||||
|
title = invocationS.toString();
|
||||||
|
Long op = invocationS.getOperationId();
|
||||||
|
if (op.compareTo(OperationsId.ChangeToDimensionColumn
|
||||||
|
.toLong()) == 0) {
|
||||||
|
WidgetRequestEvent widgetRequestEvent = new WidgetRequestEvent(
|
||||||
|
WidgetRequestType.CURATIONBYREPLACEBATCHDIALOG);
|
||||||
|
widgetRequestEvent.setTrId(trId);
|
||||||
|
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put(Constants.REQUEST_PROPERTIES_REFCOLUMN,
|
||||||
|
invocationS.getRefColumn());
|
||||||
|
map.put(Constants.REQUEST_PROPERTIES_COLUMNID,
|
||||||
|
invocationS.getColumnId());
|
||||||
|
RequestProperties props = new RequestProperties(map);
|
||||||
|
widgetRequestEvent.setRequestProperties(props);
|
||||||
|
eventBus.fireEvent(widgetRequestEvent);
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.info("Invocation Info", title);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected void retrieveValidations() {
|
protected void retrieveValidations() {
|
||||||
|
|
||||||
TDGWTServiceAsync.INSTANCE.getValidationsTasksMetadata(trId,
|
TDGWTServiceAsync.INSTANCE.getValidationsTasksMetadata(trId,
|
||||||
|
|
Loading…
Reference in New Issue