Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-information-widget@99151 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e148d1ac2c
commit
8ac3028fd0
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.user.td.informationwidget.client;
|
package org.gcube.portlets.user.td.informationwidget.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
|
@ -27,6 +28,7 @@ import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
|
@ -41,12 +43,15 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
|
||||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
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.event.SelectEvent.SelectHandler;
|
||||||
import com.sencha.gxt.widget.core.client.form.CheckBox;
|
import com.sencha.gxt.widget.core.client.form.CheckBox;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.DateField;
|
||||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
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.FieldSet;
|
||||||
import com.sencha.gxt.widget.core.client.form.TextArea;
|
import com.sencha.gxt.widget.core.client.form.TextArea;
|
||||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||||
|
|
||||||
public class TabularResourceProperties extends FramedPanel {
|
public class TabularResourceProperties extends FramedPanel {
|
||||||
|
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
protected String headingTitle;
|
protected String headingTitle;
|
||||||
protected HashMap<String, String> tabularResourcePropertiesMap;
|
protected HashMap<String, String> tabularResourcePropertiesMap;
|
||||||
protected VerticalLayoutContainer vl;
|
protected VerticalLayoutContainer vl;
|
||||||
|
@ -62,15 +67,14 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
protected TextField agencyField;
|
protected TextField agencyField;
|
||||||
protected TextField dateField;
|
protected TextField dateField;
|
||||||
protected TextArea rightField;
|
protected TextArea rightField;
|
||||||
protected TextField validFromField;
|
protected DateField validFromField;
|
||||||
protected TextField validUntilToField;
|
protected DateField validUntilToField;
|
||||||
protected TextField ownerField;
|
protected TextField ownerField;
|
||||||
protected CheckBox validField;
|
protected CheckBox validField;
|
||||||
protected CheckBox finalizedField;
|
protected CheckBox finalizedField;
|
||||||
|
|
||||||
|
|
||||||
protected TextField typeField;
|
protected TextField typeField;
|
||||||
|
|
||||||
protected IconButton btnShare;
|
protected IconButton btnShare;
|
||||||
protected FieldLabel shareLabel;
|
protected FieldLabel shareLabel;
|
||||||
|
|
||||||
|
@ -142,26 +146,21 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
rightField.setValue("");
|
rightField.setValue("");
|
||||||
layoutTabularResource.add(new FieldLabel(rightField, "Rights"),
|
layoutTabularResource.add(new FieldLabel(rightField, "Rights"),
|
||||||
new VerticalLayoutData(1, -1));
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
validFromField = new TextField();
|
validFromField = new DateField();
|
||||||
validFromField.setReadOnly(true);
|
|
||||||
validFromField.setValue("");
|
|
||||||
layoutTabularResource.add(new FieldLabel(validFromField, "Valid From"),
|
layoutTabularResource.add(new FieldLabel(validFromField, "Valid From"),
|
||||||
new VerticalLayoutData(1, -1));
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
validUntilToField = new TextField();
|
validUntilToField = new DateField();
|
||||||
validUntilToField.setReadOnly(true);
|
layoutTabularResource.add(new FieldLabel(validUntilToField,
|
||||||
validUntilToField.setValue("");
|
"Valid Until To"), new VerticalLayoutData(1, -1));
|
||||||
layoutTabularResource.add(new FieldLabel(validUntilToField, "Valid Until To"),
|
|
||||||
new VerticalLayoutData(1, -1));
|
|
||||||
|
|
||||||
|
|
||||||
ownerField = new TextField();
|
ownerField = new TextField();
|
||||||
ownerField.setReadOnly(true);
|
ownerField.setReadOnly(true);
|
||||||
ownerField.setValue("");
|
ownerField.setValue("");
|
||||||
layoutTabularResource.add(new FieldLabel(ownerField, "Owner"),
|
layoutTabularResource.add(new FieldLabel(ownerField, "Owner"),
|
||||||
new VerticalLayoutData(1, -1));
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
btnShare = new IconButton();
|
btnShare = new IconButton();
|
||||||
btnShare.setIcon(ResourceBundle.INSTANCE.share());
|
btnShare.setIcon(ResourceBundle.INSTANCE.share());
|
||||||
btnShare.addClickHandler(new ClickHandler() {
|
btnShare.addClickHandler(new ClickHandler() {
|
||||||
|
@ -174,17 +173,14 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
});
|
});
|
||||||
shareLabel = new FieldLabel(btnShare, "Share");
|
shareLabel = new FieldLabel(btnShare, "Share");
|
||||||
shareLabel.setVisible(false);
|
shareLabel.setVisible(false);
|
||||||
|
|
||||||
layoutTabularResource.add(shareLabel,
|
layoutTabularResource.add(shareLabel, new VerticalLayoutData(1, -1));
|
||||||
new VerticalLayoutData(1, -1));
|
|
||||||
|
|
||||||
|
|
||||||
validField = new CheckBox();
|
validField = new CheckBox();
|
||||||
validField.setValue(false);
|
validField.setValue(false);
|
||||||
validField.setReadOnly(true);
|
validField.setReadOnly(true);
|
||||||
layoutTabularResource.add(new FieldLabel(validField, "Valid"),
|
layoutTabularResource.add(new FieldLabel(validField, "Valid"),
|
||||||
new VerticalLayoutData(1, -1));
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
|
||||||
finalizedField = new CheckBox();
|
finalizedField = new CheckBox();
|
||||||
// finalizedField.setBoxLabel("");
|
// finalizedField.setBoxLabel("");
|
||||||
|
@ -194,8 +190,9 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
@Override
|
@Override
|
||||||
public void onValueChange(ValueChangeEvent<Boolean> event) {
|
public void onValueChange(ValueChangeEvent<Boolean> event) {
|
||||||
if (event.getValue()) {
|
if (event.getValue()) {
|
||||||
UtilsGXT3.info("Warning",
|
UtilsGXT3
|
||||||
"A TabularResource set to final can't be modified anymore!");
|
.info("Warning",
|
||||||
|
"A TabularResource set to final can't be modified anymore!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -251,8 +248,37 @@ 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());
|
||||||
validFromField.setValue(tabResource.getValidFrom());
|
|
||||||
validUntilToField.setValue(tabResource.getValidUntilTo());
|
if (tabResource.getValidFrom() == null
|
||||||
|
|| tabResource.getValidFrom().isEmpty()) {
|
||||||
|
Log.debug("ValidFrom null or empty");
|
||||||
|
} else {
|
||||||
|
Date vFrom;
|
||||||
|
try {
|
||||||
|
vFrom = sdf.parse(tabResource.getValidFrom());
|
||||||
|
validFromField.setValue(vFrom);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.error("Error Parsing Valid From for Tabular Resource: "
|
||||||
|
+ tabResource);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tabResource.getValidUntilTo() == null
|
||||||
|
|| tabResource.getValidUntilTo().isEmpty()) {
|
||||||
|
Log.debug("ValidUntilTo null or empty");
|
||||||
|
} else {
|
||||||
|
Date vUntilTo;
|
||||||
|
try {
|
||||||
|
vUntilTo = sdf.parse(tabResource.getValidFrom());
|
||||||
|
validUntilToField.setValue(vUntilTo);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.error("Error Parsing Valid Until To for Tabular Resource: "
|
||||||
|
+ tabResource);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ownerField.setValue(tabResource.getOwner().getLogin());
|
ownerField.setValue(tabResource.getOwner().getLogin());
|
||||||
validField.setValue(tabResource.isValid());
|
validField.setValue(tabResource.isValid());
|
||||||
if (tabResource.isFinalized()) {
|
if (tabResource.isFinalized()) {
|
||||||
|
@ -262,19 +288,18 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
finalizedField.setReadOnly(false);
|
finalizedField.setReadOnly(false);
|
||||||
finalizedField.setValue(false);
|
finalizedField.setValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateShareInfo(ShareInfo result){
|
protected void updateShareInfo(ShareInfo result) {
|
||||||
ArrayList<Contacts> contacts=result.getContacts();
|
ArrayList<Contacts> contacts = result.getContacts();
|
||||||
if(contacts!=null&& contacts.size()>0){
|
if (contacts != null && contacts.size() > 0) {
|
||||||
shareLabel.setVisible(true);
|
shareLabel.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
shareLabel.setVisible(false);
|
shareLabel.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTable() {
|
public void addTable() {
|
||||||
tableFieldSet = new FieldSet();
|
tableFieldSet = new FieldSet();
|
||||||
tableFieldSet.setHeadingText("Table");
|
tableFieldSet.setHeadingText("Table");
|
||||||
|
@ -318,10 +343,10 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
"TableInformation", trId, eventBus);
|
"TableInformation", trId, eventBus);
|
||||||
layoutTable.add(tableMetadataPanel, new VerticalLayoutData(-1, -1));
|
layoutTable.add(tableMetadataPanel, new VerticalLayoutData(-1, -1));
|
||||||
tableFieldSet.add(layoutTable);
|
tableFieldSet.add(layoutTable);
|
||||||
|
|
||||||
forceLayout();
|
forceLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
TDGWTServiceAsync.INSTANCE
|
TDGWTServiceAsync.INSTANCE
|
||||||
.getTabResourceInformation(new AsyncCallback<TabResource>() {
|
.getTabResourceInformation(new AsyncCallback<TabResource>() {
|
||||||
|
@ -338,8 +363,9 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
SessionExpiredType.EXPIREDONSERVER));
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
} else {
|
} else {
|
||||||
Log.error("Error retrienving properties: "
|
Log.error("Error retrienving properties: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
UtilsGXT3.alert("Error",
|
UtilsGXT3.alert(
|
||||||
|
"Error",
|
||||||
"Error retrienving properties: "
|
"Error retrienving properties: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -348,14 +374,14 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getShareInformation(TRId trId){
|
protected void getShareInformation(TRId trId) {
|
||||||
TDGWTServiceAsync.INSTANCE.getShareInfo(trId,
|
TDGWTServiceAsync.INSTANCE.getShareInfo(trId,
|
||||||
new AsyncCallback<ShareInfo>() {
|
new AsyncCallback<ShareInfo>() {
|
||||||
|
|
||||||
public void onSuccess(ShareInfo result) {
|
public void onSuccess(ShareInfo result) {
|
||||||
Log.debug("Retrived share info:" + result);
|
Log.debug("Retrived share info:" + result);
|
||||||
updateShareInfo(result);
|
updateShareInfo(result);
|
||||||
//getLastTable(tabResource.getTrId());
|
// getLastTable(tabResource.getTrId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +400,7 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getLastTable(TRId trId) {
|
protected void getLastTable(TRId trId) {
|
||||||
TDGWTServiceAsync.INSTANCE.getLastTable(trId,
|
TDGWTServiceAsync.INSTANCE.getLastTable(trId,
|
||||||
new AsyncCallback<TableData>() {
|
new AsyncCallback<TableData>() {
|
||||||
|
@ -382,7 +408,7 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
public void onSuccess(TableData result) {
|
public void onSuccess(TableData result) {
|
||||||
Log.debug("Retrived LastTable:" + result);
|
Log.debug("Retrived LastTable:" + result);
|
||||||
updateTable(result);
|
updateTable(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -392,7 +418,8 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
} else {
|
} else {
|
||||||
Log.error("Error retrienving Last Table: "
|
Log.error("Error retrienving Last Table: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
UtilsGXT3.alert("Error",
|
UtilsGXT3.alert(
|
||||||
|
"Error",
|
||||||
"Error retrienving Last Table: "
|
"Error retrienving Last Table: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -403,23 +430,48 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
|
|
||||||
public void initInformation() {
|
public void initInformation() {
|
||||||
addTabularResource();
|
addTabularResource();
|
||||||
//addTable();
|
// addTable();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onSave() {
|
protected void onSave() {
|
||||||
if (nameField.getValue() == null || nameField.getValue().isEmpty()) {
|
if (nameField.getValue() == null || nameField.getValue().isEmpty()) {
|
||||||
Log.debug("Attention Fill name field");
|
Log.debug("Attention Fill name field");
|
||||||
UtilsGXT3.info("Attention", "Fill name field");
|
UtilsGXT3.info("Attention", "Fill name 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());
|
||||||
tabResource.setValidFrom(validFromField.getValue());
|
|
||||||
tabResource.setValidUntilTo(validUntilToField.getValue());
|
Date vFrom = validFromField.getValue();
|
||||||
|
if (vFrom == null) {
|
||||||
|
Log.debug("No valid from set");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
String vFr = sdf.format(vFrom);
|
||||||
|
tabResource.setValidFrom(vFr);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.error("No valid from field: " + vFrom);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Date vUntilTo = validUntilToField.getValue();
|
||||||
|
if (vUntilTo == null) {
|
||||||
|
Log.debug("No valid until to set");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
String vUTo = sdf.format(vUntilTo);
|
||||||
|
tabResource.setValidUntilTo(vUTo);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.error("No valid until to field: " + vUntilTo);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tabResource.setValid(validField.getValue());
|
tabResource.setValid(validField.getValue());
|
||||||
tabResource.setFinalized(finalizedField.getValue());
|
tabResource.setFinalized(finalizedField.getValue());
|
||||||
|
|
||||||
|
@ -434,7 +486,8 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
Log.error("Error Setting Tabular Resoruce Properties: "
|
Log.error("Error Setting Tabular Resoruce Properties: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
UtilsGXT3.alert("Error",
|
UtilsGXT3.alert("Error",
|
||||||
"Error setting tabular resource properties: "+caught.getLocalizedMessage());
|
"Error setting tabular resource properties: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +496,7 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
+ tabResource);
|
+ tabResource);
|
||||||
UtilsGXT3.info("Proprerties",
|
UtilsGXT3.info("Proprerties",
|
||||||
"Tabular Resource properties are set");
|
"Tabular Resource properties are set");
|
||||||
if(finalizedField.getValue()){
|
if (finalizedField.getValue()) {
|
||||||
finalizedField.setReadOnly(true);
|
finalizedField.setReadOnly(true);
|
||||||
finalizedField.setValue(true);
|
finalizedField.setValue(true);
|
||||||
}
|
}
|
||||||
|
@ -454,7 +507,4 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue