Minor update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-replacebyexternal-widget@101665 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-11-20 14:51:47 +00:00 committed by Giancarlo Panichi
parent 7d874aa63f
commit 8f961871ab
3 changed files with 155 additions and 29 deletions

View File

@ -24,9 +24,10 @@ import com.sencha.gxt.widget.core.client.form.FormPanel;
*/
public class CurrentColumnSelectionCard extends WizardCard {
protected ReplaceByExternalSession replaceByExternalSession;
private ReplaceByExternalSession replaceByExternalSession;
private CurrentColumnSelectionCard thisCard;
private CurrentColumnGridPanel currentColumnGridPanel;
private String colname;
public ReplaceByExternalSession getReplaceByExternalSession() {
return replaceByExternalSession;
@ -46,6 +47,23 @@ public class CurrentColumnSelectionCard extends WizardCard {
}
public CurrentColumnSelectionCard(String colname,
final ReplaceByExternalSession replaceByExternalSession) {
super("Current Column Selection", "");
this.thisCard=this;
this.colname=colname;
if (replaceByExternalSession == null) {
Log.error("ReplaceByExternalSession is null");
}
this.replaceByExternalSession = replaceByExternalSession;
FormPanel panel = createPanel();
setContent(panel);
}
protected FormPanel createPanel() {
FormPanel panel = new FormPanel();
panel.setLabelWidth(90);
@ -55,7 +73,7 @@ public class CurrentColumnSelectionCard extends WizardCard {
panel.add(content);
// Column Selection Grid
currentColumnGridPanel = new CurrentColumnGridPanel(this);
currentColumnGridPanel = new CurrentColumnGridPanel(colname,this);
currentColumnGridPanel
.addSelectionHandler(new SelectionHandler<ColumnData>() {

View File

@ -14,12 +14,10 @@ import com.google.web.bindery.event.shared.EventBus;
*
*/
public class ReplaceByExternalTD extends WizardWindow {
protected static final int WITHWIZARD = 800;
protected static final int HEIGHTWIZARD = 520;
protected ReplaceByExternalSession replaceByExternalSession;
protected TRId trId;
private static final int WITHWIZARD = 800;
private static final int HEIGHTWIZARD = 520;
private ReplaceByExternalSession replaceByExternalSession;
/**
*
* @param trId
@ -32,17 +30,35 @@ public class ReplaceByExternalTD extends WizardWindow {
setWidth(WITHWIZARD);
setHeight(HEIGHTWIZARD);
this.trId = trId;
replaceByExternalSession = new ReplaceByExternalSession();
replaceByExternalSession.setTrId(trId);
CurrentColumnSelectionCard currentColumnSelectionCard = new CurrentColumnSelectionCard(
replaceByExternalSession);
addCard(currentColumnSelectionCard);
currentColumnSelectionCard.setup();
}
/**
*
* @param trId
* @param title
* @param eventBus
*/
public ReplaceByExternalTD(TRId trId, String columnName, String title,
EventBus eventBus) {
super(title, eventBus);
Log.debug("ReplaceByExternalTD: " + trId+" columnName: "+columnName);
setWidth(WITHWIZARD);
setHeight(HEIGHTWIZARD);
replaceByExternalSession = new ReplaceByExternalSession();
replaceByExternalSession.setTrId(trId);
CurrentColumnSelectionCard currentColumnSelectionCard = new CurrentColumnSelectionCard(
columnName, replaceByExternalSession);
addCard(currentColumnSelectionCard);
currentColumnSelectionCard.setup();
}
}

View File

@ -27,6 +27,8 @@ 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.event.StoreDataChangeEvent;
import com.sencha.gxt.data.shared.event.StoreDataChangeEvent.StoreDataChangeHandler;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
import com.sencha.gxt.data.shared.loader.ListLoadResult;
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
@ -50,22 +52,31 @@ public class CurrentColumnGridPanel extends ContentPanel implements
HasSelectionHandlers<ColumnData> {
// private static final String GRID_WIDTH ="524px";
private static final String GRID_HEIGHT = "340px";
protected static final ColumnDataProperties props = GWT
private static final ColumnDataProperties props = GWT
.create(ColumnDataProperties.class);
protected CheckBoxSelectionModel<ColumnData> sm;
private CheckBoxSelectionModel<ColumnData> sm;
protected final Grid<ColumnData> grid;
protected final CurrentColumnSelectionCard parent;
private Grid<ColumnData> grid;
private CurrentColumnSelectionCard parent;
private String columnName;
private ColumnData columnSelected;
private List<ColumnData> cols;
/**
*
* @param parent
*/
public CurrentColumnGridPanel(CurrentColumnSelectionCard parent) {
public CurrentColumnGridPanel(String columnName,
CurrentColumnSelectionCard parent) {
this.parent = parent;
this.columnName = columnName;
Log.debug("CurrentColumnGridPanel");
setHeadingText("Columns");
create();
}
protected void create() {
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
props.label());
@ -79,7 +90,18 @@ public class CurrentColumnGridPanel extends ContentPanel implements
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
store.addStoreDataChangeHandler(new StoreDataChangeHandler<ColumnData>() {
@Override
public void onDataChange(StoreDataChangeEvent<ColumnData> event) {
List<ColumnData> cols = event.getSource().getAll();
Log.debug("Columns:" + cols.size());
dataChangeOnStore(cols);
}
});
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
public void load(ListLoadConfig loadConfig,
@ -94,7 +116,6 @@ public class CurrentColumnGridPanel extends ContentPanel implements
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
store));
grid = new Grid<ColumnData>(store, cm) {
@Override
protected void onAfterFirstAttach() {
@ -106,7 +127,7 @@ public class CurrentColumnGridPanel extends ContentPanel implements
});
}
};
sm.setSelectionMode(SelectionMode.SINGLE);
grid.setSelectionModel(sm);
grid.setLoader(loader);
@ -126,7 +147,7 @@ public class CurrentColumnGridPanel extends ContentPanel implements
setWidget(con);
}
public Grid<ColumnData> getGrid() {
return grid;
}
@ -141,17 +162,49 @@ public class CurrentColumnGridPanel extends ContentPanel implements
return grid.getSelectionModel().addSelectionHandler(handler);
}
protected void dataChangeOnStore(List<ColumnData> cols){
this.cols=cols;
if(columnName==null||columnName.isEmpty()){
columnSelected=null;
} else {
retrieveColumnSelected();
}
}
protected void updateInitialColumnSelected(){
Log.debug("ColumnSelected: "+columnSelected);
if (columnSelected != null) {
String columnId;
if(columnSelected.isViewColumn()){
columnId=columnSelected.getColumnViewData().getSourceTableDimensionColumnId();
} else {
columnId=columnSelected.getColumnId();
}
for (ColumnData c : cols) {
Log.debug("Column Retrieved: "+c);
if (c.getColumnId().compareTo(columnId) == 0) {
sm.select(c, true);
sm.refresh();
break;
}
}
}
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
TRId trId=parent.getReplaceByExternalSession().getTrId();
TRId trId = parent.getReplaceByExternalSession().getTrId();
TDGWTServiceAsync.INSTANCE.getColumns(trId,
new AsyncCallback<ArrayList<ColumnData>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
parent.getEventBus()
.fireEvent(
new SessionExpiredEvent(
@ -171,19 +224,58 @@ public class CurrentColumnGridPanel extends ContentPanel implements
}
}
callback.onFailure(caught);
}
@Override
public void onSuccess(ArrayList<ColumnData> result) {
parent.getReplaceByExternalSession().setCurrentColumns(result);
parent.getReplaceByExternalSession().setCurrentColumns(
result);
callback.onSuccess(new ListLoadResultBean<ColumnData>(
result));
}
});
}
protected void retrieveColumnSelected() {
TRId trId = parent.getReplaceByExternalSession().getTrId();
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName,
new AsyncCallback<ColumnData>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
parent.getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error Locked",
caught.getLocalizedMessage());
} else {
Log.debug("Error retrieving column: "
+ caught.getLocalizedMessage());
UtilsGXT3
.alert("Error retrieving current column",
"Error retrieving current column on server!");
}
}
}
@Override
public void onSuccess(ColumnData result) {
columnSelected = result;
updateInitialColumnSelected();
}
});
}
}