176 lines
5.0 KiB
Java
176 lines
5.0 KiB
Java
|
/**
|
||
|
*
|
||
|
*/
|
||
|
package org.gcube.portlets.user.dataminermanager.client.experimentArea;
|
||
|
|
||
|
import org.gcube.portlets.user.dataminermanager.client.DataMinerManager;
|
||
|
import org.gcube.portlets.user.dataminermanager.client.bean.Operator;
|
||
|
import org.gcube.portlets.user.dataminermanager.client.common.EventBusProvider;
|
||
|
import org.gcube.portlets.user.dataminermanager.client.events.ResubmitComputationEvent;
|
||
|
import org.gcube.portlets.user.dataminermanager.client.experimentArea.WorkflowOperatorPanel.WorkflowOperatorPanelHandler;
|
||
|
|
||
|
import com.google.gwt.user.client.ui.HTML;
|
||
|
import com.google.gwt.user.client.ui.Image;
|
||
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
||
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||
|
import com.sencha.gxt.widget.core.client.TabItemConfig;
|
||
|
import com.sencha.gxt.widget.core.client.TabPanel;
|
||
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||
|
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.toolbar.LabelToolItem;
|
||
|
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||
|
|
||
|
/**
|
||
|
* @author ceras
|
||
|
*
|
||
|
*/
|
||
|
public class WorkflowPanel extends TabPanel {
|
||
|
|
||
|
public static final String DEFAULT_OPERATOR = "AQUAMAPS_SUITABLE";
|
||
|
private static final String DELETE_ALL_BUTTON_TOOLTIP = "Remove All Operators";
|
||
|
private static final boolean WORKFLOW_MODE = false;
|
||
|
private WorkflowOperatorPanel workflowOperatorPanel;
|
||
|
private TextButton removeAllButton = new TextButton(DELETE_ALL_BUTTON_TOOLTIP);
|
||
|
private ComputationPanel computationPanel;
|
||
|
private ContentPanel workflowLc;
|
||
|
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
public WorkflowPanel() {
|
||
|
super();
|
||
|
|
||
|
bind();
|
||
|
setBodyBorder(false);
|
||
|
|
||
|
TabItemConfig tabWorkFlowLcItemConf = new TabItemConfig(
|
||
|
".: Computation", false);
|
||
|
tabWorkFlowLcItemConf.setIcon(DataMinerManager.resources.folderExplore());
|
||
|
workflowLc = new ContentPanel();
|
||
|
workflowLc.setHeaderVisible(false);
|
||
|
add(workflowLc, tabWorkFlowLcItemConf);
|
||
|
|
||
|
|
||
|
|
||
|
TabItemConfig tabComputationPanelItemConf = new TabItemConfig(
|
||
|
".: Computations Execution", false);
|
||
|
tabComputationPanelItemConf.setIcon(DataMinerManager.resources.folderExplore());
|
||
|
computationPanel = new ComputationPanel();
|
||
|
add(computationPanel, tabComputationPanelItemConf);
|
||
|
|
||
|
setToolsPanel();
|
||
|
emptyPanel();
|
||
|
setActiveWidget(computationPanel);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
private void bind() {
|
||
|
EventBusProvider.INSTANCE.addHandler(ResubmitComputationEvent.getType(), new ResubmitComputationEvent.ResubmitComputationHandler() {
|
||
|
@Override
|
||
|
public void onResubmitComputation(ResubmitComputationEvent event) {
|
||
|
setActiveWidget(computationPanel);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
private void emptyPanel() {
|
||
|
workflowOperatorPanel = null;
|
||
|
removeAllButton.setEnabled(false);
|
||
|
workflowLc.clear();
|
||
|
workflowLc.add(new HTML("<br><br><br><br><br><br><br><br><br><br><br><p align='center'>Select an operator.</p>"));
|
||
|
workflowLc.forceLayout();;
|
||
|
|
||
|
}
|
||
|
|
||
|
private void setToolsPanel() {
|
||
|
ToolBar toolBar = new ToolBar();
|
||
|
toolBar.add(new LabelToolItem("Tools"));
|
||
|
|
||
|
removeAllButton.setToolTip(DELETE_ALL_BUTTON_TOOLTIP);
|
||
|
removeAllButton.setIcon(DataMinerManager.resources.removeAll());
|
||
|
removeAllButton.setScale(ButtonScale.MEDIUM);
|
||
|
removeAllButton.setEnabled(false);
|
||
|
removeAllButton.addSelectHandler(new SelectHandler() {
|
||
|
|
||
|
@Override
|
||
|
public void onSelect(SelectEvent event) {
|
||
|
emptyPanel();
|
||
|
|
||
|
}
|
||
|
});
|
||
|
|
||
|
|
||
|
toolBar.add(removeAllButton);
|
||
|
workflowLc.addTool(toolBar);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param computationTitle
|
||
|
* @param operator
|
||
|
*
|
||
|
*/
|
||
|
private void startComputation(String computationTitle, String computationDescription) {
|
||
|
|
||
|
|
||
|
if (workflowOperatorPanel!=null) {
|
||
|
forceLayout();
|
||
|
workflowOperatorPanel.updateOperatorParametersValues();
|
||
|
Operator op = workflowOperatorPanel.getOperator();
|
||
|
|
||
|
computationPanel.startNewComputation(op, computationTitle, computationDescription);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void addOperator(Operator op) {
|
||
|
|
||
|
if (!WORKFLOW_MODE)
|
||
|
workflowOperatorPanel = null;
|
||
|
|
||
|
setActiveWidget(workflowLc);
|
||
|
|
||
|
if (workflowOperatorPanel==null) {
|
||
|
workflowLc.clear();
|
||
|
workflowLc.add(new HTML(" "));
|
||
|
workflowLc.forceLayout();
|
||
|
}
|
||
|
|
||
|
workflowOperatorPanel = new WorkflowOperatorPanel(op);
|
||
|
workflowOperatorPanel.setHandler(new WorkflowOperatorPanelHandler() {
|
||
|
@Override
|
||
|
public void startComputation(String computationTitle, String computationDescription) {
|
||
|
WorkflowPanel.this.startComputation(computationTitle, computationDescription);
|
||
|
setActiveWidget(computationPanel);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
addConnector(true);
|
||
|
|
||
|
workflowLc.add(workflowOperatorPanel); // operator
|
||
|
workflowLc.forceLayout();
|
||
|
|
||
|
removeAllButton.setEnabled(true);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* @param first
|
||
|
*/
|
||
|
private void addConnector(boolean first) {
|
||
|
SimpleContainer lc = new SimpleContainer();
|
||
|
lc.setHeight(first ? 26 : 22);
|
||
|
lc.add(new Image(
|
||
|
first ? DataMinerManager.resources.workflowConnector1() : DataMinerManager.resources.workflowConnector2()
|
||
|
));
|
||
|
workflowLc.add(lc);
|
||
|
}
|
||
|
}
|