Updated TDXLiveToolItem
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@102123 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8a13cc5c89
commit
45bebc35f6
|
@ -1,7 +1,10 @@
|
|||
package org.gcube.portlets.user.tdwx.client.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.sencha.gxt.messages.client.DefaultMessages;
|
||||
import com.sencha.gxt.widget.core.client.event.LiveGridViewUpdateEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.LiveGridViewUpdateEvent.LiveGridViewUpdateHandler;
|
||||
import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||
|
@ -20,13 +23,71 @@ import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent.Selecti
|
|||
*/
|
||||
public class TDXLiveToolItem extends LiveToolItem {
|
||||
|
||||
/**
|
||||
* LiveToolItem messages.
|
||||
*/
|
||||
public interface TDXLiveToolItemMessages extends LiveToolItemMessages{
|
||||
|
||||
String displayMessage(int selected, int start, int end, int total);
|
||||
|
||||
}
|
||||
|
||||
protected static class DefaultTDXLiveToolItemMessages implements TDXLiveToolItemMessages {
|
||||
|
||||
|
||||
public String displayMessage(int selected, int start, int end, int total) {
|
||||
String msg="";
|
||||
if(selected>0){
|
||||
if(selected>1){
|
||||
msg=new String("Selected "+selected+" rows, Displaying "+start+" - "+end+" of "+total);
|
||||
} else {
|
||||
msg=new String("Selected "+selected+" row, Displaying "+start+" - "+end+" of "+total);
|
||||
}
|
||||
} else {
|
||||
msg=new String("Displaying "+start+" - "+end+" of "+total);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayMessage(int start, int end, int total) {
|
||||
return DefaultMessages.getMessages().pagingToolBar_displayMsg(start, end, total);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private HandlerRegistration handlerRegistration;
|
||||
private TDXLiveToolItemMessages messages;
|
||||
private List<?> lastSelected;
|
||||
|
||||
public TDXLiveToolItem(Grid<?> grid) {
|
||||
super(grid);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tool item messages.
|
||||
*
|
||||
* @return the messages
|
||||
*/
|
||||
public TDXLiveToolItemMessages getMessages() {
|
||||
if (messages == null) {
|
||||
messages = new DefaultTDXLiveToolItemMessages();
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tool item messages.
|
||||
*
|
||||
* @param messages the messages
|
||||
*/
|
||||
public void setMessages(TDXLiveToolItemMessages messages) {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onUpdate(LiveGridViewUpdateEvent be) {
|
||||
int pageSize = be.getRowCount();
|
||||
|
@ -36,7 +97,7 @@ public class TDXLiveToolItem extends LiveToolItem {
|
|||
if (i > totalCount) {
|
||||
i = totalCount;
|
||||
}
|
||||
setLabel(getMessages().displayMessage(
|
||||
setLabel(getMessages().displayMessage(lastSelected.size(),
|
||||
totalCount == 0 ? 0 : viewIndex + 1, i, (int) totalCount));
|
||||
}
|
||||
|
||||
|
@ -67,8 +128,9 @@ public class TDXLiveToolItem extends LiveToolItem {
|
|||
SelectionChangedEvent event) {
|
||||
if(event.getSelection()!=null){
|
||||
Log.debug("Selected List Items: "+event.getSelection().size());
|
||||
lastSelected=event.getSelection();
|
||||
} else {
|
||||
|
||||
lastSelected=null;
|
||||
}
|
||||
}});
|
||||
|
||||
|
|
Loading…
Reference in New Issue