Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@90604 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -190,3 +190,67 @@ Compiling...
|
|||
Compilation completed in 0.00 seconds
|
||||
Removing invalidated units
|
||||
Finding entry point classes
|
||||
Public resources found in...
|
||||
Translatable source found in...
|
||||
Found 0 cached/archived units. Used 0 / 2719 units from cache.
|
||||
Compiling...
|
||||
40% complete (ETR: 6 seconds)
|
||||
40% complete (ETR: 6 seconds)
|
||||
40% complete (ETR: 6 seconds)
|
||||
40% complete (ETR: 6 seconds)
|
||||
40% complete (ETR: 6 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 14.38 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
|
||||
Public resources found in...
|
||||
Translatable source found in...
|
||||
Found 0 cached/archived units. Used 0 / 2719 units from cache.
|
||||
Compiling...
|
||||
50% complete (ETR: 4 seconds)
|
||||
50% complete (ETR: 4 seconds)
|
||||
50% complete (ETR: 4 seconds)
|
||||
50% complete (ETR: 4 seconds)
|
||||
50% complete (ETR: 4 seconds)
|
||||
50% complete (ETR: 4 seconds)
|
||||
60% complete (ETR: 3 seconds)
|
||||
70% complete (ETR: 2 seconds)
|
||||
80% complete (ETR: 1 seconds)
|
||||
90% complete (ETR: 1 seconds)
|
||||
100% complete (ETR: 0 seconds)
|
||||
Compilation completed in 8.93 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
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.portlets.user.td.columnwidget.client;
|
|||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.combo.DialogCodelistSelection;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
|
@ -11,7 +11,7 @@ public class ColumnWidgetEntry implements EntryPoint {
|
|||
|
||||
|
||||
public void onModuleLoad() {
|
||||
TRId trId=new TRId();
|
||||
/*TRId trId=new TRId();
|
||||
//For example Tabular Resource 1 and table 1
|
||||
trId.setId("1");
|
||||
trId.setTableId("1");
|
||||
|
@ -25,6 +25,9 @@ public class ColumnWidgetEntry implements EntryPoint {
|
|||
|
||||
ChangeColumnTypeDialog changeColumnType=new ChangeColumnTypeDialog(trId);
|
||||
changeColumnType.show();
|
||||
*/
|
||||
DialogCodelistSelection dcs=new DialogCodelistSelection();
|
||||
dcs.show();
|
||||
|
||||
Log.info("Hello!");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,318 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.combo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
|
||||
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.KeyUpEvent;
|
||||
import com.google.gwt.event.dom.client.KeyUpHandler;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.core.client.IdentityValueProvider;
|
||||
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.Store;
|
||||
import com.sencha.gxt.data.shared.Store.StoreFilter;
|
||||
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.LoadResultListStoreBinding;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoadConfig;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoadResult;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoadResultBean;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoader;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
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.TextField;
|
||||
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
|
||||
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
||||
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
||||
import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||
import com.sencha.gxt.widget.core.client.grid.LiveGridView;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||
|
||||
public class DialogCodelistSelection extends Window {
|
||||
protected static final int WIDTH = 550;
|
||||
protected static final int HEIGHT = 520;
|
||||
protected static final int CACHE_SIZE = 200;
|
||||
|
||||
private static final TabResourcesProperties properties = GWT
|
||||
.create(TabResourcesProperties.class);
|
||||
|
||||
protected static final ColumnConfig<TabResource, String> nameColumn = new ColumnConfig<TabResource, String>(
|
||||
properties.name(), 50, "Name");
|
||||
protected static final ColumnConfig<TabResource, String> agencyColumn = new ColumnConfig<TabResource, String>(
|
||||
properties.agency(), 50, "Agency");
|
||||
protected static final ColumnConfig<TabResource, String> dateColumn = new ColumnConfig<TabResource, String>(
|
||||
properties.date(), 50, "Date");
|
||||
|
||||
protected Grid<TabResource> grid;
|
||||
protected ResourceBundle res;
|
||||
|
||||
public DialogCodelistSelection() {
|
||||
Log.info("Dialog CodelistSelection");
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
res = ResourceBundle.INSTANCE;
|
||||
setBodyBorder(false);
|
||||
setResizable(false);
|
||||
setHeadingText("Select Codelist");
|
||||
|
||||
FramedPanel panel = new FramedPanel();
|
||||
panel.setHeaderVisible(false);
|
||||
panel.setBodyBorder(false);
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
|
||||
// ////
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.add(new LabelToolItem("Search: "));
|
||||
final TextField searchField = new TextField();
|
||||
toolBar.add(searchField);
|
||||
|
||||
TextButton btnReload = new TextButton();
|
||||
// btnReload.setText("Reload");
|
||||
btnReload.setIcon(res.refresh());
|
||||
btnReload.setToolTip("Reload");
|
||||
toolBar.add(btnReload);
|
||||
|
||||
IdentityValueProvider<TabResource> identity = new IdentityValueProvider<TabResource>();
|
||||
final CheckBoxSelectionModel<TabResource> sm = new CheckBoxSelectionModel<TabResource>(
|
||||
identity);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<ColumnConfig<TabResource, ?>> columns = Arrays
|
||||
.<ColumnConfig<TabResource, ?>> asList(nameColumn,
|
||||
agencyColumn, dateColumn);
|
||||
ColumnConfig<TabResource, ?> autoexpandColumn = nameColumn;
|
||||
|
||||
ColumnModel<TabResource> cm = new ColumnModel<TabResource>(columns);
|
||||
|
||||
final ExtendedListStore<TabResource> store = new ExtendedListStore<TabResource>(
|
||||
properties.id());
|
||||
|
||||
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||
store.applyFilters();
|
||||
}
|
||||
});
|
||||
|
||||
store.addFilter(new StoreFilter<TabResource>() {
|
||||
|
||||
public boolean select(Store<TabResource> store, TabResource parent,
|
||||
TabResource item) {
|
||||
String searchTerm = searchField.getCurrentValue();
|
||||
if (searchTerm == null)
|
||||
return true;
|
||||
return DialogCodelistSelection.this.select(item, searchTerm);
|
||||
}
|
||||
});
|
||||
|
||||
store.setEnableFilters(true);
|
||||
|
||||
RpcProxy<PagingLoadConfig, PagingLoadResult<TabResource>> proxy = new RpcProxy<PagingLoadConfig, PagingLoadResult<TabResource>>() {
|
||||
|
||||
public void load(PagingLoadConfig loadConfig,
|
||||
final AsyncCallback<PagingLoadResult<TabResource>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
final PagingLoader<PagingLoadConfig, PagingLoadResult<TabResource>> loader = new PagingLoader<PagingLoadConfig, PagingLoadResult<TabResource>>(
|
||||
proxy);
|
||||
|
||||
loader.setRemoteSort(true);
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<PagingLoadConfig, TabResource, PagingLoadResult<TabResource>>(
|
||||
store));
|
||||
|
||||
final LiveGridView<TabResource> liveGridView = new LiveGridView<TabResource>();
|
||||
liveGridView.setForceFit(true);
|
||||
liveGridView.setEmptyText("No Matching Results.");
|
||||
liveGridView.setCacheSize(CACHE_SIZE);
|
||||
|
||||
grid = new Grid<TabResource>(store, cm) {
|
||||
@Override
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
public void execute() {
|
||||
loader.load(0, liveGridView.getCacheSize());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
grid.setLoader(loader);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.setView(liveGridView);
|
||||
//grid.getView().setAutoExpandColumn(autoexpandColumn);
|
||||
//grid.getView().setStripeRows(false);
|
||||
//grid.getView().setColumnLines(true);
|
||||
//grid.getView().setAutoFill(true);
|
||||
grid.setBorders(false);
|
||||
grid.setLoadMask(true);
|
||||
grid.setColumnReordering(true);
|
||||
|
||||
SelectHandler sh = new SelectHandler() {
|
||||
public void onSelect(SelectEvent event) {
|
||||
loader.load();
|
||||
}
|
||||
};
|
||||
|
||||
btnReload.addSelectHandler(sh);
|
||||
|
||||
v.add(toolBar, new VerticalLayoutData(1, -1));
|
||||
v.add(grid, new VerticalLayoutData(1, 1));
|
||||
|
||||
panel.add(v);
|
||||
panel.addButton(new TextButton("Select"));
|
||||
|
||||
add(panel);
|
||||
|
||||
}
|
||||
|
||||
protected void loadData(PagingLoadConfig loadConfig,
|
||||
final AsyncCallback<PagingLoadResult<TabResource>> callback) {
|
||||
/*
|
||||
* TDGWTServiceAsync.INSTANCE.getTabularResources(new
|
||||
* AsyncCallback<ArrayList<TabResource>>() {
|
||||
*
|
||||
* public void onFailure(Throwable caught) {
|
||||
* Log.error("load combo failure:" + caught.getLocalizedMessage());
|
||||
* callback.onFailure(caught); }
|
||||
*
|
||||
* public void onSuccess(ArrayList<TabResource> result) {
|
||||
* Log.trace("loaded " + result.size() + " ColumnData"); /*if
|
||||
* (columnName != null) { for (ColumnData cd : result) { if
|
||||
* (cd.getName().compareTo(columnName) == 0) { comboColumn.setValue(cd);
|
||||
* labelColumn.setValue(cd.getLabel());
|
||||
* comboColumnTypeCode.select(ColumnTypeCodeStore
|
||||
* .selected(cd.getTypeCode())); } } } callback.onSuccess(new
|
||||
* ListLoadResultBean<TabResource>( result));
|
||||
*
|
||||
* }
|
||||
*
|
||||
*
|
||||
* });
|
||||
*/
|
||||
ArrayList<TabResource> trs = new ArrayList<TabResource>();
|
||||
int totalLength = loadConfig.getOffset() + loadConfig.getLimit();
|
||||
int offset = loadConfig.getOffset();
|
||||
Log.debug("Offset: " + offset);
|
||||
Log.debug("Limit:" + loadConfig.getLimit());
|
||||
Log.debug("TotalLength:" + totalLength);
|
||||
|
||||
for (int i = offset; i < totalLength; i++) {
|
||||
TabResource tr = new TabResource();
|
||||
tr.setId(String.valueOf(i));
|
||||
tr.setName("Number" + i);
|
||||
tr.setAgency("Agency" + i);
|
||||
tr.setDate("2013/11/01");
|
||||
trs.add(tr);
|
||||
}
|
||||
|
||||
callback.onSuccess(new PagingLoadResultBean<TabResource>(trs, totalLength,
|
||||
offset));
|
||||
}
|
||||
|
||||
protected boolean select(TabResource item, String searchTerm) {
|
||||
if (item.getName() != null
|
||||
&& item.getName().toLowerCase()
|
||||
.contains(searchTerm.toLowerCase()))
|
||||
return true;
|
||||
if (item.getAgency() != null
|
||||
&& item.getAgency().toLowerCase()
|
||||
.contains(searchTerm.toLowerCase()))
|
||||
return true;
|
||||
if (item.getDate() != null
|
||||
&& item.getDate().toLowerCase()
|
||||
.contains(searchTerm.toLowerCase()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<TabResource>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getTabularResources(new AsyncCallback<ArrayList<TabResource>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
callback.onFailure(caught);
|
||||
AlertMessageBox d = new AlertMessageBox("Error!",
|
||||
"Details: " + caught.getLocalizedMessage());
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
//
|
||||
}
|
||||
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<TabResource> result) {
|
||||
Log.debug("loaded " + result.size()
|
||||
+ " TabularResources");
|
||||
/*
|
||||
* for(TabResource tr:result){ Log.debug("TR:"+tr); }
|
||||
*/
|
||||
callback.onSuccess(new ListLoadResultBean<TabResource>(
|
||||
result));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected HandlerRegistration addSelectionHandler(
|
||||
SelectionHandler<TabResource> handler) {
|
||||
SelectionHandler<TabResource> hand = new SelectionHandler<TabResource>() {
|
||||
|
||||
public void onSelection(SelectionEvent<TabResource> event) {
|
||||
// tabResourcesSelectionPanel.getSelectedItem();
|
||||
// getWizardWindow().setEnableNextButton(true);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return grid.getSelectionModel().addSelectionHandler(hand);
|
||||
}
|
||||
|
||||
public TabResource getSelectedItem() {
|
||||
return grid.getSelectionModel().getSelectedItem();
|
||||
}
|
||||
|
||||
protected class ExtendedListStore<M> extends ListStore<M> {
|
||||
|
||||
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
|
||||
super(keyProvider);
|
||||
}
|
||||
|
||||
public void applyFilters() {
|
||||
super.applyFilters();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.columnwidget.client.combo;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
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>
|
||||
*
|
||||
*/
|
||||
public interface TabResourcesProperties extends PropertyAccess<TabResource> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<TabResource> id();
|
||||
|
||||
ValueProvider<TabResource, String> name();
|
||||
ValueProvider<TabResource, String> agency();
|
||||
ValueProvider<TabResource, String> date();
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
@CHARSET "UTF-8";
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.columnwidget.client.resources;
|
||||
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface DialogCSS extends CssResource {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.resources;
|
||||
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface ResourceBundle extends ClientBundle {
|
||||
|
||||
public static final ResourceBundle INSTANCE=GWT.create(ResourceBundle.class);
|
||||
|
||||
@Source("Dialog.css")
|
||||
DialogCSS dialogCSS();
|
||||
|
||||
@Source("arrow-refresh_24.png")
|
||||
ImageResource refresh24();
|
||||
|
||||
@Source("arrow-refresh_16.png")
|
||||
ImageResource refresh();
|
||||
|
||||
|
||||
@Source("arrow-refresh_32.png")
|
||||
ImageResource refresh32();
|
||||
}
|
||||
|
After Width: | Height: | Size: 781 B |
After Width: | Height: | Size: 572 B |
After Width: | Height: | Size: 984 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 778 B |
After Width: | Height: | Size: 771 B |