Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-information-widget@92895 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-03-10 17:12:44 +00:00
parent 1ad1aea147
commit 5813edcb0f
2 changed files with 110 additions and 18 deletions

View File

@ -5,6 +5,7 @@ import java.util.HashMap;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
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.shared.TRId;
@ -13,12 +14,16 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FieldSet;
import com.sencha.gxt.widget.core.client.form.TextArea;
@ -33,6 +38,7 @@ public class TabularResourceProperties extends FramedPanel {
protected FieldSet trFieldSet;
protected FieldSet tableFieldSet;
protected TabResource tabResource;
protected TextField nameField;
protected TextArea descriptionField;
protected TextField agencyField;
@ -45,6 +51,7 @@ public class TabularResourceProperties extends FramedPanel {
protected TextField tableTypeNameField;
protected TableMetadataAccordionPanel tableMetadataPanel;
protected VerticalLayoutContainer layoutTable;
protected TextButton saveButton;
public TabularResourceProperties(String name, EventBus eventBus) {
super();
@ -100,11 +107,25 @@ public class TabularResourceProperties extends FramedPanel {
layoutTabularResource.add(new FieldLabel(rightField, "Rights"),
new VerticalLayoutData(1, -1));
// Save Button
saveButton = new TextButton("Save");
SelectHandler saveHandler = new SelectHandler() {
public void onSelect(SelectEvent event) {
onSave();
}
};
saveButton.addSelectHandler(saveHandler);
layoutTabularResource.add(saveButton,
new VerticalLayoutData(-1, -1,new Margins(2)));
vl.add(trFieldSet);
}
protected void updateTabularResource(TabResource tabResource) {
this.tabResource=tabResource;
Log.debug(tabResource.toString());
nameField.setValue(tabResource.getName());
descriptionField.setValue(tabResource.getDescription());
@ -141,17 +162,16 @@ public class TabularResourceProperties extends FramedPanel {
}
TRId trId = tableData.getTrId();
tableMetadataPanel= new TableMetadataAccordionPanel("TableInformation", trId, eventBus);
tableMetadataPanel = new TableMetadataAccordionPanel(
"TableInformation", trId, eventBus);
layoutTable.add(tableMetadataPanel, new VerticalLayoutData(-1, -1));
tableFieldSet.add(layoutTable);
}
public void update() {
TDGWTServiceAsync.INSTANCE
.getTabResourceInformation(new AsyncCallback<TabResource>() {
public void onSuccess(TabResource result) {
updateTabularResource(result);
Log.info("Retrived TR:" + result.getId());
@ -177,10 +197,9 @@ public class TabularResourceProperties extends FramedPanel {
});
}
protected void getLastTable(TRId trId) {
TDGWTServiceAsync.INSTANCE
.getLastTable(trId,new AsyncCallback<TableData>() {
TDGWTServiceAsync.INSTANCE.getLastTable(trId,
new AsyncCallback<TableData>() {
public void onSuccess(TableData result) {
updateTable(result);
@ -213,4 +232,55 @@ public class TabularResourceProperties extends FramedPanel {
update();
}
protected void onSave(){
/*TDGWTServiceAsync.INSTANCE.setTabResourceInfo(tabResource,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
Log.debug("Share Error: "
+ caught.getLocalizedMessage());
alert("Error sharing tabular resource",
"Error shareing tabular resource");
}
public void onSuccess(Void result) {
Log.debug("Tabular Resource Shared: "
+ shareInfo.getTabResource().getTrId()
.toString());
info("Shared",
"Tabular Resource is shared");
}
});
*/
}
private void alert(String title, String message) {
final AlertMessageBox d = new AlertMessageBox(title, message);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
}
});
d.show();
}
private void info(String title, String message) {
final InfoMessageBox d = new InfoMessageBox(title, message);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
}
});
d.show();
}
}

View File

@ -0,0 +1,22 @@
package org.gcube.portlets.user.td.informationwidget.client.util;
import com.sencha.gxt.widget.core.client.box.MessageBox;
public class InfoMessageBox extends MessageBox {
/**
* Creates a message box with an info icon and the specified title and
* message.
*
* @param title
* the message box title
* @param message
* the message displayed in the message box
*/
public InfoMessageBox(String title, String message) {
super(title, message);
setIcon(ICONS.info());
}
}