145 lines
3.6 KiB
Java
145 lines
3.6 KiB
Java
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata;
|
|
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.ToolsPanel;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.ProjectStatusEventType;
|
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
|
import com.google.gwt.event.shared.EventBus;
|
|
import com.sencha.gxt.core.client.util.Margins;
|
|
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.SimpleContainer;
|
|
|
|
/**
|
|
*
|
|
* @author Giancarlo Panichi
|
|
*
|
|
*
|
|
*/
|
|
public class WorkAreaPanel extends SimpleContainer {
|
|
|
|
private EventBus eventBus;
|
|
|
|
public WorkAreaPanel(EventBus eventBus) {
|
|
super();
|
|
this.eventBus = eventBus;
|
|
init();
|
|
create();
|
|
bindToEvents();
|
|
}
|
|
|
|
protected void init() {
|
|
forceLayoutOnResize = true;
|
|
setBorders(false);
|
|
}
|
|
|
|
protected void create() {
|
|
|
|
}
|
|
|
|
private void bindToEvents() {
|
|
eventBus.addHandler(ProjectStatusEvent.TYPE, new ProjectStatusEvent.ProjectStatusEventHandler() {
|
|
|
|
@Override
|
|
public void onProjectStatus(ProjectStatusEvent event) {
|
|
Log.debug("Catch ProjectStatusEvent");
|
|
doProjectStatusCommand(event);
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
private void doProjectStatusCommand(ProjectStatusEvent event) {
|
|
if (event.getProjectStatusEventType() == null) {
|
|
return;
|
|
}
|
|
switch (event.getProjectStatusEventType()) {
|
|
case WORK_AREA_SETUP:
|
|
setupWorkAreaPanel(event.getProject());
|
|
break;
|
|
case DELETE_MAIN_CODE:
|
|
case MAIN_CODE_SET:
|
|
case OPEN:
|
|
case WORK_AREA_READY:
|
|
case SAVE:
|
|
case START:
|
|
case UPDATE:
|
|
case SOFTWARE_CREATED:
|
|
case SOFTWARE_PUBLISH:
|
|
case SOFTWARE_REPACKAGE:
|
|
case ADD_RESOURCE:
|
|
case DELETE_RESOURCE:
|
|
case EXPLORER_REFRESH:
|
|
break;
|
|
default:
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void setupWorkAreaPanel(Project project) {
|
|
if (project != null) {
|
|
if (project.getProjectConfig() == null || project.getProjectConfig().getLanguage() == "R") {
|
|
createRArea(project);
|
|
} else {
|
|
createBlackBoxArea(project);
|
|
}
|
|
forceLayout();
|
|
fireWorkAreaReady(project);
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void createBlackBoxArea(Project project) {
|
|
ToolsPanel toolsPanel = new ToolsPanel(eventBus);
|
|
clear();
|
|
add(toolsPanel);
|
|
}
|
|
|
|
private void createRArea(Project project) {
|
|
// Main Panel
|
|
BorderLayoutContainer mainPanelLayout = new BorderLayoutContainer();
|
|
// mainPanelLayout.setId("mainPanelLayout");
|
|
mainPanelLayout.setBorders(false);
|
|
mainPanelLayout.setResize(true);
|
|
|
|
// Main
|
|
final MainDataPanel mainDataPanel = new MainDataPanel(eventBus);
|
|
MarginData mainData = new MarginData(new Margins(2));
|
|
mainPanelLayout.setCenterWidget(mainDataPanel, mainData);
|
|
|
|
// Right
|
|
ToolsPanel toolsPanel = new ToolsPanel(eventBus);
|
|
BorderLayoutData eastData = new BorderLayoutData(500);
|
|
eastData.setCollapsible(true);
|
|
eastData.setSplit(false);
|
|
eastData.setFloatable(false);
|
|
eastData.setCollapseMini(true);
|
|
eastData.setMargins(new Margins(0, 5, 0, 5));
|
|
eastData.setCollapseHidden(false);
|
|
|
|
mainPanelLayout.setEastWidget(toolsPanel, eastData);
|
|
toolsPanel.enable();
|
|
toolsPanel.collapse();
|
|
|
|
clear();
|
|
add(mainPanelLayout);
|
|
|
|
|
|
|
|
}
|
|
|
|
private void fireWorkAreaReady(Project project) {
|
|
ProjectStatusEvent event = new ProjectStatusEvent(ProjectStatusEventType.WORK_AREA_READY, project);
|
|
eventBus.fireEvent(event);
|
|
|
|
}
|
|
|
|
}
|