Added Validations button

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-information-widget@94656 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-09 17:05:19 +00:00
parent c0cdda94d2
commit 7981ddcbc3
1 changed files with 62 additions and 35 deletions

View File

@ -8,6 +8,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.informationwidget.client.util.InfoMessageBox;
import org.gcube.portlets.user.td.metadatawidget.client.TRMetadataAccordionPanel;
import org.gcube.portlets.user.td.metadatawidget.client.TableMetadataAccordionPanel;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.WidgetRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.WidgetRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
@ -34,7 +36,8 @@ public class TabularResourceProperties extends FramedPanel {
protected HashMap<String, String> tabularResourcePropertiesMap;
protected VerticalLayoutContainer vl;
protected EventBus eventBus;
protected TRId trId;
protected FieldSet trFieldSet;
protected FieldSet tableFieldSet;
@ -45,7 +48,7 @@ public class TabularResourceProperties extends FramedPanel {
protected TextField dateField;
protected TextArea rightField;
protected TextField typeField;
protected TRMetadataAccordionPanel trMetadataPanel;
protected VerticalLayoutContainer layoutTabularResource;
@ -53,13 +56,15 @@ public class TabularResourceProperties extends FramedPanel {
protected TableMetadataAccordionPanel tableMetadataPanel;
protected VerticalLayoutContainer layoutTable;
protected TextButton saveButton;
protected TextButton validationsButton;
public TabularResourceProperties(String name, EventBus eventBus) {
super();
setId(name);
this.eventBus = eventBus;
forceLayoutOnResize = true;
vl = new VerticalLayoutContainer();
vl.setScrollMode(ScrollMode.AUTO);
vl.setAdjustForScroll(true);
@ -79,19 +84,19 @@ public class TabularResourceProperties extends FramedPanel {
trFieldSet.add(layoutTabularResource);
nameField = new TextField();
//nameField.setReadOnly(true);
// nameField.setReadOnly(true);
nameField.setValue("");
layoutTabularResource.add(new FieldLabel(nameField, "Name"),
new VerticalLayoutData(1, -1));
descriptionField = new TextArea();
//descriptionField.setReadOnly(true);
// descriptionField.setReadOnly(true);
descriptionField.setValue("");
layoutTabularResource.add(new FieldLabel(descriptionField,
"Description"), new VerticalLayoutData(1, -1));
agencyField = new TextField();
//agencyField.setReadOnly(true);
// agencyField.setReadOnly(true);
agencyField.setValue("");
layoutTabularResource.add(new FieldLabel(agencyField, "Agency"),
new VerticalLayoutData(1, -1));
@ -101,7 +106,7 @@ public class TabularResourceProperties extends FramedPanel {
dateField.setValue("");
layoutTabularResource.add(new FieldLabel(dateField, "Date"),
new VerticalLayoutData(1, -1));
typeField = new TextField();
typeField.setReadOnly(true);
typeField.setValue("");
@ -109,12 +114,11 @@ public class TabularResourceProperties extends FramedPanel {
new VerticalLayoutData(1, -1));
rightField = new TextArea();
//rightField.setReadOnly(true);
// rightField.setReadOnly(true);
rightField.setValue("");
layoutTabularResource.add(new FieldLabel(rightField, "Rights"),
new VerticalLayoutData(1, -1));
// Save Button
saveButton = new TextButton("Save");
SelectHandler saveHandler = new SelectHandler() {
@ -125,15 +129,15 @@ public class TabularResourceProperties extends FramedPanel {
}
};
saveButton.addSelectHandler(saveHandler);
layoutTabularResource.add(saveButton,
new VerticalLayoutData(-1, -1,new Margins(2)));
layoutTabularResource.add(saveButton, new VerticalLayoutData(-1, -1,
new Margins(2)));
vl.add(trFieldSet);
}
protected void updateTabularResource(TabResource tabResource) {
this.tabResource=tabResource;
this.tabResource = tabResource;
Log.debug(tabResource.toString());
nameField.setValue(tabResource.getName());
descriptionField.setValue(tabResource.getDescription());
@ -141,7 +145,7 @@ public class TabularResourceProperties extends FramedPanel {
dateField.setValue(tabResource.getDate());
typeField.setValue(tabResource.getTrId().getTabularResourceType());
rightField.setValue(tabResource.getRight());
}
public void addTable() {
@ -160,16 +164,41 @@ public class TabularResourceProperties extends FramedPanel {
layoutTable.add(new FieldLabel(tableTypeNameField, "Type"),
new VerticalLayoutData(1, -1));
// Validation Button
validationsButton = new TextButton("Validations");
SelectHandler validationsHandler = new SelectHandler() {
public void onSelect(SelectEvent event) {
openValidations();
}
};
validationsButton.addSelectHandler(validationsHandler);
layoutTable.add(validationsButton, new VerticalLayoutData(-1, -1,
new Margins(2)));
vl.add(tableFieldSet);
}
protected void openValidations() {
Log.debug("Request Validations Tab");
if (trId != null) {
WidgetRequestEvent e = new WidgetRequestEvent(
WidgetRequestType.VALIDATIONSTABLEPANEL);
e.setTrId(trId);
eventBus.fireEvent(e);
} else {
Log.error("TRId is null");
}
}
protected void updateTable(TableData tableData) {
tableTypeNameField.setValue(tableData.getTypeName());
if (tableMetadataPanel != null) {
tableFieldSet.remove(layoutTable);
layoutTable.remove(tableMetadataPanel);
}
TRId trId = tableData.getTrId();
trId = tableData.getTrId();
tableMetadataPanel = new TableMetadataAccordionPanel(
"TableInformation", trId, eventBus);
@ -240,31 +269,29 @@ public class TabularResourceProperties extends FramedPanel {
addTable();
update();
}
protected void onSave(){
if(nameField.getValue()==null || nameField.getValue().isEmpty() ){
alert("Attention","Fill name field");
protected void onSave() {
if (nameField.getValue() == null || nameField.getValue().isEmpty()) {
alert("Attention", "Fill name field");
return;
}
if(descriptionField.getValue()==null || descriptionField.getValue().isEmpty() ){
alert("Attention","Fill description field");
}
if (descriptionField.getValue() == null
|| descriptionField.getValue().isEmpty()) {
alert("Attention", "Fill description field");
return;
}
if(rightField.getValue()==null || rightField.getValue().isEmpty() ){
alert("Attention","Fill rights field");
}
if (rightField.getValue() == null || rightField.getValue().isEmpty()) {
alert("Attention", "Fill rights field");
return;
}
}
tabResource.setName(nameField.getValue());
tabResource.setDescription(descriptionField.getValue());
tabResource.setAgency(agencyField.getValue());
tabResource.setRight(rightField.getValue());
TDGWTServiceAsync.INSTANCE.setTabResourceInformation(tabResource,
new AsyncCallback<Void>() {
@ -285,7 +312,7 @@ public class TabularResourceProperties extends FramedPanel {
}
});
}
private void alert(String title, String message) {