171 lines
5.7 KiB
Java
171 lines
5.7 KiB
Java
package org.gcube.portlets.user.td.client;
|
|
|
|
import org.gcube.portlets.user.td.client.rpc.TabularDataService;
|
|
import org.gcube.portlets.user.td.client.rpc.TabularDataServiceAsync;
|
|
import org.gcube.portlets.user.td.client.toolbar.TabularDataTooBar;
|
|
import org.gcube.portlets.user.tdw.client.TabularData;
|
|
import org.gcube.portlets.user.tdw.client.TabularDataGridPanel;
|
|
import org.gcube.portlets.user.tdw.client.event.FailureEvent;
|
|
import org.gcube.portlets.user.tdw.client.event.FailureEventHandler;
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
import com.google.gwt.core.client.EntryPoint;
|
|
import com.google.gwt.core.client.GWT;
|
|
import com.google.gwt.core.client.Scheduler;
|
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
import com.google.gwt.user.client.ui.RootPanel;
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
import com.google.web.bindery.event.shared.EventBus;
|
|
import com.sencha.gxt.core.client.util.Margins;
|
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
|
import com.sencha.gxt.widget.core.client.TabPanel;
|
|
import com.sencha.gxt.widget.core.client.TabPanel.TabPanelAppearance;
|
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
|
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
|
|
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
|
|
import com.sencha.gxt.widget.core.client.container.MarginData;
|
|
import com.sencha.gxt.widget.core.client.container.NorthSouthContainer;
|
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
|
import com.sencha.gxt.widget.core.client.container.Viewport;
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|
import com.sencha.gxt.widget.core.client.info.Info;
|
|
|
|
/**
|
|
* Entry point classes define <code>onModuleLoad()</code>.
|
|
*/
|
|
public class TabularDataPortlet implements EntryPoint {
|
|
|
|
protected static final String JSP_TAG_ID = "tdp";
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public static final int TOOLBOX_WIDTH = 300;
|
|
/**
|
|
*
|
|
*/
|
|
public static final int TOOLBOX_HEIGHT= 800;
|
|
|
|
|
|
/**
|
|
* Create a remote service proxy to talk to the server-side Greeting service.
|
|
*/
|
|
private final TabularDataServiceAsync greetingService = GWT.create(TabularDataService.class);
|
|
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
@Override
|
|
public void onModuleLoad() {
|
|
/*
|
|
* Install an UncaughtExceptionHandler which will produce <code>FATAL</code> log messages
|
|
*/
|
|
Log.setUncaughtExceptionHandler();
|
|
|
|
// use deferred command to catch initialization exceptions in onModuleLoad2
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
@Override
|
|
public void execute() {
|
|
loadMainPanel();
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
protected void loadMainPanel() {
|
|
|
|
TabularDataController controller = new TabularDataController();
|
|
EventBus eventBus = controller.getEventBus();
|
|
|
|
final BorderLayoutContainer mainPanelLayout = new BorderLayoutContainer();
|
|
mainPanelLayout.setBorders(true);
|
|
|
|
TabularDataTooBar tabularDataTooBar = new TabularDataTooBar(eventBus);
|
|
Widget toolBarPanel = tabularDataTooBar.getContainer();
|
|
|
|
BorderLayoutData toolBarData = new BorderLayoutData(122);
|
|
toolBarData.setMargins(new Margins(5));
|
|
toolBarData.setCollapsible(false);
|
|
toolBarData.setSplit(false);
|
|
|
|
mainPanelLayout.setNorthWidget(toolBarPanel, toolBarData);
|
|
|
|
ContentPanel workspaceTreePanel = new ContentPanel();
|
|
workspaceTreePanel.setHeaderVisible(false);
|
|
|
|
/* AppControllerExplorer workspaceTree = new AppControllerExplorer();
|
|
ExplorerPanel explorerPanel = workspaceTree.getPanel();
|
|
AsyncTreePanel asyncTreePanel = explorerPanel.getAsycTreePanel();
|
|
asyncTreePanel.setSizeTreePanel(TOOLBOX_WIDTH, TOOLBOX_HEIGHT);
|
|
asyncTreePanel.setHeaderTreeVisible(false);
|
|
workspaceTreePanel.add(asyncTreePanel);*/
|
|
workspaceTreePanel.setHeaderVisible(true);
|
|
workspaceTreePanel.setHeadingText("Workspace Tree");
|
|
|
|
BorderLayoutData workspaceTreeData = new BorderLayoutData(TOOLBOX_WIDTH);
|
|
workspaceTreeData.setCollapsible(true);
|
|
workspaceTreeData.setSplit(true);
|
|
workspaceTreeData.setCollapseMini(true);
|
|
workspaceTreeData.setMargins(new Margins(0, 5, 0, 5));
|
|
|
|
mainPanelLayout.setWestWidget(workspaceTreePanel, workspaceTreeData);
|
|
|
|
final TabularData tabularData = new TabularData("SimpleJDBCDataSourceFactory");
|
|
tabularData.addFailureHandler(new FailureEventHandler() {
|
|
|
|
@Override
|
|
public void onFailure(FailureEvent event) {
|
|
Info.display("Error: "+event.getMessage(), event.getCaught().getMessage());
|
|
|
|
}
|
|
});
|
|
|
|
final TabularDataGridPanel grid = tabularData.getGridPanel();
|
|
|
|
MarginData gridData = new MarginData();
|
|
mainPanelLayout.setCenterWidget(grid, gridData);
|
|
|
|
|
|
SimpleContainer mainPanel = new SimpleContainer();
|
|
mainPanel.add(mainPanelLayout);
|
|
|
|
|
|
|
|
/*VerticalPanel mainPanel = new VerticalPanel();
|
|
|
|
TextButton button = new TextButton("Test");
|
|
button.addSelectHandler(new SelectHandler() {
|
|
|
|
@Override
|
|
public void onSelect(SelectEvent event) {
|
|
Info.display("Button event", "Button pressed");
|
|
}
|
|
});
|
|
mainPanel.add(button);*/
|
|
|
|
bind(mainPanel);
|
|
}
|
|
|
|
protected void bind(Widget mainWidget)
|
|
{
|
|
RootPanel root = RootPanel.get(JSP_TAG_ID);
|
|
if (root == null) {
|
|
Log.trace("Div with id "+JSP_TAG_ID+" not found, starting in dev mode");
|
|
Viewport viewport = new Viewport();
|
|
viewport.setWidget(mainWidget);
|
|
RootPanel.get().add(viewport);
|
|
} else {
|
|
Log.trace("Application div with id "+JSP_TAG_ID+" found, starting in portal mode");
|
|
PortalViewport viewport = new PortalViewport();
|
|
//viewport.setEnableScroll(true);
|
|
viewport.setWidget(mainWidget);
|
|
//RootPanel.get()
|
|
root.add(viewport);
|
|
}
|
|
}
|
|
}
|