2013-12-10 18:59:22 +01:00
|
|
|
package org.gcube.portlets.user.td.toolboxwidget.client;
|
|
|
|
|
2014-02-04 18:53:27 +01:00
|
|
|
import org.gcube.portlets.user.td.columnwidget.client.ChangeColumnTypePanel;
|
2013-12-11 12:42:46 +01:00
|
|
|
import org.gcube.portlets.user.td.informationwidget.client.TabularResourceProperties;
|
2014-01-29 18:18:53 +01:00
|
|
|
import org.gcube.portlets.user.td.toolboxwidget.client.help.HelpPanel;
|
2014-02-04 18:53:27 +01:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
2013-12-11 12:42:46 +01:00
|
|
|
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
2013-12-10 18:59:22 +01:00
|
|
|
import com.google.web.bindery.event.shared.EventBus;
|
2013-12-12 11:26:33 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
2013-12-11 12:42:46 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.TabItemConfig;
|
2013-12-11 09:43:57 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.TabPanel;
|
2013-12-12 11:26:33 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
2013-12-11 12:42:46 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.event.BeforeCloseEvent;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.BeforeCloseEvent.BeforeCloseHandler;
|
2013-12-12 11:26:33 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
2013-12-16 17:47:05 +01:00
|
|
|
//import org.gcube.portlets.user.td.taskswidget.client.TdTaskController;
|
2014-02-04 18:53:27 +01:00
|
|
|
//import org.gcube.portlets.user.td.taskswidget.client.TdTaskController;
|
2013-12-10 18:59:22 +01:00
|
|
|
|
2013-12-11 09:43:57 +01:00
|
|
|
public class ToolBox extends TabPanel {
|
|
|
|
|
2013-12-11 12:42:46 +01:00
|
|
|
protected EventBus eventBus;
|
|
|
|
protected TabularResourceProperties trProperties;
|
|
|
|
protected ToolBoxPanel toolBoxPanel;
|
2014-01-29 18:18:53 +01:00
|
|
|
protected HelpPanel helpPanel;
|
2014-02-04 18:53:27 +01:00
|
|
|
protected ChangeColumnTypePanel changeColumnTypePanel;
|
2014-02-04 20:39:11 +01:00
|
|
|
// protected TdTaskController tdTaskController;
|
|
|
|
// protected DialogBox tdTaskMainWindow;
|
2013-12-12 11:28:33 +01:00
|
|
|
protected FramedPanel taskPanel;
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-11 12:42:46 +01:00
|
|
|
public ToolBox(String name, EventBus eventBus, ToolBoxPanel toolBoxPanel) {
|
2013-12-10 18:59:22 +01:00
|
|
|
super();
|
2013-12-11 12:42:46 +01:00
|
|
|
Log.debug("Create ToolBox");
|
|
|
|
this.eventBus = eventBus;
|
|
|
|
this.toolBoxPanel = toolBoxPanel;
|
2013-12-10 18:59:22 +01:00
|
|
|
setId(name);
|
2014-01-29 18:55:17 +01:00
|
|
|
setBodyBorder(false);
|
2014-01-29 19:21:23 +01:00
|
|
|
setBorders(false);
|
2013-12-11 12:42:46 +01:00
|
|
|
setAnimScroll(true);
|
|
|
|
setTabScroll(true);
|
|
|
|
setCloseContextMenu(true);
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-11 12:42:46 +01:00
|
|
|
// setResizeTabs(true);
|
2013-12-10 18:59:22 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-02-04 20:39:11 +01:00
|
|
|
public void startTabs() {
|
2014-01-31 19:14:22 +01:00
|
|
|
Log.debug("Start ToolBox Tabs");
|
|
|
|
addHelpPanel();
|
|
|
|
setActiveWidget(getWidget(0));
|
|
|
|
|
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2014-02-04 18:53:27 +01:00
|
|
|
public void openPropertiesTab() {
|
|
|
|
Log.debug("Open Properties Tab");
|
2014-01-31 19:14:22 +01:00
|
|
|
if (trProperties == null) {
|
|
|
|
addTrProperties();
|
|
|
|
}
|
|
|
|
setActiveWidget(trProperties);
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2014-01-31 19:14:22 +01:00
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2014-02-04 18:53:27 +01:00
|
|
|
public void openColumnTypeChangeTab(TRId trId, String columnName) {
|
|
|
|
Log.debug("Open Column Type Change Tab");
|
2014-02-04 20:39:11 +01:00
|
|
|
if (changeColumnTypePanel == null) {
|
2014-02-04 18:53:27 +01:00
|
|
|
addChangeColumnTypePanel(trId, columnName);
|
|
|
|
}
|
|
|
|
setActiveWidget(changeColumnTypePanel);
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2014-02-04 18:53:27 +01:00
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2014-01-31 19:14:22 +01:00
|
|
|
public void closePropertiesTabs() {
|
2014-02-04 18:53:27 +01:00
|
|
|
Log.debug("Close Properties Tab");
|
2014-02-04 20:39:11 +01:00
|
|
|
if (trProperties != null) {
|
2014-01-29 18:55:17 +01:00
|
|
|
remove(trProperties);
|
2014-02-04 20:39:11 +01:00
|
|
|
trProperties = null;
|
2014-01-29 18:55:17 +01:00
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2014-02-04 18:53:27 +01:00
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
|
|
|
public void closeChangeColumnTypePanel() {
|
2014-02-04 18:53:27 +01:00
|
|
|
Log.debug("Close ChangeColumnTypePanel Tab");
|
|
|
|
if (changeColumnTypePanel != null) {
|
|
|
|
remove(changeColumnTypePanel);
|
2014-02-04 20:39:11 +01:00
|
|
|
changeColumnTypePanel = null;
|
2014-02-04 18:53:27 +01:00
|
|
|
}
|
2013-12-11 12:42:46 +01:00
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-11 19:49:22 +01:00
|
|
|
public void updateTabs() {
|
2013-12-11 12:42:46 +01:00
|
|
|
Log.debug("Update ToolBox Tabs");
|
2013-12-11 19:49:22 +01:00
|
|
|
if (trProperties != null) {
|
2013-12-11 12:42:46 +01:00
|
|
|
trProperties.update();
|
|
|
|
}
|
2014-02-04 18:53:27 +01:00
|
|
|
if (changeColumnTypePanel != null) {
|
|
|
|
remove(changeColumnTypePanel);
|
2014-02-04 20:39:11 +01:00
|
|
|
changeColumnTypePanel = null;
|
2014-02-04 18:53:27 +01:00
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-11 12:42:46 +01:00
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2014-01-29 18:18:53 +01:00
|
|
|
protected void addHelpPanel() {
|
2014-01-29 19:21:23 +01:00
|
|
|
TabItemConfig propertiesItemConf = new TabItemConfig("Help", false);
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2014-01-29 18:18:53 +01:00
|
|
|
helpPanel = new HelpPanel("Help", eventBus);
|
|
|
|
helpPanel.setHeaderVisible(false);
|
|
|
|
add(helpPanel, propertiesItemConf);
|
|
|
|
|
|
|
|
};
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-11 19:49:22 +01:00
|
|
|
protected void addTrProperties() {
|
2013-12-11 12:42:46 +01:00
|
|
|
TabItemConfig propertiesItemConf = new TabItemConfig("Properties", true);
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-11 12:42:46 +01:00
|
|
|
trProperties = new TabularResourceProperties("TRProperties", eventBus);
|
|
|
|
trProperties.setHeaderVisible(false);
|
|
|
|
add(trProperties, propertiesItemConf);
|
2013-12-11 19:49:22 +01:00
|
|
|
|
2013-12-11 12:42:46 +01:00
|
|
|
addBeforeCloseHandler(new BeforeCloseHandler<Widget>() {
|
|
|
|
|
|
|
|
public void onBeforeClose(BeforeCloseEvent<Widget> event) {
|
2014-02-04 20:39:11 +01:00
|
|
|
if (trProperties == event.getItem()) {
|
2013-12-11 12:42:46 +01:00
|
|
|
remove(trProperties);
|
2014-02-04 20:39:11 +01:00
|
|
|
trProperties = null;
|
2013-12-11 12:42:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2013-12-11 19:49:22 +01:00
|
|
|
};
|
2014-02-04 18:53:27 +01:00
|
|
|
|
|
|
|
protected void addChangeColumnTypePanel(TRId trId, String columnName) {
|
2014-02-04 20:39:11 +01:00
|
|
|
TabItemConfig changeColumnTypeItemConf = new TabItemConfig(
|
|
|
|
"Column Type", true);
|
|
|
|
|
|
|
|
changeColumnTypePanel = new ChangeColumnTypePanel(trId, columnName,
|
|
|
|
eventBus);
|
2014-02-04 18:53:27 +01:00
|
|
|
add(changeColumnTypePanel, changeColumnTypeItemConf);
|
2013-12-11 12:42:46 +01:00
|
|
|
|
2014-02-04 18:53:27 +01:00
|
|
|
addBeforeCloseHandler(new BeforeCloseHandler<Widget>() {
|
|
|
|
|
|
|
|
public void onBeforeClose(BeforeCloseEvent<Widget> event) {
|
2014-02-04 20:39:11 +01:00
|
|
|
if (changeColumnTypePanel == event.getItem()) {
|
2014-02-04 18:53:27 +01:00
|
|
|
remove(changeColumnTypePanel);
|
2014-02-04 20:39:11 +01:00
|
|
|
changeColumnTypePanel = null;
|
|
|
|
|
2014-02-04 18:53:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-12-12 11:28:33 +01:00
|
|
|
protected void addTdTaskPanel() {
|
2014-02-04 20:39:11 +01:00
|
|
|
|
|
|
|
// tdTaskController = TdTaskController.getInstance();
|
|
|
|
// tdTaskController.bindCommonBus(eventBus);
|
|
|
|
// tdTaskMainWindow = tdTaskController.getWindowTaskMonitor(); // This
|
|
|
|
// is main panel
|
|
|
|
|
|
|
|
taskPanel = new FramedPanel();
|
2013-12-12 11:26:33 +01:00
|
|
|
taskPanel.setHeaderVisible(false);
|
2014-02-04 20:39:11 +01:00
|
|
|
TextButton buttonTask = new TextButton("Tasks");
|
2013-12-12 11:26:33 +01:00
|
|
|
buttonTask.addSelectHandler(new SelectEvent.SelectHandler() {
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-12 11:26:33 +01:00
|
|
|
public void onSelect(SelectEvent event) {
|
2014-02-04 20:39:11 +01:00
|
|
|
// tdTaskMainWindow.show();
|
|
|
|
|
2013-12-12 11:26:33 +01:00
|
|
|
}
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-12 11:26:33 +01:00
|
|
|
});
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-12 11:26:33 +01:00
|
|
|
taskPanel.add(buttonTask);
|
2014-02-04 20:39:11 +01:00
|
|
|
|
2013-12-11 19:49:22 +01:00
|
|
|
TabItemConfig tdTasksItemConf = new TabItemConfig("Tasks", true);
|
|
|
|
|
2013-12-12 11:26:33 +01:00
|
|
|
add(taskPanel, tdTasksItemConf);
|
2013-12-11 19:49:22 +01:00
|
|
|
addBeforeCloseHandler(new BeforeCloseHandler<Widget>() {
|
|
|
|
|
|
|
|
public void onBeforeClose(BeforeCloseEvent<Widget> event) {
|
|
|
|
if (getWidgetCount() == 1) {
|
|
|
|
toolBoxPanel.closePanelOnly();
|
2013-12-12 11:28:33 +01:00
|
|
|
remove(taskPanel);
|
2013-12-11 19:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2013-12-11 12:42:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-10 18:59:22 +01:00
|
|
|
}
|