Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
af3
kernel
Commits
74c67a21
Commit
74c67a21
authored
11 years ago
by
Cheng Zhang
Browse files
Options
Downloads
Patches
Plain Diff
refactor code
refs 1494
parent
d9860f12
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/DataBindingUtils.java
+18
-54
18 additions, 54 deletions
.../org/fortiss/tooling/kernel/ui/util/DataBindingUtils.java
with
18 additions
and
54 deletions
org.fortiss.tooling.kernel.ui/trunk/src/org/fortiss/tooling/kernel/ui/util/DataBindingUtils.java
+
18
−
54
View file @
74c67a21
...
...
@@ -17,15 +17,11 @@ $Id$
+--------------------------------------------------------------------------*/
package
org.fortiss.tooling.kernel.ui.util
;
import
static
org
.
eclipse
.
core
.
databinding
.
UpdateValueStrategy
.
POLICY_NEVER
;
import
org.conqat.ide.commons.ui.databinding.JFaceObservables
;
import
org.eclipse.core.databinding.Binding
;
import
org.eclipse.core.databinding.DataBindingContext
;
import
org.eclipse.core.databinding.UpdateListStrategy
;
import
org.eclipse.core.databinding.UpdateValueStrategy
;
import
org.eclipse.core.databinding.conversion.IConverter
;
import
org.eclipse.core.databinding.observable.list.IObservableList
;
import
org.eclipse.core.databinding.observable.value.IObservableValue
;
import
org.eclipse.core.databinding.validation.IValidator
;
import
org.eclipse.emf.ecore.EObject
;
...
...
@@ -61,9 +57,9 @@ public final class DataBindingUtils {
* @param feature
* the element's feature to be observed
*/
public
static
void
bind
(
DataBindingContext
dbc
,
Control
control
,
EObject
modelElement
,
public
static
Binding
[]
bind
(
DataBindingContext
dbc
,
Control
control
,
EObject
modelElement
,
EStructuralFeature
feature
)
{
performComplexTextBinding
(
dbc
,
control
,
return
performComplexTextBinding
(
dbc
,
control
,
ObservableUtils
.
observeValue
(
modelElement
,
feature
),
null
,
null
,
null
,
null
);
}
...
...
@@ -165,47 +161,10 @@ public final class DataBindingUtils {
}
/**
* Performs a complex binding of a text control to a model element. The
* validation is performed on modification (i.e. always), while model
* updates are only performed on focus out (if validation works). There is
* no validation support from model to text, as the model is considered to
* be always consistent. If the control has a {@link ControlDecoration} stored under the
* {@link #DECORATION_KEY} key, this is used to visualize
* the validation result.
*
* @param dbc
* the data binding context to be used
* @param control
* the SWT control
* @param observableList
* the model element value to be observed
* @param listToComboConverter
* the converter from the element to the control's text
* @return the array of constructed bindings
*/
public
static
Binding
[]
performTypeComboBinding
(
DataBindingContext
dbc
,
Control
control
,
IObservableList
observableList
,
IConverter
listToComboConverter
)
{
Binding
[]
bindings
=
new
Binding
[
1
];
// use POLICY_UPDATE to actually perform the update
UpdateListStrategy
listToComboStrategyWithUpdate
=
new
UpdateListStrategy
(
true
,
UpdateValueStrategy
.
POLICY_UPDATE
)
.
setConverter
(
listToComboConverter
);
// add the "normal" binding to actually update the model
bindings
[
0
]
=
dbc
.
bindList
(
SWTObservables
.
observeItems
(
control
),
observableList
,
new
UpdateListStrategy
(
POLICY_NEVER
),
listToComboStrategyWithUpdate
);
return
bindings
;
}
/**
* Performs a complex binding of a text control to a model element. The
* Performs a selection binding of a combo control to a model element. The
* validation is performed on modification (i.e. always), while model
* updates are only performed on focus out (if validation works). There is
* no validation support from
model to text, as the model
is considered to
* no validation support from
selection to model, as the selection
is considered to
* be always consistent. If the control has a {@link ControlDecoration} stored under the
* {@link #DECORATION_KEY} key, this is used to visualize
* the validation result.
...
...
@@ -217,14 +176,16 @@ public final class DataBindingUtils {
* @param modelValue
* the model element value to be observed
* @param modelToSelectionConverter
* the converter from the element to the control's text
* the converter from the
model
element to the control's text
* @param selectionToModelConverter
* the converter from the control's text to the element
* the converter from the control's text to the model element
* @param modelValidator
* the validate function for the model element
* @return the array of constructed bindings
*/
public
static
Binding
[]
performComboBinding
(
DataBindingContext
dbc
,
Control
control
,
IObservableValue
modelValue
,
IConverter
modelToSelectionConverter
,
IConverter
selectionToModelConverter
,
IValidator
v
alidator
)
{
IConverter
selectionToModelConverter
,
IValidator
modelV
alidator
)
{
Binding
[]
bindings
=
new
Binding
[
1
];
...
...
@@ -236,7 +197,7 @@ public final class DataBindingUtils {
// use POLICY_UPDATE to actually perform the update
UpdateValueStrategy
selectionToModelStrategy
=
new
UpdateValueStrategy
(
true
,
UpdateValueStrategy
.
POLICY_UPDATE
).
setConverter
(
selectionToModelConverter
).
setAfterGetValidator
(
v
alidator
);
selectionToModelConverter
).
setAfterGetValidator
(
modelV
alidator
);
// add the "normal" binding to actually update the model
bindings
[
0
]
=
...
...
@@ -247,7 +208,7 @@ public final class DataBindingUtils {
}
/**
* Performs a complex binding of a
text
control to a model element. The
* Performs a complex binding of a
cell editor
control to a model element. The
* validation is performed on modification (i.e. always), while model
* updates are only performed on focus out (if validation works). There is
* no validation support from model to text, as the model is considered to
...
...
@@ -257,15 +218,18 @@ public final class DataBindingUtils {
*
* @param dbc
* the data binding context to be used
* @param control
* the SWT control
* @param cellValue
* the model element value to be observed
* the
cell
model element value to be observed
* @param modalToCellConverter
* the converter from the element to the control's text
* the converter from the
cell model
element to the control's text
* @param cellToModelConverter
* the converter from the control's text to the element
* the converter from the control's text to the cell model element
* @param validator
* the validate function for the control's text
* @return the array of constructed bindings
*/
public
static
Binding
[]
performCellTextBinding
(
DataBindingContext
dbc
,
Control
control
,
IObservableValue
cellValue
,
IConverter
modalToCellConverter
,
IConverter
cellToModelConverter
,
IValidator
validator
)
{
...
...
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