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(
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<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);
}
});
@ -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> result) {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("index");
column.setHeader("Property");
column.setWidth(100);
// column1.setSortable(false);
TextField<String> textProperty = new TextField<String>();
// text.setAllowBlank(false);
// column1.setSortable(false);
TextField<String> textProperty = new TextField<String>();
// 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<String> textValue = new TextField<String>();
// text.setAllowBlank(false);
// column2.setSortable(false);
TextField<String> textValue = new TextField<String>();
// text.setAllowBlank(false);
column.setEditor(new CellEditor(textValue));
configs.add(column);
@ -891,46 +902,47 @@ public class GxtBorderLayoutPanel extends ContentPanel {
ListStore<Result> store = new ListStore<Result>();
store.add(dataDB);
// Grid<Result> grid = new Grid<Result>(store,
// createColumnModelForDBInfo(dataDB));
EditorGrid<Result> grid = new EditorGrid<Result>(store,
createColumnModelForDBInfo(dataDB));
// Grid<Result> grid = new Grid<Result>(store,
// createColumnModelForDBInfo(dataDB));
EditorGrid<Result> grid = new EditorGrid<Result>(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<FileModel> 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<FileModel> 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<LinkedHashMap<String, FileModel>>() {
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<LinkedHashMap<String, FileModel>>() {
MessageBox.alert("Error ",
"<br/>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<String, FileModel> 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<String> keys = result.keySet();
Object[] array = keys.toArray();
// System.out.println("array size: " +
// array.length);
// recover details
List<Result> TableDetails = new ArrayList<Result>();
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 ",
"<br/>Message:" + caught.getMessage(), null);
}
}
});
@Override
public void onSuccess(
LinkedHashMap<String, FileModel> 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<String> keys = result.keySet();
Object[] array = keys.toArray();
// System.out.println("array size: " +
// array.length);
// recover details
List<Result> TableDetails = new ArrayList<Result>();
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<Result> 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<Result> store = new ListStore<Result>();
store.add(tableDetails);
// Grid<Result> grid = new Grid<Result>(store,
// createColumnModelForDBInfo(tableDetails));
// Grid<Result> grid = new Grid<Result>(store,
// createColumnModelForDBInfo(tableDetails));
EditorGrid<Result> grid = new EditorGrid<Result>(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();
}
}