Home » Modeling » EMF » Does EMFObservables provide undo/redo functionality?
| | | | | | | | | | | | |
Re: Does EMFObservables provide undo/redo functionality? [message #420426 is a reply to message #420423] |
Sun, 29 June 2008 15:45 |
Al B Messages: 130 Registered: July 2009 |
Senior Member |
|
|
Tom,
I am also running on OS/X. However, I don't understand the problem you are
now trying to highlight. Here is an snap-shot of code I using that
resolved my problem.
protected Binding createWidgetsForAttribute(Composite parent,
Object object, EStructuralFeature feature,
String featureDisplayName, boolean editable) {
IObservableValue observeModel;
IObservableValue observeTarget;
EMFUpdateValueStrategy targetStrategy = new EMFUpdateValueStrategy(
EMFUpdateValueStrategy.POLICY_UPDATE);
EMFUpdateValueStrategy modelStrategy;
TableWrapData labelData = new TableWrapData(TableWrapData.LEFT,
TableWrapData.MIDDLE);
TableWrapData valueData = new TableWrapData(TableWrapData.LEFT,
TableWrapData.MIDDLE);
Label label = toolkit.createLabel(parent,
((featureDisplayName != null) ? featureDisplayName :
feature.getName()) + ": ");
label.setLayoutData(labelData);
if (target instanceof EObject) {
observeModel = EMFEditObservables.observeValue(
AdapterFactoryEditingDomain.getEditingDomainFor(object), (EObject) object,
feature);
} else if (target instanceof IObservableValue) {
observeModel = EMFObservables.observeDetailValue(Realm.getDefault(),
(IObservableValue) object, feature);
valueData.rowspan = 2;
} else {
throw new IllegalArgumentException("Invalid value for Object
parameter: " + target + ". Must be an EObject or IObservableValue.");
}
toolkit.setBorderStyle(SWT.BORDER);
Text value = toolkit.createText(parent, null);
value.setLayoutData(valueData);
observeTarget = SWTObservables.observeText(value, SWT.FocusOut);
modelStrategy = new EMFUpdateValueStrategy(
EMFUpdateValueStrategy.POLICY_UPDATE);
return dbctx.bindValue(observeTarget, observeModel, modelStrategy,
targetStrategy);
}
|
|
| |
Re: Does EMFObservables provide undo/redo functionality? [message #420428 is a reply to message #420423] |
Sun, 29 June 2008 16:56 |
Ed Merks Messages: 33143 Registered: July 2009 |
Senior Member |
|
|
Tom,
There's currently nothing that would allow commands to be merged once
executed. The issues you mention sound like yet more things that ought
to be handled at the UI level, i.e., some type of commit pending changes
on the widget with focus, otherwise what good is a focus out approach in
general...
Tom Schindl wrote:
> But on focus out is also :-( because you can't rely on it on all
> platforms (OS-X doesn't has a focus lost when you hit the save button
> because buttons don't receive focus which is nice because you can hit
> save and are immediately back at the position you left of). The same
> is true for if your hit CTRL+S, ... .
>
> Is there a user defined way of creating a composite command from
> single change commands?
>
> This way an UI-Logic could be:
> - Change Model on ever key-stroke
> - On FocusOut look at the executed commands and replace them through one
> CompositeCommand
>
> Tom
>
> Ed Merks schrieb:
>> Tom,
>>
>> There are composite commands already, but the tricky part is it would
>> somehow have to merge a new command with an already executed command
>> and know when that's appropriate. I think the UI side of things has
>> the best idea of when a change should really be committed to the
>> model... Committing for every key stroke is a little much...
>>
>>
>> Tom Schindl wrote:
>>> On the other hand Ed, do you think the Command-Framework could be
>>> able to create a "CombinedCommand" from a list of single ones?
>>>
>>> Tom
>>>
>>> Tom Schindl schrieb:
>>>> What Ed means is that the Text-Observable is created with
>>>> SWT.FocusOut instead of SWT.Modify. Special care has to be taken
>>>> when doing this on OS-X!
>>>>
>>>> Tom
>>>>
>>>> Ed Merks schrieb:
>>>>> AJ,
>>>>>
>>>>> Yes, I don't think each key stroke should change the model and
>>>>> only JFace knows what's happening in the UI.
>>>>>
>>>>>
>>>>> AJ wrote:
>>>>>> Ed,
>>>>>>
>>>>>> When you say "it is something that should be done on the other
>>>>>> side of the fence", are you referring to my side of the fence
>>>>>> where I need to extend the EMFEditObservables functionality or
>>>>>> the JFace/Platform side of the fence?
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>
>>>>
>>>
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | |
Goto Forum:
Current Time: Thu May 02 22:45:44 GMT 2024
Powered by FUDForum. Page generated in 0.05480 seconds
|