2013-03-15 17:32:47 +01:00
|
|
|
package org.gcube.portlets.user.td.client;
|
|
|
|
|
2016-04-13 16:22:57 +02:00
|
|
|
|
2013-09-16 11:43:07 +02:00
|
|
|
import org.gcube.portlets.user.td.client.ribbon.TabularDataRibbon;
|
2014-10-15 18:45:45 +02:00
|
|
|
import org.gcube.portlets.user.td.mainboxwidget.client.MainBoxPanel;
|
2013-12-11 14:28:10 +01:00
|
|
|
import org.gcube.portlets.user.td.toolboxwidget.client.ToolBoxPanel;
|
2013-12-16 13:08:05 +01:00
|
|
|
|
2013-03-15 17:32:47 +01:00
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
|
|
import com.google.gwt.core.client.EntryPoint;
|
|
|
|
import com.google.gwt.core.client.Scheduler;
|
|
|
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
|
|
|
import com.google.gwt.user.client.ui.RootPanel;
|
2013-05-14 14:26:16 +02:00
|
|
|
import com.google.web.bindery.event.shared.EventBus;
|
|
|
|
import com.sencha.gxt.core.client.util.Margins;
|
2013-09-27 17:35:58 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.TabPanel;
|
2013-05-14 14:26:16 +02:00
|
|
|
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;
|
2013-03-15 17:32:47 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.container.Viewport;
|
2013-11-27 16:56:24 +01:00
|
|
|
|
2013-03-15 17:32:47 +01:00
|
|
|
/**
|
2013-11-27 16:56:24 +01:00
|
|
|
*
|
2013-12-06 18:25:33 +01:00
|
|
|
* @author "Giancarlo Panichi" <a
|
|
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
|
|
*
|
2013-03-15 17:32:47 +01:00
|
|
|
*/
|
|
|
|
public class TabularDataPortlet implements EntryPoint {
|
|
|
|
|
2015-02-12 12:54:34 +01:00
|
|
|
private static final String JSP_TAG_ID = "tdp";
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2013-03-15 17:32:47 +01:00
|
|
|
|
2013-10-15 19:36:36 +02:00
|
|
|
// Main Panel
|
2013-10-14 16:09:43 +02:00
|
|
|
private static BorderLayoutContainer mainPanelLayout;
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2014-10-31 15:57:00 +01:00
|
|
|
|
2013-03-15 17:32:47 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public void onModuleLoad() {
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2013-03-15 17:32:47 +01:00
|
|
|
/*
|
2013-10-15 19:36:36 +02:00
|
|
|
* Install an UncaughtExceptionHandler which will produce
|
|
|
|
* <code>FATAL</code> log messages
|
2013-03-15 17:32:47 +01:00
|
|
|
*/
|
|
|
|
Log.setUncaughtExceptionHandler();
|
|
|
|
|
2013-10-15 19:36:36 +02:00
|
|
|
// use deferred command to catch initialization exceptions in
|
|
|
|
// onModuleLoad2
|
2013-03-15 17:32:47 +01:00
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
public void execute() {
|
2017-01-30 12:13:14 +01:00
|
|
|
loadMainPanel();
|
2013-03-15 17:32:47 +01:00
|
|
|
}
|
|
|
|
});
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2013-03-15 17:32:47 +01:00
|
|
|
}
|
2016-04-13 16:22:57 +02:00
|
|
|
|
2013-03-15 17:32:47 +01:00
|
|
|
|
2016-04-13 16:22:57 +02:00
|
|
|
private void loadMainPanel() {
|
2013-05-14 14:26:16 +02:00
|
|
|
TabularDataController controller = new TabularDataController();
|
|
|
|
EventBus eventBus = controller.getEventBus();
|
2013-10-15 19:36:36 +02:00
|
|
|
|
|
|
|
// Layout
|
2013-10-14 16:09:43 +02:00
|
|
|
mainPanelLayout = new BorderLayoutContainer();
|
2013-10-16 18:36:22 +02:00
|
|
|
mainPanelLayout.setId("mainPanelLayout");
|
2013-10-15 19:36:36 +02:00
|
|
|
mainPanelLayout.setBorders(true);
|
|
|
|
|
|
|
|
// Ribbon Menu
|
2014-10-31 15:57:00 +01:00
|
|
|
TabularDataRibbon tabularDataRibbon = new TabularDataRibbon(eventBus);
|
|
|
|
TabPanel ribbonBarPanel = tabularDataRibbon.getContainer();
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2014-12-01 18:50:15 +01:00
|
|
|
BorderLayoutData ribbonBarData = new BorderLayoutData(105);
|
2014-10-31 15:57:00 +01:00
|
|
|
ribbonBarData.setMargins(new Margins(5));
|
|
|
|
ribbonBarData.setCollapsible(false);
|
|
|
|
ribbonBarData.setSplit(false);
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2014-10-31 15:57:00 +01:00
|
|
|
mainPanelLayout.setNorthWidget(ribbonBarPanel, ribbonBarData);
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2014-10-31 15:57:00 +01:00
|
|
|
// MainBox Panel
|
2014-10-15 18:45:45 +02:00
|
|
|
final MainBoxPanel mainBoxPanel = new MainBoxPanel("MainBoxPanel",
|
|
|
|
eventBus);
|
|
|
|
controller.setMainBoxPanel(mainBoxPanel);
|
|
|
|
|
2013-09-27 17:35:58 +02:00
|
|
|
MarginData gridData = new MarginData();
|
2014-10-15 18:45:45 +02:00
|
|
|
mainPanelLayout.setCenterWidget(mainBoxPanel, gridData);
|
|
|
|
|
2013-12-11 14:28:10 +01:00
|
|
|
// ToolBox Panel
|
2014-10-31 15:57:00 +01:00
|
|
|
final ToolBoxPanel toolBoxPanel = new ToolBoxPanel("ToolBoxPanel", eventBus);
|
2014-04-16 19:10:47 +02:00
|
|
|
|
2014-10-31 15:57:00 +01:00
|
|
|
BorderLayoutData westData = new BorderLayoutData(310);
|
2013-12-12 12:09:31 +01:00
|
|
|
westData.setCollapsible(true);
|
|
|
|
westData.setSplit(false);
|
|
|
|
westData.setFloatable(false);
|
|
|
|
westData.setCollapseMini(true);
|
|
|
|
westData.setMargins(new Margins(0, 5, 0, 5));
|
|
|
|
westData.setCollapseHidden(true);
|
2014-04-16 19:10:47 +02:00
|
|
|
|
|
|
|
|
2013-12-12 12:09:31 +01:00
|
|
|
mainPanelLayout.setWestWidget(toolBoxPanel, westData);
|
2014-01-29 19:51:28 +01:00
|
|
|
toolBoxPanel.expand();
|
|
|
|
toolBoxPanel.enable();
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2013-12-11 14:28:10 +01:00
|
|
|
controller.setToolBoxPanel(toolBoxPanel);
|
2013-12-20 15:51:58 +01:00
|
|
|
controller.setWestData(westData);
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2013-10-14 16:09:43 +02:00
|
|
|
bind(mainPanelLayout);
|
2014-03-18 16:13:44 +01:00
|
|
|
// menu(gridPanel);
|
2014-10-02 19:07:33 +02:00
|
|
|
controller.restoreUISession();
|
2013-03-15 17:32:47 +01:00
|
|
|
}
|
|
|
|
|
2016-04-13 16:22:57 +02:00
|
|
|
private void bind(BorderLayoutContainer mainWidget) {
|
2013-10-15 19:36:36 +02:00
|
|
|
try {
|
|
|
|
RootPanel root = RootPanel.get(JSP_TAG_ID);
|
|
|
|
Log.info("Root Panel: " + root);
|
|
|
|
if (root == null) {
|
|
|
|
Log.info("Div with id " + JSP_TAG_ID
|
|
|
|
+ " not found, starting in dev mode");
|
|
|
|
Viewport viewport = new Viewport();
|
|
|
|
viewport.setWidget(mainWidget);
|
2013-10-28 16:29:32 +01:00
|
|
|
viewport.onResize();
|
2013-10-15 19:36:36 +02:00
|
|
|
RootPanel.get().add(viewport);
|
|
|
|
} else {
|
|
|
|
Log.info("Application div with id " + JSP_TAG_ID
|
|
|
|
+ " found, starting in portal mode");
|
2013-12-06 18:25:33 +01:00
|
|
|
PortalViewport viewport = new PortalViewport();
|
2013-10-15 19:36:36 +02:00
|
|
|
Log.info("Created Viewport");
|
2013-11-26 15:40:58 +01:00
|
|
|
viewport.setEnableScroll(false);
|
2013-10-15 19:36:36 +02:00
|
|
|
viewport.setWidget(mainWidget);
|
|
|
|
Log.info("Set Widget");
|
|
|
|
Log.info("getOffsetWidth(): " + viewport.getOffsetWidth());
|
|
|
|
Log.info("getOffsetHeight(): " + viewport.getOffsetHeight());
|
2013-10-28 16:29:32 +01:00
|
|
|
viewport.onResize();
|
2013-10-15 19:36:36 +02:00
|
|
|
root.add(viewport);
|
|
|
|
Log.info("Added viewport to root");
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
Log.error("Error in attach viewport:" + e.getLocalizedMessage());
|
2013-03-15 17:32:47 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-15 19:36:36 +02:00
|
|
|
|
2013-03-15 17:32:47 +01:00
|
|
|
}
|