Notification not working [message #156384] |
Fri, 19 October 2007 11:22 |
Eclipse User |
|
|
|
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 #156393 is a reply to message #156388] |
Fri, 19 October 2007 13:28 |
Eclipse User |
|
|
|
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 |
Stefan Kuhn 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 #156571 is a reply to message #156499] |
Sat, 20 October 2007 12:55 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 #156951 is a reply to message #156493] |
Wed, 24 October 2007 11:58 |
Eclipse User |
|
|
|
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-----
|
|
|
Powered by
FUDForum. Page generated in 0.03834 seconds