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