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:
Giancarlo Panichi 2014-09-04 16:33:48 +00:00
parent 4b2fe78d99
commit c7b5c3bf36
2 changed files with 53 additions and 78 deletions

View File

@ -28,8 +28,6 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
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.ClickHandler;
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.core.client.dom.ScrollSupport.ScrollMode;
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.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.ListLoadResultBean;
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.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
@ -66,9 +60,9 @@ import com.sencha.gxt.widget.core.client.form.TextArea;
import com.sencha.gxt.widget.core.client.form.TextField;
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");
protected String headingTitle;
protected HashMap<String, String> tabularResourcePropertiesMap;
protected VerticalLayoutContainer vl;
@ -108,6 +102,8 @@ public class TabularResourceProperties extends FramedPanel {
protected TextButton saveButton;
protected TextButton validationsButton;
protected ArrayList<LicenceData> licencesList;
public TabularResourceProperties(String name, EventBus eventBus) {
super();
setId(name);
@ -118,11 +114,12 @@ public class TabularResourceProperties extends FramedPanel {
vl.setScrollMode(ScrollMode.AUTO);
vl.setAdjustForScroll(true);
initInformation();
this.add(vl);
retrieveLicencesList();
}
public void addTabularResource() {
trFieldSet = new FieldSet();
trFieldSet.setHeadingText("Tabular Resource");
@ -181,47 +178,16 @@ public class TabularResourceProperties extends FramedPanel {
LicenceDataPropertiesCombo propsLicenceData = GWT
.create(LicenceDataPropertiesCombo.class);
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,
propsLicenceData.licence()) {
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loader.load();
}
});
}
};
comboLicences.setWidth(191);
propsLicenceData.licence());
comboLicences.setMinListWidth(250);
comboLicences.setEditable(false);
comboLicences.setTypeAhead(false);
comboLicences.setTriggerAction(TriggerAction.ALL);
Log.trace("Combo Licence created");
// /
@ -309,11 +275,10 @@ public class TabularResourceProperties extends FramedPanel {
new Margins(2)));
vl.add(trFieldSet);
add(vl);
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<LicenceData>> callback) {
protected void retrieveLicencesList() {
TDGWTServiceAsync.INSTANCE
.getLicences(new AsyncCallback<ArrayList<LicenceData>>() {
@ -327,14 +292,12 @@ public class TabularResourceProperties extends FramedPanel {
UtilsGXT3.alert("Error",
"Error retrieving licences.");
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<LicenceData> result) {
Log.trace("loaded " + result.size() + " ColumnData");
callback.onSuccess(new ListLoadResultBean<LicenceData>(
result));
Log.trace("loaded " + result.size() + " LicenceData");
licencesList = result;
initInformation();
}
});
@ -385,15 +348,24 @@ public class TabularResourceProperties extends FramedPanel {
if (tabResource.getLicence() != null
&& !tabResource.getLicence().isEmpty()) {
List<LicenceData> listLicence = storeCombo.getAll();
for (int i=0; i<listLicence.size(); i++) {
if (tabResource.getLicence().compareTo(listLicence.get(i).getLicence()) == 0) {
comboLicences.setValue(listLicence.get(i),true);
}
boolean licenceFound = false;
for (int i = 0; i < listLicence.size(); i++) {
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());
validField.setValue(tabResource.isValid());
@ -404,7 +376,7 @@ public class TabularResourceProperties extends FramedPanel {
finalizedField.setReadOnly(false);
finalizedField.setValue(false);
}
}
protected void updateShareInfo(ShareInfo result) {
@ -586,14 +558,16 @@ public class TabularResourceProperties extends FramedPanel {
Log.error("No valid until to field: " + vUntilTo);
e.printStackTrace();
}
}
if(comboLicences.getCurrentValue()!=null&&
comboLicences.getCurrentValue().getLicence()!=null&& !comboLicences.getCurrentValue().getLicence().isEmpty()){
tabResource.setLicence(comboLicences.getCurrentValue().getLicence());
if (comboLicences.getCurrentValue() != null
&& comboLicences.getCurrentValue().getLicence() != null
&& !comboLicences.getCurrentValue().getLicence().isEmpty()) {
tabResource
.setLicence(comboLicences.getCurrentValue().getLicence());
}
tabResource.setValid(validField.getValue());
tabResource.setFinalized(finalizedField.getValue());

View File

@ -3,24 +3,25 @@ package org.gcube.portlets.user.td.informationwidget.client.licence;
import org.gcube.portlets.user.td.gwtservice.shared.licenses.LicenceData;
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.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface LicenceDataPropertiesCombo extends
PropertyAccess<LicenceData> {
public interface LicenceDataPropertiesCombo extends PropertyAccess<LicenceData> {
@Path("id")
ModelKeyProvider<LicenceData> id();
LabelProvider<LicenceData> licence();
@Path("licence")
ValueProvider<LicenceData, String> licenceValueProvider();
}