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