1452: Implement a GUI for StatMan Algorithms Importer
Task-Url: https://support.d4science.org/issues/1452 Updated UI behavior git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122078 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -1,11 +1,11 @@
|
|||
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;
|
||||
|
||||
import com.google.gwt.regexp.shared.RegExp;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi email: <a
|
||||
|
@ -14,8 +14,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.Select
|
|||
*/
|
||||
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 IMAGE_PATTERN = "([^\\s]+(\\.(jpg|png|gif|bmp)\"))";
|
||||
private static final String FILE_PATTERN = "([^\\s]+(\\.(txt|csv|pdf|doc)\"))";
|
||||
private static final String ENUM1_PATTERN = "(c\\([^\\)]*\\))";
|
||||
private static final String ENUM2_PATTERN = "(\\{[^\\}]*\\})";
|
||||
|
||||
|
@ -33,7 +33,8 @@ public class CodeParser {
|
|||
if (parameter.contains("<-")) {
|
||||
String[] varDescription = parameter.split("<-");
|
||||
selectedRowsVariables = new SelectedRowsVariables(
|
||||
varDescription[0].trim(), varDescription[0].trim(), varDescription[1].trim(),
|
||||
varDescription[0].trim(), varDescription[0].trim(),
|
||||
varDescription[1].trim(),
|
||||
checkDataType(varDescription[1].trim()), ioType, parameter);
|
||||
|
||||
} else {
|
||||
|
@ -41,8 +42,9 @@ public class CodeParser {
|
|||
String[] varDescription = parameter.split("=");
|
||||
selectedRowsVariables = new SelectedRowsVariables(
|
||||
varDescription[0].trim(), varDescription[0].trim(),
|
||||
varDescription[1].trim(), checkDataType(varDescription[1].trim()),
|
||||
ioType, parameter);
|
||||
varDescription[1].trim(),
|
||||
checkDataType(varDescription[1].trim()), ioType,
|
||||
parameter);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -55,28 +57,27 @@ public class CodeParser {
|
|||
if (data == null || data.isEmpty()) {
|
||||
return DataType.STRING;
|
||||
}
|
||||
|
||||
|
||||
Pattern patternFile = Pattern.compile(FILE_PATTERN);
|
||||
if (patternFile.matcher(data).matches()) {
|
||||
|
||||
// Compile and use regular expression
|
||||
RegExp regExpFile = RegExp.compile(FILE_PATTERN);
|
||||
if (regExpFile.test(data)) {
|
||||
return DataType.FILE;
|
||||
}
|
||||
|
||||
Pattern patternImage = Pattern.compile(IMAGE_PATTERN);
|
||||
if (patternImage.matcher(data).matches()) {
|
||||
RegExp regExpImage = RegExp.compile(IMAGE_PATTERN);
|
||||
if (regExpImage.test(data)) {
|
||||
return DataType.FILE;
|
||||
}
|
||||
|
||||
Pattern patternEnum1 = Pattern.compile(ENUM1_PATTERN);
|
||||
if (patternEnum1.matcher(data).matches()) {
|
||||
|
||||
RegExp regExpEnum1 = RegExp.compile(ENUM1_PATTERN);
|
||||
if (regExpEnum1.test(data)) {
|
||||
return DataType.ENUMERATED;
|
||||
}
|
||||
|
||||
Pattern patternEnum2 = Pattern.compile(ENUM2_PATTERN);
|
||||
if (patternEnum2.matcher(data).matches()) {
|
||||
|
||||
RegExp regExpEnum2 = RegExp.compile(ENUM2_PATTERN);
|
||||
if (regExpEnum2.test(data)) {
|
||||
return DataType.ENUMERATED;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Integer.parseInt(data);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class CodeEditPanel extends ContentPanel {
|
|||
|
||||
private void create(Project project) {
|
||||
btnSave = new TextButton("Save");
|
||||
btnSave.setIcon(StatAlgoImporterResources.INSTANCE.add16());
|
||||
btnSave.setIcon(StatAlgoImporterResources.INSTANCE.save16());
|
||||
btnSave.setScale(ButtonScale.SMALL);
|
||||
btnSave.setIconAlign(IconAlign.LEFT);
|
||||
btnSave.setToolTip("Save");
|
||||
|
|
|
@ -25,6 +25,9 @@ import com.allen_sauer.gwt.log.client.Log;
|
|||
import com.google.gwt.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.core.client.dom.XDOM;
|
||||
import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.event.DialogHideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.DialogHideEvent.DialogHideHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -313,6 +316,36 @@ public class ProjectManager {
|
|||
}
|
||||
|
||||
public void setMainCode(final ItemDescription itemDescription) {
|
||||
if(project!=null&& project.getMainCode()!=null&& project.getMainCode().getItemDescription()!=null){
|
||||
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention",
|
||||
"All previous configurations will be lost. Would you like to change main code?");
|
||||
mb.addDialogHideHandler(new DialogHideHandler() {
|
||||
|
||||
@Override
|
||||
public void onDialogHide(DialogHideEvent event) {
|
||||
switch (event.getHideButton()) {
|
||||
case NO:
|
||||
break;
|
||||
case YES:
|
||||
setMainCodeOnServer(itemDescription);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mb.setWidth(300);
|
||||
mb.show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void setMainCodeOnServer(final ItemDescription itemDescription){
|
||||
|
||||
Log.debug("Set Main Code: " + itemDescription);
|
||||
StatAlgoImporterServiceAsync.INSTANCE.setMainCode(itemDescription,
|
||||
new AsyncCallback<Void>() {
|
||||
|
@ -335,7 +368,7 @@ public class ProjectManager {
|
|||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
project.setMainCode(new MainCode(itemDescription));
|
||||
fireProjectStatusUpdateEvent();
|
||||
fireProjectStatusMainCodeSetEvent();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -408,6 +441,14 @@ public class ProjectManager {
|
|||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
protected void fireProjectStatusMainCodeSetEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
ProjectStatusEventType.MAIN_CODE_SET, project);
|
||||
eventBus.fireEvent(projectStatusEvent);
|
||||
Log.debug("ProjectStatusEvent fired! " + projectStatusEvent);
|
||||
}
|
||||
|
||||
|
||||
protected void fireProjectStatusStartEvent() {
|
||||
ProjectStatusEvent projectStatusEvent = new ProjectStatusEvent(
|
||||
|
|
|
@ -96,5 +96,9 @@ public interface StatAlgoImporterResources extends ClientBundle {
|
|||
@Source("delete_16.png")
|
||||
ImageResource delete16();
|
||||
|
||||
|
||||
@Source("save_24.png")
|
||||
ImageResource save24();
|
||||
|
||||
@Source("save_16.png")
|
||||
ImageResource save16();
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 509 B |
Before Width: | Height: | Size: 803 B After Width: | Height: | Size: 758 B |
After Width: | Height: | Size: 501 B |
After Width: | Height: | Size: 720 B |
|
@ -136,7 +136,7 @@ public class HomeToolBar {
|
|||
btnSaveProject.setIconAlign(IconAlign.LEFT);
|
||||
btnSaveProject.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnSaveProject.setToolTip(msgs.btnSaveProjectToolTip());
|
||||
|
||||
btnSaveProject.disable();
|
||||
btnSaveProject.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -166,8 +166,9 @@ public class HomeToolBar {
|
|||
btnAddResource.setIconAlign(IconAlign.LEFT);
|
||||
btnAddResource.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnAddResource.setToolTip(msgs.btnAddResourceToolTip());
|
||||
btnAddResource.disable();
|
||||
btnAddResource.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new StatAlgoImporterRibbonEvent(
|
||||
StatAlgoImporterRibbonType.RESOURCE_ADD));
|
||||
|
@ -194,7 +195,7 @@ public class HomeToolBar {
|
|||
btnCreateSoftware.setIconAlign(IconAlign.LEFT);
|
||||
btnCreateSoftware.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
btnCreateSoftware.setToolTip(msgs.btnCreateSoftwareToolTip());
|
||||
|
||||
btnCreateSoftware.disable();
|
||||
btnCreateSoftware.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -356,14 +357,13 @@ public class HomeToolBar {
|
|||
case UPDATE:
|
||||
case ADD_RESOURCE:
|
||||
case DELETE_RESOURCE:
|
||||
case SAVE:
|
||||
case SAVE:
|
||||
case MAIN_CODE_SET:
|
||||
btnCreateProject.enable();
|
||||
btnOpenProject.enable();
|
||||
btnSaveProject.enable();
|
||||
btnAddResource.enable();
|
||||
btnHelp.enable();
|
||||
break;
|
||||
case MAIN_CODE_SET:
|
||||
btnCreateSoftware.enable();
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
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.EnvironmentVariablesProperties;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.DataTypePropertiesCombo;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.EnvironmentVariablesProperties;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.DataType;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -140,6 +141,7 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
&& project.getInputData().getListSelectedRows() != null) {
|
||||
storeEnvironmentVariable.addAll(project.getInputData()
|
||||
.getListEnvironmentVariables());
|
||||
seq = project.getInputData().getListEnvironmentVariables().size();
|
||||
}
|
||||
|
||||
final GridSelectionModel<EnvironmentVariables> sm = new GridSelectionModel<EnvironmentVariables>();
|
||||
|
@ -229,6 +231,22 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
if (addStatus) {
|
||||
addStatus = false;
|
||||
}
|
||||
|
||||
List<EnvironmentVariables> listSelected=storeEnvironmentVariable.getAll();
|
||||
List<EnvironmentVariables> listNewSelected= new ArrayList<EnvironmentVariables>();
|
||||
for(int i=0; i<listSelected.size(); i++){
|
||||
EnvironmentVariables var=listSelected.get(i);
|
||||
var.setId(i);
|
||||
listNewSelected.add(var);
|
||||
}
|
||||
|
||||
storeEnvironmentVariable.clear();
|
||||
storeEnvironmentVariable.addAll(listNewSelected);
|
||||
storeEnvironmentVariable.commitChanges();
|
||||
|
||||
seq=listNewSelected.size();
|
||||
Log.debug("Current Seq: "+seq);
|
||||
|
||||
}
|
||||
});
|
||||
ButtonBar buttonBar = gridEnvironmentVariableEditing.getButtonBar();
|
||||
|
@ -335,6 +353,7 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
storeEnvironmentVariable.clear();
|
||||
storeEnvironmentVariable.addAll(project.getInputData().getListEnvironmentVariables());
|
||||
storeEnvironmentVariable.commitChanges();
|
||||
seq = project.getInputData().getListEnvironmentVariables().size();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -345,4 +364,12 @@ public class EnvironmentVariablesPanel extends ContentPanel {
|
|||
return listEnviromentVarialbles;
|
||||
}
|
||||
|
||||
public void setMainCode(Project project) {
|
||||
storeEnvironmentVariable.clear();
|
||||
storeEnvironmentVariable.commitChanges();
|
||||
seq = 0;
|
||||
forceLayout();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class InputVariablePanel extends ContentPanel {
|
|||
|
||||
private EventBus eventBus;
|
||||
private InputVariableTabPanel inputVariableTabPanel;
|
||||
private InputVariablePanelState state;
|
||||
//private InputVariablePanelState state;
|
||||
|
||||
public InputVariablePanel(EventBus eventBus) {
|
||||
super();
|
||||
|
@ -124,6 +124,7 @@ public class InputVariablePanel extends ContentPanel {
|
|||
case ADD_RESOURCE:
|
||||
break;
|
||||
case MAIN_CODE_SET:
|
||||
setMainCode(event.getProject());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -145,16 +146,21 @@ public class InputVariablePanel extends ContentPanel {
|
|||
private void startPanel(Project project) {
|
||||
enable();
|
||||
expand();
|
||||
state = InputVariablePanelState.OPENED;
|
||||
//state = InputVariablePanelState.OPENED;
|
||||
inputVariableTabPanel.startTabs(project);
|
||||
|
||||
}
|
||||
|
||||
private void updatePanel(Project project) {
|
||||
if (state == InputVariablePanelState.OPENED) {
|
||||
inputVariableTabPanel.updateTabs(project);
|
||||
Log.debug("ToolBoxPanel Updated");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setMainCode(Project project) {
|
||||
inputVariableTabPanel.setMainCode(project);
|
||||
Log.debug("ToolBoxPanel Updated");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,20 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
*/
|
||||
|
||||
//
|
||||
public void setMainCode(Project project) {
|
||||
try {
|
||||
enviromentVariablesPanel.setMainCode(project);
|
||||
selectedRowsPanel.setMainCode(project);
|
||||
|
||||
forceLayout();
|
||||
} catch (Throwable e) {
|
||||
Log.error("Error in InputVariableTabPanel: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void updateTabs(Project project) {
|
||||
try {
|
||||
|
@ -133,4 +147,6 @@ public class InputVariableTabPanel extends TabPanel {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -453,4 +453,12 @@ public class SelectedRowsPanel extends ContentPanel {
|
|||
return listEnviromentVarialbles;
|
||||
}
|
||||
|
||||
public void setMainCode(Project project) {
|
||||
storeSelectedRows.clear();
|
||||
storeSelectedRows.commitChanges();
|
||||
seq = 0;
|
||||
forceLayout();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 509 B |
Before Width: | Height: | Size: 803 B After Width: | Height: | Size: 758 B |
After Width: | Height: | Size: 501 B |
After Width: | Height: | Size: 720 B |