From c96134de8dc334e3f3cf2e5851b2e6bc52e8f80d Mon Sep 17 00:00:00 2001 From: izabel <izabel> Date: Wed, 1 Dec 2010 10:01:53 +0000 Subject: [PATCH] [LMS-1903] script tester: automatically set entity kind value SVN: 18952 --- .../script/AbstractScriptEditRegisterForm.java | 17 ++++++++++++++++- .../ui/script/ScriptExecutionFramework.java | 13 +++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/AbstractScriptEditRegisterForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/AbstractScriptEditRegisterForm.java index 59559425dc4..5f4e7bae029 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/AbstractScriptEditRegisterForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/AbstractScriptEditRegisterForm.java @@ -20,8 +20,11 @@ import com.extjs.gxt.ui.client.event.BaseEvent; import com.extjs.gxt.ui.client.event.ButtonEvent; import com.extjs.gxt.ui.client.event.Events; import com.extjs.gxt.ui.client.event.Listener; +import com.extjs.gxt.ui.client.event.SelectionChangedEvent; +import com.extjs.gxt.ui.client.event.SelectionChangedListener; import com.extjs.gxt.ui.client.event.SelectionListener; import com.extjs.gxt.ui.client.widget.form.FormPanel; +import com.extjs.gxt.ui.client.widget.form.SimpleComboValue; import com.extjs.gxt.ui.client.widget.form.TextField; import com.google.gwt.user.client.Element; @@ -78,12 +81,24 @@ abstract public class AbstractScriptEditRegisterForm extends AbstractRegistratio super(viewContext, createId(scriptIdOrNull), DEFAULT_LABEL_WIDTH + 20, DEFAULT_FIELD_WIDTH); this.viewContext = viewContext; this.nameField = new VarcharField(viewContext.getMessage(Dict.NAME), true); + this.scriptExecution = + new ScriptExecutionFramework(viewContext, asValidable(formPanel), entityKindOrNull); this.entityKindField = new EntityKindSelectionWidget(viewContext, entityKindOrNull, scriptIdOrNull == null, true); + entityKindField + .addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() + { + @Override + public void selectionChanged( + SelectionChangedEvent<SimpleComboValue<String>> se) + { + scriptExecution.updateEntityKind(entityKindField.tryGetEntityKind()); + } + }); this.descriptionField = AbstractRegistrationDialog.createDescriptionField(viewContext); this.scriptField = createScriptField(viewContext); - this.scriptExecution = new ScriptExecutionFramework(viewContext, asValidable(formPanel)); + scriptField.addListener(Events.Change, new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/ScriptExecutionFramework.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/ScriptExecutionFramework.java index dda9e45d301..0b7dec96153 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/ScriptExecutionFramework.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/script/ScriptExecutionFramework.java @@ -116,11 +116,12 @@ public class ScriptExecutionFramework } public ScriptExecutionFramework(IViewContext<ICommonClientServiceAsync> viewContext, - IValidable validable) + IValidable validable, EntityKind entityKindOrNull) { this.viewContext = viewContext; this.validable = validable; - entityKindChooser = new EntityKindSelectionWidget(viewContext, null, true, false); + entityKindChooser = + new EntityKindSelectionWidget(viewContext, entityKindOrNull, true, false); sampleChooser = SampleChooserField.create(viewContext.getMessage(Dict.SAMPLE), true, null, true, true, false, viewContext.getCommonViewContext(), @@ -285,6 +286,14 @@ public class ScriptExecutionFramework state.setScript(script); } + public void updateEntityKind(EntityKind kind) + { + if (kind != null) + { + entityKindChooser.setSimpleValue(kind.name()); + } + } + private void evaluate() { if (StringUtils.isBlank(sampleChooser.getValue()) == false) -- GitLab