diff --git a/src/main/java/org/gcube/portlets/user/td/informationwidget/client/TabularResourceProperties.java b/src/main/java/org/gcube/portlets/user/td/informationwidget/client/TabularResourceProperties.java index 7792c5c..bba8fd5 100644 --- a/src/main/java/org/gcube/portlets/user/td/informationwidget/client/TabularResourceProperties.java +++ b/src/main/java/org/gcube/portlets/user/td/informationwidget/client/TabularResourceProperties.java @@ -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 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() { @@ -285,7 +312,7 @@ public class TabularResourceProperties extends FramedPanel { } }); - + } private void alert(String title, String message) {