Updated the behavior of the toolbox

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@94959 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-17 10:28:04 +00:00
parent 328fa5df30
commit 8b1ec0fecb
5 changed files with 142 additions and 78 deletions

View File

@ -59,6 +59,7 @@ import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderL
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.info.Info;
//import org.gcube.portlets.user.tdtemplate.client.TdTemplateController;
/**
@ -97,11 +98,11 @@ public class TabularDataController {
bindToEvents();
}
protected void checkSession(){
//if you do not need to something when the session expire
protected void checkSession() {
// if you do not need to something when the session expire
CheckSession.getInstance().startPolling();
}
/**
* @return the eventBus
*/
@ -208,20 +209,44 @@ public class TabularDataController {
}
// Resume state of user interface
protected void resumeUIState() {
try {
if (uiState == UIStateType.TR_OPEN) {
UIStateEvent uiStateEvent = new UIStateEvent(
UIStateType.TR_OPEN);
UIStateEvent uiStateEvent;
switch (uiState) {
case START:
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
break;
case TABLECURATION:
uiStateEvent = new UIStateEvent(UIStateType.TABLECURATION);
uiStateEvent.setTrId(trId);
eventBus.fireEvent(uiStateEvent);
} else {
break;
case TABLEUPDATE:
uiStateEvent = new UIStateEvent(UIStateType.TABLEUPDATE);
uiStateEvent.setTrId(trId);
eventBus.fireEvent(uiStateEvent);
break;
case TR_CLOSE:
eventBus.fireEvent(new UIStateEvent(UIStateType.TR_CLOSE));
break;
case TR_OPEN:
uiStateEvent = new UIStateEvent(UIStateType.TR_OPEN);
uiStateEvent.setTrId(trId);
eventBus.fireEvent(uiStateEvent);
break;
case TR_READONLY:
uiStateEvent = new UIStateEvent(UIStateType.TR_READONLY);
uiStateEvent.setTrId(trId);
eventBus.fireEvent(uiStateEvent);
break;
case WIZARD_OPEN:
break;
default:
break;
}
} catch (Exception e) {
Log.debug("Resume :" + e.getLocalizedMessage());
}
@ -229,7 +254,7 @@ public class TabularDataController {
// Open Table
protected void openTable(TRId tabularResourceId) {
Log.debug("openTabe: " + tabularResourceId);
Log.debug("openTable: " + tabularResourceId);
trId = tabularResourceId;
tableOpening = new TableId(Constants.TDX_DATASOURCE_FACTORY_ID,
trId.getTableId());
@ -240,6 +265,32 @@ public class TabularDataController {
eventBus.fireEvent(uiStateEvent);
}
// Update Table
protected void updateTable(TRId tabularResourceId) {
Log.debug("updateTable: " + tabularResourceId);
trId = tabularResourceId;
tableOpening = new TableId(Constants.TDX_DATASOURCE_FACTORY_ID,
trId.getTableId());
tabularData.openTable(tableOpening);
uiState = UIStateType.TABLEUPDATE;
UIStateEvent uiStateEvent = new UIStateEvent(UIStateType.TABLEUPDATE);
uiStateEvent.setTrId(tabularResourceId);
eventBus.fireEvent(uiStateEvent);
}
// Update Table For Curation
protected void updateTableForCuration(TRId tabularResourceId) {
Log.debug("updateTableForCuration: " + tabularResourceId);
trId = tabularResourceId;
tableOpening = new TableId(Constants.TDX_DATASOURCE_FACTORY_ID,
trId.getTableId());
tabularData.openTable(tableOpening);
uiState = UIStateType.TABLECURATION;
UIStateEvent uiStateEvent = new UIStateEvent(UIStateType.TABLECURATION);
uiStateEvent.setTrId(tabularResourceId);
eventBus.fireEvent(uiStateEvent);
}
// Close Tabular Resource
protected void closeTabularResource() {
if (uiState == UIStateType.TR_OPEN) {
@ -270,8 +321,7 @@ public class TabularDataController {
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
UtilsGXT3.alert(
"Error on Delete",
UtilsGXT3.alert("Error on Delete",
caught.getLocalizedMessage());
}
@ -307,7 +357,7 @@ public class TabularDataController {
break;
case CLONE:
cloneTabularResource();
break;
break;
case CLOSE:
closeTabularResource();
break;
@ -340,7 +390,7 @@ public class TabularDataController {
break;
case TEMPLATEDELETE:
openTemplateDelete();
break;
break;
case SHARE:
openShareWindow();
break;
@ -469,8 +519,6 @@ public class TabularDataController {
}
}
protected void openSDMXImportWizard() {
GWT.runAsync(new RunAsyncCallback() {
@ -680,45 +728,44 @@ public class TabularDataController {
tdTemplateController.getWindowTemplatePanel().show();
}
protected void openTemplateDelete() {
TemplateDeleteDialog tdDialog = new TemplateDeleteDialog(eventBus);
tdDialog.show();
}
protected void openTemplateOpen() {
Log.debug("Template Open call");
TemplateOpenDialog tdDialog = new TemplateOpenDialog(eventBus);
tdDialog.show();
}
protected void openShareWindow(){
protected void openShareWindow() {
Log.debug("Open Share Window");
@SuppressWarnings("unused")
TRShare trShare=new TRShare(trId,eventBus);
TRShare trShare = new TRShare(trId, eventBus);
}
protected void callDiscard(){
HistoryDiscard historyDiscard=new HistoryDiscard(eventBus);
protected void callDiscard() {
HistoryDiscard historyDiscard = new HistoryDiscard(eventBus);
historyDiscard.discard();
}
protected void openTemplateApply(){
protected void openTemplateApply() {
Log.debug("Template Apply call");
if (trId != null) {
TemplateApplyDialog taDialog = new TemplateApplyDialog(trId, eventBus);
TemplateApplyDialog taDialog = new TemplateApplyDialog(trId,
eventBus);
taDialog.show();
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No current tabular resource present");
UtilsGXT3.alert("Error", "No current tabular resource present");
}
}
protected void openMultiColumnFilter() {
Log.debug("Request Open Multi Column Filter Dialog");
if (trId != null) {
@ -727,7 +774,7 @@ public class TabularDataController {
mcfDialog.show();
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No current tabular resource present");
UtilsGXT3.alert("Error", "No current tabular resource present");
}
}
@ -739,7 +786,7 @@ public class TabularDataController {
cfDialog.show();
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No current tabular resource present");
UtilsGXT3.alert("Error", "No current tabular resource present");
}
}
@ -757,39 +804,35 @@ public class TabularDataController {
eventBus.fireEvent(e);
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No current tabular resource present");
UtilsGXT3.alert("Error", "No current tabular resource present");
}
}
protected void cloneTabularResource(){
CloneTabularResource cloneTR=new CloneTabularResource(trId, eventBus);
protected void cloneTabularResource() {
CloneTabularResource cloneTR = new CloneTabularResource(trId, eventBus);
cloneTR.cloneTR();
}
protected void openColumnBatchReplace() {
openColumnDelete(null);
}
protected void openColumnBatchReplace(String columnName){
protected void openColumnBatchReplace(String columnName) {
Log.debug("Request Open Batch Replace Dialog");
if (trId != null) {
ReplaceBatchDialog dialog = new ReplaceBatchDialog(
trId, columnName,eventBus);
ReplaceBatchDialog dialog = new ReplaceBatchDialog(trId,
columnName, eventBus);
dialog.show();
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No tabular resource present");
UtilsGXT3.alert("Error", "No tabular resource present");
}
};
protected void openColumnDelete() {
openColumnDelete(null);
}
protected void openColumnDelete(String columnName) {
Log.debug("Request Delete Column Tab");
if (trId != null) {
@ -800,7 +843,7 @@ public class TabularDataController {
eventBus.fireEvent(e);
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No tabular resource present");
UtilsGXT3.alert("Error", "No tabular resource present");
}
}
@ -818,7 +861,7 @@ public class TabularDataController {
eventBus.fireEvent(e);
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No tabular resource present");
UtilsGXT3.alert("Error", "No tabular resource present");
}
}
@ -831,10 +874,10 @@ public class TabularDataController {
eventBus.fireEvent(e);
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No tabular resource present");
UtilsGXT3.alert("Error", "No tabular resource present");
}
}
protected void openDuplicatesRows() {
Log.debug("Request Duplicates Rows Tab");
if (trId != null) {
@ -844,50 +887,58 @@ public class TabularDataController {
eventBus.fireEvent(e);
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error","No tabular resource present");
UtilsGXT3.alert("Error", "No tabular resource present");
}
}
protected void doChangeTableRequestEventCommand(
ChangeTableRequestEvent event) {
Log.debug("Change Table Request to " + event.getTrId());
openTable(event.getTrId());
switch (event.getWhy()) {
case TABLECURATION:
updateTableForCuration(event.getTrId());
break;
case TABLEUPDATED:
updateTable(event.getTrId());
break;
default:
break;
}
// TODO
};
protected void doRowsAdd(){
protected void doRowsAdd() {
ArrayList<String> rows = tabularData.getGridPanel().getSelectedRowsId();
onRowsAdd(rows);
}
protected void doRowsDelete(){
protected void doRowsDelete() {
ArrayList<String> rows = tabularData.getGridPanel().getSelectedRowsId();
onRowsDelete(rows);
}
private void onRowsDelete(ArrayList<String> rows){
if(rows==null || rows.size()==0){
private void onRowsDelete(ArrayList<String> rows) {
if (rows == null || rows.size() == 0) {
UtilsGXT3.alert("No rows selected", "No rows selected");
} else {
DeleteRows deleteRows=new DeleteRows(trId, rows,eventBus);
DeleteRows deleteRows = new DeleteRows(trId, rows, eventBus);
deleteRows.delete();
}
}
private void onReplace(CellData cellData){
if(cellData==null){
private void onReplace(CellData cellData) {
if (cellData == null) {
UtilsGXT3.alert("No cell selected", "No cell selected");
} else {
ReplaceDialog replaceDialog=new ReplaceDialog(cellData,trId,eventBus);
ReplaceDialog replaceDialog = new ReplaceDialog(cellData, trId,
eventBus);
replaceDialog.show();
}
}
private void onRowsAdd(ArrayList<String> rows){
private void onRowsAdd(ArrayList<String> rows) {
tabularData.addRow(rows);
}
@ -896,8 +947,8 @@ public class TabularDataController {
"OperationId: " + event.getGridOperationId());
GridOperationId gridOperationId = event.getGridOperationId();
ArrayList<String> rows = event.getRows();
CellData cellData=event.getCellData();
CellData cellData = event.getCellData();
switch (gridOperationId) {
case ROWADD:
onRowsAdd(rows);
@ -914,8 +965,7 @@ public class TabularDataController {
}
}
protected void doGridHeaderColumnMenuCommand(
GridHeaderColumnMenuItemEvent event) {
Log.debug("GridHeaderColumnMenu Fire Event",
@ -931,7 +981,8 @@ public class TabularDataController {
if (opId.compareTo(GridHeaderOperationId.COLUMNADD.toString()) == 0) {
} else {
if (opId.compareTo(GridHeaderOperationId.COLUMNBATCHREPLACE.toString()) == 0) {
if (opId.compareTo(GridHeaderOperationId.COLUMNBATCHREPLACE
.toString()) == 0) {
openColumnBatchReplace(columnName);
} else {
if (opId.compareTo(GridHeaderOperationId.COLUMNDELETE

View File

@ -5,6 +5,7 @@ import org.gcube.portlets.user.td.client.template.TemplateApplyDialog;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
@ -37,6 +38,7 @@ public class TemplateApplyProgressDialog extends Window implements TemplateApply
protected TemplateApplyProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private ChangeTableWhy why;
public TemplateApplyProgressDialog(TemplateApplyDialog dialog, EventBus eventBus) {
this.dialog=dialog;
@ -99,6 +101,7 @@ public class TemplateApplyProgressDialog extends Window implements TemplateApply
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: "+trId.toString());
this.trId=trId;
why=ChangeTableWhy.TABLEUPDATED;
updateInvocation();
}
@ -113,7 +116,7 @@ public class TemplateApplyProgressDialog extends Window implements TemplateApply
public void updateInvocation(){
if(trId!=null){
ChangeTableRequestEvent changeTableRequestEvent=
new ChangeTableRequestEvent(ChangeTableRequestType.TEMPLATEAPPLY, trId);
new ChangeTableRequestEvent(ChangeTableRequestType.TEMPLATEAPPLY, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
}
dialog.hide();
@ -126,5 +129,6 @@ public class TemplateApplyProgressDialog extends Window implements TemplateApply
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
ok.setVisible(true);
this.trId=trId;
why=ChangeTableWhy.TABLECURATION;
}
}

View File

@ -365,6 +365,7 @@ public class CurationToolBar {
generateSummaryButton.disable();
break;
case TR_CLOSE:
case TR_READONLY:
duplicateDetectionButton.disable();
rulesButton.disable();
normalizeButton.disable();
@ -380,6 +381,8 @@ public class CurationToolBar {
generateSummaryButton.disable();
break;
case TR_OPEN:
case TABLEUPDATE:
case TABLECURATION:
duplicateDetectionButton.enable();
rulesButton.disable();
normalizeButton.disable();

View File

@ -542,6 +542,7 @@ public class FileToolBar {
discardAllButton.disable();
break;
case TR_CLOSE:
case TR_READONLY:
openButton.enable();
cloneButton.disable();
closeButton.disable();
@ -563,6 +564,8 @@ public class FileToolBar {
discardAllButton.disable();
break;
case TR_OPEN:
case TABLEUPDATE:
case TABLECURATION:
openButton.enable();
cloneButton.enable();
closeButton.enable();

View File

@ -314,6 +314,7 @@ public class ModifyToolBar {
replaceValueBatchButton.disable();
break;
case TR_CLOSE:
case TR_READONLY:
// Table
filterButton.disable();
unionButton.disable();
@ -328,6 +329,8 @@ public class ModifyToolBar {
replaceValueBatchButton.disable();
break;
case TR_OPEN:
case TABLEUPDATE:
case TABLECURATION:
// Table
filterButton.disable();
unionButton.disable();