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);
@ -727,7 +730,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// tablesLoaded.hide();
// MessageBox.alert("Error ", "<br/>Message:"
// MessageBox.alert("Error ",
// "<br/>Message:"
// + "no tables available", null);
// if
@ -750,6 +754,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (keyword == null) {
startSearchTable = false;
}
toolBarTop.enable();
}
});
@ -854,6 +861,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
grid.getSelectionModel().addSelectionChangedListener(
@ -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.
@ -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);
@ -1267,8 +1288,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
keyword = null;
startSearchTable = false;
// if ((grid.getState().containsKey("offset"))){
// rootLogger.log(Level.INFO, "setting the state");
//