diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/custom/ColonSpaceValidator.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/custom/ColonSpaceValidator.java new file mode 100644 index 0000000..68a8013 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/custom/ColonSpaceValidator.java @@ -0,0 +1,25 @@ +package org.gcube.portlets.user.statisticalalgorithmsimporter.client.custom; + +import java.util.List; + +import com.google.gwt.editor.client.Editor; +import com.google.gwt.editor.client.EditorError; +import com.sencha.gxt.widget.core.client.form.validator.AbstractValidator; + +/** + * + * @author Giancarlo Panichi + * + * + */ +public class ColonSpaceValidator extends AbstractValidator { + + @Override + public List validate(Editor editor, String value) { + if (value != null && !value.isEmpty() && value.contains(": ")) { + return createError(editor, "Invalid sequence of characters=': '", value); + } + return null; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableTabPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableTabPanel.java index ccf8c79..9b1da13 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableTabPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/InputVariableTabPanel.java @@ -77,10 +77,10 @@ public class InputVariableTabPanel extends TabPanel { // public void setMainCode(Project project) { try { - globalVariablesPanel.update(project); - inputOutputVariablesPanel.update(project); projectInfoPanel.update(project); + inputOutputVariablesPanel.update(project); interpreterInfoPanel.update(project); + globalVariablesPanel.update(project); forceLayout(); } catch (Throwable e) { Log.error("Error in InputVariableTabPanel: " + e.getLocalizedMessage()); @@ -91,10 +91,10 @@ public class InputVariableTabPanel extends TabPanel { public void setBinaryCode(Project project) { try { - globalVariablesPanel.update(project); - inputOutputVariablesPanel.update(project); projectInfoPanel.update(project); + inputOutputVariablesPanel.update(project); interpreterInfoPanel.update(project); + globalVariablesPanel.update(project); forceLayout(); } catch (Throwable e) { Log.error("Error in InputVariableTabPanel: " + e.getLocalizedMessage()); @@ -105,10 +105,10 @@ public class InputVariableTabPanel extends TabPanel { public void updateTabs(Project project) { try { - globalVariablesPanel.update(project); + projectInfoPanel.update(project); inputOutputVariablesPanel.update(project); interpreterInfoPanel.update(project); - projectInfoPanel.update(project); + globalVariablesPanel.update(project); forceLayout(); } catch (Throwable e) { Log.error("Error in InputVariableTabPanel: " + e.getLocalizedMessage()); @@ -120,29 +120,30 @@ public class InputVariableTabPanel extends TabPanel { InputData inputData = new InputData(); - if (globalVariablesPanel != null) { - inputData.setListGlobalVariables(globalVariablesPanel.getGlobalVariables()); - } - - if (inputOutputVariablesPanel != null) { - inputData.setListInputOutputVariables(inputOutputVariablesPanel.getInputOutputVariables()); - } - - if (interpreterInfoPanel != null) { - inputData.setInterpreterInfo(interpreterInfoPanel.getInterpreterInfo()); - } - InputReadyEvent inputReadyEvent; + try { if (projectInfoPanel != null) { ProjectInfo projectInfo = projectInfoPanel.getProjectInfo(); inputData.setProjectInfo(projectInfo); - inputReadyEvent = new InputReadyEvent(inputData); - } else { - inputReadyEvent = new InputReadyEvent(inputData, "Error loading ProjectInfoPanel!"); } - } catch (Exception e) { - Log.error("Attention invalid project info: " + e.getLocalizedMessage()); + + if (inputOutputVariablesPanel != null) { + inputData.setListInputOutputVariables(inputOutputVariablesPanel.getInputOutputVariables()); + } + + if (interpreterInfoPanel != null) { + inputData.setInterpreterInfo(interpreterInfoPanel.getInterpreterInfo()); + } + + if (globalVariablesPanel != null) { + inputData.setListGlobalVariables(globalVariablesPanel.getGlobalVariables()); + } + + inputReadyEvent = new InputReadyEvent(inputData); + + } catch (Throwable e) { + Log.error("Attention invalid info: " + e.getLocalizedMessage()); inputReadyEvent = new InputReadyEvent(inputData, e.getLocalizedMessage()); } @@ -152,6 +153,15 @@ public class InputVariableTabPanel extends TabPanel { } // Add + private void addProjectInfoPanel(Project project) { + TabItemConfig projectInfoPanelItemConf = new TabItemConfig(msgs.projectInfo(), false); + + projectInfoPanel = new ProjectInfoPanel(project, eventBus); + projectInfoPanel.setHeaderVisible(false); + add(projectInfoPanel, projectInfoPanelItemConf); + + } + private void addInputOutputVariablesPanel(Project project) { TabItemConfig inputOutputPanelItemConf = new TabItemConfig(msgs.inputOutputVariables(), false); @@ -178,15 +188,6 @@ public class InputVariableTabPanel extends TabPanel { } - private void addProjectInfoPanel(Project project) { - TabItemConfig projectInfoPanelItemConf = new TabItemConfig(msgs.projectInfo(), false); - - projectInfoPanel = new ProjectInfoPanel(project, eventBus); - projectInfoPanel.setHeaderVisible(false); - add(projectInfoPanel, projectInfoPanelItemConf); - - } - public void addSelectedRowsVariable(InputOutputVariables inputOutputVariable) { setActiveWidget(inputOutputVariablesPanel); inputOutputVariablesPanel.addNewInputOutputVariables(inputOutputVariable); diff --git a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java index c063939..cdd95de 100644 --- a/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java +++ b/src/main/java/org/gcube/portlets/user/statisticalalgorithmsimporter/client/tools/input/ProjectInfoPanel.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input; +import org.gcube.portlets.user.statisticalalgorithmsimporter.client.custom.ColonSpaceValidator; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.ProjectInfo; import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project; @@ -73,9 +74,11 @@ public class ProjectInfoPanel extends ContentPanel { algorithmDescription = new TextField(); algorithmDescription.setAllowBlank(false); algorithmDescription.setEmptyText("Enter description..."); + algorithmDescription.addValidator(new ColonSpaceValidator()); algorithmDescription.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed")); algorithmDescription.addValidator(new RegExValidator("^[^|]*$", "Attention character | is not allowed")); - + algorithmDescription.addValidator(new RegExValidator("^[a-zA-Z0-9_\\-\\s\\t\\.,;:\\(\\)\\[\\]\\{\\}/~]*$", "Attention the special characters are not allowed")); + FieldLabel descriptionLabel = new FieldLabel(algorithmDescription, "Description"); descriptionLabel.setLabelWidth(LABAEL_WIDTH);