2013-02-08 10:56:27 +01:00
|
|
|
package org.gcube.portlets.user.workspace.client.view;
|
|
|
|
|
|
|
|
|
|
|
|
import org.gcube.portlets.user.workspace.client.ConstantsPortlet;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
|
|
|
import org.gcube.portlets.user.workspace.client.model.ListStoreModel;
|
|
|
|
|
|
|
|
import com.extjs.gxt.ui.client.event.Events;
|
|
|
|
import com.extjs.gxt.ui.client.event.Listener;
|
|
|
|
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
|
|
|
|
import com.extjs.gxt.ui.client.store.ListStore;
|
|
|
|
import com.extjs.gxt.ui.client.util.Format;
|
|
|
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
|
|
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
|
|
|
import com.extjs.gxt.ui.client.widget.ListView;
|
2016-09-15 16:42:41 +02:00
|
|
|
|
2013-02-08 10:56:27 +01:00
|
|
|
/**
|
2019-02-22 14:40:30 +01:00
|
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
|
2013-02-08 10:56:27 +01:00
|
|
|
*
|
|
|
|
*/
|
2016-09-15 16:42:41 +02:00
|
|
|
public class GxtListView extends LayoutContainer {
|
|
|
|
|
2013-02-08 10:56:27 +01:00
|
|
|
private ContentPanel cp = new ContentPanel();
|
|
|
|
// private String headerTitle = ConstantsPortlet.RESULT;
|
|
|
|
private ListStore<FileGridModel> store = ListStoreModel.getInstance().getStore();
|
2016-09-15 16:42:41 +02:00
|
|
|
|
|
|
|
public GxtListView() {
|
|
|
|
|
2013-02-08 10:56:27 +01:00
|
|
|
cp.setBodyBorder(false);
|
|
|
|
cp.setHeading(ConstantsPortlet.RESULT);
|
|
|
|
cp.setHeaderVisible(true);
|
2016-09-15 16:42:41 +02:00
|
|
|
|
|
|
|
ListView<FileGridModel> view = new ListView<FileGridModel>() {
|
|
|
|
@Override
|
|
|
|
protected FileGridModel prepareData(FileGridModel model) {
|
|
|
|
String s = model.get(FileModel.NAME);
|
|
|
|
model.set("shortName", Format.ellipse(s, 15));
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
view.setStore(store);
|
|
|
|
view.setItemSelector("div.thumb-wrap");
|
|
|
|
view.getSelectionModel().addListener(Events.SelectionChange, new Listener<SelectionChangedEvent<FileModel>>() {
|
|
|
|
|
|
|
|
public void handleEvent(SelectionChangedEvent<FileModel> be) {
|
|
|
|
cp.setHeading("Simple ListView (" + be.getSelection().size()
|
|
|
|
+ " items selected)");
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
cp.add(view);
|
2013-02-08 10:56:27 +01:00
|
|
|
add(cp);
|
2016-09-15 16:42:41 +02:00
|
|
|
}
|
2013-02-08 10:56:27 +01:00
|
|
|
|
|
|
|
private native String getTemplate() /*-{
|
|
|
|
return [ '<tpl for=".">', '<div class="thumb-wrap" id="{Name}">',
|
|
|
|
'<div class="thumb"><img src="{path}" title="{Name}"></div>',
|
|
|
|
'<span class="x-editable">{shortName}</span></div>', '</tpl>',
|
|
|
|
'<div class="x-clear"></div>' ].join("");
|
|
|
|
|
2016-09-15 16:42:41 +02:00
|
|
|
}-*/;
|
|
|
|
}
|