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
This commit is contained in:
Loredana Liccardo 2014-07-04 09:24:13 +00:00
parent 6807afaf2c
commit 8412019b17
1 changed files with 151 additions and 131 deletions

View File

@ -206,6 +206,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void onSelectedItem( public void onSelectedItem(
SelectedItemEvent selectedItemEvent) { SelectedItemEvent selectedItemEvent) {
centerBottom.removeAll();
centerBottom.layout(true);
// System.out // System.out
// .println("GxtBorderLayoutPanel: Event received"); // .println("GxtBorderLayoutPanel: Event received");
@ -332,7 +335,18 @@ public class GxtBorderLayoutPanel extends ContentPanel {
ShowCreateTableEvent showCreateTableEvent) { ShowCreateTableEvent showCreateTableEvent) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
getTableDetails(); // get the selected table
List<FileModel> 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);
} }
}); });
@ -783,7 +797,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
column.setWidth(100); column.setWidth(100);
column.setSortable(false); column.setSortable(false);
configs.add(column); configs.add(column);
for (int i = 0; i < listAttributes.size(); i++) { for (int i = 0; i < listAttributes.size(); i++) {
@ -845,14 +858,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
column.setId("index"); column.setId("index");
column.setHeader("Property"); column.setHeader("Property");
column.setWidth(100); column.setWidth(100);
// column1.setSortable(false); // column1.setSortable(false);
TextField<String> textProperty = new TextField<String>(); TextField<String> textProperty = new TextField<String>();
// text.setAllowBlank(false); // text.setAllowBlank(false);
column.setEditor(new CellEditor(textProperty)); column.setEditor(new CellEditor(textProperty));
configs.add(column); configs.add(column);
column = new ColumnConfig(); column = new ColumnConfig();
@ -860,10 +871,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
column.setHeader("Value"); column.setHeader("Value");
column.setWidth(600); column.setWidth(600);
// column2.setSortable(false); // column2.setSortable(false);
TextField<String> textValue = new TextField<String>(); TextField<String> textValue = new TextField<String>();
// text.setAllowBlank(false); // text.setAllowBlank(false);
column.setEditor(new CellEditor(textValue)); column.setEditor(new CellEditor(textValue));
configs.add(column); configs.add(column);
@ -891,8 +902,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
ListStore<Result> store = new ListStore<Result>(); ListStore<Result> store = new ListStore<Result>();
store.add(dataDB); store.add(dataDB);
// Grid<Result> grid = new Grid<Result>(store, // Grid<Result> grid = new Grid<Result>(store,
// createColumnModelForDBInfo(dataDB)); // createColumnModelForDBInfo(dataDB));
EditorGrid<Result> grid = new EditorGrid<Result>(store, EditorGrid<Result> grid = new EditorGrid<Result>(store,
createColumnModelForDBInfo(dataDB)); createColumnModelForDBInfo(dataDB));
@ -902,19 +913,19 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// grid.setAutoWidth(true); // grid.setAutoWidth(true);
// RowData data = new RowData(.5, 1); // RowData data = new RowData(.5, 1);
// data.setMargins(new Margins(6)); // data.setMargins(new Margins(6));
centerUpper.removeAll(); centerUpper.removeAll();
// centerUpper.add(grid, data); // centerUpper.add(grid, data);
centerUpper.add(grid); centerUpper.add(grid);
centerUpper.layout(true); centerUpper.layout(true);
} }
private void getTableDetails() { private void getTableDetails(final FileModel selectedTable) {
this.mask("Loading", "x-mask-loading"); this.mask("Loading", "x-mask-loading");
@ -922,15 +933,16 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.SEVERE, "Start RPC - getTableDetails"); rootLogger.log(Level.SEVERE, "Start RPC - getTableDetails");
// get the selected table // // get the selected table
//
List<FileModel> data = treePanel.getTreePanel().getSelectionModel() // List<FileModel> data = treePanel.getTreePanel().getSelectionModel()
.getSelectedItems(); // .getSelectedItems();
//
// the selected item is a table // // the selected item is a table
final FileModel selectedTable = data.get(0); // final FileModel selectedTable = data.get(0);
//
rootLogger.log(Level.INFO, "the selected table is: " + selectedTable); // rootLogger.log(Level.INFO, "the selected table is: " +
// selectedTable);
// recover data inputs // recover data inputs
@ -974,6 +986,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
.log(Level.INFO, "SchemaName: " + selectedTable.getName()); .log(Level.INFO, "SchemaName: " + selectedTable.getName());
} }
if (selectedTable.isTableDetailsDisplayed()) {
displayTableDetails(selectedTable);
} else {
// call remote service // call remote service
RPCservice.getTableDetails(dataInput, RPCservice.getTableDetails(dataInput,
new AsyncCallback<LinkedHashMap<String, FileModel>>() { new AsyncCallback<LinkedHashMap<String, FileModel>>() {
@ -1017,7 +1035,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
if (array[i].toString().contains("CreateTable")) { if (array[i].toString().contains(
"CreateTable")) {
// recover the showCreateTable statement // recover the showCreateTable statement
@ -1029,8 +1048,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
if (array[i].toString() if (array[i].toString().contains(
.contains("Column Names")) { "Column Names")) {
// recover the column names // recover the column names
@ -1042,7 +1061,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
if (array[i].toString().contains("NumberRows")) { if (array[i].toString().contains(
"NumberRows")) {
// recover the column names // recover the column names
@ -1060,6 +1080,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
displayTableDetails(selectedTable); displayTableDetails(selectedTable);
selectedTable.setTableDetailsDisplayed(true);
} }
} }
@ -1067,13 +1090,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
}
private void displayTableDetails(FileModel table) { private void displayTableDetails(FileModel table) {
rootLogger.log(Level.INFO, "displaying table details"); rootLogger.log(Level.INFO, "displaying table details");
List<Result> tableDetails = table.getTableDetails(); List<Result> tableDetails = table.getTableDetails();
// System.out.println("GxtBorderLayout->size info: " + dataDB.size()); // System.out.println("GxtBorderLayout->size info: " + dataDB.size());
@ -1084,24 +1106,23 @@ public class GxtBorderLayoutPanel extends ContentPanel {
store.add(tableDetails); store.add(tableDetails);
// Grid<Result> grid = new Grid<Result>(store, // Grid<Result> grid = new Grid<Result>(store,
// createColumnModelForDBInfo(tableDetails)); // createColumnModelForDBInfo(tableDetails));
EditorGrid<Result> grid = new EditorGrid<Result>(store, EditorGrid<Result> grid = new EditorGrid<Result>(store,
createColumnModelForDBInfo(tableDetails)); createColumnModelForDBInfo(tableDetails));
// grid.setAutoExpandColumn("name"); // grid.setAutoExpandColumn("name");
grid.setBorders(true); grid.setBorders(true);
// grid.setAutoWidth(true); // grid.setAutoWidth(true);
// RowData data = new RowData(.5, .1); // RowData data = new RowData(.5, .1);
// data.setMargins(new Margins(6)); // data.setMargins(new Margins(6));
centerBottom.removeAll(); centerBottom.removeAll();
// centerBottom.add(grid, data); // centerBottom.add(grid, data);
centerBottom.add(grid); centerBottom.add(grid);
centerBottom.layout(true); centerBottom.layout(true);
@ -1110,7 +1131,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
this.unmask(); this.unmask();
} }
} }
} }