Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
65958370
Commit
65958370
authored
14 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
[LMS-1833] refactorization (part 1)
SVN: 18309
parent
7808fa4d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/ParameterField.java
+36
-129
36 additions, 129 deletions
...lient/web/client/application/ui/field/ParameterField.java
with
36 additions
and
129 deletions
openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/ParameterField.java
+
36
−
129
View file @
65958370
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field
;
package
ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
com.extjs.gxt.ui.client.data.ModelData
;
import
com.extjs.gxt.ui.client.data.ModelData
;
...
@@ -27,12 +26,9 @@ import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
...
@@ -27,12 +26,9 @@ import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import
com.extjs.gxt.ui.client.event.SelectionChangedListener
;
import
com.extjs.gxt.ui.client.event.SelectionChangedListener
;
import
com.extjs.gxt.ui.client.widget.MessageBox
;
import
com.extjs.gxt.ui.client.widget.MessageBox
;
import
com.extjs.gxt.ui.client.widget.form.Field
;
import
com.extjs.gxt.ui.client.widget.form.Field
;
import
com.extjs.gxt.ui.client.widget.form.SimpleComboBox
;
import
com.extjs.gxt.ui.client.widget.form.SimpleComboValue
;
import
com.extjs.gxt.ui.client.widget.form.TriggerField
;
import
com.extjs.gxt.ui.client.widget.form.TriggerField
;
import
com.google.gwt.user.client.Element
;
import
com.google.gwt.user.client.Element
;
import
ch.systemsx.cisd.common.shared.basic.utils.StringUtils
;
import
ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback
;
import
ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback
;
import
ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext
;
import
ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext
;
import
ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames
;
import
ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames
;
...
@@ -61,12 +57,6 @@ public class ParameterField extends TriggerField<ModelData> implements IParamete
...
@@ -61,12 +57,6 @@ public class ParameterField extends TriggerField<ModelData> implements IParamete
private
static
String
QUERY_LIST_EXPRESSION_PREFIX
=
"query="
;
private
static
String
QUERY_LIST_EXPRESSION_PREFIX
=
"query="
;
private
final
String
parameterName
;
private
final
IDelegatedAction
onValueChangeAction
;
private
final
String
initialValueOrNull
;
public
static
IParameterField
create
(
IViewContext
<?>
viewContextOrNull
,
String
parameterName
,
public
static
IParameterField
create
(
IViewContext
<?>
viewContextOrNull
,
String
parameterName
,
String
initialValueOrNull
,
IDelegatedAction
onValueChangeAction
,
String
initialValueOrNull
,
IDelegatedAction
onValueChangeAction
,
IParameterValuesLoader
loaderOrNull
)
IParameterValuesLoader
loaderOrNull
)
...
@@ -74,40 +64,41 @@ public class ParameterField extends TriggerField<ModelData> implements IParamete
...
@@ -74,40 +64,41 @@ public class ParameterField extends TriggerField<ModelData> implements IParamete
String
[]
split
=
parameterName
.
split
(
PARAMETER_NAME_SEPARATOR
);
String
[]
split
=
parameterName
.
split
(
PARAMETER_NAME_SEPARATOR
);
if
(
split
.
length
==
2
)
if
(
split
.
length
==
2
)
{
{
String
namePart
=
split
[
0
];
final
String
namePart
=
split
[
0
];
String
expressionPart
=
split
[
1
];
final
String
expressionPart
=
split
[
1
];
final
String
idSuffix
=
parameterName
.
replaceAll
(
" "
,
"_"
);
if
(
expressionPart
.
startsWith
(
ENUM_LIST_EXPRESSION_PREFIX
))
if
(
expressionPart
.
startsWith
(
ENUM_LIST_EXPRESSION_PREFIX
))
{
{
String
itemList
=
expressionPart
.
substring
(
ENUM_LIST_EXPRESSION_PREFIX
.
length
());
String
itemList
=
expressionPart
.
substring
(
ENUM_LIST_EXPRESSION_PREFIX
.
length
());
String
[]
values
=
itemList
.
split
(
ENUM_LIST_SEPARATOR
);
String
[]
values
=
itemList
.
split
(
ENUM_LIST_SEPARATOR
);
return
createSelectionField
(
namePart
,
Arrays
.
asList
(
values
),
initialValueOrNull
,
List
<
ParameterValue
>
parameterValues
=
new
ArrayList
<
ParameterValue
>();
onValueChangeAction
);
for
(
String
value
:
values
)
{
parameterValues
.
add
(
new
ParameterValue
(
value
,
null
));
}
return
ParameterSelectionDropDownList
.
createWithValues
(
parameterName
,
idSuffix
,
parameterValues
,
initialValueOrNull
,
onValueChangeAction
);
}
else
if
(
expressionPart
.
startsWith
(
QUERY_LIST_EXPRESSION_PREFIX
))
}
else
if
(
expressionPart
.
startsWith
(
QUERY_LIST_EXPRESSION_PREFIX
))
{
{
String
queryExpression
=
String
queryExpression
=
expressionPart
.
substring
(
QUERY_LIST_EXPRESSION_PREFIX
.
length
());
expressionPart
.
substring
(
QUERY_LIST_EXPRESSION_PREFIX
.
length
());
return
createSelectionField
(
viewContextOrNull
,
namePart
,
queryExpression
,
return
ParameterSelectionDropDownList
.
createWithLoader
(
parameterName
,
loaderOrNull
,
initialValueOrNull
,
onValueChangeAction
);
queryExpression
,
idSuffix
,
viewContextOrNull
,
loaderOrNull
,
initialValueOrNull
,
onValueChangeAction
);
}
else
}
else
{
{
MessageBox
.
alert
(
"Error"
,
"Filter parameter '"
+
namePart
MessageBox
.
alert
(
"Error"
,
"Filter parameter '"
+
namePart
+
"' is not defined properly."
,
null
);
+
"' is not defined properly."
,
null
);
return
new
ParameterField
(
namePart
,
onValueChangeAction
,
initialValueOrNull
);
}
}
}
}
return
new
ParameterField
(
parameterName
,
onValueChangeAction
,
initialValueOrNull
);
return
new
ParameterField
(
parameterName
,
onValueChangeAction
,
initialValueOrNull
);
}
}
private
static
IParameterField
createSelectionField
(
IViewContext
<?>
viewContextOrNull
,
private
final
String
parameterName
;
String
parameterName
,
String
queryExpression
,
IParameterValuesLoader
loaderOrNull
,
String
initialValueOrNull
,
IDelegatedAction
onValueChangeAction
)
private
final
IDelegatedAction
onValueChangeAction
;
{
final
String
idSuffix
=
parameterName
.
replaceAll
(
" "
,
"_"
);
private
final
String
initialValueOrNull
;
return
ParameterSelectionDropDownList
.
create
(
parameterName
,
queryExpression
,
idSuffix
,
parameterName
,
viewContextOrNull
,
loaderOrNull
,
true
,
initialValueOrNull
,
onValueChangeAction
);
}
private
ParameterField
(
String
parameterName
,
IDelegatedAction
onValueChangeAction
,
private
ParameterField
(
String
parameterName
,
IDelegatedAction
onValueChangeAction
,
String
initialValueOrNull
)
String
initialValueOrNull
)
...
@@ -156,84 +147,7 @@ public class ParameterField extends TriggerField<ModelData> implements IParamete
...
@@ -156,84 +147,7 @@ public class ParameterField extends TriggerField<ModelData> implements IParamete
onValueChangeAction
.
execute
();
onValueChangeAction
.
execute
();
}
}
private
static
ParameterSelectionField
createSelectionField
(
String
parameterName
,
List
<
String
>
parameterValues
,
String
initialValueOrNull
,
IDelegatedAction
onValueChangeAction
)
{
return
new
ParameterSelectionField
(
parameterName
,
parameterValues
,
initialValueOrNull
,
onValueChangeAction
);
}
// TODO 2010-10-13, Piotr Buczek: extract common code with ParameterField
// TODO 2010-10-13, Piotr Buczek: extract common code with ParameterField
private
static
class
ParameterSelectionField
extends
SimpleComboBox
<
String
>
implements
IParameterField
{
private
final
String
parameterName
;
private
final
String
initialValueOrNull
;
private
final
IDelegatedAction
onValueChangeAction
;
ParameterSelectionField
(
final
String
parameterName
,
final
List
<
String
>
values
,
String
initialValueOrNull
,
final
IDelegatedAction
onValueChangeAction
)
{
this
.
parameterName
=
parameterName
;
this
.
initialValueOrNull
=
initialValueOrNull
;
this
.
onValueChangeAction
=
onValueChangeAction
;
GWTUtils
.
setToolTip
(
this
,
parameterName
);
GWTUtils
.
setupAutoWidth
(
this
);
setEmptyText
(
emptyText
);
setAllowBlank
(
false
);
setAutoValidate
(
true
);
setValidateOnBlur
(
true
);
setWidth
(
100
);
add
(
values
);
getPropertyEditor
().
setList
(
store
.
getModels
());
addSelectionChangedListener
(
new
SelectionChangedListener
<
SimpleComboValue
<
String
>>()
{
@Override
public
void
selectionChanged
(
SelectionChangedEvent
<
SimpleComboValue
<
String
>>
se
)
{
onValueChangeAction
.
execute
();
}
});
}
@Override
public
String
getSimpleValue
()
{
return
StringUtils
.
trimToNull
(
super
.
getSimpleValue
());
}
public
Field
<?>
asWidget
()
{
return
this
;
}
public
ParameterWithValue
getParameterWithValue
()
{
return
new
ParameterWithValue
(
parameterName
,
getRawValue
());
}
@Override
protected
void
onRender
(
Element
target
,
int
index
)
{
super
.
onRender
(
target
,
index
);
setRawValue
(
initialValueOrNull
);
}
@Override
protected
void
onKeyUp
(
FieldEvent
fe
)
{
super
.
onKeyUp
(
fe
);
onValueChangeAction
.
execute
();
}
}
private
static
class
ParameterSelectionDropDownList
extends
private
static
class
ParameterSelectionDropDownList
extends
DropDownList
<
ParameterValueModel
,
ParameterValue
>
implements
IParameterField
DropDownList
<
ParameterValueModel
,
ParameterValue
>
implements
IParameterField
{
{
...
@@ -257,57 +171,50 @@ public class ParameterField extends TriggerField<ModelData> implements IParamete
...
@@ -257,57 +171,50 @@ public class ParameterField extends TriggerField<ModelData> implements IParamete
private
final
IDelegatedAction
onValueChangeAction
;
private
final
IDelegatedAction
onValueChangeAction
;
/**
/**
* Allows to choose one of the specified values, is able to refresh the available values by
* Allows to choose one of the values received from server.
* calling the server.
*
* @param onValueChangeAction
*/
*/
public
static
IParameterField
create
(
final
String
parameterName
,
String
queryExpression
,
public
static
IParameterField
create
WithLoader
(
final
String
parameterName
,
String
idSuffix
,
String
label
,
IViewContext
<?>
viewContextOrNull
,
String
queryExpression
,
String
idSuffix
,
IViewContext
<?>
viewContextOrNull
,
IParameterValuesLoader
loader
,
final
boolean
mandatory
,
String
initialValueOrNull
,
IParameterValuesLoader
loader
,
String
initialValueOrNull
,
IDelegatedAction
onValueChangeAction
)
IDelegatedAction
onValueChangeAction
)
{
{
return
new
ParameterSelectionDropDownList
(
parameterName
,
idSuffix
,
label
,
mandatory
,
return
new
ParameterSelectionDropDownList
(
parameterName
,
idSuffix
,
viewContextOrNull
,
loader
,
queryExpression
,
viewContextOrNull
,
null
,
initialValueOrNull
,
loader
,
queryExpression
,
null
,
initialValueOrNull
,
onValueChangeAction
);
onValueChangeAction
);
}
}
/**
/**
* Allows to choose one of the specified values.
* Allows to choose one of the specified values.
*/
*/
@SuppressWarnings
(
"unused"
)
public
static
IParameterField
createWithValues
(
final
String
parameterName
,
String
idSuffix
,
public
ParameterSelectionDropDownList
(
final
String
parameterName
,
String
idSuffix
,
List
<
ParameterValue
>
initialValues
,
String
initialValueOrNull
,
String
label
,
final
boolean
mandatory
,
List
<
ParameterValue
>
initialValuesOrNull
,
IDelegatedAction
onValueChangeAction
)
String
initialValueOrNull
)
{
{
th
is
(
parameterName
,
idSuffix
,
label
,
mandatory
,
null
,
null
,
null
,
initialValuesOrN
ull
,
return
new
ParameterSelectionDropDownL
is
t
(
parameterName
,
idSuffix
,
null
,
null
,
n
ull
,
initialValue
OrNull
,
null
);
initialValue
s
,
initialValueOrNull
,
onValueChangeAction
);
}
}
protected
ParameterSelectionDropDownList
(
final
String
parameterName
,
String
idSuffix
,
protected
ParameterSelectionDropDownList
(
final
String
parameterName
,
String
idSuffix
,
String
label
,
boolean
mandatory
,
IParameterValuesLoader
loaderOrNull
,
IViewContext
<?>
viewContextOrNull
,
IParameterValuesLoader
loaderOrNull
,
String
queryExpressionOrNull
,
IViewContext
<?>
viewContextOrNull
,
String
queryExpressionOrNull
,
List
<
ParameterValue
>
valuesOrNull
,
List
<
ParameterValue
>
valuesOrNull
,
String
initialValueOrNull
,
String
initialValueOrNull
,
final
IDelegatedAction
onValueChangeAction
)
final
IDelegatedAction
onValueChangeAction
)
{
{
super
(
idSuffix
,
ModelDataPropertyNames
.
CODE
,
label
,
CHOOSE_MSG
,
EMPTY_MSG
,
super
(
idSuffix
,
ModelDataPropertyNames
.
CODE
,
parameterName
,
CHOOSE_MSG
,
EMPTY_MSG
,
VALUE_NOT_IN_LIST_MSG
,
mandatory
,
viewContextOrNull
,
valuesOrNull
==
null
);
VALUE_NOT_IN_LIST_MSG
,
true
,
viewContextOrNull
,
valuesOrNull
==
null
);
this
.
parameterName
=
parameterName
;
this
.
parameterName
=
parameterName
;
this
.
queryExpressionOrNull
=
queryExpressionOrNull
;
this
.
queryExpressionOrNull
=
queryExpressionOrNull
;
this
.
viewContextOrNull
=
viewContextOrNull
;
this
.
viewContextOrNull
=
viewContextOrNull
;
this
.
loaderOrNull
=
loaderOrNull
;
this
.
loaderOrNull
=
loaderOrNull
;
this
.
initialValueOrNull
=
initialValueOrNull
;
this
.
initialValueOrNull
=
initialValueOrNull
;
this
.
onValueChangeAction
=
onValueChangeAction
;
this
.
onValueChangeAction
=
onValueChangeAction
;
FieldUtil
.
setMandatoryFlag
(
this
,
mandatory
);
setAllowBlank
(
mandatory
==
false
);
if
(
valuesOrNull
!=
null
)
if
(
valuesOrNull
!=
null
)
{
{
setValues
(
valuesOrNull
);
setValues
(
valuesOrNull
);
}
}
setTemplate
(
GWTUtils
.
getTooltipTemplate
(
ModelDataPropertyNames
.
CODE
,
setTemplate
(
GWTUtils
.
getTooltipTemplate
(
ModelDataPropertyNames
.
CODE
,
ModelDataPropertyNames
.
TOOLTIP
));
ModelDataPropertyNames
.
TOOLTIP
));
setWidth
(
100
);
FieldUtil
.
setMandatoryFlag
(
this
,
true
);
setAllowValueNotFromList
(
true
);
setAllowValueNotFromList
(
true
);
setWidth
(
100
);
addSelectionChangedListener
(
new
SelectionChangedListener
<
ParameterValueModel
>()
addSelectionChangedListener
(
new
SelectionChangedListener
<
ParameterValueModel
>()
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment