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 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.resource.StatAlgoImporterResources;
|
||||
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.shared.code.CodeData;
|
||||
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 com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -92,7 +96,7 @@ public class CodeEditPanel extends ContentPanel {
|
|||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
||||
saveVariable(IOType.INPUT);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -107,7 +111,7 @@ public class CodeEditPanel extends ContentPanel {
|
|||
|
||||
@Override
|
||||
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() {
|
||||
String code = editor.getText();
|
||||
StatAlgoImporterServiceAsync.INSTANCE.saveCode(code,
|
||||
|
@ -250,7 +281,7 @@ public class CodeEditPanel extends ContentPanel {
|
|||
|
||||
if (editorSelection.isMultiLine()) {
|
||||
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()) {
|
||||
tempTest = editor.getLine(i);
|
||||
tempTest.substring(startPosition.getColumn());
|
||||
|
@ -258,7 +289,7 @@ public class CodeEditPanel extends ContentPanel {
|
|||
} else {
|
||||
if (i == endPosition.getRow()) {
|
||||
tempTest = editor.getLine(i);
|
||||
tempTest.substring(0, endPosition.getColumn() + 1);
|
||||
tempTest.substring(0, endPosition.getColumn());
|
||||
selectedText += tempTest;
|
||||
} else {
|
||||
selectedText += editor.getLine(i);
|
||||
|
@ -269,7 +300,7 @@ public class CodeEditPanel extends ContentPanel {
|
|||
String tempTest;
|
||||
tempTest = editor.getLine(startPosition.getRow());
|
||||
selectedText = tempTest.substring(startPosition.getColumn(),
|
||||
endPosition.getColumn() + 1);
|
||||
endPosition.getColumn());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,4 +29,7 @@ public interface SelectedRowsVariablesProperties extends
|
|||
|
||||
ValueProvider<SelectedRowsVariables, IOType> ioType();
|
||||
|
||||
ValueProvider<SelectedRowsVariables, String> sourceSelection();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
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.NewSelectedRowsVariableEvent;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.event.ProjectStatusEvent;
|
||||
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 com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -84,7 +86,29 @@ 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) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
|
||||
|
||||
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.Project;
|
||||
|
||||
|
@ -124,4 +125,12 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
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;
|
||||
|
||||
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.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.button.ButtonBar;
|
||||
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.VerticalLayoutContainer;
|
||||
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.GridSelectionModel;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
public SelectedRowsPanel(Project project, EventBus eventBus) {
|
||||
super();
|
||||
Log.debug("SelectedRowsPanel");
|
||||
|
@ -104,6 +102,13 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
private void create(Project project) {
|
||||
if (project != null && project.getInputData() != null
|
||||
&& project.getInputData().getListSelectedRows() != null) {
|
||||
seq = project.getInputData().getListSelectedRows().size();
|
||||
} else {
|
||||
seq = 0;
|
||||
}
|
||||
|
||||
// Grid
|
||||
SelectedRowsVariablesProperties props = GWT
|
||||
.create(SelectedRowsVariablesProperties.class);
|
||||
|
@ -133,8 +138,7 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
ColumnConfig<SelectedRowsVariables, String> defaultValueColumn = new ColumnConfig<SelectedRowsVariables, String>(
|
||||
props.defaultValue(), 100, "Default");
|
||||
// defaColumn.setMenuDisabled(true);
|
||||
|
||||
|
||||
|
||||
ColumnConfig<SelectedRowsVariables, IOType> ioTypeColumn = new ColumnConfig<SelectedRowsVariables, IOType>(
|
||||
props.ioType(), 100, "I/O");
|
||||
// inputTypeColumn.setMenuDisabled(true);
|
||||
|
@ -148,8 +152,6 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
sb.append(ioTypeTemplates.format(ioType.getLabel()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
ArrayList<ColumnConfig<SelectedRowsVariables, ?>> l = new ArrayList<ColumnConfig<SelectedRowsVariables, ?>>();
|
||||
l.add(nameColumn);
|
||||
|
@ -161,8 +163,7 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
ColumnModel<SelectedRowsVariables> columns = new ColumnModel<SelectedRowsVariables>(
|
||||
l);
|
||||
|
||||
storeSelectedRows = new ListStore<SelectedRowsVariables>(
|
||||
props.id());
|
||||
storeSelectedRows = new ListStore<SelectedRowsVariables>(props.id());
|
||||
|
||||
/*
|
||||
* ArrayList<SelectedRowsVariables> list = new ArrayList<>(); for (int i
|
||||
|
@ -174,14 +175,15 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
|
||||
if (project != null && project.getInputData() != null
|
||||
&& project.getInputData().getListSelectedRows() != null) {
|
||||
storeSelectedRows.addAll(project.getInputData().getListSelectedRows());
|
||||
storeSelectedRows.addAll(project.getInputData()
|
||||
.getListSelectedRows());
|
||||
}
|
||||
|
||||
final GridSelectionModel<SelectedRowsVariables> sm = new GridSelectionModel<SelectedRowsVariables>();
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
|
||||
gridSelectedRows = new Grid<SelectedRowsVariables>(
|
||||
storeSelectedRows, columns);
|
||||
gridSelectedRows = new Grid<SelectedRowsVariables>(storeSelectedRows,
|
||||
columns);
|
||||
gridSelectedRows.setSelectionModel(sm);
|
||||
gridSelectedRows.getView().setStripeRows(true);
|
||||
gridSelectedRows.getView().setColumnLines(true);
|
||||
|
@ -207,7 +209,7 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
*/
|
||||
|
||||
// EDITING //
|
||||
|
||||
|
||||
// DataType
|
||||
DataTypePropertiesCombo dataTypePropertiesCombo = GWT
|
||||
.create(DataTypePropertiesCombo.class);
|
||||
|
@ -222,13 +224,16 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
|
||||
comboDataType.setTriggerAction(TriggerAction.ALL);
|
||||
addHandlersForComboDataType(dataTypePropertiesCombo.label());
|
||||
|
||||
|
||||
storeComboDataType.clear();
|
||||
storeComboDataType.addAll(DataType.asList());
|
||||
storeComboDataType.commitChanges();
|
||||
|
||||
// IOType
|
||||
IOTypePropertiesCombo ioTypePropertiesCombo = GWT
|
||||
.create(IOTypePropertiesCombo.class);
|
||||
|
||||
storeComboIOType = new ListStore<IOType>(
|
||||
ioTypePropertiesCombo.id());
|
||||
storeComboIOType = new ListStore<IOType>(ioTypePropertiesCombo.id());
|
||||
|
||||
comboIOType = new ComboBox<IOType>(storeComboIOType,
|
||||
ioTypePropertiesCombo.label());
|
||||
|
@ -238,22 +243,20 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
comboIOType.setTriggerAction(TriggerAction.ALL);
|
||||
addHandlersForComboIOType(ioTypePropertiesCombo.label());
|
||||
|
||||
|
||||
storeComboIOType.clear();
|
||||
storeComboIOType.addAll(IOType.asList());
|
||||
storeComboIOType.commitChanges();
|
||||
|
||||
//
|
||||
|
||||
|
||||
gridSelectedRowsEditing = new GridRowEditing<SelectedRowsVariables>(
|
||||
gridSelectedRows);
|
||||
gridSelectedRowsEditing.addEditor(nameColumn, new TextField());
|
||||
gridSelectedRowsEditing.addEditor(descriptionColumn,
|
||||
new TextField());
|
||||
gridSelectedRowsEditing.addEditor(dataTypeColumn,
|
||||
comboDataType);
|
||||
gridSelectedRowsEditing.addEditor(defaultValueColumn,
|
||||
new TextField());
|
||||
|
||||
gridSelectedRowsEditing.addEditor(ioTypeColumn,
|
||||
comboIOType);
|
||||
|
||||
gridSelectedRowsEditing.addEditor(descriptionColumn, new TextField());
|
||||
gridSelectedRowsEditing.addEditor(dataTypeColumn, comboDataType);
|
||||
gridSelectedRowsEditing.addEditor(defaultValueColumn, new TextField());
|
||||
|
||||
gridSelectedRowsEditing.addEditor(ioTypeColumn, comboIOType);
|
||||
|
||||
btnAdd = new TextButton();
|
||||
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||
|
@ -279,12 +282,27 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
storeSelectedRows.remove(rowIndex);
|
||||
storeSelectedRows.commitChanges();
|
||||
|
||||
gridSelectedRowsEditing.getCancelButton().setVisible(
|
||||
true);
|
||||
gridSelectedRowsEditing.getCancelButton().setVisible(true);
|
||||
btnAdd.setEnabled(true);
|
||||
if (addStatus) {
|
||||
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();
|
||||
|
@ -338,14 +356,14 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
}
|
||||
});
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
|
||||
// ToolBar toolBar = new ToolBar();
|
||||
// toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
|
||||
|
||||
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
|
||||
vlc.setAdjustForScroll(false);
|
||||
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)));
|
||||
|
||||
add(vlc, new MarginData(new Margins(0)));
|
||||
|
@ -368,23 +386,43 @@ 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) {
|
||||
try {
|
||||
Log.debug("Current Seq: " + seq);
|
||||
seq++;
|
||||
SelectedRowsVariables newEnvironmentVariable = new SelectedRowsVariables(
|
||||
seq, "", "", "", DataType.STRING, IOType.INPUT);
|
||||
Log.debug("New Environment Variable: " + newEnvironmentVariable);
|
||||
SelectedRowsVariables newSelectedRowsVariable = new SelectedRowsVariables(
|
||||
seq, "", "", "", DataType.STRING, IOType.INPUT, "");
|
||||
Log.debug("New Selected Rows Variable: " + newSelectedRowsVariable);
|
||||
gridSelectedRowsEditing.cancelEditing();
|
||||
addStatus = true;
|
||||
gridSelectedRowsEditing.getCancelButton().setVisible(false);
|
||||
storeSelectedRows.add(newEnvironmentVariable);
|
||||
int row = storeSelectedRows.indexOf(newEnvironmentVariable);
|
||||
storeSelectedRows.add(newSelectedRowsVariable);
|
||||
int row = storeSelectedRows.indexOf(newSelectedRowsVariable);
|
||||
|
||||
storeComboDataType.clear();
|
||||
storeComboDataType.addAll(DataType.asList());
|
||||
storeComboDataType.commitChanges();
|
||||
|
||||
|
||||
storeComboIOType.clear();
|
||||
storeComboIOType.addAll(IOType.asList());
|
||||
storeComboIOType.commitChanges();
|
||||
|
@ -396,12 +434,15 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
public void update(Project project) {
|
||||
Log.debug("Update Selected Rows: " + project);
|
||||
if (project != null && project.getInputData() != null
|
||||
&& project.getInputData().getListSelectedRows() != null) {
|
||||
storeSelectedRows.clear();
|
||||
storeSelectedRows.addAll(project.getInputData().getListSelectedRows());
|
||||
storeSelectedRows.addAll(project.getInputData()
|
||||
.getListSelectedRows());
|
||||
storeSelectedRows.commitChanges();
|
||||
|
||||
seq = project.getInputData().getListSelectedRows().size();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,14 +11,11 @@ import java.util.List;
|
|||
*/
|
||||
public enum DataType {
|
||||
STRING("String"),
|
||||
NUMBER("Number"),
|
||||
INTEGER("Integer"),
|
||||
DOUBLE("Double"),
|
||||
ENUMERATED("Enumerated"),
|
||||
CONSTANT("Constant"),
|
||||
RANDOM("Random"),
|
||||
FILE("File"),
|
||||
MAP("Map"),
|
||||
BOOLEAN("Boolean"),
|
||||
IMAGES("Images");
|
||||
BOOLEAN("Boolean");
|
||||
|
||||
|
||||
//private static InputTypeMessages msgs=GWT.create(InputTypeMessages.class);
|
||||
|
|
|
@ -17,13 +17,28 @@ public class SelectedRowsVariables implements Serializable {
|
|||
private String defaultValue;
|
||||
private DataType dataType;
|
||||
private IOType ioType;
|
||||
|
||||
private String sourceSelection;
|
||||
|
||||
public SelectedRowsVariables() {
|
||||
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,
|
||||
String defaultValue, DataType dataType, IOType ioType) {
|
||||
String defaultValue, DataType dataType, IOType ioType,
|
||||
String sourceSelection) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
|
@ -31,6 +46,7 @@ public class SelectedRowsVariables implements Serializable {
|
|||
this.defaultValue = defaultValue;
|
||||
this.dataType = dataType;
|
||||
this.ioType = ioType;
|
||||
this.sourceSelection = sourceSelection;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
@ -81,15 +97,22 @@ public class SelectedRowsVariables implements Serializable {
|
|||
this.ioType = ioType;
|
||||
}
|
||||
|
||||
public String getSourceSelection() {
|
||||
return sourceSelection;
|
||||
}
|
||||
|
||||
public void setSourceSelection(String sourceSelection) {
|
||||
this.sourceSelection = sourceSelection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SelectedRowsVariables [id=" + id + ", name=" + name
|
||||
+ ", description=" + description + ", defaultValue="
|
||||
+ defaultValue + ", dataType=" + dataType + ", ioType="
|
||||
+ ioType + "]";
|
||||
+ ioType + ", sourceSelection=" + sourceSelection + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue