From 8412019b17d26eb3eb9effe4a72887293dc99c38 Mon Sep 17 00:00:00 2001 From: Loredana Liccardo Date: Fri, 4 Jul 2014 09:24:13 +0000 Subject: [PATCH] some bugs fixed for the "Show Create Table" functionality git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@98415 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/panels/GxtBorderLayoutPanel.java | 282 ++++++++++-------- 1 file changed, 151 insertions(+), 131 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/databasesmanager/client/panels/GxtBorderLayoutPanel.java b/src/main/java/org/gcube/portlets/user/databasesmanager/client/panels/GxtBorderLayoutPanel.java index 3a0d05b..9cce800 100644 --- a/src/main/java/org/gcube/portlets/user/databasesmanager/client/panels/GxtBorderLayoutPanel.java +++ b/src/main/java/org/gcube/portlets/user/databasesmanager/client/panels/GxtBorderLayoutPanel.java @@ -206,6 +206,9 @@ public class GxtBorderLayoutPanel extends ContentPanel { public void onSelectedItem( SelectedItemEvent selectedItemEvent) { + centerBottom.removeAll(); + centerBottom.layout(true); + // System.out // .println("GxtBorderLayoutPanel: Event received"); @@ -332,7 +335,18 @@ public class GxtBorderLayoutPanel extends ContentPanel { ShowCreateTableEvent showCreateTableEvent) { // TODO Auto-generated method stub - getTableDetails(); + // get the selected table + + List data = treePanel.getTreePanel() + .getSelectionModel().getSelectedItems(); + + // the selected item is a table + FileModel selectedTable = data.get(0); + + rootLogger.log(Level.INFO, "the selected table is: " + + selectedTable); + + getTableDetails(selectedTable); } }); @@ -782,7 +796,6 @@ public class GxtBorderLayoutPanel extends ContentPanel { column.setHeader("Index"); column.setWidth(100); column.setSortable(false); - configs.add(column); @@ -838,20 +851,18 @@ public class GxtBorderLayoutPanel extends ContentPanel { } private ColumnModel createColumnModelForDBInfo(List result) { - + List configs = new ArrayList(); ColumnConfig column = new ColumnConfig(); column.setId("index"); column.setHeader("Property"); column.setWidth(100); -// column1.setSortable(false); - - TextField textProperty = new TextField(); -// text.setAllowBlank(false); + // column1.setSortable(false); + + TextField textProperty = new TextField(); + // text.setAllowBlank(false); column.setEditor(new CellEditor(textProperty)); - - configs.add(column); @@ -859,11 +870,11 @@ public class GxtBorderLayoutPanel extends ContentPanel { column.setId("value"); column.setHeader("Value"); column.setWidth(600); - -// column2.setSortable(false); - - TextField textValue = new TextField(); -// text.setAllowBlank(false); + + // column2.setSortable(false); + + TextField textValue = new TextField(); + // text.setAllowBlank(false); column.setEditor(new CellEditor(textValue)); configs.add(column); @@ -891,46 +902,47 @@ public class GxtBorderLayoutPanel extends ContentPanel { ListStore store = new ListStore(); store.add(dataDB); -// Grid grid = new Grid(store, -// createColumnModelForDBInfo(dataDB)); - - EditorGrid grid = new EditorGrid(store, - createColumnModelForDBInfo(dataDB)); + // Grid grid = new Grid(store, + // createColumnModelForDBInfo(dataDB)); + + EditorGrid grid = new EditorGrid(store, + createColumnModelForDBInfo(dataDB)); // grid.setAutoExpandColumn("name"); grid.setBorders(true); // grid.setAutoWidth(true); -// RowData data = new RowData(.5, 1); -// data.setMargins(new Margins(6)); + // RowData data = new RowData(.5, 1); + // data.setMargins(new Margins(6)); centerUpper.removeAll(); -// centerUpper.add(grid, data); - + // centerUpper.add(grid, data); + centerUpper.add(grid); centerUpper.layout(true); } - private void getTableDetails() { - + private void getTableDetails(final FileModel selectedTable) { + this.mask("Loading", "x-mask-loading"); // System.out.println("Start RPC - submitQuery"); rootLogger.log(Level.SEVERE, "Start RPC - getTableDetails"); - // get the selected table - - List data = treePanel.getTreePanel().getSelectionModel() - .getSelectedItems(); - - // the selected item is a table - final FileModel selectedTable = data.get(0); - - rootLogger.log(Level.INFO, "the selected table is: " + selectedTable); + // // get the selected table + // + // List data = treePanel.getTreePanel().getSelectionModel() + // .getSelectedItems(); + // + // // the selected item is a table + // final FileModel selectedTable = data.get(0); + // + // rootLogger.log(Level.INFO, "the selected table is: " + + // selectedTable); // recover data inputs @@ -974,106 +986,116 @@ public class GxtBorderLayoutPanel extends ContentPanel { .log(Level.INFO, "SchemaName: " + selectedTable.getName()); } - // call remote service - RPCservice.getTableDetails(dataInput, - new AsyncCallback>() { + if (selectedTable.isTableDetailsDisplayed()) { - @Override - public void onFailure(Throwable caught) { - // TODO Auto-generated method stub + displayTableDetails(selectedTable); + + } else { - rootLogger.log(Level.SEVERE, - "FAILURE RPC getTableDetails"); + // call remote service + RPCservice.getTableDetails(dataInput, + new AsyncCallback>() { - MessageBox.alert("Error ", - "
Message:" + caught.getMessage(), null); + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub - } + rootLogger.log(Level.SEVERE, + "FAILURE RPC getTableDetails"); - @Override - public void onSuccess( - LinkedHashMap result) { - // TODO Auto-generated method stub - - rootLogger.log(Level.SEVERE, - "SUCCESS RPC getTableDetails"); - - // details are recovered about the selected table - - if (result.size() != 0) { - - // recover keys from the result - - Set keys = result.keySet(); - - Object[] array = keys.toArray(); - - // System.out.println("array size: " + - // array.length); - - // recover details - - List TableDetails = new ArrayList(); - - for (int i = 0; i < result.size(); i++) { - - if (array[i].toString().contains("CreateTable")) { - - // recover the showCreateTable statement - - Result row = new Result("CreateTable", - result.get(array[i].toString()) - .getName()); - - TableDetails.add(row); - - } - - if (array[i].toString() - .contains("Column Names")) { - - // recover the column names - - Result row = new Result("Column Names", - result.get(array[i].toString()) - .getName()); - - TableDetails.add(row); - - } - - if (array[i].toString().contains("NumberRows")) { - - // recover the column names - - Result row = new Result("NumberRows", - result.get(array[i].toString()) - .getName()); - - TableDetails.add(row); - - } - - } - - selectedTable.setTableDetails(TableDetails); - - displayTableDetails(selectedTable); + MessageBox.alert("Error ", + "
Message:" + caught.getMessage(), null); } - } - }); + @Override + public void onSuccess( + LinkedHashMap result) { + // TODO Auto-generated method stub + + rootLogger.log(Level.SEVERE, + "SUCCESS RPC getTableDetails"); + + // details are recovered about the selected table + + if (result.size() != 0) { + + // recover keys from the result + + Set keys = result.keySet(); + + Object[] array = keys.toArray(); + + // System.out.println("array size: " + + // array.length); + + // recover details + + List TableDetails = new ArrayList(); + + for (int i = 0; i < result.size(); i++) { + + if (array[i].toString().contains( + "CreateTable")) { + + // recover the showCreateTable statement + + Result row = new Result("CreateTable", + result.get(array[i].toString()) + .getName()); + + TableDetails.add(row); + + } + + if (array[i].toString().contains( + "Column Names")) { + + // recover the column names + + Result row = new Result("Column Names", + result.get(array[i].toString()) + .getName()); + + TableDetails.add(row); + + } + + if (array[i].toString().contains( + "NumberRows")) { + + // recover the column names + + Result row = new Result("NumberRows", + result.get(array[i].toString()) + .getName()); + + TableDetails.add(row); + + } + + } + + selectedTable.setTableDetails(TableDetails); + + displayTableDetails(selectedTable); + + selectedTable.setTableDetailsDisplayed(true); + + + } + + } + }); + + } } private void displayTableDetails(FileModel table) { rootLogger.log(Level.INFO, "displaying table details"); - - - List tableDetails = table.getTableDetails(); // System.out.println("GxtBorderLayout->size info: " + dataDB.size()); @@ -1081,35 +1103,33 @@ public class GxtBorderLayoutPanel extends ContentPanel { rootLogger.log(Level.INFO, "details size: " + tableDetails.size()); ListStore store = new ListStore(); - + store.add(tableDetails); -// Grid grid = new Grid(store, -// createColumnModelForDBInfo(tableDetails)); - + // Grid grid = new Grid(store, + // createColumnModelForDBInfo(tableDetails)); + EditorGrid grid = new EditorGrid(store, createColumnModelForDBInfo(tableDetails)); -// grid.setAutoExpandColumn("name"); + // grid.setAutoExpandColumn("name"); grid.setBorders(true); - // grid.setAutoWidth(true); -// RowData data = new RowData(.5, .1); -// data.setMargins(new Margins(6)); + // RowData data = new RowData(.5, .1); + // data.setMargins(new Margins(6)); centerBottom.removeAll(); -// centerBottom.add(grid, data); - + // centerBottom.add(grid, data); + centerBottom.add(grid); centerBottom.layout(true); - + if (this.isMasked()) { this.unmask(); } - }