paging implemeneted in a dialog
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@98561 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b1020383fc
commit
33da8115af
|
@ -6,11 +6,13 @@ import java.util.List;
|
|||
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||
|
||||
//import org.gcube.portlets.user.dbmanager.client.datamodel.FileModel;
|
||||
//import org.gcube.portlets.user.dbmanager.client.datamodel.Result;
|
||||
//import org.gcube.portlets.user.dbmanager.client.datamodel.Row;
|
||||
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
|
@ -20,8 +22,7 @@ public interface GWTdbManagerService extends RemoteService {
|
|||
|
||||
List<FileModel> getResource() throws Exception;
|
||||
|
||||
List<FileModel> getTables(LinkedHashMap<String, String> dataInput)
|
||||
throws Exception;
|
||||
|
||||
|
||||
LinkedHashMap<String, FileModel> getDBInfo(String resourceName)
|
||||
throws Exception;
|
||||
|
@ -45,5 +46,7 @@ public interface GWTdbManagerService extends RemoteService {
|
|||
|
||||
LinkedHashMap<String, FileModel> getTableDetails(LinkedHashMap<String, String> dataInput) throws Exception;
|
||||
|
||||
PagingLoadResult<Result> LoadTables(PagingLoadConfig config, LinkedHashMap<String, String> dataInput) throws Exception;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,11 +6,13 @@ import java.util.List;
|
|||
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||
|
||||
//import org.gcube.portlets.user.dbmanager.client.datamodel.FileModel;
|
||||
//import org.gcube.portlets.user.dbmanager.client.datamodel.Result;
|
||||
//import org.gcube.portlets.user.dbmanager.client.datamodel.Row;
|
||||
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public interface GWTdbManagerServiceAsync {
|
||||
|
@ -20,8 +22,10 @@ public interface GWTdbManagerServiceAsync {
|
|||
void getDBInfo(String resourceName,
|
||||
AsyncCallback<LinkedHashMap<String, FileModel>> asyncCallback);
|
||||
|
||||
void getTables(LinkedHashMap<String, String> dataInput,
|
||||
AsyncCallback<List<FileModel>> callback);
|
||||
// void getTables(LinkedHashMap<String, String> dataInput,
|
||||
// AsyncCallback<List<FileModel>> callback);
|
||||
|
||||
|
||||
|
||||
void getDBSchema(LinkedHashMap<String, String> dataInput,
|
||||
AsyncCallback<List<FileModel>> callback);
|
||||
|
@ -45,4 +49,7 @@ public interface GWTdbManagerServiceAsync {
|
|||
void randomSample(LinkedHashMap<String, String> dataInput,
|
||||
AsyncCallback<List<Result>> callback);
|
||||
|
||||
void LoadTables(PagingLoadConfig config, LinkedHashMap<String, String> dataInput,
|
||||
AsyncCallback<PagingLoadResult<Result>> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ public enum EventsTypeEnum {
|
|||
SHOW_CREATE_TABLE_EVENT,
|
||||
SAMPLING_EVENT,
|
||||
SMART_SAMPLING_EVENT,
|
||||
RANDOM_SAMPLING_EVENT;
|
||||
RANDOM_SAMPLING_EVENT,
|
||||
LOAD_TABLES_EVENT;
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.gcube.portlets.user.databasesmanager.client.events;
|
||||
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.LoadTablesEventHandler;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.RandomSamplingEventHandler;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
import com.google.gwt.event.shared.GwtEvent.Type;
|
||||
|
||||
public class LoadTablesEvent extends GwtEvent<LoadTablesEventHandler>{
|
||||
|
||||
public static Type<LoadTablesEventHandler> TYPE = new Type<LoadTablesEventHandler>();
|
||||
|
||||
@Override
|
||||
protected void dispatch(LoadTablesEventHandler handler) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
handler.onLoadTables(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<LoadTablesEventHandler> getAssociatedType() {
|
||||
// TODO Auto-generated method stub
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public EventsTypeEnum getKey() {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
return EventsTypeEnum.LOAD_TABLES_EVENT;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.gcube.portlets.user.databasesmanager.client.events.interfaces;
|
||||
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
public interface LoadTablesEventHandler extends EventHandler{
|
||||
public void onLoadTables(LoadTablesEvent loadTablesEvent);
|
||||
}
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.databasesmanager.client.panels;
|
|||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -12,12 +13,14 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
|||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.RandomSamplingEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.SamplingEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.SelectedItemEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.ShowCreateTableEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.SmartSamplingEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.SubmitQueryEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.LoadTablesEventHandler;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.RandomSamplingEventHandler;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SamplingEventHandler;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SelectedItemEventHandler;
|
||||
|
@ -40,15 +43,29 @@ import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
|||
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
||||
import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
|
||||
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
||||
import com.extjs.gxt.ui.client.widget.grid.LiveGridView;
|
||||
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
|
||||
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
||||
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
|
||||
import com.extjs.gxt.ui.client.widget.toolbar.LiveToolItem;
|
||||
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
|
||||
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
||||
import com.extjs.gxt.ui.client.data.BasePagingLoader;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoader;
|
||||
import com.extjs.gxt.ui.client.data.RpcProxy;
|
||||
import com.extjs.gxt.ui.client.event.Events;
|
||||
import com.extjs.gxt.ui.client.event.GridEvent;
|
||||
import com.extjs.gxt.ui.client.event.Listener;
|
||||
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
|
||||
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
||||
|
||||
//class that represents the container of all components
|
||||
public class GxtBorderLayoutPanel extends ContentPanel {
|
||||
|
@ -77,6 +94,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
// variable that keeps track of the managed event
|
||||
private boolean submitQueryEventManaged = false;
|
||||
|
||||
// private PagingToolBar toolBar = new PagingToolBar(100);
|
||||
|
||||
public GxtBorderLayoutPanel(HandlerManager eBus,
|
||||
GWTdbManagerServiceAsync service) throws Exception {
|
||||
|
||||
|
@ -151,6 +170,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
centerUpper.setHeading("Database Information");
|
||||
centerUpper.setScrollMode(Scroll.NONE);
|
||||
|
||||
// centerUpper.setBottomComponent(toolBar);
|
||||
// toolBar.hide();
|
||||
|
||||
|
||||
// CENTER BOTTOM
|
||||
|
||||
centerBottom = new ContentPanel();
|
||||
|
@ -297,6 +320,17 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
});
|
||||
|
||||
eventBus.addHandler(LoadTablesEvent.TYPE, new LoadTablesEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onLoadTables(LoadTablesEvent loadTablesEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
loadTables();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
eventBus.addHandler(SubmitQueryEvent.TYPE,
|
||||
new SubmitQueryEventHandler() {
|
||||
|
||||
|
@ -379,6 +413,306 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
}
|
||||
|
||||
private void loadTables() {
|
||||
|
||||
// System.out.println("Start RPC - loadTables");
|
||||
|
||||
rootLogger.log(Level.SEVERE, "Start RPC - loadTables");
|
||||
|
||||
// to mask the entire content panel
|
||||
|
||||
// this.mask("Loading", "x-mask-loading");
|
||||
|
||||
// get the selected item
|
||||
|
||||
List<FileModel> data = treePanel.getTreePanel().getSelectionModel()
|
||||
.getSelectedItems();
|
||||
|
||||
FileModel element = data.get(0);
|
||||
|
||||
// recover data inputs
|
||||
|
||||
final LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
|
||||
|
||||
// check if the table has an associated schema
|
||||
|
||||
String resource = "";
|
||||
String database = "";
|
||||
String schema = "";
|
||||
|
||||
if (element.isDatabase()) { // the selected item is a database
|
||||
|
||||
rootLogger.log(Level.INFO, "element is a database ");
|
||||
|
||||
database = element.getName();
|
||||
resource = treePanel.getTreeStore().getParent(element).getName();
|
||||
|
||||
dataInput.put("ResourceName", resource);
|
||||
dataInput.put("DatabaseName", database);
|
||||
dataInput.put("SchemaName", "");
|
||||
|
||||
} else { // the selected item is a schema
|
||||
|
||||
rootLogger.log(Level.INFO, "element is a schema ");
|
||||
|
||||
FileModel db = treePanel.getTreeStore().getParent(element);
|
||||
database = db.getName();
|
||||
|
||||
resource = treePanel.getTreeStore().getParent(db).getName();
|
||||
schema = element.getName();
|
||||
|
||||
dataInput.put("ResourceName", resource);
|
||||
dataInput.put("DatabaseName", database);
|
||||
dataInput.put("SchemaName", schema);
|
||||
|
||||
// dataInput.put("ResourceName", resource.getName());
|
||||
// dataInput.put("DatabaseName", database.getName());
|
||||
// dataInput.put("SchemaName", element.getName());
|
||||
|
||||
}
|
||||
|
||||
// FileModel database = store.getParent(element);
|
||||
// FileModel resource = store.getParent(database);
|
||||
//
|
||||
// dataInput.put("ResourceName", resource.getName());
|
||||
// dataInput.put("DatabaseName", database.getName());
|
||||
|
||||
// if (element.getDatabaseType().equals(ConstantsPortlet.POSTGRES)){
|
||||
//
|
||||
//
|
||||
// }
|
||||
// else{
|
||||
// dataInput.put("SchemaName", "");
|
||||
// }
|
||||
|
||||
// System.out.println("schema name: " + element.getName());
|
||||
|
||||
// rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
|
||||
// rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
|
||||
// rootLogger.log(Level.INFO, "SchemaName: " + element.getName());
|
||||
|
||||
rootLogger.log(Level.INFO, "ResourceName: " + resource);
|
||||
rootLogger.log(Level.INFO, "DatabaseName: " + database);
|
||||
rootLogger.log(Level.INFO, "SchemaName: " + schema);
|
||||
|
||||
// FileModel schema;
|
||||
// FileModel database;
|
||||
// FileModel resource;
|
||||
//
|
||||
// if (treePanel.getTreeStore().getParent(selectedItem).isDatabase()) {
|
||||
//
|
||||
// // the table has not a schema
|
||||
//
|
||||
// database = treePanel.getTreeStore().getParent(selectedItem);
|
||||
// resource = treePanel.getTreeStore().getParent(database);
|
||||
//
|
||||
// dataInput.put("ResourceName", resource.getName());
|
||||
// dataInput.put("DatabaseName", database.getName());
|
||||
// dataInput.put("SchemaName", "");
|
||||
// // dataInput.put("TableName", selectedItem.getName());
|
||||
//
|
||||
// rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
|
||||
// rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
|
||||
// rootLogger.log(Level.INFO, "SchemaName: " + selectedItem.getName());
|
||||
//
|
||||
// // schema = treePanel.getTreeStore().getParent(selectedItem);
|
||||
// // database = treePanel.getTreeStore().getParent(schema);
|
||||
// // resource = treePanel.getTreeStore().getParent(database);
|
||||
// //
|
||||
// // dataInput.put("ResourceName", resource.getName());
|
||||
// // dataInput.put("DatabaseName", database.getName());
|
||||
// // dataInput.put("SchemaName", schema.getName());
|
||||
// // dataInput.put("TableName", selectedItem.getName());
|
||||
// //
|
||||
// // rootLogger.log(Level.INFO, "ResourceName: " +
|
||||
// // resource.getName());
|
||||
// // rootLogger.log(Level.INFO, "DatabaseName: " +
|
||||
// // database.getName());
|
||||
// // rootLogger.log(Level.INFO, "SchemaName: " + schema.getName());
|
||||
// // rootLogger.log(Level.INFO, "SchemaName: " +
|
||||
// // selectedItem.getName());
|
||||
//
|
||||
// } else {
|
||||
// // the table has a schema
|
||||
//
|
||||
// schema = treePanel.getTreeStore().getParent(selectedItem);
|
||||
// database = treePanel.getTreeStore().getParent(schema);
|
||||
// resource = treePanel.getTreeStore().getParent(database);
|
||||
//
|
||||
// dataInput.put("ResourceName", resource.getName());
|
||||
// dataInput.put("DatabaseName", database.getName());
|
||||
// dataInput.put("SchemaName", schema.getName());
|
||||
// // dataInput.put("TableName", selectedItem.getName());
|
||||
//
|
||||
// rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
|
||||
// rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
|
||||
// rootLogger.log(Level.INFO, "SchemaName: " + schema.getName());
|
||||
// // rootLogger.log(Level.INFO, "SchemaName: " +
|
||||
// selectedItem.getName());
|
||||
//
|
||||
// // the table has not a schema
|
||||
// // database = treePanel.getTreeStore().getParent(selectedItem);
|
||||
// // resource = treePanel.getTreeStore().getParent(database);
|
||||
// //
|
||||
// // dataInput.put("ResourceName", resource.getName());
|
||||
// // dataInput.put("DatabaseName", database.getName());
|
||||
// // dataInput.put("SchemaName", "");
|
||||
// // dataInput.put("TableName", selectedItem.getName());
|
||||
// //
|
||||
// // rootLogger.log(Level.INFO, "ResourceName: " +
|
||||
// // resource.getName());
|
||||
// // rootLogger.log(Level.INFO, "DatabaseName: " +
|
||||
// // database.getName());
|
||||
// // rootLogger.log(Level.INFO, "SchemaName: " + "");
|
||||
// // rootLogger.log(Level.INFO, "SchemaName: " +
|
||||
// // selectedItem.getName());
|
||||
// }
|
||||
|
||||
// create RpcProxy object to use the load configuration
|
||||
|
||||
RpcProxy<PagingLoadResult<Result>> proxy = new RpcProxy<PagingLoadResult<Result>>() {
|
||||
|
||||
@Override
|
||||
protected void load(Object loadConfig,
|
||||
AsyncCallback<PagingLoadResult<Result>> callback) {
|
||||
|
||||
RPCservice.LoadTables((PagingLoadConfig) loadConfig, dataInput,
|
||||
callback);
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// loader to load page enabled set of data
|
||||
|
||||
final PagingLoader<PagingLoadResult<Result>> loader = new BasePagingLoader<PagingLoadResult<Result>>(
|
||||
proxy);
|
||||
// loader.setRemoteSort(true);
|
||||
|
||||
// to create the lsitstore using the loader
|
||||
|
||||
ListStore<Result> result = new ListStore<Result>(loader);
|
||||
|
||||
// bind the loader with a PagingToolBar.
|
||||
final PagingToolBar toolBar = new PagingToolBar(100);
|
||||
toolBar.bind(loader);
|
||||
|
||||
// craete the column configuration
|
||||
ColumnModel cm = createColumnModelForTables();
|
||||
|
||||
// create the grid with a result list and the column model
|
||||
|
||||
final Grid<Result> grid = new Grid<Result>(result, cm);
|
||||
|
||||
grid.setStateId("pagingGridExample");
|
||||
grid.setStateful(true);
|
||||
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
|
||||
public void handleEvent(GridEvent<Result> be) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
// grid.setLoadMask(true);
|
||||
grid.setBorders(true);
|
||||
// grid.setAutoExpandColumn("comments");
|
||||
// grid.setStyleAttribute("borderTop", "none");
|
||||
// grid.setStripeRows(true);
|
||||
|
||||
Dialog tablesLoaded = new Dialog();
|
||||
tablesLoaded.setLayout(new FitLayout());
|
||||
tablesLoaded.setHeading("Result");
|
||||
tablesLoaded.setResizable(false);
|
||||
|
||||
tablesLoaded.setModal(true);
|
||||
tablesLoaded.setBlinkModal(true);
|
||||
|
||||
tablesLoaded.setSize(600, 400);
|
||||
tablesLoaded.setScrollMode(Scroll.NONE);
|
||||
tablesLoaded.setHideOnButtonClick(true);
|
||||
tablesLoaded.setMaximizable(true);
|
||||
//
|
||||
tablesLoaded.setBottomComponent(toolBar);
|
||||
|
||||
// aggiungere la toolbart
|
||||
|
||||
// centerUpper.setBottomComponent(toolBar);
|
||||
|
||||
// LiveGridView liveView = new LiveGridView();
|
||||
// liveView.setEmptyText("No rows available on the server.");
|
||||
// liveView.setRowHeight(32);
|
||||
// grid.setView(liveView);
|
||||
//
|
||||
// ToolBar toolBar = new ToolBar();
|
||||
// toolBar.add(new FillToolItem());
|
||||
//
|
||||
// LiveToolItem item = new LiveToolItem();
|
||||
// item.bindGrid(grid);
|
||||
//
|
||||
// toolBar.add(item);
|
||||
// tablesLoaded.setBottomComponent(toolBar);
|
||||
|
||||
|
||||
// centerUpper.removeAll();
|
||||
|
||||
|
||||
// centerUpper.setBottomComponent(toolBar);
|
||||
|
||||
// ContentPanel tablesLoaded = new ContentPanel();
|
||||
// tablesLoaded.setLayout(new FitLayout());
|
||||
// tablesLoaded.setBottomComponent(toolBar);
|
||||
// tablesLoaded.add(grid);
|
||||
|
||||
// centerUpper.removeAll();
|
||||
|
||||
// centerUpper.add(tablesLoaded);
|
||||
// toolBar.show();
|
||||
// centerUpper.setBottomComponent(toolBar);
|
||||
// centerUpper.add(grid);
|
||||
// centerUpper.layout(true);
|
||||
|
||||
|
||||
// centerUpper.show();
|
||||
|
||||
// RowData d = new RowData(.5, 1);
|
||||
// d.setMargins(new Margins(6));
|
||||
|
||||
// tablesLoaded.add(grid, d);
|
||||
|
||||
tablesLoaded.add(grid);
|
||||
|
||||
tablesLoaded.show();
|
||||
|
||||
// ContentPanel panel = new ContentPanel();
|
||||
// panel.setFrame(true);
|
||||
// panel.setCollapsible(true);
|
||||
// panel.setAnimCollapse(false);
|
||||
//
|
||||
// panel.setHeading("Paging Grid");
|
||||
// panel.setLayout(new FitLayout());
|
||||
// panel.add(grid);
|
||||
// panel.setSize(600, 350);
|
||||
// panel.setBottomComponent(toolBar);
|
||||
// grid.getAriaSupport().setLabelledBy(panel.getId());
|
||||
// add(panel);
|
||||
|
||||
}
|
||||
|
||||
private void submitQuery() {
|
||||
|
||||
// System.out.println("Start RPC - submitQuery");
|
||||
|
@ -685,7 +1019,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), null);
|
||||
|
||||
if (obj.isMasked()){
|
||||
if (obj.isMasked()) {
|
||||
obj.unmask();
|
||||
}
|
||||
|
||||
|
@ -833,7 +1167,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), null);
|
||||
|
||||
if (obj.isMasked()){
|
||||
if (obj.isMasked()) {
|
||||
obj.unmask();
|
||||
}
|
||||
|
||||
|
@ -1310,6 +1644,37 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
return new ColumnModel(configs);
|
||||
}
|
||||
|
||||
private ColumnModel createColumnModelForTables() {
|
||||
|
||||
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||
|
||||
ColumnConfig column = new ColumnConfig();
|
||||
column.setId("index");
|
||||
column.setHeader("Index");
|
||||
column.setWidth(100);
|
||||
|
||||
configs.add(column);
|
||||
|
||||
column = new ColumnConfig();
|
||||
column.setId("value");
|
||||
column.setHeader("Name");
|
||||
column.setWidth(600);
|
||||
|
||||
// column2.setSortable(false);
|
||||
|
||||
TextField<String> textValue = new TextField<String>();
|
||||
// text.setAllowBlank(false);
|
||||
column.setEditor(new CellEditor(textValue));
|
||||
|
||||
configs.add(column);
|
||||
|
||||
// ListStore<Result> store = new ListStore<Result>();
|
||||
// store.add(result);
|
||||
|
||||
return new ColumnModel(configs);
|
||||
|
||||
}
|
||||
|
||||
private void displayDBInfo(FileModel element) {
|
||||
|
||||
// System.out.println("GxtBorderLayout->displaying info");
|
||||
|
@ -1320,35 +1685,36 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
List<Result> dataDB = element.getDBInfo();
|
||||
|
||||
if (dataDB!=null){
|
||||
if (dataDB != null) {
|
||||
|
||||
// System.out.println("GxtBorderLayout->size info: " + dataDB.size());
|
||||
// System.out.println("GxtBorderLayout->size info: " +
|
||||
// dataDB.size());
|
||||
|
||||
rootLogger.log(Level.INFO, "info size: " + dataDB.size());
|
||||
rootLogger.log(Level.INFO, "info size: " + dataDB.size());
|
||||
|
||||
ListStore<Result> store = new ListStore<Result>();
|
||||
store.add(dataDB);
|
||||
ListStore<Result> store = new ListStore<Result>();
|
||||
store.add(dataDB);
|
||||
|
||||
// Grid<Result> grid = new Grid<Result>(store,
|
||||
// createColumnModelForDBInfo(dataDB));
|
||||
// Grid<Result> grid = new Grid<Result>(store,
|
||||
// createColumnModelForDBInfo(dataDB));
|
||||
|
||||
EditorGrid<Result> grid = new EditorGrid<Result>(store,
|
||||
createColumnModelForDBInfo(dataDB));
|
||||
EditorGrid<Result> grid = new EditorGrid<Result>(store,
|
||||
createColumnModelForDBInfo(dataDB));
|
||||
|
||||
// grid.setAutoExpandColumn("name");
|
||||
grid.setBorders(true);
|
||||
// grid.setAutoExpandColumn("name");
|
||||
grid.setBorders(true);
|
||||
|
||||
// grid.setAutoWidth(true);
|
||||
// grid.setAutoWidth(true);
|
||||
|
||||
// RowData data = new RowData(.5, 1);
|
||||
// data.setMargins(new Margins(6));
|
||||
// RowData data = new RowData(.5, 1);
|
||||
// data.setMargins(new Margins(6));
|
||||
|
||||
centerUpper.removeAll();
|
||||
centerUpper.removeAll();
|
||||
|
||||
// centerUpper.add(grid, data);
|
||||
// centerUpper.add(grid, data);
|
||||
|
||||
centerUpper.add(grid);
|
||||
centerUpper.layout(true);
|
||||
centerUpper.add(grid);
|
||||
centerUpper.layout(true);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.logging.Logger;
|
|||
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.SelectedItemEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
||||
import com.extjs.gxt.ui.client.Style.SelectionMode;
|
||||
|
@ -707,6 +708,9 @@ public class GxtTreePanel extends LayoutContainer {
|
|||
|
||||
private void loadTables(final FileModel element) {
|
||||
|
||||
if (treePanel.isMasked())
|
||||
treePanel.unmask();
|
||||
|
||||
// System.out.println("Start RPC - getTables");
|
||||
|
||||
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getTables");
|
||||
|
@ -771,6 +775,8 @@ public class GxtTreePanel extends LayoutContainer {
|
|||
|
||||
if (element.isDatabase()) { // the selected item is a database
|
||||
|
||||
rootLogger.log(Level.INFO, "element is a database ");
|
||||
|
||||
database = element.getName();
|
||||
resource = store.getParent(element).getName();
|
||||
|
||||
|
@ -780,6 +786,8 @@ public class GxtTreePanel extends LayoutContainer {
|
|||
|
||||
} else { // the selected item is a schema
|
||||
|
||||
rootLogger.log(Level.INFO, "element is a schema ");
|
||||
|
||||
FileModel db = store.getParent(element);
|
||||
database = db.getName();
|
||||
|
||||
|
@ -824,102 +832,116 @@ public class GxtTreePanel extends LayoutContainer {
|
|||
// System.out.println(parent.getName());
|
||||
// System.out.println(element.getName());
|
||||
|
||||
// call remote service
|
||||
// // call remote service
|
||||
//
|
||||
// RPCservice.getTables(dataInput, new AsyncCallback<List<FileModel>>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// // Window.alert(caught.getMessage());
|
||||
// // System.out.println("FAILURE");
|
||||
// rootLogger.log(Level.SEVERE, "FAILURE RPC getTables");
|
||||
//
|
||||
// // no tables are available (the schema has not table)
|
||||
// if (caught.getMessage().equals(
|
||||
// "java.lang.Exception: Result not available")) {
|
||||
//
|
||||
// element.setIsExpanded(false);
|
||||
//
|
||||
// treePanel.setExpanded(element, false);
|
||||
//
|
||||
// element.setIsLoaded(true);
|
||||
//
|
||||
// if (treePanel.isMasked())
|
||||
// treePanel.unmask();
|
||||
//
|
||||
// treePanel.enableEvents(true);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(),
|
||||
// // null);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(List<FileModel> result) {
|
||||
//
|
||||
//
|
||||
//
|
||||
// // System.out.println("SUCCESS");
|
||||
//
|
||||
// rootLogger.log(Level.SEVERE, "SUCCESS RPC getTables");
|
||||
//
|
||||
// if (result.size() == 0) { // the database has not tables
|
||||
//
|
||||
// // System.out.println("the database has not tables");
|
||||
//
|
||||
// rootLogger.log(Level.SEVERE, "the database has not tables");
|
||||
//
|
||||
// // loadTables(element);
|
||||
//// element.setIsExpanded(false);
|
||||
////
|
||||
//// treePanel.setExpanded(element, false);
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// for (int i = 0; i < result.size(); i++) {
|
||||
//
|
||||
// result.get(i).setIsTable(true);
|
||||
//
|
||||
//// result.get(i).setIsExpanded(false);
|
||||
//
|
||||
// result.get(i).setIsLoaded(true);
|
||||
//
|
||||
// // result.get(i).setIsSchema(false);
|
||||
//
|
||||
// // element.setIsLoaded(true);
|
||||
//
|
||||
// // ppritn check
|
||||
// // System.out.println(result.get(i).getName());
|
||||
//
|
||||
// // rootLogger.log(Level.INFO, "table: "
|
||||
// // + result.get(i).getName());
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // int numChildrenFolder = store.getChildCount(element);
|
||||
//
|
||||
// // if (numChildrenFolder == 0) {
|
||||
//
|
||||
//
|
||||
// //addChildren(element, result);
|
||||
//
|
||||
// //
|
||||
//
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// element.setIsLoaded(true);
|
||||
//
|
||||
// element.setIsExpanded(false);
|
||||
// treePanel.setExpanded(element, false);
|
||||
//
|
||||
// if (treePanel.isMasked())
|
||||
// treePanel.unmask();
|
||||
//
|
||||
// treePanel.enableEvents(true);
|
||||
//
|
||||
// //fire event
|
||||
// eventBus.fireEvent(new LoadTablesEvent());
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// //System.out.println("End RPC - getTables");
|
||||
//
|
||||
// rootLogger.log(Level.SEVERE, "End RPC getTables");
|
||||
|
||||
RPCservice.getTables(dataInput, new AsyncCallback<List<FileModel>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
// System.out.println("FAILURE");
|
||||
rootLogger.log(Level.SEVERE, "FAILURE RPC getTables");
|
||||
|
||||
// no tables are available (the schema has not table)
|
||||
if (caught.getMessage().equals(
|
||||
"java.lang.Exception: Result not available")) {
|
||||
|
||||
element.setIsExpanded(false);
|
||||
|
||||
treePanel.setExpanded(element, false);
|
||||
|
||||
element.setIsLoaded(true);
|
||||
|
||||
if (treePanel.isMasked())
|
||||
treePanel.unmask();
|
||||
|
||||
treePanel.enableEvents(true);
|
||||
|
||||
}
|
||||
|
||||
// MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(),
|
||||
// null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<FileModel> result) {
|
||||
|
||||
|
||||
|
||||
// System.out.println("SUCCESS");
|
||||
|
||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC getTables");
|
||||
|
||||
if (result.size() == 0) { // the database has not tables
|
||||
|
||||
// System.out.println("the database has not tables");
|
||||
|
||||
rootLogger.log(Level.SEVERE, "the database has not tables");
|
||||
|
||||
// loadTables(element);
|
||||
element.setIsExpanded(false);
|
||||
|
||||
treePanel.setExpanded(element, false);
|
||||
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
|
||||
result.get(i).setIsTable(true);
|
||||
|
||||
result.get(i).setIsExpanded(false);
|
||||
|
||||
result.get(i).setIsLoaded(true);
|
||||
|
||||
// result.get(i).setIsSchema(false);
|
||||
|
||||
// element.setIsLoaded(true);
|
||||
|
||||
// ppritn check
|
||||
// System.out.println(result.get(i).getName());
|
||||
|
||||
// rootLogger.log(Level.INFO, "table: "
|
||||
// + result.get(i).getName());
|
||||
|
||||
}
|
||||
|
||||
// int numChildrenFolder = store.getChildCount(element);
|
||||
|
||||
// if (numChildrenFolder == 0) {
|
||||
|
||||
addChildren(element, result);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
element.setIsLoaded(true);
|
||||
|
||||
if (treePanel.isMasked())
|
||||
treePanel.unmask();
|
||||
|
||||
treePanel.enableEvents(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// System.out.println("End RPC - getTables");
|
||||
|
||||
rootLogger.log(Level.SEVERE, "End RPC getTables");
|
||||
//fire event to manage the tables loading
|
||||
eventBus.fireEvent(new LoadTablesEvent());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,9 @@ import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil;
|
|||
//import org.gcube.portlets.user.dbmanager.client.datamodel.Row;
|
||||
//import org.gcube.portlets.user.dbmanager.server.util.SessionUtil;
|
||||
|
||||
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
|
||||
|
@ -190,8 +193,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
inputParameters.get(i).setValue(resourceName);
|
||||
|
||||
|
||||
// rootLogger.log(Level.INFO, "ResourceName: " + resourceName);
|
||||
// rootLogger.log(Level.INFO, "ResourceName: " + resourceName);
|
||||
rootLogger.log(Level.INFO, inputParameters.get(i).getName());
|
||||
|
||||
}
|
||||
|
@ -276,12 +278,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.get(0).setValue(dataInput.get("ResourceName"));
|
||||
inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
|
||||
|
||||
rootLogger.log(Level.INFO, "ResourceName: " + dataInput.get("ResourceName"));
|
||||
|
||||
rootLogger.log(Level.INFO, "DatabaseName: " + dataInput.get("DatabaseName"));
|
||||
|
||||
|
||||
rootLogger.log(Level.INFO,
|
||||
"ResourceName: " + dataInput.get("ResourceName"));
|
||||
|
||||
rootLogger.log(Level.INFO,
|
||||
"DatabaseName: " + dataInput.get("DatabaseName"));
|
||||
|
||||
String computationId = startComputation(algorithmId, inputParameters);
|
||||
|
||||
|
@ -298,7 +299,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
FileModel obj = new FileModel(outputMap.get(String.valueOf(i)));
|
||||
|
||||
// obj.setIsSchema(true);
|
||||
// obj.setIsSchema(true);
|
||||
|
||||
// obj.setIsLoaded(true);
|
||||
|
||||
|
@ -310,15 +311,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileModel> getTables(LinkedHashMap<String, String> dataInput)
|
||||
private List<Result> getTables(LinkedHashMap<String, String> dataInput)
|
||||
throws Exception {
|
||||
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
|
||||
// List<String> outputParameters = new ArrayList<String>();
|
||||
|
||||
List<FileModel> outputParameters = new ArrayList<FileModel>();
|
||||
List<Result> outputParameters = new ArrayList<Result>();
|
||||
|
||||
// get list of algorithms
|
||||
|
||||
|
@ -362,11 +362,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
|
||||
inputParameters.get(2).setValue(dataInput.get("SchemaName"));
|
||||
|
||||
rootLogger.log(Level.SEVERE, "ResourceName: " + dataInput.get("ResourceName"));
|
||||
rootLogger.log(Level.SEVERE, "DatabaseName: " + dataInput.get("DatabaseName"));
|
||||
rootLogger.log(Level.SEVERE, "SchemaName: " + dataInput.get("SchemaName"));
|
||||
|
||||
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"ResourceName: " + dataInput.get("ResourceName"));
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"DatabaseName: " + dataInput.get("DatabaseName"));
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"SchemaName: " + dataInput.get("SchemaName"));
|
||||
|
||||
// System.out.println("size outputMap pre computation: "
|
||||
// + outputMap.size());
|
||||
|
@ -380,20 +381,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
rootLogger.log(Level.SEVERE, "output data retrieved");
|
||||
rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
|
||||
|
||||
// System.out.println("size outputMap: " + outputMap.size());
|
||||
// System.out.println("size outputMap: " + outputMap.size());
|
||||
|
||||
for (int i = 0; i < outputMap.size(); i++) {
|
||||
|
||||
// outputParameters.add(outputKey.get(String.valueOf(i)) + " "
|
||||
// + outputMap.get(String.valueOf(i)));
|
||||
|
||||
FileModel obj = new FileModel(outputMap.get(String.valueOf(i)));
|
||||
// FileModel obj = new FileModel(outputMap.get(String.valueOf(i)));
|
||||
|
||||
// obj.setIsLoaded(true);
|
||||
|
||||
// obj.setIsTable(true);
|
||||
|
||||
outputParameters.add(obj);
|
||||
Result row = new Result(String.valueOf(i), outputMap.get(String
|
||||
.valueOf(i)));
|
||||
|
||||
outputParameters.add(row);
|
||||
|
||||
}
|
||||
|
||||
|
@ -401,6 +405,35 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
|
||||
LinkedHashMap<String, String> dataInput) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// get tables
|
||||
List<Result> result = getTables(dataInput);
|
||||
|
||||
// Create a sublist and add data to list according
|
||||
// to the limit and offset value of the config
|
||||
|
||||
ArrayList<Result> sublist = new ArrayList<Result>();
|
||||
|
||||
int start = config.getOffset();
|
||||
int limit = result.size();
|
||||
|
||||
if (config.getLimit() > 0) {
|
||||
limit = Math.min(start + config.getLimit(), limit);
|
||||
}
|
||||
|
||||
for (int i = config.getOffset(); i < limit; i++) {
|
||||
sublist.add(result.get(i));
|
||||
}
|
||||
|
||||
return new BasePagingLoadResult<Result>(sublist,
|
||||
config.getOffset(), result.size());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Result> submitQuery(LinkedHashMap<String, String> dataDB,
|
||||
String query, boolean valueReadOnlyQuery,
|
||||
|
@ -466,7 +499,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
inputParameters.get(0).setValue(dataDB.get("ResourceName"));
|
||||
inputParameters.get(1).setValue(dataDB.get("DatabaseName"));
|
||||
|
||||
rootLogger.log(Level.INFO, "ResourceName " + dataDB.get("ResourceName"));
|
||||
rootLogger
|
||||
.log(Level.INFO, "ResourceName " + dataDB.get("ResourceName"));
|
||||
rootLogger.log(Level.INFO, "DatabaseName" + dataDB.get("DatabaseName"));
|
||||
|
||||
inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
|
||||
|
@ -600,7 +634,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public List<Result> smartSample(LinkedHashMap<String, String> dataInput)
|
||||
throws Exception {
|
||||
|
||||
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
|
||||
// sample result
|
||||
|
@ -1297,6 +1330,4 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue