top toolbar made disabled in the dialog that displays the tables list in order to disallow a user the table search.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@98776 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-07-18 09:42:27 +00:00
parent 38a7e3daa5
commit bc6775ffc5
1 changed files with 154 additions and 135 deletions

View File

@ -128,6 +128,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
private String keyword = "";
private boolean startSearchTable = false;
// toolbar for table search functionality
private ToolBar toolBarTop = null;
// private Grid<Result> grid;
// private PagingToolBar toolBar = new PagingToolBar(100);
@ -675,7 +678,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.SEVERE,
"FAILURE RPC getTables");
// caught.printStackTrace();
// caught.printStackTrace();
callback.onFailure(caught);
@ -725,10 +728,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// tablesLoaded.show();
// tablesLoaded.hide();
// tablesLoaded.hide();
// MessageBox.alert("Error ", "<br/>Message:"
// + "no tables available", null);
// MessageBox.alert("Error ",
// "<br/>Message:"
// + "no tables available", null);
// if
// (((EditorGrid<Result>)tablesLoaded.getWidget(0)).isMasked())
@ -750,6 +754,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (keyword == null) {
startSearchTable = false;
}
toolBarTop.enable();
}
});
@ -803,8 +810,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// grid = new Grid<Result>(result, cm);
// grid.setStateId("TablesList");
// grid.setStateful(true);
// grid.setStateId("TablesList");
// grid.setStateful(true);
grid.setLoadMask(true);
grid.setBorders(true);
@ -853,6 +860,104 @@ public class GxtBorderLayoutPanel extends ContentPanel {
//
// }
// });
// add the search functionality
// Top toolbar for search table functionality
// final ToolBar toolBarTop = new ToolBar();
toolBarTop = new ToolBar();
//TextField for specify the table name to search
final TextField<String> searchTable = new TextField<String>();
searchTable.setEmptyText("enter a text");
searchTable.setToolTip("search a table in the database");
searchTable.setAllowBlank(true);
// add the button search
final Button searchButton = new Button("", Images.iconSearch());
searchButton.setToolTip("Search");
// add the button cancel
Button cancel = new Button("", Images.iconCancel());
cancel.setToolTip("Cancel");
// add Buttons and TextField to the toolbar
toolBarTop.add(searchTable);
toolBarTop.add(searchButton);
toolBarTop.add(cancel);
searchButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// TODO Auto-generated method stub
// start search calling the rpc
// get the keyword
keyword = searchTable.getValue();
startSearchTable = true;
rootLogger.log(Level.INFO, "keyword: " + keyword);
rootLogger.log(Level.INFO, "Search Table: " + startSearchTable);
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(100);
// Map<String, Object> state = grid.getState();
// if (state.containsKey("offset")) {
// int offset = (Integer) state.get("offset");
// int limit = (Integer) state.get("limit");
// config.setOffset(offset);
// config.setLimit(limit);
// }
// if (state.containsKey("sortField")) {
// config.setSortField((String) state.get("sortField"));
// config.setSortDir(SortDir.valueOf((String) state
// .get("sortDir")));
// }
loader.load(config);
}
});
cancel.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// TODO Auto-generated method stub
keyword = null;
startSearchTable = false;
searchTable.clear();
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(100);
loader.load(config);
}
});
// "Enter" listener for the search table functionality
searchTable.addKeyListener(new KeyListener() {
@Override
public void componentKeyDown(ComponentEvent event) {
super.componentKeyDown(event);
if (event.getKeyCode() == KeyCodes.KEY_ENTER)
searchButton.fireEvent(Events.Select);
}
});
// listener to manage the table selection in the grid
@ -952,13 +1057,22 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
});
// this listener catch the Attach event.It fires when the selection of
// the Tables List button
// it seems to fire when the event source is attached to the browser's
// document or detached from it.
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
public void handleEvent(GridEvent<Result> be) {
rootLogger.log(Level.INFO, "event Attach handled");
// disable the top toolbar at the first tables loading in such a
// way to disallow a user the search. It will be enabled in the
// rpc when the tables are retrieved.
toolBarTop.disable();
// searchTable.disable();
PagingLoadConfig config = new BasePagingLoadConfig();
// The offset for the first record to retrieve.
@ -967,21 +1081,21 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// The number of records being requested.
config.setLimit(100);
// Map<String, Object> state = grid.getState();
// if (state.containsKey("offset")) {
//
//// rootLogger.log(Level.INFO, "state contains offset");
//
// int offset = (Integer) state.get("offset");
// rootLogger.log(Level.INFO, "offset: " + offset);
//
// int limit = (Integer) state.get("limit");
// rootLogger.log(Level.INFO, "limit: " + limit);
//
// config.setOffset(offset);
// config.setLimit(limit);
// }
// Map<String, Object> state = grid.getState();
// if (state.containsKey("offset")) {
//
// // rootLogger.log(Level.INFO, "state contains offset");
//
// int offset = (Integer) state.get("offset");
// rootLogger.log(Level.INFO, "offset: " + offset);
//
// int limit = (Integer) state.get("limit");
// rootLogger.log(Level.INFO, "limit: " + limit);
//
// config.setOffset(offset);
// config.setLimit(limit);
// }
// if (state.containsKey("sortField")) {
// config.setSortField((String) state.get("sortField"));
// config.setSortDir(SortDir.valueOf((String) state
@ -1080,7 +1194,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// Dialog tablesLoaded = new Dialog();
tablesLoaded = new Dialog();
tablesLoaded.setLayout(new FitLayout());
//ADD CANCEL BUTTON
// ADD CANCEL BUTTON
tablesLoaded.addButton(new Button("CANCEL"));
tablesLoaded.setHeading("Tables");
@ -1123,97 +1237,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// TextField<String> searchTable = new TextField<String>();
// searchTable.setFieldLabel("Search: ");
// Top toolbar
ToolBar toolBarTop = new ToolBar();
// add the search functionality
final TextField<String> searchTable = new TextField<String>();
searchTable.setEmptyText("enter a text");
searchTable.setToolTip("search a table in the database");
searchTable.setAllowBlank(true);
// add the button search
final Button searchButton = new Button("", Images.iconSearch());
searchButton.setToolTip("Search");
// add the button cancel
Button cancel = new Button("", Images.iconCancel());
cancel.setToolTip("Cancel");
// add Buttons and TextField to the toolbar
toolBarTop.add(searchTable);
toolBarTop.add(searchButton);
toolBarTop.add(cancel);
searchButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// TODO Auto-generated method stub
// start search calling the rpc
// get the keyword
keyword = searchTable.getValue();
startSearchTable = true;
rootLogger.log(Level.INFO, "keyword: " + keyword);
rootLogger.log(Level.INFO, "Search Table: " + startSearchTable);
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(100);
// Map<String, Object> state = grid.getState();
// if (state.containsKey("offset")) {
// int offset = (Integer) state.get("offset");
// int limit = (Integer) state.get("limit");
// config.setOffset(offset);
// config.setLimit(limit);
// }
// if (state.containsKey("sortField")) {
// config.setSortField((String) state.get("sortField"));
// config.setSortDir(SortDir.valueOf((String) state
// .get("sortDir")));
// }
loader.load(config);
}
});
cancel.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
// TODO Auto-generated method stub
keyword = null;
startSearchTable = false;
searchTable.clear();
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(100);
loader.load(config);
}
});
searchTable.addKeyListener(new KeyListener() {
@Override
public void componentKeyDown(ComponentEvent event) {
super.componentKeyDown(event);
if (event.getKeyCode() == KeyCodes.KEY_ENTER)
searchButton.fireEvent(Events.Select);
}
});
// searchTable.addListener(Events.KeyPress, new Listener<FieldEvent>() {
//
// @Override
@ -1246,8 +1269,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// tablesLoaded.add(toolBarTop);
// listener to manage the table selection in the grid
Button ok = (Button) tablesLoaded.getButtonBar().getWidget(0);
@ -1266,19 +1287,17 @@ public class GxtBorderLayoutPanel extends ContentPanel {
keyword = null;
startSearchTable = false;
// if ((grid.getState().containsKey("offset"))){
// rootLogger.log(Level.INFO, "setting the state");
//
// grid.getState().remove("offset");
// grid.getState().remove("limit");
//
//
// }
//
// grid.getState().clear();
// if ((grid.getState().containsKey("offset"))){
// rootLogger.log(Level.INFO, "setting the state");
//
// grid.getState().remove("offset");
// grid.getState().remove("limit");
//
//
// }
//
// grid.getState().clear();
if (selectedTable != null) {
@ -1339,9 +1358,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
keyword = null;
startSearchTable = false;
// rootLogger.log(Level.INFO, "setting the state");
// grid.getState().clear();
// rootLogger.log(Level.INFO, "setting the state");
// grid.getState().clear();
tablesLoaded.hide();
@ -1405,7 +1424,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
//
// }
// });
tablesLoaded.add(grid);
tablesLoaded.show();