table name displayed in the panel "Database Information"

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@98662 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-07-15 16:43:38 +00:00
parent 8e9323bbd8
commit 421387df68
1 changed files with 354 additions and 352 deletions

View File

@ -621,8 +621,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // selectedItem.getName()); // // selectedItem.getName());
// } // }
// create RpcProxy object to use the load configuration // create RpcProxy object to use the load configuration
// RpcProxy<PagingLoadResult<Result>> proxy = new // RpcProxy<PagingLoadResult<Result>> proxy = new
@ -842,6 +840,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "table selected: " rootLogger.log(Level.INFO, "table selected: "
+ selectedTable); + selectedTable);
} }
}); });
@ -872,12 +872,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// System.out.println("table selected: " + // System.out.println("table selected: " +
// be.getValue().toString()); // be.getValue().toString());
// rootLogger.log(Level.INFO, "table selected: " // rootLogger.log(Level.INFO, "table selected: "
// + be.getValue().toString()); // + be.getValue().toString());
// //
// //
// //
// selectedTable = be.getValue().toString(); // selectedTable = be.getValue().toString();
rootLogger.log(Level.INFO, "table clicked: " rootLogger.log(Level.INFO, "table clicked: "
+ grid.getSelectionModel().getSelectedItems().get(0) + grid.getSelectionModel().getSelectedItems().get(0)
@ -887,7 +887,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
grid.getSelectionModel().getSelectedItems().get(0), grid.getSelectionModel().getSelectedItems().get(0),
true); true);
// selectedTable = grid.getSelectionModel().getSelectedItems().get(0).getValue(); // selectedTable =
// grid.getSelectionModel().getSelectedItems().get(0).getValue();
// tablesLoaded.addListener(Events.Hide, new // tablesLoaded.addListener(Events.Hide, new
// Listener<WindowEvent>() { // Listener<WindowEvent>() {
@ -910,7 +911,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
}); });
grid.addListener(Events.BeforeEdit, new Listener<GridEvent<Result>>() { grid.addListener(Events.BeforeEdit, new Listener<GridEvent<Result>>() {
@Override @Override
@ -919,16 +919,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "table edited: " rootLogger.log(Level.INFO, "table edited: "
+ be.getValue().toString()); + be.getValue().toString());
// selectedTable = be.getValue().toString();
// selectedTable = be.getValue().toString();
} }
}); });
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() { grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
public void handleEvent(GridEvent<Result> be) { public void handleEvent(GridEvent<Result> be) {
@ -1069,7 +1064,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
Button cancel = (Button) tablesLoaded.getButtonBar().getWidget(1); Button cancel = (Button) tablesLoaded.getButtonBar().getWidget(1);
rootLogger.log(Level.INFO, "button: " + cancel.getText()); rootLogger.log(Level.INFO, "button: " + cancel.getText());
//listener for buttons // listener for buttons
ok.addSelectionListener(new SelectionListener<ButtonEvent>() { ok.addSelectionListener(new SelectionListener<ButtonEvent>() {
@ -1077,49 +1072,51 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
if (selectedTable != null){ if (selectedTable != null) {
//fire event // display the table in the panel "Database Information"
displayTableName(selectedTable);
// fire event
eventBus.fireEvent(new SelectedTableEvent()); eventBus.fireEvent(new SelectedTableEvent());
} }
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>()
// {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
//
// // rootLogger.log(Level.INFO, "button clicked");
//
// eventBus.fireEvent(new SelectedTableEvent());
//
// }
// };
// if (selectedTable != null) {
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() { //
// // // MessageBox.alert("Information",
// @Override // // "The table "+selectedTable+ " was selected",
// public void handleEvent(MessageBoxEvent be) { // // null);
// // TODO Auto-generated method stub //
// // MessageBox.info("Information", "The table " + selectedTable
// // rootLogger.log(Level.INFO, "button clicked"); // + " was selected", l);
// //
// eventBus.fireEvent(new SelectedTableEvent()); // // eventBus.fireEvent(new SelectedTableEvent());
// //
// } // } else {
// }; //
// // MessageBox.alert("Warning",
// if (selectedTable != null) { // // "No table "+selectedTable+ " was selected",
// // // null);
// // MessageBox.alert("Information", //
// // "The table "+selectedTable+ " was selected", // MessageBox.info("Information", "No table was selected",
// // null); // null);
// //
// MessageBox.info("Information", "The table " + selectedTable // }
// + " was selected", l);
//
// // eventBus.fireEvent(new SelectedTableEvent());
//
// } else {
//
// // MessageBox.alert("Warning",
// // "No table "+selectedTable+ " was selected",
// // null);
//
// MessageBox.info("Information", "No table was selected",
// null);
//
// }
} }
}); });
@ -1662,34 +1659,32 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // selectedItem.getName()); // // selectedItem.getName());
// } // }
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() { // Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
// //
// @Override // @Override
// public void handleEvent(MessageBoxEvent be) { // public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub // // TODO Auto-generated method stub
// //
// Button btn = be.getButtonClicked(); // Button btn = be.getButtonClicked();
// //
// if (btn.getText().equals("Yes")) { // if (btn.getText().equals("Yes")) {
// to mask the entire content panel // to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading"); obj.mask("Sampling the table", "x-mask-loading");
// call remote service // call remote service
RPCservice.sample(dataInput, RPCservice.sample(dataInput, new AsyncCallback<List<Result>>() {
new AsyncCallback<List<Result>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage()); // Window.alert(caught.getMessage());
// System.out.println("FAILURE"); // System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "FAILURE RPC sample");
"FAILURE RPC sample");
MessageBox.alert("Error ", "<br/>Message:" MessageBox.alert("Error ",
+ caught.getMessage(), null); "<br/>Message:" + caught.getMessage(), null);
if (obj.isMasked()) { if (obj.isMasked()) {
obj.unmask(); obj.unmask();
@ -1700,16 +1695,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
@Override @Override
public void onSuccess(List<Result> result) { public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "SUCCESS RPC sample");
"SUCCESS RPC sample");
// rows = new ArrayList<Row>(); // rows = new ArrayList<Row>();
// System.out.println("result size: " + // System.out.println("result size: " +
// result.size()); // result.size());
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "output size: " + result.size());
"output size: " + result.size());
// get the attributes list for the result // get the attributes list for the result
// table // table
@ -1727,14 +1720,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}); });
// } // }
// //
// } // }
// //
// }; // };
// MessageBox.confirm("Confirm", "Are you sure you want to sample the " // MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l); // + selectedTable + " table?", l);
} }
@ -1917,33 +1910,31 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // selectedItem.getName()); // // selectedItem.getName());
// } // }
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() { // Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
// //
// @Override // @Override
// public void handleEvent(MessageBoxEvent be) { // public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub // // TODO Auto-generated method stub
// Button btn = be.getButtonClicked(); // Button btn = be.getButtonClicked();
// //
// if (btn.getText().equals("Yes")) { // if (btn.getText().equals("Yes")) {
// to mask the entire content panel // to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading"); obj.mask("Sampling the table", "x-mask-loading");
// call remote service // call remote service
RPCservice.smartSample(dataInput, RPCservice.smartSample(dataInput, new AsyncCallback<List<Result>>() {
new AsyncCallback<List<Result>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage()); // Window.alert(caught.getMessage());
// System.out.println("FAILURE"); // System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "FAILURE RPC smartSample");
"FAILURE RPC smartSample");
MessageBox.alert("Error ", "<br/>Message:" MessageBox.alert("Error ",
+ caught.getMessage(), null); "<br/>Message:" + caught.getMessage(), null);
if (obj.isMasked()) { if (obj.isMasked()) {
obj.unmask(); obj.unmask();
@ -1954,16 +1945,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
@Override @Override
public void onSuccess(List<Result> result) { public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "SUCCESS RPC smartSample");
"SUCCESS RPC smartSample");
// rows = new ArrayList<Row>(); // rows = new ArrayList<Row>();
// System.out.println("result size: " + // System.out.println("result size: " +
// result.size()); // result.size());
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "output size: " + result.size());
"output size: " + result.size());
// get the attributes list for the result // get the attributes list for the result
// table // table
@ -1981,14 +1970,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}); });
// } // }
// //
// } // }
// //
// }; // };
// //
// MessageBox.confirm("Confirm", "Are you sure you want to sample the " // MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l); // + selectedTable + " table?", l);
} }
@ -2171,34 +2160,32 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // selectedItem.getName()); // // selectedItem.getName());
// } // }
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() { // Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
// //
// @Override // @Override
// public void handleEvent(MessageBoxEvent be) { // public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub // // TODO Auto-generated method stub
// //
// Button btn = be.getButtonClicked(); // Button btn = be.getButtonClicked();
// //
// if (btn.getText().equals("Yes")) { // if (btn.getText().equals("Yes")) {
// to mask the entire content panel // to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading"); obj.mask("Sampling the table", "x-mask-loading");
// call remote service // call remote service
RPCservice.randomSample(dataInput, RPCservice.randomSample(dataInput, new AsyncCallback<List<Result>>() {
new AsyncCallback<List<Result>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage()); // Window.alert(caught.getMessage());
// System.out.println("FAILURE"); // System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "FAILURE RPC randomSample");
"FAILURE RPC randomSample");
MessageBox.alert("Error ", "<br/>Message:" MessageBox.alert("Error ",
+ caught.getMessage(), null); "<br/>Message:" + caught.getMessage(), null);
if (obj.isMasked()) { if (obj.isMasked()) {
obj.unmask(); obj.unmask();
@ -2209,16 +2196,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
@Override @Override
public void onSuccess(List<Result> result) { public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "SUCCESS RPC randomSample");
"SUCCESS RPC randomSample");
// rows = new ArrayList<Row>(); // rows = new ArrayList<Row>();
// System.out.println("result size: " + // System.out.println("result size: " +
// result.size()); // result.size());
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE, "output size: " + result.size());
"output size: " + result.size());
// get the attributes list for the result // get the attributes list for the result
// table // table
@ -2236,14 +2221,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}); });
// } // }
// //
// } // }
// //
// }; // };
// MessageBox.confirm("Confirm", "Are you sure you want to sample the " // MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l); // + selectedTable + " table?", l);
} }
@ -2607,8 +2592,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
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);
@ -2817,44 +2800,36 @@ public class GxtBorderLayoutPanel extends ContentPanel {
displayTableDetails(Table); displayTableDetails(Table);
} } else {
else { //
// // Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() { //
// // @Override
// @Override // public void handleEvent(MessageBoxEvent be) {
// public void handleEvent(MessageBoxEvent be) { // // TODO Auto-generated method stub
// // TODO Auto-generated method stub //
// // Button btn = be.getButtonClicked();
// Button btn = be.getButtonClicked(); //
// // if (btn.getText().equals("Yes")) {
// if (btn.getText().equals("Yes")) {
// to mask the entire content panel // to mask the entire content panel
obj.mask("Loading details", "x-mask-loading"); obj.mask("Loading details", "x-mask-loading");
// call remote service // call remote service
RPCservice RPCservice.getTableDetails(dataInput,
.getTableDetails(
dataInput,
new AsyncCallback<LinkedHashMap<String, FileModel>>() { new AsyncCallback<LinkedHashMap<String, FileModel>>() {
@Override @Override
public void onFailure( public void onFailure(Throwable caught) {
Throwable caught) {
// TODO Auto-generated method // TODO Auto-generated method
// stub // stub
rootLogger rootLogger.log(Level.SEVERE,
.log(Level.SEVERE,
"FAILURE RPC getTableDetails"); "FAILURE RPC getTableDetails");
MessageBox MessageBox.alert("Error ",
.alert("Error ", "<br/>Message:" + caught.getMessage(), null);
"<br/>Message:"
+ caught.getMessage(),
null);
if (obj.isMasked()) { if (obj.isMasked()) {
obj.unmask(); obj.unmask();
@ -2868,8 +2843,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// TODO Auto-generated method // TODO Auto-generated method
// stub // stub
rootLogger rootLogger.log(Level.SEVERE,
.log(Level.SEVERE,
"SUCCESS RPC getTableDetails"); "SUCCESS RPC getTableDetails");
// details are recovered about // details are recovered about
@ -2880,11 +2854,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// recover keys from the // recover keys from the
// result // result
Set<String> keys = result Set<String> keys = result.keySet();
.keySet();
Object[] array = keys Object[] array = keys.toArray();
.toArray();
// System.out.println("array size: " // System.out.println("array size: "
// + // +
@ -2894,64 +2866,48 @@ public class GxtBorderLayoutPanel extends ContentPanel {
List<Result> TableDetails = new ArrayList<Result>(); List<Result> TableDetails = new ArrayList<Result>();
for (int i = 0; i < result for (int i = 0; i < result.size(); i++) {
.size(); i++) {
if (array[i] if (array[i].toString().contains(
.toString()
.contains(
"CreateTable")) { "CreateTable")) {
// recover the // recover the
// showCreateTable // showCreateTable
// statement // statement
Result row = new Result( Result row = new Result("CreateTable",
"CreateTable", result.get(array[i].toString())
result.get(
array[i].toString())
.getName()); .getName());
TableDetails TableDetails.add(row);
.add(row);
} }
if (array[i] if (array[i].toString().contains(
.toString()
.contains(
"Column Names")) { "Column Names")) {
// recover the // recover the
// column names // column names
Result row = new Result( Result row = new Result("Column Names",
"Column Names", result.get(array[i].toString())
result.get(
array[i].toString())
.getName()); .getName());
TableDetails TableDetails.add(row);
.add(row);
} }
if (array[i] if (array[i].toString().contains(
.toString()
.contains(
"NumberRows")) { "NumberRows")) {
// recover the // recover the
// column names // column names
Result row = new Result( Result row = new Result("NumberRows",
"NumberRows", result.get(array[i].toString())
result.get(
array[i].toString())
.getName()); .getName());
TableDetails TableDetails.add(row);
.add(row);
} }
@ -2972,15 +2928,15 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
}); });
// } // }
// //
// } // }
// //
// }; // };
// MessageBox.confirm("Confirm", // MessageBox.confirm("Confirm",
// "Are you sure you want to get details for " + selectedTable // "Are you sure you want to get details for " + selectedTable
// + " table?", l); // + " table?", l);
// // call remote service // // call remote service
// RPCservice.getTableDetails(dataInput, // RPCservice.getTableDetails(dataInput,
@ -3132,4 +3088,50 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
private void displayTableName(String tableName) {
rootLogger.log(Level.INFO, "displaying table name" + table
+ " in the panel");
Result table = new Result("The selected table is:", tableName);
// create column configuration
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("index");
column.setHeader("Description");
column.setWidth(200);
configs.add(column);
column = new ColumnConfig();
column.setId("value");
column.setHeader("Value");
column.setWidth(600);
TextField<String> textValue = new TextField<String>();
// text.setAllowBlank(false);
column.setEditor(new CellEditor(textValue));
configs.add(column);
ColumnModel cm = new ColumnModel(configs);
ListStore<Result> store = new ListStore<Result>();
store.add(table);
//grid
EditorGrid<Result> grid = new EditorGrid<Result>(store,cm);
//display information in the panel
centerUpper.removeAll();
centerUpper.add(grid);
centerUpper.layout(true);
}
} }