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:
parent
6807afaf2c
commit
8412019b17
|
@ -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,30 +902,30 @@ 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));
|
||||||
|
|
||||||
// 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));
|
||||||
|
|
||||||
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,96 +986,109 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
.log(Level.INFO, "SchemaName: " + selectedTable.getName());
|
.log(Level.INFO, "SchemaName: " + selectedTable.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// call remote service
|
if (selectedTable.isTableDetailsDisplayed()) {
|
||||||
RPCservice.getTableDetails(dataInput,
|
|
||||||
new AsyncCallback<LinkedHashMap<String, FileModel>>() {
|
|
||||||
|
|
||||||
@Override
|
displayTableDetails(selectedTable);
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE,
|
} else {
|
||||||
"FAILURE RPC getTableDetails");
|
|
||||||
|
|
||||||
MessageBox.alert("Error ",
|
// call remote service
|
||||||
"<br/>Message:" + caught.getMessage(), null);
|
RPCservice.getTableDetails(dataInput,
|
||||||
|
new AsyncCallback<LinkedHashMap<String, FileModel>>() {
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
@Override
|
rootLogger.log(Level.SEVERE,
|
||||||
public void onSuccess(
|
"FAILURE RPC getTableDetails");
|
||||||
LinkedHashMap<String, FileModel> result) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
rootLogger.log(Level.SEVERE,
|
MessageBox.alert("Error ",
|
||||||
"SUCCESS RPC getTableDetails");
|
"<br/>Message:" + caught.getMessage(), null);
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,9 +1096,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue