Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@94701 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
030e8964ca
commit
169b7745b6
|
@ -33,7 +33,6 @@ import com.sencha.gxt.widget.core.client.FramedPanel;
|
|||
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.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
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.grid.Grid;
|
||||
|
@ -57,7 +56,7 @@ public class ValidationsTablePanel extends FramedPanel {
|
|||
protected ComboBox<Validations> comboValidations;
|
||||
protected ListStore<Validations> storeValidations;
|
||||
protected ListLoader<ListLoadConfig, ListLoadResult<Validations>> loader;
|
||||
protected Grid<Validations> grid;
|
||||
protected Grid<Validations> grid;
|
||||
|
||||
public ValidationsTablePanel(TRId trId, EventBus eventBus) {
|
||||
super();
|
||||
|
@ -75,44 +74,42 @@ public class ValidationsTablePanel extends FramedPanel {
|
|||
setBodyBorder(false);
|
||||
}
|
||||
|
||||
protected void create(){
|
||||
ValidationsProperties props = GWT
|
||||
.create(ValidationsProperties.class);
|
||||
|
||||
protected void create() {
|
||||
ValidationsProperties props = GWT.create(ValidationsProperties.class);
|
||||
|
||||
ColumnConfig<Validations, String> descriptionCol = new ColumnConfig<Validations, String>(
|
||||
props.description(), 168, "Description");
|
||||
ColumnConfig<Validations, Boolean> validCol = new ColumnConfig<Validations, Boolean>(
|
||||
props.valid(), 32, "Valid");
|
||||
validCol.setCell(new AbstractCell<Boolean>(){
|
||||
validCol.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) {
|
||||
sb.appendHtmlConstant("<img src='"
|
||||
+ ResourceBundle.INSTANCE.ok().getSafeUri()
|
||||
.asString() + "' alt='true'>");
|
||||
|
||||
} else {
|
||||
sb.appendHtmlConstant("<img src='"+ResourceBundle.INSTANCE.exit().getSafeUri().asString()+"' alt='true'>");
|
||||
|
||||
sb.appendHtmlConstant("<img src='"
|
||||
+ ResourceBundle.INSTANCE.exit().getSafeUri()
|
||||
.asString() + "' alt='true'>");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
List<ColumnConfig<Validations, ?>> l = new ArrayList<ColumnConfig<Validations, ?>>();
|
||||
l.add(descriptionCol);
|
||||
l.add(validCol);
|
||||
|
||||
|
||||
ColumnModel<Validations> cm = new ColumnModel<Validations>(l);
|
||||
|
||||
storeValidations = new ListStore<Validations>(props.id());
|
||||
|
||||
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<Validations>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<Validations>>() {
|
||||
|
||||
public void load(ListLoadConfig loadConfig,
|
||||
|
@ -120,9 +117,8 @@ public class ValidationsTablePanel extends FramedPanel {
|
|||
loadData(loadConfig, callback);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
loader = new ListLoader<ListLoadConfig, ListLoadResult<Validations>>(
|
||||
proxy);
|
||||
|
||||
|
@ -130,10 +126,7 @@ public class ValidationsTablePanel extends FramedPanel {
|
|||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, Validations, ListLoadResult<Validations>>(
|
||||
storeValidations) {
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
grid = new Grid<Validations>(storeValidations, cm) {
|
||||
@Override
|
||||
protected void onAfterFirstAttach() {
|
||||
|
@ -157,56 +150,55 @@ public class ValidationsTablePanel extends FramedPanel {
|
|||
grid.setColumnReordering(true);
|
||||
grid.setColumnResize(true);
|
||||
grid.getView().setAutoExpandColumn(descriptionCol);
|
||||
|
||||
//FieldLabel validationsLabel = new FieldLabel(null, "Validations");
|
||||
//validationsLabel.getElement().applyStyles("font-weight:bold");
|
||||
|
||||
grid.getView().setEmptyText("No validations");
|
||||
|
||||
// FieldLabel validationsLabel = new FieldLabel(null, "Validations");
|
||||
// validationsLabel.getElement().applyStyles("font-weight:bold");
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
v.setScrollMode(ScrollMode.AUTO);
|
||||
//v.add(validationsLabel, new VerticalLayoutData(-1, -1, new Margins(2,1,5,1)));
|
||||
// v.add(validationsLabel, new VerticalLayoutData(-1, -1, new
|
||||
// Margins(2,1,5,1)));
|
||||
v.add(grid, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
add(v);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<Validations>> callback) {
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.getTableValidationsMetadata(trId,
|
||||
TDGWTServiceAsync.INSTANCE.getTableValidationsMetadata(trId,
|
||||
new AsyncCallback<TabValidationsMetadata>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("load validations metadata failure:"
|
||||
Log.error("Load validations metadata failure: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving validations metadata",
|
||||
UtilsGXT3.alert(
|
||||
"Error retrieving validations metadata",
|
||||
"Error retrieving validations metadata");
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onSuccess(TabValidationsMetadata result) {
|
||||
Log.trace("loaded " + result.getId());
|
||||
if(result.getValidations()!=null){
|
||||
callback.onSuccess(new ListLoadResultBean<Validations>(
|
||||
result.getValidations()));
|
||||
} else {
|
||||
Log.error("load validations metadata failure: null");
|
||||
UtilsGXT3.alert("Error retrieving validations metadata",
|
||||
"Error retrieving validations metadata");
|
||||
callback.onFailure(new Exception("Error retrieving validations metadata"));
|
||||
}
|
||||
|
||||
Log.debug("loaded " + result.getId());
|
||||
if (result.getValidations() != null) {
|
||||
Log.debug("Validations Retrieved: "
|
||||
+ result.getValidations().size());
|
||||
callback.onSuccess(new ListLoadResultBean<Validations>(
|
||||
result.getValidations()));
|
||||
} else {
|
||||
Log.debug("No validations");
|
||||
ArrayList<Validations> empty=new ArrayList<Validations>();
|
||||
callback.onSuccess(new ListLoadResultBean<Validations>(
|
||||
empty));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void update(TRId trId) {
|
||||
this.trId = trId;
|
||||
loader.load();
|
||||
|
|
Loading…
Reference in New Issue