Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Notification not working
Notification not working [message #156384] Fri, 19 October 2007 11:22 Go to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

I have debugged an error, and it seems like this line in setName()
crashes, when I call setName from the getname method.

eNotify(new ENotificationImpl(this, Notification.SET,
EditorPackage.CLASS_NODE__NAME, oldName, name));

Why would a notification crash? (it's parameters - oldName and name are
correct and valid)

Regards,

Tomas
Re: Notification not working [message #156388 is a reply to message #156384] Fri, 19 October 2007 12:07 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Tomas,

Can you post a stacktrace of "crash" here?

-----------------
Alex Shatalin
Re: Notification not working [message #156393 is a reply to message #156388] Fri, 19 October 2007 13:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

Thanks :)

I made a try catch, which resultet in:

java.lang.IllegalStateException: Cannot modify resource set without a
write transaction

Alex Shatalin wrote:
> Hello Tomas,
>
> Can you post a stacktrace of "crash" here?
>
> -----------------
> Alex Shatalin
>
>
Re: Notification not working [message #156493 is a reply to message #156393] Fri, 19 October 2007 15:01 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

you should create a command and execute it on through the commandStack.
If you want to make it undoable by eclipse you want to use
AbstractEMFCommand.

This might help you as an example, it applies a profile to a package:

private static class ApplyProfile extends AbstractEMFOperation{
Package package_;
Profile profile;
public ApplyProfile(TransactionalEditingDomain editingDomain,
org.eclipse.uml2.uml.Package package_,Profile profile) {
super(editingDomain, "ApplyProfile "+profile.getName());
this.package_=package_;
this.profile=profile;
}
@Override
protected IStatus doExecute(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {
try{
package_.applyProfile(profile);
return org.eclipse.core.runtime.Status.OK_STATUS;
} catch (Exception e){
return org.eclipse.core.runtime.Status.CANCEL_STATUS;
}
}
}

And is executed by:

// Ausfuehren
AbstractEMFOperation op = new
ApplyProfile((TransactionalEditingDomain) editingDomain,model,oioProfile);
try {

UMLDiagramEditorPlugin.getInstance().getWorkbench().getOpera tionSupport().getOperationHistory().execute(op,
new NullProgressMonitor(), null);
} catch (ExecutionException e) {
UMLDiagramEditorPlugin.getInstance().logError("www.OiO.de Profile
Application Error" , e);
}

For background information, read the EMF-Transaction Tutorials
Working with EMF Operations and Creating Transactions.
You can find both in the Eclipse Help.

- -stefan

Tomas Zijdemans schrieb:
> Thanks :)
>
> I made a try catch, which resultet in:
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
>
> Alex Shatalin wrote:
>> Hello Tomas,
>>
>> Can you post a stacktrace of "crash" here?
>>
>> -----------------
>> Alex Shatalin
>>
>>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHGMbIIYVWjMSpDwwRAlFRAJ99Oees6Cvv1p72YtGRhTrTDTlVkgCf RK4b
nuX8F9U6KU782hK+AP4Z4lY=
=El+1
-----END PGP SIGNATURE-----
Re: Notification not working [message #156499 is a reply to message #156393] Fri, 19 October 2007 15:02 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

oh, I forgot to mention, you have to make sure not executing this
command in a read-only transaction context.


Tomas Zijdemans schrieb:
> Thanks :)
>
> I made a try catch, which resultet in:
>
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
>
> Alex Shatalin wrote:
>> Hello Tomas,
>>
>> Can you post a stacktrace of "crash" here?
>>
>> -----------------
>> Alex Shatalin
>>
>>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHGMcPIYVWjMSpDwwRAn36AJ9YssDh45rAVYGsRsql+KeG4ezaXQCg mJBf
DONh4qmA2UOk8wIinrdSyUs=
=k8Wd
-----END PGP SIGNATURE-----
Re: Notification not working [message #156571 is a reply to message #156499] Sat, 20 October 2007 12:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

Thanks for helping!

I'll try this out. I thought of using a GMF command like:

SetRequest setRequest = new SetRequest(nodeElement,
nodeElement.eClass().getEStructuralFeature(EditorPackage.CLA SS_NODE__NAME),
a.getName());

selectedElement.getDiagramEditDomain().getDiagramCommandStac k().execute(
new ICommandProxy(new SetValueCommand(setRequest)));

But your solution sounds much better.

Thanks again :)

Tomas

SKuhn wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> oh, I forgot to mention, you have to make sure not executing this
> command in a read-only transaction context.
>
>
> Tomas Zijdemans schrieb:
>> Thanks :)
>>
>> I made a try catch, which resultet in:
>>
>> java.lang.IllegalStateException: Cannot modify resource set without a
>> write transaction
>>
>> Alex Shatalin wrote:
>>> Hello Tomas,
>>>
>>> Can you post a stacktrace of "crash" here?
>>>
>>> -----------------
>>> Alex Shatalin
>>>
>>>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFHGMcPIYVWjMSpDwwRAn36AJ9YssDh45rAVYGsRsql+KeG4ezaXQCg mJBf
> DONh4qmA2UOk8wIinrdSyUs=
> =k8Wd
> -----END PGP SIGNATURE-----
Re: Notification not working [message #156591 is a reply to message #156499] Sat, 20 October 2007 14:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

What exactly do you mean by this, how can I make that distinction?

Regards,

Tomas


SKuhn wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> oh, I forgot to mention, you have to make sure not executing this
> command in a read-only transaction context.
Re: Notification not working [message #156693 is a reply to message #156591] Mon, 22 October 2007 16:25 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

it depends where you execute your command. E.g. you can't execute a
command in the constructor of an EditPart because there's already a
read-only Command running. But if you don't face problems, don't care :)


Tomas Zijdemans schrieb:
> What exactly do you mean by this, how can I make that distinction?
>
> Regards,
>
> Tomas
>
>
> SKuhn wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> oh, I forgot to mention, you have to make sure not executing this
>> command in a read-only transaction context.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHHM8WIYVWjMSpDwwRAoaQAJ9ArIy5r+dYAVxy6A5KiVyn8EryGQCf X0QF
p/prY7dfqkReLT/pEew7eiM=
=csoF
-----END PGP SIGNATURE-----
Re: Notification not working [message #156951 is a reply to message #156493] Wed, 24 October 2007 11:58 Go to previous message
Eclipse UserFriend
Originally posted by: trommas.yahoo.com

Thanks, but I really just need a simple command that sets a name to an
element.

I've tried to get this working with:

TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(book);

CommandStack stack = domain.getCommandStack();

// execute some change
Command cmd = domain.createCommand(SetCommand.class, new
CommandParameter(book, EditorPackage.BOOK__NAME, "dummy"));

stack.execute(cmd);

But I think I'm getting the editing domain wrong, any suggestions?


Thanks,

Tomas


SKuhn wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> you should create a command and execute it on through the commandStack.
> If you want to make it undoable by eclipse you want to use
> AbstractEMFCommand.
>
> This might help you as an example, it applies a profile to a package:
>
> private static class ApplyProfile extends AbstractEMFOperation{
> Package package_;
> Profile profile;
> public ApplyProfile(TransactionalEditingDomain editingDomain,
> org.eclipse.uml2.uml.Package package_,Profile profile) {
> super(editingDomain, "ApplyProfile "+profile.getName());
> this.package_=package_;
> this.profile=profile;
> }
> @Override
> protected IStatus doExecute(IProgressMonitor monitor,
> IAdaptable info) throws ExecutionException {
> try{
> package_.applyProfile(profile);
> return org.eclipse.core.runtime.Status.OK_STATUS;
> } catch (Exception e){
> return org.eclipse.core.runtime.Status.CANCEL_STATUS;
> }
> }
> }
>
> And is executed by:
>
> // Ausfuehren
> AbstractEMFOperation op = new
> ApplyProfile((TransactionalEditingDomain) editingDomain,model,oioProfile);
> try {
>
> UMLDiagramEditorPlugin.getInstance().getWorkbench().getOpera tionSupport().getOperationHistory().execute(op,
> new NullProgressMonitor(), null);
> } catch (ExecutionException e) {
> UMLDiagramEditorPlugin.getInstance().logError("www.OiO.de Profile
> Application Error" , e);
> }
>
> For background information, read the EMF-Transaction Tutorials
> Working with EMF Operations and Creating Transactions.
> You can find both in the Eclipse Help.
>
> - -stefan
>
> Tomas Zijdemans schrieb:
>> Thanks :)
>>
>> I made a try catch, which resultet in:
>>
>> java.lang.IllegalStateException: Cannot modify resource set without a
>> write transaction
>>
>> Alex Shatalin wrote:
>>> Hello Tomas,
>>>
>>> Can you post a stacktrace of "crash" here?
>>>
>>> -----------------
>>> Alex Shatalin
>>>
>>>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFHGMbIIYVWjMSpDwwRAlFRAJ99Oees6Cvv1p72YtGRhTrTDTlVkgCf RK4b
> nuX8F9U6KU782hK+AP4Z4lY=
> =El+1
> -----END PGP SIGNATURE-----
Previous Topic:drag and drop - update new element
Next Topic:NPE
Goto Forum:
  


Current Time: Thu Nov 07 05:57:07 GMT 2024

Powered by FUDForum. Page generated in 0.03834 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top