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:
parent
7d874aa63f
commit
8f961871ab
|
@ -24,9 +24,10 @@ import com.sencha.gxt.widget.core.client.form.FormPanel;
|
||||||
*/
|
*/
|
||||||
public class CurrentColumnSelectionCard extends WizardCard {
|
public class CurrentColumnSelectionCard extends WizardCard {
|
||||||
|
|
||||||
protected ReplaceByExternalSession replaceByExternalSession;
|
private ReplaceByExternalSession replaceByExternalSession;
|
||||||
private CurrentColumnSelectionCard thisCard;
|
private CurrentColumnSelectionCard thisCard;
|
||||||
private CurrentColumnGridPanel currentColumnGridPanel;
|
private CurrentColumnGridPanel currentColumnGridPanel;
|
||||||
|
private String colname;
|
||||||
|
|
||||||
public ReplaceByExternalSession getReplaceByExternalSession() {
|
public ReplaceByExternalSession getReplaceByExternalSession() {
|
||||||
return replaceByExternalSession;
|
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() {
|
protected FormPanel createPanel() {
|
||||||
FormPanel panel = new FormPanel();
|
FormPanel panel = new FormPanel();
|
||||||
panel.setLabelWidth(90);
|
panel.setLabelWidth(90);
|
||||||
|
@ -55,7 +73,7 @@ public class CurrentColumnSelectionCard extends WizardCard {
|
||||||
panel.add(content);
|
panel.add(content);
|
||||||
|
|
||||||
// Column Selection Grid
|
// Column Selection Grid
|
||||||
currentColumnGridPanel = new CurrentColumnGridPanel(this);
|
currentColumnGridPanel = new CurrentColumnGridPanel(colname,this);
|
||||||
|
|
||||||
currentColumnGridPanel
|
currentColumnGridPanel
|
||||||
.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
||||||
|
|
|
@ -14,12 +14,10 @@ import com.google.web.bindery.event.shared.EventBus;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReplaceByExternalTD extends WizardWindow {
|
public class ReplaceByExternalTD extends WizardWindow {
|
||||||
protected static final int WITHWIZARD = 800;
|
private static final int WITHWIZARD = 800;
|
||||||
protected static final int HEIGHTWIZARD = 520;
|
private static final int HEIGHTWIZARD = 520;
|
||||||
|
|
||||||
protected ReplaceByExternalSession replaceByExternalSession;
|
|
||||||
protected TRId trId;
|
|
||||||
|
|
||||||
|
private ReplaceByExternalSession replaceByExternalSession;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param trId
|
* @param trId
|
||||||
|
@ -32,7 +30,6 @@ public class ReplaceByExternalTD extends WizardWindow {
|
||||||
setWidth(WITHWIZARD);
|
setWidth(WITHWIZARD);
|
||||||
setHeight(HEIGHTWIZARD);
|
setHeight(HEIGHTWIZARD);
|
||||||
|
|
||||||
this.trId = trId;
|
|
||||||
replaceByExternalSession = new ReplaceByExternalSession();
|
replaceByExternalSession = new ReplaceByExternalSession();
|
||||||
replaceByExternalSession.setTrId(trId);
|
replaceByExternalSession.setTrId(trId);
|
||||||
|
|
||||||
|
@ -42,7 +39,26 @@ public class ReplaceByExternalTD extends WizardWindow {
|
||||||
currentColumnSelectionCard.setup();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -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.core.client.util.Margins;
|
||||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||||
import com.sencha.gxt.data.shared.ListStore;
|
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.ListLoadConfig;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
|
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
|
||||||
|
@ -50,21 +52,30 @@ public class CurrentColumnGridPanel extends ContentPanel implements
|
||||||
HasSelectionHandlers<ColumnData> {
|
HasSelectionHandlers<ColumnData> {
|
||||||
// private static final String GRID_WIDTH ="524px";
|
// private static final String GRID_WIDTH ="524px";
|
||||||
private static final String GRID_HEIGHT = "340px";
|
private static final String GRID_HEIGHT = "340px";
|
||||||
protected static final ColumnDataProperties props = GWT
|
private static final ColumnDataProperties props = GWT
|
||||||
.create(ColumnDataProperties.class);
|
.create(ColumnDataProperties.class);
|
||||||
protected CheckBoxSelectionModel<ColumnData> sm;
|
private CheckBoxSelectionModel<ColumnData> sm;
|
||||||
|
|
||||||
protected final Grid<ColumnData> grid;
|
private Grid<ColumnData> grid;
|
||||||
protected final CurrentColumnSelectionCard parent;
|
private CurrentColumnSelectionCard parent;
|
||||||
|
private String columnName;
|
||||||
|
private ColumnData columnSelected;
|
||||||
|
private List<ColumnData> cols;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
*/
|
*/
|
||||||
public CurrentColumnGridPanel(CurrentColumnSelectionCard parent) {
|
public CurrentColumnGridPanel(String columnName,
|
||||||
|
CurrentColumnSelectionCard parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
this.columnName = columnName;
|
||||||
Log.debug("CurrentColumnGridPanel");
|
Log.debug("CurrentColumnGridPanel");
|
||||||
setHeadingText("Columns");
|
setHeadingText("Columns");
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create() {
|
||||||
|
|
||||||
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
|
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
|
||||||
props.label());
|
props.label());
|
||||||
|
@ -80,6 +91,17 @@ public class CurrentColumnGridPanel extends ContentPanel implements
|
||||||
|
|
||||||
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
|
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>>() {
|
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
||||||
|
|
||||||
public void load(ListLoadConfig loadConfig,
|
public void load(ListLoadConfig loadConfig,
|
||||||
|
@ -94,7 +116,6 @@ public class CurrentColumnGridPanel extends ContentPanel implements
|
||||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
||||||
store));
|
store));
|
||||||
|
|
||||||
|
|
||||||
grid = new Grid<ColumnData>(store, cm) {
|
grid = new Grid<ColumnData>(store, cm) {
|
||||||
@Override
|
@Override
|
||||||
protected void onAfterFirstAttach() {
|
protected void onAfterFirstAttach() {
|
||||||
|
@ -141,9 +162,41 @@ public class CurrentColumnGridPanel extends ContentPanel implements
|
||||||
return grid.getSelectionModel().addSelectionHandler(handler);
|
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,
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||||
TRId trId=parent.getReplaceByExternalSession().getTrId();
|
TRId trId = parent.getReplaceByExternalSession().getTrId();
|
||||||
|
|
||||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||||
|
@ -176,13 +229,52 @@ public class CurrentColumnGridPanel extends ContentPanel implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ArrayList<ColumnData> result) {
|
public void onSuccess(ArrayList<ColumnData> result) {
|
||||||
parent.getReplaceByExternalSession().setCurrentColumns(result);
|
parent.getReplaceByExternalSession().setCurrentColumns(
|
||||||
|
result);
|
||||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||||
result));
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue