From fff545a8bba3dbbac3d821fea9f73d3c4d88fea6 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 16 Jan 2015 17:19:38 +0000 Subject: [PATCH] Fixed error on clone git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@111413 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/td/client/TabularDataController.java | 254 ++++++++++++------ .../user/td/tabulardataportlet.gwt.xml | 6 +- 2 files changed, 172 insertions(+), 88 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java b/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java index e259ac0..6844945 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java +++ b/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java @@ -20,7 +20,9 @@ import org.gcube.portlets.user.td.expressionwidget.client.MultiColumnFilterDialo import org.gcube.portlets.user.td.expressionwidget.client.ReplaceColumnByExpressionDialog; import org.gcube.portlets.user.td.extractcodelistwidget.client.ExtractCodelistWizardTD; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; +import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo; import org.gcube.portlets.user.td.jsonexportwidget.client.JSONExportWidgetTD; import org.gcube.portlets.user.td.mainboxwidget.client.MainBoxPanel; @@ -94,7 +96,7 @@ public class TabularDataController { // implements HasCloseHandlers, HasOpenHandlers { private SimpleEventBus eventBus; - // protected TabularDataX tabularData; + // private TabularDataX tabularData; private MainBoxPanel mainBoxPanel; private UIStateType uiState = UIStateType.START; @@ -117,7 +119,7 @@ public class TabularDataController { /** * Grid TableId */ - // protected TableId tableOpening; + // private TableId tableOpening; private TRId openTRIdAfterServerUpdate; @@ -128,12 +130,12 @@ public class TabularDataController { bindToEvents(); } - protected void checkSession() { + private void checkSession() { // if you do not need to something when the session expire CheckSession.getInstance().startPolling(); } - protected void sessionExpiredShow() { + private void sessionExpiredShow() { CheckSession.showLogoutDialog(); } @@ -170,7 +172,7 @@ public class TabularDataController { } - protected void callHello() { + private void callHello() { TDGWTServiceAsync.INSTANCE.hello(new AsyncCallback() { @Override @@ -195,7 +197,7 @@ public class TabularDataController { } - protected void sessionExpiredShowDelayed() { + private void sessionExpiredShowDelayed() { Timer timeoutTimer = new Timer() { public void run() { sessionExpiredShow(); @@ -209,7 +211,7 @@ public class TabularDataController { } // Bind Controller to events on bus - protected void bindToEvents() { + private void bindToEvents() { eventBus.addHandler(SessionExpiredEvent.TYPE, new SessionExpiredEvent.SessionExpiredEventHandler() { @@ -337,7 +339,7 @@ public class TabularDataController { } // TODO - protected void putInBackgroundUIState() { + private void putInBackgroundUIState() { try { requestCloseCurrent(); // closeAllTabularResource(); @@ -350,7 +352,7 @@ public class TabularDataController { } // Resume state of user interface - protected void resumeUIState() { + private void resumeUIState() { try { UIStateEvent uiStateEvent; switch (uiState) { @@ -398,7 +400,7 @@ public class TabularDataController { } // Open Table - protected void openTable(TRId tabularResourceId) { + private void openTable(TRId tabularResourceId) { Log.debug("openTable: " + tabularResourceId); trId = tabularResourceId; // tableOpening = new TableId(Constants.TDX_DATASOURCE_FACTORY_ID, @@ -411,7 +413,7 @@ public class TabularDataController { } // Update Table - protected void updateTable(TRId tabularResourceId) { + private void updateTable(TRId tabularResourceId) { Log.debug("updateTable: " + tabularResourceId); trId = tabularResourceId; // tableOpening = new TableId(Constants.TDX_DATASOURCE_FACTORY_ID, @@ -425,7 +427,7 @@ public class TabularDataController { } // Update Table For Curation - protected void updateTableForCuration(TRId tabularResourceId) { + private void updateTableForCuration(TRId tabularResourceId) { Log.debug("updateTableForCuration: " + tabularResourceId); trId = tabularResourceId; // tableOpening = new TableId(Constants.TDX_DATASOURCE_FACTORY_ID, @@ -439,7 +441,7 @@ public class TabularDataController { } // Close Tabular Resource - protected void closeAllTabularResource() { + private void closeAllTabularResource() { switch (uiState) { case START: break; @@ -472,7 +474,7 @@ public class TabularDataController { } - protected void closeAllTabularResourceOnServer() { + private void closeAllTabularResourceOnServer() { TDGWTServiceAsync.INSTANCE .closeAllTabularResources(new AsyncCallback() { @@ -490,7 +492,7 @@ public class TabularDataController { } // TODO - protected void doActiveAfterClose(DataViewActiveEvent event) { + private void doActiveAfterClose(DataViewActiveEvent event) { Log.debug("doActiveAfterClose: " + event); DataView dataView = event.getDataView(); @@ -545,7 +547,7 @@ public class TabularDataController { } - protected void doOpenTRIdAfterServerUpdate() { + private void doOpenTRIdAfterServerUpdate() { if (trId != null && trId.getId().compareTo(openTRIdAfterServerUpdate.getId()) == 0 && trId.getTableId().compareTo(trId.getTableId()) == 0) { @@ -556,7 +558,7 @@ public class TabularDataController { } } - protected void doNewActive(DataViewActiveEvent event) { + private void doNewActive(DataViewActiveEvent event) { Log.debug("doNewActive: " + event); DataView dataView = event.getDataView(); if (dataView instanceof TabularResourceDataView) { @@ -597,7 +599,7 @@ public class TabularDataController { } } - protected void doDataViewClose(DataViewActiveEvent event) { + private void doDataViewClose(DataViewActiveEvent event) { Log.debug("doDataViewClose: " + event); DataView oldDataView = event.getOldDataView(); if (oldDataView instanceof TabularResourceDataView) { @@ -634,7 +636,7 @@ public class TabularDataController { } } - protected void requestCloseCurrent() { + private void requestCloseCurrent() { DataViewRequestEvent dataViewRequestEvent = new DataViewRequestEvent(); dataViewRequestEvent.setDataViewRequestType(DataViewRequestType.CLOSE); dataViewRequestEvent.setDataView(new TabularResourceDataView(trId)); @@ -642,7 +644,7 @@ public class TabularDataController { } // TODO - protected void deleteTabularResource() { + private void deleteTabularResource() { final ConfirmMessageBox mb = new ConfirmMessageBox("Confirm", "Are you sure you want to delete the taular resource?"); @@ -705,7 +707,7 @@ public class TabularDataController { } - protected void openWizard() { + private void openWizard() { eventBus.fireEvent(new UIStateEvent(UIStateType.WIZARD_OPEN)); } @@ -894,7 +896,7 @@ public class TabularDataController { } } - protected void doTasksMonitorCommand(TasksMonitorEvent event) { + private void doTasksMonitorCommand(TasksMonitorEvent event) { TaskType taskType = event.getTaskType(); Log.debug("Received TaskMonitorEvent: " + taskType); switch (taskType) { @@ -907,7 +909,7 @@ public class TabularDataController { } // TODO - protected void doWidgetRequestCommand(WidgetRequestEvent event) { + private void doWidgetRequestCommand(WidgetRequestEvent event) { WidgetRequestType widgetRequestType = event.getWidgetRequestType(); switch (widgetRequestType) { case CHANGECOLUMNTYPEPANEL: @@ -951,13 +953,13 @@ public class TabularDataController { } } - protected void openLogsWindow() { + private void openLogsWindow() { Log.debug("Request Open Logs Window"); TDMLogs tdmLogs = new TDMLogs(eventBus); tdmLogs.show(); } - protected void openBatchReplace(TRId trId, + private void openBatchReplace(TRId trId, RequestProperties requestProperties) { Log.debug("Request Open Batch Replace Dialog: " + trId + " " + requestProperties); @@ -971,7 +973,7 @@ public class TabularDataController { } } - protected void openSDMXImportWizard() { + private void openSDMXImportWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1014,7 +1016,7 @@ public class TabularDataController { } - protected void openCSVExportWizard() { + private void openCSVExportWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1059,7 +1061,7 @@ public class TabularDataController { } - protected void openJSONExportWizard() { + private void openJSONExportWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1104,7 +1106,7 @@ public class TabularDataController { } - protected void openSDMXExportWizard() { + private void openSDMXExportWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1144,7 +1146,7 @@ public class TabularDataController { } - protected void openExtractCodelistWizard() { + private void openExtractCodelistWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1184,7 +1186,7 @@ public class TabularDataController { } - protected void openCodelistMappingWizard() { + private void openCodelistMappingWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1224,7 +1226,7 @@ public class TabularDataController { } - protected void openTableUnionWizard() { + private void openTableUnionWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1264,11 +1266,11 @@ public class TabularDataController { } - protected void openReplaceByExternalColWizard() { + private void openReplaceByExternalColWizard() { openReplaceByExternalColWizard(null, null); } - protected void openReplaceByExternalColWizard(final String columnLocalId, + private void openReplaceByExternalColWizard(final String columnLocalId, final String columnname) { GWT.runAsync(new RunAsyncCallback() { @@ -1317,7 +1319,7 @@ public class TabularDataController { } - protected void openCreateChart() { + private void openCreateChart() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1356,7 +1358,7 @@ public class TabularDataController { } - protected void openCreateMapWizard() { + private void openCreateMapWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1399,7 +1401,7 @@ public class TabularDataController { * @param switchState * */ - protected void openTabularResource(final boolean switchState) { + private void openTabularResource(final boolean switchState) { Log.info("Open Tabular Resources"); GWT.runAsync(new RunAsyncCallback() { @@ -1447,7 +1449,7 @@ public class TabularDataController { } - protected void openCSVImportWizard() { + private void openCSVImportWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1488,9 +1490,9 @@ public class TabularDataController { } - protected com.extjs.gxt.ui.client.widget.Window tdTaskMainWindow; + private com.extjs.gxt.ui.client.widget.Window tdTaskMainWindow; - protected void openTasksManagerWizard() { + private void openTasksManagerWizard() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @@ -1510,7 +1512,7 @@ public class TabularDataController { }); } - protected void initTaskManager() { + private void initTaskManager() { if (!taskManagerInit) { taskManagerInit = true; tdTaskController = TdTaskController.getInstance(); @@ -1521,7 +1523,7 @@ public class TabularDataController { } } - protected void openTemplateNew() { + private void openTemplateNew() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { TdTemplateController tdTemplateController = new TdTemplateController(); @@ -1535,7 +1537,7 @@ public class TabularDataController { }); } - protected void openTemplateDelete() { + private void openTemplateDelete() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { TemplateDeleteDialog tdDialog = new TemplateDeleteDialog( @@ -1550,7 +1552,7 @@ public class TabularDataController { } - protected void openTemplateOpen() { + private void openTemplateOpen() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { Log.debug("Template Open call"); @@ -1565,7 +1567,7 @@ public class TabularDataController { } - protected void openTemplateApply() { + private void openTemplateApply() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { Log.debug("Template Apply call"); @@ -1587,7 +1589,7 @@ public class TabularDataController { } - protected void openShareWindow() { + private void openShareWindow() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { Log.debug("Open Share Window"); @@ -1601,12 +1603,12 @@ public class TabularDataController { }); } - protected void callDiscard() { + private void callDiscard() { HistoryDiscard historyDiscard = new HistoryDiscard(eventBus); historyDiscard.discard(); } - protected void openStatistical() { + private void openStatistical() { GWT.runAsync(new RunAsyncCallback() { public void onSuccess() { @SuppressWarnings("unused") @@ -1621,7 +1623,7 @@ public class TabularDataController { } - protected void openMultiColumnFilter() { + private void openMultiColumnFilter() { Log.debug("Request Open Multi Column Filter Dialog"); if (trId != null) { MultiColumnFilterDialog mcfDialog = new MultiColumnFilterDialog( @@ -1633,7 +1635,7 @@ public class TabularDataController { } } - protected void openColumnFilter(String columnLocalId, String columnName) { + private void openColumnFilter(String columnLocalId, String columnName) { Log.debug("Request Open Column Filter Dialog"); if (trId != null) { ColumnFilterDialog cfDialog = new ColumnFilterDialog(trId, @@ -1645,7 +1647,7 @@ public class TabularDataController { } } - protected void openReplaceColumnByExpression(String columnLocalId, + private void openReplaceColumnByExpression(String columnLocalId, String columnName) { Log.debug("Request Open Replace Column By Expression Dialog"); if (trId != null) { @@ -1658,11 +1660,11 @@ public class TabularDataController { } } - protected void openChangeColumnType() { + private void openChangeColumnType() { openChangeColumnType(null, null); } - protected void openChangeColumnType(String columnLocalId, String columnName) { + private void openChangeColumnType(String columnLocalId, String columnName) { Log.debug("Request Change Column Type Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1677,11 +1679,11 @@ public class TabularDataController { } } - protected void openNormalize() { + private void openNormalize() { openNormalize(null); } - protected void openNormalize(String columnName) { + private void openNormalize(String columnName) { Log.debug("Request Open Normalize Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1695,11 +1697,11 @@ public class TabularDataController { } } - protected void openDenormalize() { + private void openDenormalize() { openDenormalize(null); } - protected void openDenormalize(String columnName) { + private void openDenormalize(String columnName) { Log.debug("Request Open Denormalize Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1713,16 +1715,17 @@ public class TabularDataController { } } - protected void cloneTabularResource() { + private void cloneTabularResource() { CloneTabularResource cloneTR = new CloneTabularResource(trId, eventBus); cloneTR.cloneTR(); } - protected void openColumnBatchReplace() { + @SuppressWarnings("unused") + private void openColumnBatchReplace() { openColumnBatchReplace(null, null); } - protected void openColumnBatchReplace(String columnLocalId, + private void openColumnBatchReplace(String columnLocalId, String columnName) { Log.debug("Request Open Batch Replace Dialog"); if (trId != null) { @@ -1735,11 +1738,11 @@ public class TabularDataController { } }; - protected void openColumnAdd() { + private void openColumnAdd() { openColumnAdd(null, null); } - protected void openColumnAdd(String columnLocalId, String columnName) { + private void openColumnAdd(String columnLocalId, String columnName) { Log.debug("Request Add Column Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1752,11 +1755,11 @@ public class TabularDataController { } } - protected void openColumnDelete() { + private void openColumnDelete() { openColumnDelete(null, null); } - protected void openColumnDelete(String columnLocalId, String columnName) { + private void openColumnDelete(String columnLocalId, String columnName) { Log.debug("Request Delete Column Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1771,11 +1774,11 @@ public class TabularDataController { } } - protected void openColumnSplit() { + private void openColumnSplit() { openColumnSplit(null, null); } - protected void openColumnSplit(String columnLocalId, String columnName) { + private void openColumnSplit(String columnLocalId, String columnName) { Log.debug("Request Split Column Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1790,11 +1793,11 @@ public class TabularDataController { } } - protected void openColumnMerge() { + private void openColumnMerge() { openColumnMerge(null, null); } - protected void openColumnMerge(String columnLocalId, String columnName) { + private void openColumnMerge(String columnLocalId, String columnName) { Log.debug("Request Merge Column Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1809,11 +1812,11 @@ public class TabularDataController { } } - protected void openGroupBy() { + private void openGroupBy() { openGroupBy(null); } - protected void openGroupBy(String columnName) { + private void openGroupBy(String columnName) { Log.debug("Request Group By Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1827,11 +1830,11 @@ public class TabularDataController { } } - protected void openTimeAggregate() { + private void openTimeAggregate() { openTimeAggregate(null); } - protected void openTimeAggregate(String columnName) { + private void openTimeAggregate(String columnName) { Log.debug("Request Time Aggregate Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1845,11 +1848,11 @@ public class TabularDataController { } } - protected void openColumnLabel() { + private void openColumnLabel() { openColumnLabel(null, null); } - protected void openColumnLabel(String columnLocalId, String columnName) { + private void openColumnLabel(String columnLocalId, String columnName) { Log.debug("Request Column Label Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1864,7 +1867,7 @@ public class TabularDataController { } } - protected void openTableType() { + private void openTableType() { Log.debug("Request Change Table Type Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1877,7 +1880,7 @@ public class TabularDataController { } } - protected void openDuplicatesRows() { + private void openDuplicatesRows() { Log.debug("Request Duplicates Rows Tab"); if (trId != null) { WidgetRequestEvent e = new WidgetRequestEvent( @@ -1890,14 +1893,14 @@ public class TabularDataController { } } - protected void openBackgroundMonitor() { + private void openBackgroundMonitor() { Log.debug("Request Open Monitor Background Tab"); WidgetRequestEvent e = new WidgetRequestEvent( WidgetRequestType.MONITORBACKGROUNDPANEL); eventBus.fireEvent(e); } - protected void doChangeTableRequestEventCommand( + private void doChangeTableRequestEventCommand( ChangeTableRequestEvent event) { Log.debug("Change Table Request: " + event); switch (event.getWhy()) { @@ -1907,18 +1910,99 @@ public class TabularDataController { case TABLEUPDATED: updateTable(event.getTrId()); break; + case TABLECLONED: + addActiveTabularResourceAndOpen(event.getTrId()); + break; default: break; } }; + + + private void addActiveTabularResourceAndOpen(final TRId trId){ + Log.debug("Add Active TabResource Search: "+trId); + TDGWTServiceAsync.INSTANCE.getTabResourceInformation(trId, + new AsyncCallback() { + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); - protected void doRowAdd() { + } else { + Log.error("Error on set TabResource: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert( + "Error", + "Error on set TabResource: " + + caught.getLocalizedMessage()); + } + + } + + } + + public void onSuccess(TabResource result) { + addActiveTabularResourceAndOpen(result); + } + + }); + + } + private void addActiveTabularResourceAndOpen(final TabResource tabResource) { + Log.debug("Add Active TabResource: "+tabResource); + TDGWTServiceAsync.INSTANCE.setTabResource(tabResource + , + new AsyncCallback() { + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + getEventBus() + .fireEvent( + new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + + } else { + Log.error("Error on set TabResource: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert( + "Error", + "Error on set TabResource: " + + caught.getLocalizedMessage()); + } + + } + + } + + public void onSuccess(Void result) { + openTable(tabResource.getTrId()); + } + + }); + + } + + + + + private void doRowAdd() { onRowAdd(); } - protected void doRowsDelete() { + private void doRowsDelete() { // ArrayList rows = // tabularData.getGridPanel().getSelectedRowsId(); ArrayList rows = mainBoxPanel.getSelectedRowsId(); @@ -1979,7 +2063,7 @@ public class TabularDataController { } - protected void doGridContextMenuCommand(GridContextMenuItemEvent event) { + private void doGridContextMenuCommand(GridContextMenuItemEvent event) { Log.debug("GridContextMenu Fire Event", "OperationId: " + event.getGridOperationId()); GridOperationId gridOperationId = event.getGridOperationId(); @@ -2005,13 +2089,13 @@ public class TabularDataController { } - protected void doSessionExpiredCommand(SessionExpiredEvent event) { + private void doSessionExpiredCommand(SessionExpiredEvent event) { Log.debug("Session Expired Event: " + event.getSessionExpiredType()); sessionExpiredShow(); } - protected void doDataViewActiveCommand(DataViewActiveEvent event) { + private void doDataViewActiveCommand(DataViewActiveEvent event) { Log.debug("DataViewActive Event: " + event); switch (event.getDataViewActiveType()) { case ACTIVEAFTERCLOSE: @@ -2028,7 +2112,7 @@ public class TabularDataController { } } - protected void doGridHeaderColumnMenuCommand( + private void doGridHeaderColumnMenuCommand( GridHeaderColumnMenuItemEvent event) { Log.debug("GridHeaderColumnMenu Fire Event", "OperationId: " + event.getOperationId() + " Column: \n" @@ -2120,7 +2204,7 @@ public class TabularDataController { } - protected void asyncCodeLoadingFailed(Throwable reason) { + private void asyncCodeLoadingFailed(Throwable reason) { Log.error("Async code loading failed", reason); eventBus.fireEvent(new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); diff --git a/src/main/resources/org/gcube/portlets/user/td/tabulardataportlet.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/tabulardataportlet.gwt.xml index 3945b54..066b501 100644 --- a/src/main/resources/org/gcube/portlets/user/td/tabulardataportlet.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/td/tabulardataportlet.gwt.xml @@ -74,14 +74,14 @@ - + --> - +