Added Expand and Collapse on Validations

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@95666 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-14 10:56:52 +00:00 committed by Giancarlo Panichi
parent bf4c4b5807
commit 924d659745
16 changed files with 137 additions and 78 deletions

View File

@ -4,7 +4,6 @@ package org.gcube.portlets.user.td.tablewidget.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.resources.client.ClientBundle.Source;
/**
* Resource Bundle
@ -89,10 +88,31 @@ public interface ResourceBundle extends ClientBundle {
@Source("basket_32.png")
ImageResource basket32();
@Source("pencil_32.png")
ImageResource rowEdit32();
@Source("pencil.png")
ImageResource rowEdit();
@Source("pencil_32.png")
ImageResource rowEdit32();
@Source("collapseall.png")
ImageResource collapseAll();
@Source("collapseall_12.png")
ImageResource collapseAll12();
@Source("collapseall_32.png")
ImageResource collapseAll32();
@Source("expandall.png")
ImageResource expandAll();
@Source("expandall_12.png")
ImageResource expandAll12();
@Source("expandall_32.png")
ImageResource expandAll32();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

View File

@ -12,23 +12,33 @@ 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.ValidationDto;
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.google.gwt.cell.client.AbstractCell;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
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.button.TextButton;
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.event.CollapseItemEvent;
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.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
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.toolbar.ToolBar;
import com.sencha.gxt.widget.core.client.treegrid.TreeGrid;
/**
@ -42,7 +52,7 @@ public class ValidationsTasksPanel extends FramedPanel {
protected String HEIGHT = "520px";
protected TRId trId;
protected VerticalLayoutContainer vl;
protected VerticalLayoutContainer con;
protected EventBus eventBus;
protected ValidationsTasksMetadata validationsTasksMetadata;
@ -76,7 +86,7 @@ public class ValidationsTasksPanel extends FramedPanel {
}
protected void draw() {
if(tree!=null){
if (tree != null) {
remove(tree);
}
init();
@ -96,12 +106,10 @@ public class ValidationsTasksPanel extends FramedPanel {
}
protected void create() {
/*
* vl = new VerticalLayoutContainer();
* vl.setScrollMode(ScrollMode.AUTO); vl.setAdjustForScroll(true);
* this.add(vl);
*/
con = new VerticalLayoutContainer();
con.setScrollMode(ScrollMode.AUTO);
//con.setAdjustForScroll(true);
store = new TreeStore<BaseDto>(new KeyProvider());
FolderDto root = gen.getRoot();
@ -113,50 +121,42 @@ public class ValidationsTasksPanel extends FramedPanel {
}
ColumnConfig<BaseDto, String> cc1 = new ColumnConfig<BaseDto, String>(
new ToStringValueProvider<BaseDto>("task"),168, "Task");
new ToStringValueProvider<BaseDto>("task"), 168, "Task");
cc1.setHeader("Task");
cc1.setCell(new AbstractCell<String>() {
@Override
public void render(Context context,
String value, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<span title='"+value+"'>"
+ value + "</span>");
}}
);
public void render(Context context, String value, SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<span title='"
+ SafeHtmlUtils.htmlEscape(value) + "'>" + value
+ "</span>");
}
});
/*
* ColumnConfig<BaseDto, String> cc2 = new ColumnConfig<BaseDto,
* String>( new ValueProvider<BaseDto, String>() {
*
* @Override public String getValue(BaseDto object) { return object
* instanceof ValidationDto ? ((ValidationDto) object) .getDescription()
* : ""; }
*
* @Override public void setValue(BaseDto object, String value) { if
* (object instanceof ValidationDto) { ((ValidationDto)
* object).setDescription(value); } }
*
* @Override public String getPath() { return "description"; } });
* cc2.setHeader("Description");
*/
/*ColumnConfig<BaseDto, String> cc2 = new ColumnConfig<BaseDto, String>(
new ValueProvider<BaseDto, String>() {
@Override
public String getValue(BaseDto object) {
return object instanceof ValidationDto ? ((ValidationDto) object)
.getDescription() : "";
}
@Override
public void setValue(BaseDto object, String value) {
if (object instanceof ValidationDto) {
((ValidationDto) object).setDescription(value);
}
}
@Override
public String getPath() {
return "description";
}
});
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() : null;
return object instanceof ValidationDto ? ((ValidationDto) object).getValid()
: null;
}
@Override
@ -199,63 +199,102 @@ 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);
tree = new TreeGrid<BaseDto>(store, cm, cc1);
//tree.getStyle().setLeafIcon(ResourceBundle.INSTANCE.tableValidation());
//tree.getView().setStripeRows(true);
//tree.getView().setColumnLines(true);
// tree.getStyle().setLeafIcon(ResourceBundle.INSTANCE.tableValidation());
// tree.getView().setStripeRows(true);
// tree.getView().setColumnLines(true);
tree.getView().setAutoFill(true);
tree.setBorders(false);
tree.setLoadMask(true);
tree.setColumnResize(true);
tree.getView().setAutoExpandColumn(cc1);
IconProvider<BaseDto> iconProvider=new IconProvider<BaseDto>() {
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();
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();
if (type.compareTo("task") == 0) {
img = ResourceBundle.INSTANCE.basket();
} else {
}
}
} else {
img=ResourceBundle.INSTANCE.tableValidation();
img = ResourceBundle.INSTANCE.tableValidation();
}
return img;
}
};
tree.setIconProvider(iconProvider);
tree.addExpandHandler(new ExpandItemHandler<BaseDto>() {
@Override
public void onExpand(ExpandItemEvent<BaseDto> event) {
forceLayout();
}
});
/*
* ToolBar buttonBar = new ToolBar();
*
* buttonBar.add(new TextButton("Expand All", new SelectHandler() {
*
* @Override public void onSelect(SelectEvent event) { tree.expandAll();
* } })); buttonBar.add(new TextButton("Collapse All", new
* SelectHandler() {
*
* @Override public void onSelect(SelectEvent event) {
* tree.collapseAll(); } }));
*
* v.add(buttonBar, new VerticalLayoutData(1, -1));
*/
add(tree, new MarginData(0));
onResize();
tree.addCollapseHandler(new CollapseItemHandler<BaseDto>() {
@Override
public void onCollapse(CollapseItemEvent<BaseDto> event) {
forceLayout();
}
});
ToolBar toolBar = new ToolBar();
TextButton btnExpandAll = new TextButton();
// btnReload.setText("Expand All");
btnExpandAll.setIcon(ResourceBundle.INSTANCE.collapseAll12());
btnExpandAll.setToolTip("Expand All");
btnExpandAll.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
tree.expandAll();
forceLayout();
}
});
toolBar.add(btnExpandAll);
TextButton btnCollapseAll = new TextButton();
// btnReload.setText("Expand All");
btnCollapseAll.setIcon(ResourceBundle.INSTANCE.expandAll12());
btnCollapseAll.setToolTip("Collapse All");
btnCollapseAll.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
tree.collapseAll();
forceLayout();
}
});
toolBar.add(btnCollapseAll);
con.add(toolBar, new VerticalLayoutData(1, -1));
con.add(tree, new VerticalLayoutData(1, -1));
add(con,new MarginData(0));

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B