Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-information-widget@99514 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4b2fe78d99
commit
c7b5c3bf36
|
@ -28,8 +28,6 @@ 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;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.core.client.Scheduler;
|
|
||||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
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;
|
||||||
|
@ -41,14 +39,10 @@ import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
|
||||||
import com.sencha.gxt.data.shared.ListStore;
|
import com.sencha.gxt.data.shared.ListStore;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
|
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoadConfigBean;
|
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
|
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoader;
|
import com.sencha.gxt.data.shared.loader.ListLoader;
|
||||||
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
|
||||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||||
|
@ -66,7 +60,7 @@ 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 static final String LISTVIEWWIDTH="250px";
|
// private static final String LISTVIEWWIDTH="250px";
|
||||||
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
protected String headingTitle;
|
protected String headingTitle;
|
||||||
|
@ -108,6 +102,8 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
protected TextButton saveButton;
|
protected TextButton saveButton;
|
||||||
protected TextButton validationsButton;
|
protected TextButton validationsButton;
|
||||||
|
|
||||||
|
protected ArrayList<LicenceData> licencesList;
|
||||||
|
|
||||||
public TabularResourceProperties(String name, EventBus eventBus) {
|
public TabularResourceProperties(String name, EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
setId(name);
|
setId(name);
|
||||||
|
@ -118,11 +114,12 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
vl.setScrollMode(ScrollMode.AUTO);
|
vl.setScrollMode(ScrollMode.AUTO);
|
||||||
vl.setAdjustForScroll(true);
|
vl.setAdjustForScroll(true);
|
||||||
|
|
||||||
initInformation();
|
retrieveLicencesList();
|
||||||
this.add(vl);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void addTabularResource() {
|
public void addTabularResource() {
|
||||||
trFieldSet = new FieldSet();
|
trFieldSet = new FieldSet();
|
||||||
trFieldSet.setHeadingText("Tabular Resource");
|
trFieldSet.setHeadingText("Tabular Resource");
|
||||||
|
@ -181,43 +178,12 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
LicenceDataPropertiesCombo propsLicenceData = GWT
|
LicenceDataPropertiesCombo propsLicenceData = GWT
|
||||||
.create(LicenceDataPropertiesCombo.class);
|
.create(LicenceDataPropertiesCombo.class);
|
||||||
storeCombo = new ListStore<LicenceData>(propsLicenceData.id());
|
storeCombo = new ListStore<LicenceData>(propsLicenceData.id());
|
||||||
|
storeCombo.addAll(licencesList);
|
||||||
|
|
||||||
Log.debug("StoreCombo created");
|
|
||||||
|
|
||||||
RpcProxy<ListLoadConfig, ListLoadResult<LicenceData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<LicenceData>>() {
|
|
||||||
|
|
||||||
public void load(ListLoadConfig loadConfig,
|
|
||||||
final AsyncCallback<ListLoadResult<LicenceData>> callback) {
|
|
||||||
loadData(loadConfig, callback);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
loader = new ListLoader<ListLoadConfig, ListLoadResult<LicenceData>>(
|
|
||||||
proxy) {
|
|
||||||
@Override
|
|
||||||
protected ListLoadConfig newLoadConfig() {
|
|
||||||
return (ListLoadConfig) new ListLoadConfigBean();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, LicenceData, ListLoadResult<LicenceData>>(
|
|
||||||
storeCombo));
|
|
||||||
Log.trace("LoaderCombo created");
|
|
||||||
|
|
||||||
comboLicences = new ComboBox<LicenceData>(storeCombo,
|
comboLicences = new ComboBox<LicenceData>(storeCombo,
|
||||||
propsLicenceData.licence()) {
|
propsLicenceData.licence());
|
||||||
|
comboLicences.setMinListWidth(250);
|
||||||
protected void onAfterFirstAttach() {
|
|
||||||
super.onAfterFirstAttach();
|
|
||||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
||||||
public void execute() {
|
|
||||||
loader.load();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
comboLicences.setWidth(191);
|
|
||||||
comboLicences.setEditable(false);
|
comboLicences.setEditable(false);
|
||||||
comboLicences.setTypeAhead(false);
|
comboLicences.setTypeAhead(false);
|
||||||
comboLicences.setTriggerAction(TriggerAction.ALL);
|
comboLicences.setTriggerAction(TriggerAction.ALL);
|
||||||
|
@ -309,11 +275,10 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
new Margins(2)));
|
new Margins(2)));
|
||||||
|
|
||||||
vl.add(trFieldSet);
|
vl.add(trFieldSet);
|
||||||
|
add(vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadData(ListLoadConfig loadConfig,
|
protected void retrieveLicencesList() {
|
||||||
final AsyncCallback<ListLoadResult<LicenceData>> callback) {
|
|
||||||
TDGWTServiceAsync.INSTANCE
|
TDGWTServiceAsync.INSTANCE
|
||||||
.getLicences(new AsyncCallback<ArrayList<LicenceData>>() {
|
.getLicences(new AsyncCallback<ArrayList<LicenceData>>() {
|
||||||
|
|
||||||
|
@ -327,14 +292,12 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
UtilsGXT3.alert("Error",
|
UtilsGXT3.alert("Error",
|
||||||
"Error retrieving licences.");
|
"Error retrieving licences.");
|
||||||
}
|
}
|
||||||
callback.onFailure(caught);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSuccess(ArrayList<LicenceData> result) {
|
public void onSuccess(ArrayList<LicenceData> result) {
|
||||||
Log.trace("loaded " + result.size() + " ColumnData");
|
Log.trace("loaded " + result.size() + " LicenceData");
|
||||||
callback.onSuccess(new ListLoadResultBean<LicenceData>(
|
licencesList = result;
|
||||||
result));
|
initInformation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -385,15 +348,24 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
if (tabResource.getLicence() != null
|
if (tabResource.getLicence() != null
|
||||||
&& !tabResource.getLicence().isEmpty()) {
|
&& !tabResource.getLicence().isEmpty()) {
|
||||||
List<LicenceData> listLicence = storeCombo.getAll();
|
List<LicenceData> listLicence = storeCombo.getAll();
|
||||||
for (int i=0; i<listLicence.size(); i++) {
|
boolean licenceFound = false;
|
||||||
if (tabResource.getLicence().compareTo(listLicence.get(i).getLicence()) == 0) {
|
for (int i = 0; i < listLicence.size(); i++) {
|
||||||
comboLicences.setValue(listLicence.get(i),true);
|
if (tabResource.getLicence().compareTo(
|
||||||
|
listLicence.get(i).getLicence()) == 0) {
|
||||||
|
comboLicences.setValue(listLicence.get(i));
|
||||||
|
licenceFound = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (licenceFound) {
|
||||||
|
Log.debug("Licence " + tabResource.getLicence() + " is found");
|
||||||
|
} else {
|
||||||
|
Log.debug("Licence " + tabResource.getLicence()
|
||||||
|
+ " is not found");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.debug("Licence is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ownerField.setValue(tabResource.getOwner().getLogin());
|
ownerField.setValue(tabResource.getOwner().getLogin());
|
||||||
validField.setValue(tabResource.isValid());
|
validField.setValue(tabResource.isValid());
|
||||||
|
@ -589,9 +561,11 @@ public class TabularResourceProperties extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(comboLicences.getCurrentValue()!=null&&
|
if (comboLicences.getCurrentValue() != null
|
||||||
comboLicences.getCurrentValue().getLicence()!=null&& !comboLicences.getCurrentValue().getLicence().isEmpty()){
|
&& comboLicences.getCurrentValue().getLicence() != null
|
||||||
tabResource.setLicence(comboLicences.getCurrentValue().getLicence());
|
&& !comboLicences.getCurrentValue().getLicence().isEmpty()) {
|
||||||
|
tabResource
|
||||||
|
.setLicence(comboLicences.getCurrentValue().getLicence());
|
||||||
}
|
}
|
||||||
|
|
||||||
tabResource.setValid(validField.getValue());
|
tabResource.setValid(validField.getValue());
|
||||||
|
|
|
@ -3,24 +3,25 @@ package org.gcube.portlets.user.td.informationwidget.client.licence;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
|
||||||
|
|
||||||
import com.google.gwt.editor.client.Editor.Path;
|
import com.google.gwt.editor.client.Editor.Path;
|
||||||
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
import com.sencha.gxt.data.shared.LabelProvider;
|
import com.sencha.gxt.data.shared.LabelProvider;
|
||||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
import com.sencha.gxt.data.shared.PropertyAccess;
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author "Giancarlo Panichi"
|
* @author "Giancarlo Panichi" <a
|
||||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface LicenceDataPropertiesCombo extends
|
public interface LicenceDataPropertiesCombo extends PropertyAccess<LicenceData> {
|
||||||
PropertyAccess<LicenceData> {
|
|
||||||
|
|
||||||
@Path("id")
|
@Path("id")
|
||||||
ModelKeyProvider<LicenceData> id();
|
ModelKeyProvider<LicenceData> id();
|
||||||
|
|
||||||
LabelProvider<LicenceData> licence();
|
LabelProvider<LicenceData> licence();
|
||||||
|
|
||||||
|
@Path("licence")
|
||||||
|
ValueProvider<LicenceData, String> licenceValueProvider();
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue