Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@95458 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -75,5 +75,17 @@ public interface ResourceBundle extends ClientBundle {
|
|||
|
||||
@Source("table-validation_32.png")
|
||||
ImageResource tableValidation32();
|
||||
|
||||
@Source("cog.png")
|
||||
ImageResource cog();
|
||||
|
||||
@Source("cog_32.png")
|
||||
ImageResource cog32();
|
||||
|
||||
@Source("basket.png")
|
||||
ImageResource basket();
|
||||
|
||||
@Source("basket_32.png")
|
||||
ImageResource basket32();
|
||||
|
||||
}
|
After Width: | Height: | Size: 591 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 844 B |
After Width: | Height: | Size: 1.7 KiB |
|
@ -15,17 +15,20 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
|||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.cell.client.AbstractCell;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.core.client.ToStringValueProvider;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||
import com.sencha.gxt.data.shared.IconProvider;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.TreeStore;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
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.VerticalLayoutData;
|
||||
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.treegrid.TreeGrid;
|
||||
|
@ -44,20 +47,20 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
protected VerticalLayoutContainer vl;
|
||||
protected EventBus eventBus;
|
||||
protected ValidationsTasksMetadata validationsTasksMetadata;
|
||||
|
||||
|
||||
protected TreeDataGenerator gen;
|
||||
protected TreeStore<BaseDto> store;
|
||||
|
||||
class KeyProvider implements ModelKeyProvider<BaseDto> {
|
||||
@Override
|
||||
public String getKey(BaseDto item) {
|
||||
return (item instanceof FolderDto ? "f-" : "m-")
|
||||
+ item.getId().toString();
|
||||
return (item instanceof FolderDto ? "f-" : "v-") + item.getId();
|
||||
}
|
||||
}
|
||||
|
||||
public ValidationsTasksPanel(EventBus eventBus) {
|
||||
super();
|
||||
Log.debug("ValidationsTasksPanel");
|
||||
this.eventBus = eventBus;
|
||||
forceLayoutOnResize = true;
|
||||
retrieveCurrentTR();
|
||||
|
@ -66,6 +69,7 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
|
||||
public ValidationsTasksPanel(TRId trId, EventBus eventBus) {
|
||||
super();
|
||||
Log.debug("ValidationsTasksPanel: " + trId);
|
||||
this.trId = trId;
|
||||
this.eventBus = eventBus;
|
||||
forceLayoutOnResize = true;
|
||||
|
@ -84,21 +88,22 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
setBodyBorder(false);
|
||||
}
|
||||
|
||||
protected void createTreeData(){
|
||||
gen=new TreeDataGenerator(validationsTasksMetadata);
|
||||
protected void createTreeData() {
|
||||
gen = new TreeDataGenerator(validationsTasksMetadata);
|
||||
create();
|
||||
}
|
||||
|
||||
|
||||
protected void create() {
|
||||
vl = new VerticalLayoutContainer();
|
||||
vl.setScrollMode(ScrollMode.AUTO);
|
||||
vl.setAdjustForScroll(true);
|
||||
this.add(vl);
|
||||
/*
|
||||
* vl = new VerticalLayoutContainer();
|
||||
* vl.setScrollMode(ScrollMode.AUTO); vl.setAdjustForScroll(true);
|
||||
* this.add(vl);
|
||||
*/
|
||||
|
||||
store = new TreeStore<BaseDto>(new KeyProvider());
|
||||
|
||||
FolderDto root = gen.getRoot();
|
||||
for (BaseDto base : root.getChildren()) {
|
||||
for (BaseDto base : root.getChildrens()) {
|
||||
store.add(base);
|
||||
if (base instanceof FolderDto) {
|
||||
processFolder(store, (FolderDto) base);
|
||||
|
@ -108,8 +113,19 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
ColumnConfig<BaseDto, String> cc1 = new ColumnConfig<BaseDto, String>(
|
||||
new ToStringValueProvider<BaseDto>("task"));
|
||||
cc1.setHeader("Task");
|
||||
cc1.setCell(new AbstractCell<String>() {
|
||||
|
||||
ColumnConfig<BaseDto, String> cc2 = new ColumnConfig<BaseDto, String>(
|
||||
@Override
|
||||
public void render(Context context,
|
||||
String value, SafeHtmlBuilder sb) {
|
||||
sb.appendHtmlConstant("<span title='"+value+"'>"
|
||||
+ value + "</span>");
|
||||
|
||||
}}
|
||||
);
|
||||
|
||||
|
||||
/*ColumnConfig<BaseDto, String> cc2 = new ColumnConfig<BaseDto, String>(
|
||||
new ValueProvider<BaseDto, String>() {
|
||||
|
||||
@Override
|
||||
|
@ -131,14 +147,14 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
}
|
||||
});
|
||||
cc2.setHeader("Description");
|
||||
|
||||
*/
|
||||
ColumnConfig<BaseDto, Boolean> cc3 = new ColumnConfig<BaseDto, Boolean>(
|
||||
new ValueProvider<BaseDto, Boolean>() {
|
||||
|
||||
@Override
|
||||
public Boolean getValue(BaseDto object) {
|
||||
return object instanceof ValidationDto ? ((ValidationDto) object)
|
||||
.getValid() : false;
|
||||
.getValid() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,22 +170,27 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
}
|
||||
});
|
||||
cc3.setHeader("Valid");
|
||||
cc3.setWidth(48);
|
||||
cc3.setCell(new AbstractCell<Boolean>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, Boolean value,
|
||||
SafeHtmlBuilder sb) {
|
||||
|
||||
if (value) {
|
||||
sb.appendHtmlConstant("<img src='"
|
||||
+ ResourceBundle.INSTANCE.ok().getSafeUri()
|
||||
.asString() + "' alt='true'>");
|
||||
|
||||
if (value == null) {
|
||||
sb.appendHtmlConstant("");
|
||||
} else {
|
||||
sb.appendHtmlConstant("<img src='"
|
||||
+ ResourceBundle.INSTANCE.exit().getSafeUri()
|
||||
.asString() + "' alt='true'>");
|
||||
if (value) {
|
||||
sb.appendHtmlConstant("<img src='"
|
||||
+ ResourceBundle.INSTANCE.ok().getSafeUri()
|
||||
.asString() + "' alt='true'>");
|
||||
|
||||
} else {
|
||||
sb.appendHtmlConstant("<img src='"
|
||||
+ ResourceBundle.INSTANCE.exit().getSafeUri()
|
||||
.asString() + "' alt='true'>");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,13 +198,41 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
|
||||
List<ColumnConfig<BaseDto, ?>> l = new ArrayList<ColumnConfig<BaseDto, ?>>();
|
||||
l.add(cc1);
|
||||
l.add(cc2);
|
||||
//l.add(cc2);
|
||||
l.add(cc3);
|
||||
ColumnModel<BaseDto> cm = new ColumnModel<BaseDto>(l);
|
||||
|
||||
final TreeGrid<BaseDto> tree = new TreeGrid<BaseDto>(store, cm, cc1);
|
||||
tree.getStyle().setLeafIcon(ResourceBundle.INSTANCE.tableValidation());
|
||||
//tree.getStyle().setLeafIcon(ResourceBundle.INSTANCE.tableValidation());
|
||||
//tree.getStyle().setNodeCloseIcon(ResourceBundle.INSTANCE.cog());
|
||||
//tree.getStyle().setNodeOpenIcon(ResourceBundle.INSTANCE.cog());
|
||||
tree.getView().setAutoExpandColumn(cc1);
|
||||
|
||||
IconProvider<BaseDto> iconProvider=new IconProvider<BaseDto>() {
|
||||
|
||||
@Override
|
||||
public ImageResource getIcon(BaseDto model) {
|
||||
ImageResource img=null;
|
||||
if(model instanceof FolderDto){
|
||||
String type=((FolderDto) model).getType();
|
||||
if (type.compareTo("job")==0){
|
||||
img=ResourceBundle.INSTANCE.cog();
|
||||
} else {
|
||||
if (type.compareTo("task")==0){
|
||||
img=ResourceBundle.INSTANCE.basket();
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
img=ResourceBundle.INSTANCE.tableValidation();
|
||||
}
|
||||
return img;
|
||||
}
|
||||
};
|
||||
tree.setIconProvider(iconProvider);
|
||||
|
||||
|
||||
/*
|
||||
* ToolBar buttonBar = new ToolBar();
|
||||
*
|
||||
|
@ -198,8 +247,16 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
*
|
||||
* v.add(buttonBar, new VerticalLayoutData(1, -1));
|
||||
*/
|
||||
vl.add(tree, new VerticalLayoutData(1, 1));
|
||||
add(tree, new MarginData(0));
|
||||
onResize();
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
public void execute() {
|
||||
tree.expandAll();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void retrieveValidations() {
|
||||
|
@ -217,7 +274,7 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
}
|
||||
|
||||
public void onSuccess(ValidationsTasksMetadata result) {
|
||||
Log.debug("loaded " + result.getId());
|
||||
Log.debug("Loaded " + result.getId());
|
||||
validationsTasksMetadata = result;
|
||||
createTreeData();
|
||||
|
||||
|
@ -258,7 +315,7 @@ public class ValidationsTasksPanel extends FramedPanel {
|
|||
}
|
||||
|
||||
private void processFolder(TreeStore<BaseDto> store, FolderDto folder) {
|
||||
for (BaseDto child : folder.getChildren()) {
|
||||
for (BaseDto child : folder.getChildrens()) {
|
||||
store.add(folder, child);
|
||||
if (child instanceof FolderDto) {
|
||||
processFolder(store, (FolderDto) child);
|
||||
|
|
|
@ -29,4 +29,11 @@ public class BaseDto implements Serializable {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BaseDto [id=" + id + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,19 +14,37 @@ public class FolderDto extends BaseDto {
|
|||
private static final long serialVersionUID = 4644048540524701598L;
|
||||
protected String description;
|
||||
protected ArrayList<BaseDto> childrens;
|
||||
|
||||
protected String type;
|
||||
|
||||
public FolderDto(){
|
||||
|
||||
}
|
||||
|
||||
public FolderDto(String id,String description, ArrayList<BaseDto> childrens){
|
||||
public FolderDto(String type,String id,String description, ArrayList<BaseDto> childrens){
|
||||
super(id);
|
||||
this.type=type;
|
||||
this.description=description;
|
||||
this.childrens=childrens;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ArrayList<BaseDto> getChildrens() {
|
||||
return childrens;
|
||||
}
|
||||
|
||||
public void setChildrens(ArrayList<BaseDto> childrens) {
|
||||
this.childrens = childrens;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -35,18 +53,10 @@ public class FolderDto extends BaseDto {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public ArrayList<BaseDto> getChildren() {
|
||||
return childrens;
|
||||
}
|
||||
|
||||
public void setChildren(ArrayList<BaseDto> children) {
|
||||
this.childrens = children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FolderDto [id="+id+", description=" + description + ", childrens="
|
||||
+ childrens + "]";
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.TaskS;
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.Validations;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
|
||||
public class TreeDataGenerator {
|
||||
|
@ -16,31 +17,51 @@ public class TreeDataGenerator {
|
|||
protected FolderDto root;
|
||||
|
||||
public TreeDataGenerator(ValidationsTasksMetadata validationsTasksMetadata) {
|
||||
Log.debug("TreeDataGenerator");
|
||||
ArrayList<BaseDto> childrens = new ArrayList<BaseDto>();
|
||||
if (validationsTasksMetadata.getTasks().size() > 0) {
|
||||
ArrayList<BaseDto> childrens = new ArrayList<BaseDto>();
|
||||
for (TaskS task : validationsTasksMetadata.getTasks()) {
|
||||
ArrayList<BaseDto> jobs = new ArrayList<BaseDto>();
|
||||
for (JobS job : task.getJobs()) {
|
||||
ArrayList<BaseDto> validations = new ArrayList<BaseDto>();
|
||||
for (Validations v : job.getValidations()) {
|
||||
ValidationDto validationDto = new ValidationDto(
|
||||
ValidationDto validationDto = new ValidationDto(task.getId()+"-"+job.getId()+"-"+v.getId(),
|
||||
v.getDescription(), v.isValid());
|
||||
validations.add(validationDto);
|
||||
}
|
||||
FolderDto foldJob = new FolderDto(job.getId(),
|
||||
FolderDto foldJob = new FolderDto("job",task.getId()+"-"+job.getId(),
|
||||
job.getDescription(), validations);
|
||||
jobs.add(foldJob);
|
||||
}
|
||||
FolderDto foldTask = new FolderDto(task.getId(),
|
||||
FolderDto foldTask = new FolderDto("task",task.getId(),
|
||||
sdf.format(task.getStartTime()), jobs);
|
||||
childrens.add(foldTask);
|
||||
}
|
||||
root = new FolderDto("0", "root", childrens);
|
||||
root = new FolderDto("root","-1", "root", childrens);
|
||||
Log.debug("Generated root");
|
||||
printRecorsive(root);
|
||||
|
||||
} else {
|
||||
root = new FolderDto("root","-1", "root", childrens);
|
||||
Log.debug("Generated root without childrens");
|
||||
}
|
||||
}
|
||||
|
||||
public FolderDto getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
protected void printRecorsive(FolderDto root){
|
||||
for(BaseDto base:root.getChildrens()){
|
||||
Log.debug("+++");
|
||||
Log.debug("Children:"+base.toString());
|
||||
if(base instanceof FolderDto){
|
||||
printRecorsive((FolderDto) base);
|
||||
}
|
||||
Log.debug("---");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ public class ValidationDto extends BaseDto {
|
|||
|
||||
}
|
||||
|
||||
public ValidationDto(String description, Boolean valid){
|
||||
public ValidationDto(String id,String description, Boolean valid){
|
||||
super(id);
|
||||
this.description=description;
|
||||
this.valid=valid;
|
||||
}
|
||||
|
@ -40,8 +41,7 @@ public class ValidationDto extends BaseDto {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValidationDto [description=" + description + ", valid=" + valid
|
||||
+ "]";
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
|
|
After Width: | Height: | Size: 591 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 844 B |
After Width: | Height: | Size: 1.7 KiB |