Home » Modeling » EMF » Re-setting a property depending on another property
Re-setting a property depending on another property [message #418971] |
Tue, 06 May 2008 09:14  |
Eclipse User |
|
|
|
Originally posted by: marsha.rohrer.swisscom.com
Hi,
In my editor property x only is editable if property y is set to true. To
achieve this I implemented an XXXItemProviderDescriptor which checks the
value of property y in the canSetProperty() method.
Like this if property y is true I can add a text to property x. Now if
property y is set to false again I would like to reset the value of x to
"". But I don't know how to notify x about that fact. Do I have to do it
in the notifyChanged() method of the corresponding XXXItemProvider? And if
yes how exactly?
Thank you for your help,
Greets
Marsha
|
|
| | | | | |
Re: Re-setting a property depending on another property [message #419225 is a reply to message #419222] |
Tue, 13 May 2008 11:16   |
Eclipse User |
|
|
|
Originally posted by: marsha.rohrer.swisscom.com
Hi Ed,
Thank you this works fine. But now I have another problem. The changes
aren't visualized in the properties sheet. I think the command does not go
through the whole stack. Can you see where is my mistake?
@Override
public void setPropertyValue(Object object, Object value) {
EditingDomain editingDomain = getEditingDomain(object);
if(value instanceof MaxInstances){
MaxInstances maxInst = (MaxInstances) value;
if(maxInst.getLiteral().equals("one")){
CompoundCommand cCmd = new CompoundCommand();
cCmd.append(SetCommand.create(editingDomain, getCommandOwner(object),
feature, value));
cCmd.append(SetCommand.create(editingDomain, getCommandOwner(object),
GamePackage.eINSTANCE.STEP__INSTANTIATION_CONDITION,
SetCommand.UNSET_VALUE));
editingDomain.getCommandStack().execute(cCmd);
}else super.setPropertyValue(object, value);
}
}
Thank you for your help,
Marsha
|
|
|
Re: Re-setting a property depending on another property [message #419226 is a reply to message #419225] |
Tue, 13 May 2008 12:36   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------030105060406000708000404
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Marsha,
Comments below.
Marsha wrote:
> Hi Ed,
>
> Thank you this works fine. But now I have another problem. The changes
> aren't visualized in the properties sheet. I think the command does
> not go through the whole stack. Can you see where is my mistake?
>
> @Override
> public void setPropertyValue(Object object, Object value) {
> EditingDomain editingDomain = getEditingDomain(object);
> if(value instanceof MaxInstances){
>
> MaxInstances maxInst = (MaxInstances) value;
> if(maxInst.getLiteral().equals("one")){
> CompoundCommand cCmd = new CompoundCommand();
> cCmd.append(SetCommand.create(editingDomain,
> getCommandOwner(object), feature, value));
> cCmd.append(SetCommand.create(editingDomain,
> getCommandOwner(object),
> GamePackage.eINSTANCE.STEP__INSTANTIATION_CONDITION,
> SetCommand.UNSET_VALUE));
> editingDomain.getCommandStack().execute(cCmd);
Have you stepped through the code to see if the command is actually
executable and being executed? Normally the properties view would be
updated because the code in the editor that listens to the command stack
executing a command will explicitly tell the properties view to refresh
itself.
// Add a listener to set the most recent command's affected objects
to be the selection of the viewer with focus.
//
commandStack.addCommandStackListener
(new CommandStackListener()
{
public void commandStackChanged(final EventObject event)
{
getContainer().getDisplay().asyncExec
(new Runnable()
{
public void run()
{
firePropertyChange(IEditorPart.PROP_DIRTY);
// Try to select the affected objects.
//
Command mostRecentCommand =
((CommandStack)event.getSource()).getMostRecentCommand();
if (mostRecentCommand != null)
{
setSelectionToViewer(mostRecentCommand.getAffectedObjects()) ;
}
if (propertySheetPage != null &&
!propertySheetPage.getControl().isDisposed())
{
propertySheetPage.refresh();
}
}
});
}
});
> }else super.setPropertyValue(object, value);
> }
> }
>
> Thank you for your help,
> Marsha
>
--------------030105060406000708000404
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Marsha,<br>
<br>
Comments below.<br>
<br>
Marsha wrote:
<blockquote
cite="mid:44075b2d52fa5c6eb6f54decfbedbe1f$1@www.eclipse.org"
type="cite">Hi Ed,
<br>
<br>
Thank you this works fine. But now I have another problem. The changes
aren't visualized in the properties sheet. I think the command does not
go through the whole stack. Can you see where is my mistake?
<br>
<br>
@Override
<br>
|
|
|
Re: Re-setting a property depending on another property [message #419234 is a reply to message #419226] |
Wed, 14 May 2008 03:58   |
Eclipse User |
|
|
|
Originally posted by: marsha.rohrer.swisscom.com
Hi Ed,
Your help is very useful to me, but since I'm not that experienced with
Commands I still have some problems, sorry for that.
> Have you stepped through the code to see if the command is actually
> executable and being executed?
I debuged my code and I found out that my CompoundCommand is executed as
expected (update property sheet write changes into model) if I comment out
the reset of the InstantiationCondition:
cCmd.append(SetCommand.create(editingDomain, getCommandOwner(object),
GamePackage.STEP__INSTANTIATION_CONDITION, SetCommand.UNSET_VALUE));
Nevertheless if I check the isExecutable flag of my CompoundCommand it is
set to false.
As soon as I uncomment the line above the CompoundCommand isn't executed
correctly (property sheet and model not updated). What I found out is that
the feature in the SetCommand is null, where I want to reset the
Step_InstantiationCondition (line above). The isExecutable flag of the
cCmd still is false as before.
I tried to initialize the CompoundComand in those three ways, which had no
effect on the execution:
CompoundCommand cCmd = new CompoundCommand();
CompoundCommand cCmd = new
CompoundCommand(CompoundCommand.LAST_COMMAND_ALL);
CompoundCommand cCmd = new
CompoundCommand(CompoundCommand.MERGE_COMMAND_ALL);
What I tried to change as well is using
GamePackage.STEP__INSTANTIATION_CONDITION instead of
GamePackage.eINSTANCE.STEP__INSTANTIATION_CONDITION since I get a warning
saying that I should not access in a static manner.
Unfortunately now I already ran out of ideas...do you have an idea where
my problem is? Do I need a function to get the feature? Why is the
isExecutable flag of my CompoundComand false?
> Normally the properties view would be
> updated because the code in the editor that listens to the command stack
> executing a command will explicitly tell the properties view to refresh
> itself.
Since my CompoundCommand does not update the model either I think that the
problem is in the command itself.
Thanks a lot,
Marsha
|
|
|
Re: Re-setting a property depending on another property [message #419240 is a reply to message #419234] |
Wed, 14 May 2008 10:10   |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------010407000600020607050204
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Marsha,
Comments below.
Marsha wrote:
> Hi Ed,
>
> Your help is very useful to me, but since I'm not that experienced
> with Commands I still have some problems, sorry for that.
>
>> Have you stepped through the code to see if the command is actually
>> executable and being executed?
> I debuged my code and I found out that my CompoundCommand is executed
> as expected (update property sheet write changes into model) if I
> comment out the reset of the InstantiationCondition:
> cCmd.append(SetCommand.create(editingDomain, getCommandOwner(object),
> GamePackage.STEP__INSTANTIATION_CONDITION, SetCommand.UNSET_VALUE));
> Nevertheless if I check the isExecutable flag of my CompoundCommand it
> is set to false.
> As soon as I uncomment the line above the CompoundCommand isn't
> executed correctly (property sheet and model not updated). What I
> found out is that the feature in the SetCommand is null, where I want
> to reset the Step_InstantiationCondition (line above). The
> isExecutable flag of the cCmd still is false as before.
>
> I tried to initialize the CompoundComand in those three ways, which
> had no effect on the execution:
> CompoundCommand cCmd = new CompoundCommand();
> CompoundCommand cCmd = new
> CompoundCommand(CompoundCommand.LAST_COMMAND_ALL);
> CompoundCommand cCmd = new
> CompoundCommand(CompoundCommand.MERGE_COMMAND_ALL);
>
> What I tried to change as well is using
> GamePackage.STEP__INSTANTIATION_CONDITION instead of
> GamePackage.eINSTANCE.STEP__INSTANTIATION_CONDITION since I get a
> warning saying that I should not access in a static manner.
Oh dear. You're accessing the numeric feature ID not the actual feature
object. You need to use
GamePackage.*Literals*.STEP__INSTANTIATION_CONDITION which will be the
same object as GamePackage.eINSTANCE.getStep__InstantiationCondition()...
>
> Unfortunately now I already ran out of ideas...do you have an idea
> where my problem is? Do I need a function to get the feature? Why is
> the isExecutable flag of my CompoundComand false?
>
>> Normally the properties view would be updated because the code in the
>> editor that listens to the command stack executing a command will
>> explicitly tell the properties view to refresh itself.
> Since my CompoundCommand does not update the model either I think that
> the problem is in the command itself.
Yes.
>
> Thanks a lot,
> Marsha
>
>
--------------010407000600020607050204
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Marsha,<br>
<br>
<br>
Comments below.<br>
<br>
Marsha wrote:
<blockquote
cite="mid:d063a560c6b531a8b8721c474766a68f$1@www.eclipse.org"
type="cite">Hi Ed,
<br>
<br>
Your help is very useful to me, but since I'm not that experienced with
Commands I still have some problems, sorry for that.
<br>
<br>
<blockquote type="cite">Have you stepped through the code to see if
the command is actually executable and being executed?
|
|
| |
Goto Forum:
Current Time: Sat Jul 12 13:00:53 EDT 2025
Powered by FUDForum. Page generated in 0.05087 seconds
|