Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@90131 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-01-15 11:35:40 +00:00
parent 9156ce2ade
commit 56d68d49c3
3 changed files with 144 additions and 16 deletions

32
.gwt/.gwt-log Normal file
View File

@ -0,0 +1,32 @@
Public resources found in...
Translatable source found in...
Found 0 cached/archived units. Used 0 / 2719 units from cache.
Compiling...
40% complete (ETR: 7 seconds)
40% complete (ETR: 7 seconds)
40% complete (ETR: 7 seconds)
40% complete (ETR: 7 seconds)
40% complete (ETR: 7 seconds)
50% complete (ETR: 5 seconds)
60% complete (ETR: 4 seconds)
70% complete (ETR: 3 seconds)
80% complete (ETR: 2 seconds)
90% complete (ETR: 1 seconds)
100% complete (ETR: 0 seconds)
Compilation completed in 16.85 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes

View File

@ -1,20 +1,40 @@
package org.gcube.portlets.user.td.columnwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
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.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.widget.client.TextButton;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
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.ContentPanel;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.Window;
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.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.info.Info;
public class ChangeLabelColumnDialog extends Window {
@ -22,6 +42,7 @@ public class ChangeLabelColumnDialog extends Window {
protected TextField label=null;
protected String columnName=null;
protected ColumnData column=null;
protected ComboBox<ColumnData> combo=null;
public ChangeLabelColumnDialog(TRId trId) {
create(trId, null);
@ -36,9 +57,9 @@ public class ChangeLabelColumnDialog extends Window {
this.columnName=columnName;
setBodyBorder(false);
// getHeader().setIcon(Resources.IMAGES.side_list());
setHeadingText("Remove Column");
setHeadingText("Change Column Label");
setWidth(400);
setHeight(120);
setHeight(140);
setResizable(false);
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
@ -52,14 +73,51 @@ public class ChangeLabelColumnDialog extends Window {
VerticalLayoutContainer v = new VerticalLayoutContainer();
label = new TextField();
ColumnDataProperties props = GWT.create(ColumnDataProperties.class);
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
Log.trace("Store created");
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
public void load(ListLoadConfig loadConfig, final AsyncCallback<ListLoadResult<ColumnData>> callback) {
loadData(loadConfig, callback);
}
};
final ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(proxy);
loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(store));
Log.trace("Loader created");
label = new TextField();
label.setAllowBlank(false);
label.setWidth(150);
combo = new ComboBox<ColumnData>(store,
props.label()){
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
loader.load();
}
});
}
};
Log.trace("Combo created");
addHandlersForEventObservation(combo, props.label());
combo.setEmptyText("Select a column...");
combo.setWidth(150);
combo.setTypeAhead(true);
combo.setTriggerAction(TriggerAction.ALL);
combo.setLoader(loader);
v.add(new FieldLabel(combo, "Column"), new VerticalLayoutData(1, -1));
v.add(new FieldLabel(label, "Column Label"), new VerticalLayoutData(1, -1));
loadData();
form.add(v);
form.addButton(new TextButton("Remove"));
form.addButton(new TextButton("Change"));
panel.add(form);
@ -68,24 +126,61 @@ public class ChangeLabelColumnDialog extends Window {
add(basicLayout);
}
private <T> void addHandlersForEventObservation(ComboBox<T> combo,
final LabelProvider<T> labelProvider) {
combo.addValueChangeHandler(new ValueChangeHandler<T>() {
public void onValueChange(ValueChangeEvent<T> event) {
Info.display(
"Value Changed",
"New value: "
+ (event.getValue() == null ? "nothing"
: labelProvider.getLabel(event
.getValue()) + "!"));
}
});
combo.addSelectionHandler(new SelectionHandler<T>() {
public void onSelection(SelectionEvent<T> event) {
Info.display(
"State Selected",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem()) + "!"));
}
});
}
protected void loadData() {
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName, new AsyncCallback<ColumnData>(){
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
TDGWTServiceAsync.INSTANCE.getColumns(trId, new AsyncCallback<ArrayList<ColumnData>>(){
public void onFailure(Throwable caught) {
Log.error("load column data failure:"+caught.getLocalizedMessage());
Log.error("load combo failure:"+caught.getLocalizedMessage());
callback.onFailure(caught);
}
public void onSuccess(ColumnData result) {
Log.trace("loaded " + result);
column=result;
label.setValue(result.getLabel());
public void onSuccess(ArrayList<ColumnData> result) {
Log.trace("loaded " + result.size() + " ColumnData");
if(columnName!=null){
for(ColumnData cd: result){
if(cd.getName().compareTo(columnName)==0){
combo.setValue(cd);
column=cd;
label.setValue(cd.getLabel());
}
}
}
callback.onSuccess(new ListLoadResultBean<ColumnData>(
result));
}
});
});
}
}

View File

@ -63,7 +63,7 @@ public class RemoveColumnDialog extends Window {
ContentPanel panel = new ContentPanel();
panel.setHeaderVisible(false);
panel.setBodyStyle("margin: 0px;");
//panel.setBodyStyle("margin: 0px;");
ColumnDataProperties props = GWT.create(ColumnDataProperties.class);
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
@ -109,9 +109,10 @@ public class RemoveColumnDialog extends Window {
form.setBodyStyle("background: none;");
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.add(new FieldLabel(combo, "Column"), new VerticalLayoutData(1, -1));
form.add(v);
form.addButton(new TextButton("Remove"));
v.add(new FieldLabel(combo, "Column"), new VerticalLayoutData(1, -1));
panel.add(form);
basicLayout.add(panel, new VerticalLayoutData(-1, -1, new Margins()));