1452: Implement a GUI for StatMan Algorithms Importer
Task-Url: https://support.d4science.org/issues/1452 Added selected rows variable support git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122042 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1a70c2788c
commit
0fc62789bd
|
@ -0,0 +1,99 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.codeparser;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Giancarlo Panichi email: <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CodeParser {
|
||||||
|
|
||||||
|
private static final String IMAGE_PATTERN = "([^\\s]+(\\.(?i)(jpg|png|gif|bmp)\")$)";
|
||||||
|
private static final String FILE_PATTERN = "([^\\s]+(\\.(?i)(txt|csv|pdf|doc)\")$)";
|
||||||
|
private static final String ENUM1_PATTERN = "(c\\([^\\)]*\\))";
|
||||||
|
private static final String ENUM2_PATTERN = "(\\{[^\\}]*\\})";
|
||||||
|
|
||||||
|
public CodeParser() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectedRowsVariables parse(String parameter, IOType ioType) {
|
||||||
|
SelectedRowsVariables selectedRowsVariables = null;
|
||||||
|
|
||||||
|
if (parameter == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameter.contains("<-")) {
|
||||||
|
String[] varDescription = parameter.split("<-");
|
||||||
|
selectedRowsVariables = new SelectedRowsVariables(
|
||||||
|
varDescription[0].trim(), varDescription[0].trim(), varDescription[1].trim(),
|
||||||
|
checkDataType(varDescription[1].trim()), ioType, parameter);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (parameter.contains("=")) {
|
||||||
|
String[] varDescription = parameter.split("=");
|
||||||
|
selectedRowsVariables = new SelectedRowsVariables(
|
||||||
|
varDescription[0].trim(), varDescription[0].trim(),
|
||||||
|
varDescription[1].trim(), checkDataType(varDescription[1].trim()),
|
||||||
|
ioType, parameter);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedRowsVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataType checkDataType(String data) {
|
||||||
|
if (data == null || data.isEmpty()) {
|
||||||
|
return DataType.STRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Pattern patternFile = Pattern.compile(FILE_PATTERN);
|
||||||
|
if (patternFile.matcher(data).matches()) {
|
||||||
|
return DataType.FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pattern patternImage = Pattern.compile(IMAGE_PATTERN);
|
||||||
|
if (patternImage.matcher(data).matches()) {
|
||||||
|
return DataType.FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pattern patternEnum1 = Pattern.compile(ENUM1_PATTERN);
|
||||||
|
if (patternEnum1.matcher(data).matches()) {
|
||||||
|
return DataType.ENUMERATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pattern patternEnum2 = Pattern.compile(ENUM2_PATTERN);
|
||||||
|
if (patternEnum2.matcher(data).matches()) {
|
||||||
|
return DataType.ENUMERATED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
Integer.parseInt(data);
|
||||||
|
return DataType.INTEGER;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Double.parseDouble(data);
|
||||||
|
return DataType.DOUBLE;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataType.STRING;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.event;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
import com.google.gwt.event.shared.HandlerRegistration;
|
||||||
|
import com.google.gwt.event.shared.HasHandlers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input Save Event
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class NewSelectedRowsVariableEvent
|
||||||
|
extends
|
||||||
|
GwtEvent<NewSelectedRowsVariableEvent.NewSelectedRowsVariableEventHandler> {
|
||||||
|
|
||||||
|
public static Type<NewSelectedRowsVariableEventHandler> TYPE = new Type<NewSelectedRowsVariableEventHandler>();
|
||||||
|
private SelectedRowsVariables selectedRowsVariable;
|
||||||
|
|
||||||
|
public interface NewSelectedRowsVariableEventHandler extends EventHandler {
|
||||||
|
void onNewVariable(NewSelectedRowsVariableEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface HasNewSelectedRowsVariableEventHandler extends HasHandlers {
|
||||||
|
public HandlerRegistration addNewSelectedRowsVariableEventHandler(
|
||||||
|
NewSelectedRowsVariableEventHandler handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NewSelectedRowsVariableEvent(
|
||||||
|
SelectedRowsVariables selectedRowsVariable) {
|
||||||
|
this.selectedRowsVariable = selectedRowsVariable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dispatch(NewSelectedRowsVariableEventHandler handler) {
|
||||||
|
handler.onNewVariable(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type<NewSelectedRowsVariableEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Type<NewSelectedRowsVariableEventHandler> getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void fire(HasHandlers source,
|
||||||
|
NewSelectedRowsVariableEvent newSelectedRowsVariableEvent) {
|
||||||
|
source.fireEvent(newSelectedRowsVariableEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelectedRowsVariables getSelectedRowsVariable() {
|
||||||
|
return selectedRowsVariable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "NewSelectedRowsVariableEvent [selectedRowsVariable="
|
||||||
|
+ selectedRowsVariable + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,6 +2,8 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.maindata;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.codeparser.CodeParser;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewSelectedRowsVariableEvent;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.SessionExpiredEvent;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterServiceAsync;
|
||||||
|
@ -9,6 +11,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.type.Session
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.utils.UtilsGXT3;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.code.CodeData;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.IOType;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
@ -92,7 +96,7 @@ public class CodeEditPanel extends ContentPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
|
saveVariable(IOType.INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -107,7 +111,7 @@ public class CodeEditPanel extends ContentPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
|
saveVariable(IOType.OUTPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -149,6 +153,33 @@ public class CodeEditPanel extends ContentPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveVariable(IOType ioType) {
|
||||||
|
String parameter = getSelectedText();
|
||||||
|
Log.debug("Save Variable: " + ioType + ", " + parameter);
|
||||||
|
if (parameter == null) {
|
||||||
|
Log.debug("No text selected");
|
||||||
|
UtilsGXT3.alert("Attention", "Select parameter in the code!");
|
||||||
|
} else {
|
||||||
|
createSelectedRowVariable(parameter, ioType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createSelectedRowVariable(String parameter, IOType ioType) {
|
||||||
|
CodeParser codeParser = new CodeParser();
|
||||||
|
SelectedRowsVariables selectedRowsVariable = codeParser.parse(
|
||||||
|
parameter, ioType);
|
||||||
|
if (selectedRowsVariable == null) {
|
||||||
|
Log.debug("No valid selection, change selection and try again!");
|
||||||
|
UtilsGXT3.alert("Attention", "No valid selected row, change selection and try again!");
|
||||||
|
} else {
|
||||||
|
NewSelectedRowsVariableEvent newSelectedRowsVariableEvent = new NewSelectedRowsVariableEvent(
|
||||||
|
selectedRowsVariable);
|
||||||
|
eventBus.fireEvent(newSelectedRowsVariableEvent);
|
||||||
|
Log.debug("Fire: " + newSelectedRowsVariableEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void saveCode() {
|
protected void saveCode() {
|
||||||
String code = editor.getText();
|
String code = editor.getText();
|
||||||
StatAlgoImporterServiceAsync.INSTANCE.saveCode(code,
|
StatAlgoImporterServiceAsync.INSTANCE.saveCode(code,
|
||||||
|
@ -250,7 +281,7 @@ public class CodeEditPanel extends ContentPanel {
|
||||||
|
|
||||||
if (editorSelection.isMultiLine()) {
|
if (editorSelection.isMultiLine()) {
|
||||||
String tempTest;
|
String tempTest;
|
||||||
for (int i = startPosition.getRow(); i < endPosition.getRow() + 1; i++) {
|
for (int i = startPosition.getRow(); i < endPosition.getRow(); i++) {
|
||||||
if (i == startPosition.getRow()) {
|
if (i == startPosition.getRow()) {
|
||||||
tempTest = editor.getLine(i);
|
tempTest = editor.getLine(i);
|
||||||
tempTest.substring(startPosition.getColumn());
|
tempTest.substring(startPosition.getColumn());
|
||||||
|
@ -258,7 +289,7 @@ public class CodeEditPanel extends ContentPanel {
|
||||||
} else {
|
} else {
|
||||||
if (i == endPosition.getRow()) {
|
if (i == endPosition.getRow()) {
|
||||||
tempTest = editor.getLine(i);
|
tempTest = editor.getLine(i);
|
||||||
tempTest.substring(0, endPosition.getColumn() + 1);
|
tempTest.substring(0, endPosition.getColumn());
|
||||||
selectedText += tempTest;
|
selectedText += tempTest;
|
||||||
} else {
|
} else {
|
||||||
selectedText += editor.getLine(i);
|
selectedText += editor.getLine(i);
|
||||||
|
@ -269,7 +300,7 @@ public class CodeEditPanel extends ContentPanel {
|
||||||
String tempTest;
|
String tempTest;
|
||||||
tempTest = editor.getLine(startPosition.getRow());
|
tempTest = editor.getLine(startPosition.getRow());
|
||||||
selectedText = tempTest.substring(startPosition.getColumn(),
|
selectedText = tempTest.substring(startPosition.getColumn(),
|
||||||
endPosition.getColumn() + 1);
|
endPosition.getColumn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,4 +29,7 @@ public interface SelectedRowsVariablesProperties extends
|
||||||
|
|
||||||
ValueProvider<SelectedRowsVariables, IOType> ioType();
|
ValueProvider<SelectedRowsVariables, IOType> ioType();
|
||||||
|
|
||||||
|
ValueProvider<SelectedRowsVariables, String> sourceSelection();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
||||||
|
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveEvent;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.NewSelectedRowsVariableEvent;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStateEvent;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.UIStateEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
@ -85,6 +87,28 @@ public class InputVariablePanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eventBus.addHandler(
|
||||||
|
NewSelectedRowsVariableEvent.TYPE,
|
||||||
|
new NewSelectedRowsVariableEvent.NewSelectedRowsVariableEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNewVariable(NewSelectedRowsVariableEvent event) {
|
||||||
|
addNewSelectedRowsVariable(event
|
||||||
|
.getSelectedRowsVariable());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addNewSelectedRowsVariable(
|
||||||
|
SelectedRowsVariables selectedRowsVariable) {
|
||||||
|
inputVariableTabPanel.addSelectedRowsVariable(selectedRowsVariable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void manageInputSaveEvents(InputSaveEvent event) {
|
protected void manageInputSaveEvents(InputSaveEvent event) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
||||||
|
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveReadyEvent;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.InputSaveReadyEvent;
|
||||||
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.SelectedRowsVariables;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.InputData;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||||
|
|
||||||
|
@ -124,4 +125,12 @@ public class InputVariableTabPanel extends TabPanel {
|
||||||
add(enviromentVariablesPanel, enviromentVariablePanelItemConf);
|
add(enviromentVariablesPanel, enviromentVariablePanelItemConf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSelectedRowsVariable(
|
||||||
|
SelectedRowsVariables selectedRowsVariable) {
|
||||||
|
setActiveWidget(selectedRowsPanel);
|
||||||
|
selectedRowsPanel.addNewSelectedRowsVariable(selectedRowsVariable);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.DataTypePropertiesCombo;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.DataTypePropertiesCombo;
|
||||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.IOTypePropertiesCombo;
|
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.IOTypePropertiesCombo;
|
||||||
|
@ -27,7 +28,6 @@ import com.sencha.gxt.data.shared.ListStore;
|
||||||
import com.sencha.gxt.widget.core.client.ContentPanel;
|
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||||
import com.sencha.gxt.widget.core.client.button.ButtonBar;
|
import com.sencha.gxt.widget.core.client.button.ButtonBar;
|
||||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
@ -47,7 +47,6 @@ import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||||
import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
|
import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
|
||||||
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
|
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
|
||||||
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
|
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
|
||||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -80,7 +79,6 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
SafeHtml format(String value);
|
SafeHtml format(String value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SelectedRowsPanel(Project project, EventBus eventBus) {
|
public SelectedRowsPanel(Project project, EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
Log.debug("SelectedRowsPanel");
|
Log.debug("SelectedRowsPanel");
|
||||||
|
@ -104,6 +102,13 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create(Project project) {
|
private void create(Project project) {
|
||||||
|
if (project != null && project.getInputData() != null
|
||||||
|
&& project.getInputData().getListSelectedRows() != null) {
|
||||||
|
seq = project.getInputData().getListSelectedRows().size();
|
||||||
|
} else {
|
||||||
|
seq = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Grid
|
// Grid
|
||||||
SelectedRowsVariablesProperties props = GWT
|
SelectedRowsVariablesProperties props = GWT
|
||||||
.create(SelectedRowsVariablesProperties.class);
|
.create(SelectedRowsVariablesProperties.class);
|
||||||
|
@ -134,7 +139,6 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
props.defaultValue(), 100, "Default");
|
props.defaultValue(), 100, "Default");
|
||||||
// defaColumn.setMenuDisabled(true);
|
// defaColumn.setMenuDisabled(true);
|
||||||
|
|
||||||
|
|
||||||
ColumnConfig<SelectedRowsVariables, IOType> ioTypeColumn = new ColumnConfig<SelectedRowsVariables, IOType>(
|
ColumnConfig<SelectedRowsVariables, IOType> ioTypeColumn = new ColumnConfig<SelectedRowsVariables, IOType>(
|
||||||
props.ioType(), 100, "I/O");
|
props.ioType(), 100, "I/O");
|
||||||
// inputTypeColumn.setMenuDisabled(true);
|
// inputTypeColumn.setMenuDisabled(true);
|
||||||
|
@ -149,8 +153,6 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ArrayList<ColumnConfig<SelectedRowsVariables, ?>> l = new ArrayList<ColumnConfig<SelectedRowsVariables, ?>>();
|
ArrayList<ColumnConfig<SelectedRowsVariables, ?>> l = new ArrayList<ColumnConfig<SelectedRowsVariables, ?>>();
|
||||||
l.add(nameColumn);
|
l.add(nameColumn);
|
||||||
l.add(descriptionColumn);
|
l.add(descriptionColumn);
|
||||||
|
@ -161,8 +163,7 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
ColumnModel<SelectedRowsVariables> columns = new ColumnModel<SelectedRowsVariables>(
|
ColumnModel<SelectedRowsVariables> columns = new ColumnModel<SelectedRowsVariables>(
|
||||||
l);
|
l);
|
||||||
|
|
||||||
storeSelectedRows = new ListStore<SelectedRowsVariables>(
|
storeSelectedRows = new ListStore<SelectedRowsVariables>(props.id());
|
||||||
props.id());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ArrayList<SelectedRowsVariables> list = new ArrayList<>(); for (int i
|
* ArrayList<SelectedRowsVariables> list = new ArrayList<>(); for (int i
|
||||||
|
@ -174,14 +175,15 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
|
|
||||||
if (project != null && project.getInputData() != null
|
if (project != null && project.getInputData() != null
|
||||||
&& project.getInputData().getListSelectedRows() != null) {
|
&& project.getInputData().getListSelectedRows() != null) {
|
||||||
storeSelectedRows.addAll(project.getInputData().getListSelectedRows());
|
storeSelectedRows.addAll(project.getInputData()
|
||||||
|
.getListSelectedRows());
|
||||||
}
|
}
|
||||||
|
|
||||||
final GridSelectionModel<SelectedRowsVariables> sm = new GridSelectionModel<SelectedRowsVariables>();
|
final GridSelectionModel<SelectedRowsVariables> sm = new GridSelectionModel<SelectedRowsVariables>();
|
||||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
|
||||||
gridSelectedRows = new Grid<SelectedRowsVariables>(
|
gridSelectedRows = new Grid<SelectedRowsVariables>(storeSelectedRows,
|
||||||
storeSelectedRows, columns);
|
columns);
|
||||||
gridSelectedRows.setSelectionModel(sm);
|
gridSelectedRows.setSelectionModel(sm);
|
||||||
gridSelectedRows.getView().setStripeRows(true);
|
gridSelectedRows.getView().setStripeRows(true);
|
||||||
gridSelectedRows.getView().setColumnLines(true);
|
gridSelectedRows.getView().setColumnLines(true);
|
||||||
|
@ -223,12 +225,15 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
comboDataType.setTriggerAction(TriggerAction.ALL);
|
comboDataType.setTriggerAction(TriggerAction.ALL);
|
||||||
addHandlersForComboDataType(dataTypePropertiesCombo.label());
|
addHandlersForComboDataType(dataTypePropertiesCombo.label());
|
||||||
|
|
||||||
|
storeComboDataType.clear();
|
||||||
|
storeComboDataType.addAll(DataType.asList());
|
||||||
|
storeComboDataType.commitChanges();
|
||||||
|
|
||||||
// IOType
|
// IOType
|
||||||
IOTypePropertiesCombo ioTypePropertiesCombo = GWT
|
IOTypePropertiesCombo ioTypePropertiesCombo = GWT
|
||||||
.create(IOTypePropertiesCombo.class);
|
.create(IOTypePropertiesCombo.class);
|
||||||
|
|
||||||
storeComboIOType = new ListStore<IOType>(
|
storeComboIOType = new ListStore<IOType>(ioTypePropertiesCombo.id());
|
||||||
ioTypePropertiesCombo.id());
|
|
||||||
|
|
||||||
comboIOType = new ComboBox<IOType>(storeComboIOType,
|
comboIOType = new ComboBox<IOType>(storeComboIOType,
|
||||||
ioTypePropertiesCombo.label());
|
ioTypePropertiesCombo.label());
|
||||||
|
@ -238,22 +243,20 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
comboIOType.setTriggerAction(TriggerAction.ALL);
|
comboIOType.setTriggerAction(TriggerAction.ALL);
|
||||||
addHandlersForComboIOType(ioTypePropertiesCombo.label());
|
addHandlersForComboIOType(ioTypePropertiesCombo.label());
|
||||||
|
|
||||||
|
storeComboIOType.clear();
|
||||||
|
storeComboIOType.addAll(IOType.asList());
|
||||||
|
storeComboIOType.commitChanges();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
gridSelectedRowsEditing = new GridRowEditing<SelectedRowsVariables>(
|
gridSelectedRowsEditing = new GridRowEditing<SelectedRowsVariables>(
|
||||||
gridSelectedRows);
|
gridSelectedRows);
|
||||||
gridSelectedRowsEditing.addEditor(nameColumn, new TextField());
|
gridSelectedRowsEditing.addEditor(nameColumn, new TextField());
|
||||||
gridSelectedRowsEditing.addEditor(descriptionColumn,
|
gridSelectedRowsEditing.addEditor(descriptionColumn, new TextField());
|
||||||
new TextField());
|
gridSelectedRowsEditing.addEditor(dataTypeColumn, comboDataType);
|
||||||
gridSelectedRowsEditing.addEditor(dataTypeColumn,
|
gridSelectedRowsEditing.addEditor(defaultValueColumn, new TextField());
|
||||||
comboDataType);
|
|
||||||
gridSelectedRowsEditing.addEditor(defaultValueColumn,
|
|
||||||
new TextField());
|
|
||||||
|
|
||||||
gridSelectedRowsEditing.addEditor(ioTypeColumn,
|
|
||||||
comboIOType);
|
|
||||||
|
|
||||||
|
gridSelectedRowsEditing.addEditor(ioTypeColumn, comboIOType);
|
||||||
|
|
||||||
btnAdd = new TextButton();
|
btnAdd = new TextButton();
|
||||||
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||||
|
@ -279,12 +282,27 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
storeSelectedRows.remove(rowIndex);
|
storeSelectedRows.remove(rowIndex);
|
||||||
storeSelectedRows.commitChanges();
|
storeSelectedRows.commitChanges();
|
||||||
|
|
||||||
gridSelectedRowsEditing.getCancelButton().setVisible(
|
gridSelectedRowsEditing.getCancelButton().setVisible(true);
|
||||||
true);
|
|
||||||
btnAdd.setEnabled(true);
|
btnAdd.setEnabled(true);
|
||||||
if (addStatus) {
|
if (addStatus) {
|
||||||
addStatus = false;
|
addStatus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<SelectedRowsVariables> listSelected=storeSelectedRows.getAll();
|
||||||
|
List<SelectedRowsVariables> listNewSelected= new ArrayList<SelectedRowsVariables>();
|
||||||
|
for(int i=0; i<listSelected.size(); i++){
|
||||||
|
SelectedRowsVariables var=listSelected.get(i);
|
||||||
|
var.setId(i);
|
||||||
|
listNewSelected.add(var);
|
||||||
|
}
|
||||||
|
|
||||||
|
storeSelectedRows.clear();
|
||||||
|
storeSelectedRows.addAll(listNewSelected);
|
||||||
|
storeSelectedRows.commitChanges();
|
||||||
|
|
||||||
|
seq=listNewSelected.size();
|
||||||
|
Log.debug("Current Seq: "+seq);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ButtonBar buttonBar = gridSelectedRowsEditing.getButtonBar();
|
ButtonBar buttonBar = gridSelectedRowsEditing.getButtonBar();
|
||||||
|
@ -338,14 +356,14 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ToolBar toolBar = new ToolBar();
|
// ToolBar toolBar = new ToolBar();
|
||||||
toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
|
// toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
|
||||||
|
|
||||||
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||||
vlc.setAdjustForScroll(false);
|
vlc.setAdjustForScroll(false);
|
||||||
vlc.setScrollMode(ScrollMode.NONE);
|
vlc.setScrollMode(ScrollMode.NONE);
|
||||||
|
|
||||||
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
// vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
vlc.add(gridSelectedRows, new VerticalLayoutData(1, 1, new Margins(0)));
|
vlc.add(gridSelectedRows, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||||
|
|
||||||
add(vlc, new MarginData(new Margins(0)));
|
add(vlc, new MarginData(new Margins(0)));
|
||||||
|
@ -368,18 +386,38 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addNewSelectedRowsVariable(
|
||||||
|
SelectedRowsVariables selectedRowsVariable) {
|
||||||
|
try {
|
||||||
|
Log.debug("Current Seq: " + seq);
|
||||||
|
seq++;
|
||||||
|
selectedRowsVariable.setId(seq);
|
||||||
|
Log.debug("New Selected Rows Variable: " + selectedRowsVariable);
|
||||||
|
storeSelectedRows.add(selectedRowsVariable);
|
||||||
|
storeSelectedRows.commitChanges();
|
||||||
|
|
||||||
|
if (gridSelectedRowsEditing.isEditing()) {
|
||||||
|
gridSelectedRowsEditing.cancelEditing();
|
||||||
|
}
|
||||||
|
forceLayout();
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Log.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addSelectedRow(SelectEvent event) {
|
private void addSelectedRow(SelectEvent event) {
|
||||||
try {
|
try {
|
||||||
|
Log.debug("Current Seq: " + seq);
|
||||||
seq++;
|
seq++;
|
||||||
SelectedRowsVariables newEnvironmentVariable = new SelectedRowsVariables(
|
SelectedRowsVariables newSelectedRowsVariable = new SelectedRowsVariables(
|
||||||
seq, "", "", "", DataType.STRING, IOType.INPUT);
|
seq, "", "", "", DataType.STRING, IOType.INPUT, "");
|
||||||
Log.debug("New Environment Variable: " + newEnvironmentVariable);
|
Log.debug("New Selected Rows Variable: " + newSelectedRowsVariable);
|
||||||
gridSelectedRowsEditing.cancelEditing();
|
gridSelectedRowsEditing.cancelEditing();
|
||||||
addStatus = true;
|
addStatus = true;
|
||||||
gridSelectedRowsEditing.getCancelButton().setVisible(false);
|
gridSelectedRowsEditing.getCancelButton().setVisible(false);
|
||||||
storeSelectedRows.add(newEnvironmentVariable);
|
storeSelectedRows.add(newSelectedRowsVariable);
|
||||||
int row = storeSelectedRows.indexOf(newEnvironmentVariable);
|
int row = storeSelectedRows.indexOf(newSelectedRowsVariable);
|
||||||
|
|
||||||
storeComboDataType.clear();
|
storeComboDataType.clear();
|
||||||
storeComboDataType.addAll(DataType.asList());
|
storeComboDataType.addAll(DataType.asList());
|
||||||
|
@ -396,11 +434,14 @@ public class SelectedRowsPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Project project) {
|
public void update(Project project) {
|
||||||
|
Log.debug("Update Selected Rows: " + project);
|
||||||
if (project != null && project.getInputData() != null
|
if (project != null && project.getInputData() != null
|
||||||
&& project.getInputData().getListSelectedRows() != null) {
|
&& project.getInputData().getListSelectedRows() != null) {
|
||||||
storeSelectedRows.clear();
|
storeSelectedRows.clear();
|
||||||
storeSelectedRows.addAll(project.getInputData().getListSelectedRows());
|
storeSelectedRows.addAll(project.getInputData()
|
||||||
|
.getListSelectedRows());
|
||||||
storeSelectedRows.commitChanges();
|
storeSelectedRows.commitChanges();
|
||||||
|
seq = project.getInputData().getListSelectedRows().size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,11 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public enum DataType {
|
public enum DataType {
|
||||||
STRING("String"),
|
STRING("String"),
|
||||||
NUMBER("Number"),
|
INTEGER("Integer"),
|
||||||
|
DOUBLE("Double"),
|
||||||
ENUMERATED("Enumerated"),
|
ENUMERATED("Enumerated"),
|
||||||
CONSTANT("Constant"),
|
|
||||||
RANDOM("Random"),
|
|
||||||
FILE("File"),
|
FILE("File"),
|
||||||
MAP("Map"),
|
BOOLEAN("Boolean");
|
||||||
BOOLEAN("Boolean"),
|
|
||||||
IMAGES("Images");
|
|
||||||
|
|
||||||
|
|
||||||
//private static InputTypeMessages msgs=GWT.create(InputTypeMessages.class);
|
//private static InputTypeMessages msgs=GWT.create(InputTypeMessages.class);
|
||||||
|
|
|
@ -17,13 +17,28 @@ public class SelectedRowsVariables implements Serializable {
|
||||||
private String defaultValue;
|
private String defaultValue;
|
||||||
private DataType dataType;
|
private DataType dataType;
|
||||||
private IOType ioType;
|
private IOType ioType;
|
||||||
|
private String sourceSelection;
|
||||||
|
|
||||||
public SelectedRowsVariables() {
|
public SelectedRowsVariables() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SelectedRowsVariables(String name, String description,
|
||||||
|
String defaultValue, DataType dataType, IOType ioType,
|
||||||
|
String sourceSelection){
|
||||||
|
super();
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
this.dataType = dataType;
|
||||||
|
this.ioType = ioType;
|
||||||
|
this.sourceSelection = sourceSelection;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public SelectedRowsVariables(int id, String name, String description,
|
public SelectedRowsVariables(int id, String name, String description,
|
||||||
String defaultValue, DataType dataType, IOType ioType) {
|
String defaultValue, DataType dataType, IOType ioType,
|
||||||
|
String sourceSelection) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -31,6 +46,7 @@ public class SelectedRowsVariables implements Serializable {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
this.dataType = dataType;
|
this.dataType = dataType;
|
||||||
this.ioType = ioType;
|
this.ioType = ioType;
|
||||||
|
this.sourceSelection = sourceSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
@ -81,15 +97,22 @@ public class SelectedRowsVariables implements Serializable {
|
||||||
this.ioType = ioType;
|
this.ioType = ioType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSourceSelection() {
|
||||||
|
return sourceSelection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSourceSelection(String sourceSelection) {
|
||||||
|
this.sourceSelection = sourceSelection;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SelectedRowsVariables [id=" + id + ", name=" + name
|
return "SelectedRowsVariables [id=" + id + ", name=" + name
|
||||||
+ ", description=" + description + ", defaultValue="
|
+ ", description=" + description + ", defaultValue="
|
||||||
+ defaultValue + ", dataType=" + dataType + ", ioType="
|
+ defaultValue + ", dataType=" + dataType + ", ioType="
|
||||||
+ ioType + "]";
|
+ ioType + ", sourceSelection=" + sourceSelection + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue