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

@ -545,7 +545,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "ResourceName: " + resource);
rootLogger.log(Level.INFO, "DatabaseName: " + database);
rootLogger.log(Level.INFO, "SchemaName: " + schema);
tablesListNotNull = false;
// FileModel schema;
@ -621,8 +621,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // selectedItem.getName());
// }
// create RpcProxy object to use the load configuration
// RpcProxy<PagingLoadResult<Result>> proxy = new
@ -768,7 +766,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// create the grid with a result list and the column model
final EditorGrid<Result> grid = new EditorGrid<Result>(result, cm);
grid.setClicksToEdit(ClicksToEdit.TWO);
// final Grid<Result> grid = new Grid<Result>(result, cm);
@ -835,12 +833,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void selectionChanged(
SelectionChangedEvent<Result> se) {
// TODO Auto-generated method stub
selectedTable = grid.getSelectionModel()
.getSelectedItems().get(0).getValue();
rootLogger.log(Level.INFO, "table selected: "
+ selectedTable);
rootLogger.log(Level.INFO, "table selected: "
+ selectedTable);
}
});
@ -872,12 +872,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// System.out.println("table selected: " +
// be.getValue().toString());
// rootLogger.log(Level.INFO, "table selected: "
// + be.getValue().toString());
//
//
//
// selectedTable = be.getValue().toString();
// rootLogger.log(Level.INFO, "table selected: "
// + be.getValue().toString());
//
//
//
// selectedTable = be.getValue().toString();
rootLogger.log(Level.INFO, "table clicked: "
+ grid.getSelectionModel().getSelectedItems().get(0)
@ -886,8 +886,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
grid.getSelectionModel().select(
grid.getSelectionModel().getSelectedItems().get(0),
true);
// selectedTable = grid.getSelectionModel().getSelectedItems().get(0).getValue();
// selectedTable =
// grid.getSelectionModel().getSelectedItems().get(0).getValue();
// tablesLoaded.addListener(Events.Hide, new
// Listener<WindowEvent>() {
@ -909,26 +910,20 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
});
grid.addListener(Events.BeforeEdit, new Listener<GridEvent<Result>>() {
@Override
public void handleEvent(final GridEvent<Result> be) {
rootLogger.log(Level.INFO, "table edited: "
+ be.getValue().toString());
// selectedTable = be.getValue().toString();
rootLogger.log(Level.INFO, "table edited: "
+ be.getValue().toString());
// selectedTable = be.getValue().toString();
}
});
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
public void handleEvent(GridEvent<Result> be) {
@ -1068,58 +1063,60 @@ public class GxtBorderLayoutPanel extends ContentPanel {
Button cancel = (Button) tablesLoaded.getButtonBar().getWidget(1);
rootLogger.log(Level.INFO, "button: " + cancel.getText());
//listener for buttons
// listener for buttons
ok.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// TODO Auto-generated method stub
if (selectedTable != null){
//fire event
eventBus.fireEvent(new SelectedTableEvent());
if (selectedTable != null) {
// display the table in the panel "Database Information"
displayTableName(selectedTable);
// fire event
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());
//
// }
// };
// 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) {
//
// // MessageBox.alert("Information",
// // "The table "+selectedTable+ " was selected",
// // 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);
//
// }
// if (selectedTable != null) {
//
// // MessageBox.alert("Information",
// // "The table "+selectedTable+ " was selected",
// // 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,79 +1659,75 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // selectedItem.getName());
// }
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
//
// Button btn = be.getButtonClicked();
//
// if (btn.getText().equals("Yes")) {
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
//
// Button btn = be.getButtonClicked();
//
// if (btn.getText().equals("Yes")) {
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// call remote service
// call remote service
RPCservice.sample(dataInput,
new AsyncCallback<List<Result>>() {
RPCservice.sample(dataInput, new AsyncCallback<List<Result>>() {
@Override
public void onFailure(Throwable caught) {
@Override
public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
rootLogger.log(Level.SEVERE,
"FAILURE RPC sample");
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, "FAILURE RPC sample");
MessageBox.alert("Error ", "<br/>Message:"
+ caught.getMessage(), null);
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null);
if (obj.isMasked()) {
obj.unmask();
}
if (obj.isMasked()) {
obj.unmask();
}
}
}
@Override
public void onSuccess(List<Result> result) {
@Override
public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE,
"SUCCESS RPC sample");
rootLogger.log(Level.SEVERE, "SUCCESS RPC sample");
// rows = new ArrayList<Row>();
// rows = new ArrayList<Row>();
// System.out.println("result size: " +
// result.size());
// System.out.println("result size: " +
// result.size());
rootLogger.log(Level.SEVERE,
"output size: " + result.size());
rootLogger.log(Level.SEVERE, "output size: " + result.size());
// get the attributes list for the result
// table
getListAttributes(result.get(0).getValue());
// get the attributes list for the result
// table
getListAttributes(result.get(0).getValue());
// remove the header in order to parse only
// the result
result.remove(0);
// remove the header in order to parse only
// the result
result.remove(0);
// parse the result in order to obtain a
// table
parseResult(result);
// parse the result in order to obtain a
// table
parseResult(result);
}
}
});
});
// }
//
// }
//
// };
// }
//
// }
//
// };
// MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l);
// MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l);
}
@ -1917,78 +1910,74 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // selectedItem.getName());
// }
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
// Button btn = be.getButtonClicked();
//
// if (btn.getText().equals("Yes")) {
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
// Button btn = be.getButtonClicked();
//
// if (btn.getText().equals("Yes")) {
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// call remote service
// call remote service
RPCservice.smartSample(dataInput,
new AsyncCallback<List<Result>>() {
RPCservice.smartSample(dataInput, new AsyncCallback<List<Result>>() {
@Override
public void onFailure(Throwable caught) {
@Override
public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
rootLogger.log(Level.SEVERE,
"FAILURE RPC smartSample");
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, "FAILURE RPC smartSample");
MessageBox.alert("Error ", "<br/>Message:"
+ caught.getMessage(), null);
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null);
if (obj.isMasked()) {
obj.unmask();
}
if (obj.isMasked()) {
obj.unmask();
}
}
}
@Override
public void onSuccess(List<Result> result) {
@Override
public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE,
"SUCCESS RPC smartSample");
rootLogger.log(Level.SEVERE, "SUCCESS RPC smartSample");
// rows = new ArrayList<Row>();
// rows = new ArrayList<Row>();
// System.out.println("result size: " +
// result.size());
// System.out.println("result size: " +
// result.size());
rootLogger.log(Level.SEVERE,
"output size: " + result.size());
rootLogger.log(Level.SEVERE, "output size: " + result.size());
// get the attributes list for the result
// table
getListAttributes(result.get(0).getValue());
// get the attributes list for the result
// table
getListAttributes(result.get(0).getValue());
// remove the header in order to parse only
// the result
result.remove(0);
// remove the header in order to parse only
// the result
result.remove(0);
// parse the result in order to obtain a
// table
parseResult(result);
// parse the result in order to obtain a
// table
parseResult(result);
}
}
});
});
// }
//
// }
//
// };
//
// MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l);
// }
//
// }
//
// };
//
// MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l);
}
@ -2171,79 +2160,75 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // selectedItem.getName());
// }
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
//
// Button btn = be.getButtonClicked();
//
// if (btn.getText().equals("Yes")) {
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
//
// Button btn = be.getButtonClicked();
//
// if (btn.getText().equals("Yes")) {
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// to mask the entire content panel
obj.mask("Sampling the table", "x-mask-loading");
// call remote service
// call remote service
RPCservice.randomSample(dataInput,
new AsyncCallback<List<Result>>() {
RPCservice.randomSample(dataInput, new AsyncCallback<List<Result>>() {
@Override
public void onFailure(Throwable caught) {
@Override
public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
rootLogger.log(Level.SEVERE,
"FAILURE RPC randomSample");
// Window.alert(caught.getMessage());
// System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, "FAILURE RPC randomSample");
MessageBox.alert("Error ", "<br/>Message:"
+ caught.getMessage(), null);
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null);
if (obj.isMasked()) {
obj.unmask();
}
if (obj.isMasked()) {
obj.unmask();
}
}
}
@Override
public void onSuccess(List<Result> result) {
@Override
public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE,
"SUCCESS RPC randomSample");
rootLogger.log(Level.SEVERE, "SUCCESS RPC randomSample");
// rows = new ArrayList<Row>();
// rows = new ArrayList<Row>();
// System.out.println("result size: " +
// result.size());
// System.out.println("result size: " +
// result.size());
rootLogger.log(Level.SEVERE,
"output size: " + result.size());
rootLogger.log(Level.SEVERE, "output size: " + result.size());
// get the attributes list for the result
// table
getListAttributes(result.get(0).getValue());
// get the attributes list for the result
// table
getListAttributes(result.get(0).getValue());
// remove the header in order to parse only
// the result
result.remove(0);
// remove the header in order to parse only
// the result
result.remove(0);
// parse the result in order to obtain a
// table
parseResult(result);
// parse the result in order to obtain a
// table
parseResult(result);
}
}
});
});
// }
//
// }
//
// };
// }
//
// }
//
// };
// MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l);
// MessageBox.confirm("Confirm", "Are you sure you want to sample the "
// + selectedTable + " table?", l);
}
@ -2606,8 +2591,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
EditorGrid<Result> grid = new EditorGrid<Result>(store,
createColumnModelForDBInfo(dataDB));
// grid.setAutoExpandColumn("name");
grid.setBorders(true);
@ -2817,170 +2800,143 @@ public class GxtBorderLayoutPanel extends ContentPanel {
displayTableDetails(Table);
}
else {
//
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
//
// Button btn = be.getButtonClicked();
//
// if (btn.getText().equals("Yes")) {
} else {
//
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
//
// @Override
// public void handleEvent(MessageBoxEvent be) {
// // TODO Auto-generated method stub
//
// Button btn = be.getButtonClicked();
//
// 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
RPCservice
.getTableDetails(
dataInput,
new AsyncCallback<LinkedHashMap<String, FileModel>>() {
// call remote service
RPCservice.getTableDetails(dataInput,
new AsyncCallback<LinkedHashMap<String, FileModel>>() {
@Override
public void onFailure(
Throwable caught) {
// TODO Auto-generated method
// stub
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method
// stub
rootLogger
.log(Level.SEVERE,
"FAILURE RPC getTableDetails");
rootLogger.log(Level.SEVERE,
"FAILURE RPC getTableDetails");
MessageBox
.alert("Error ",
"<br/>Message:"
+ caught.getMessage(),
null);
MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null);
if (obj.isMasked()) {
obj.unmask();
}
if (obj.isMasked()) {
obj.unmask();
}
}
}
@Override
public void onSuccess(
LinkedHashMap<String, FileModel> result) {
// TODO Auto-generated method
// stub
@Override
public void onSuccess(
LinkedHashMap<String, FileModel> result) {
// TODO Auto-generated method
// stub
rootLogger
.log(Level.SEVERE,
"SUCCESS RPC getTableDetails");
rootLogger.log(Level.SEVERE,
"SUCCESS RPC getTableDetails");
// details are recovered about
// the selected table
// details are recovered about
// the selected table
if (result.size() != 0) {
if (result.size() != 0) {
// recover keys from the
// result
// recover keys from the
// result
Set<String> keys = result
.keySet();
Set<String> keys = result.keySet();
Object[] array = keys
.toArray();
Object[] array = keys.toArray();
// System.out.println("array size: "
// +
// array.length);
// System.out.println("array size: "
// +
// array.length);
// recover details
// recover details
List<Result> TableDetails = new ArrayList<Result>();
List<Result> TableDetails = new ArrayList<Result>();
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
Result row = new Result(
"CreateTable",
result.get(
array[i].toString())
.getName());
Result row = new Result("CreateTable",
result.get(array[i].toString())
.getName());
TableDetails
.add(row);
TableDetails.add(row);
}
}
if (array[i]
.toString()
.contains(
"Column Names")) {
if (array[i].toString().contains(
"Column Names")) {
// recover the
// column names
// recover the
// column names
Result row = new Result(
"Column Names",
result.get(
array[i].toString())
.getName());
Result row = new Result("Column Names",
result.get(array[i].toString())
.getName());
TableDetails
.add(row);
TableDetails.add(row);
}
}
if (array[i]
.toString()
.contains(
"NumberRows")) {
if (array[i].toString().contains(
"NumberRows")) {
// recover the
// column names
// recover the
// column names
Result row = new Result(
"NumberRows",
result.get(
array[i].toString())
.getName());
Result row = new Result("NumberRows",
result.get(array[i].toString())
.getName());
TableDetails
.add(row);
TableDetails.add(row);
}
}
}
}
Table.setTableDetails(TableDetails);
Table.setTableDetails(TableDetails);
displayTableDetails(Table);
displayTableDetails(Table);
Table.setTableDetailsDisplayed(true);
Table.setTableDetailsDisplayed(true);
}
}
// if (obj.isMasked()) {
// obj.unmask();
// }
// if (obj.isMasked()) {
// obj.unmask();
// }
}
});
}
});
// }
//
// }
//
// };
// }
//
// }
//
// };
// MessageBox.confirm("Confirm",
// "Are you sure you want to get details for " + selectedTable
// + " table?", l);
// MessageBox.confirm("Confirm",
// "Are you sure you want to get details for " + selectedTable
// + " table?", l);
// // call remote service
// 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);
}
}