Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Rectilinear Routing as Default in GMF 2.1.1 +
Rectilinear Routing as Default in GMF 2.1.1 + [message #485571] Sun, 13 September 2009 14:54 Go to next message
Ugo Sangiorgi is currently offline Ugo Sangiorgi
Messages: 44
Registered: July 2009
Member
Hello all,
I used a custom decorateView method at <Connection>ViewFactory to have
Rectilinear Routing as default, but after an update I cannot.

How should I proceed?

Thanks in advance
Re: Rectilinear Routing as Default in GMF 2.1.1 + [message #485621 is a reply to message #485571] Mon, 14 September 2009 04:15 Go to previous messageGo to next message
Olivier Marot is currently offline Olivier Marot
Messages: 14
Registered: September 2009
Junior Member
Hi Ugo,
You can modify the routing style directly in your connection's EditPart.
Here is an example :

/**
* @generated NOT
*/
protected Connection createConnectionFigure() {
	ConnectionFigure figure = new ConnectionFigure();
	RoutingStyle style = (RoutingStyle) ((View) getModel()).getStyle(NotationPackage.Literals.ROUTING_STYLE);
	style.setRouting(Routing.RECTILINEAR_LITERAL);
	return figure;
}
Re: Rectilinear Routing as Default in GMF 2.1.1 + [message #502108 is a reply to message #485621] Sat, 05 December 2009 14:18 Go to previous messageGo to next message
Ugo Sangiorgi is currently offline Ugo Sangiorgi
Messages: 44
Registered: July 2009
Member
Thank you Olivier, but now im getting an IllegalStateException, is there
another way of doing this?

the exception:
java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:348)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:302)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:284)
at
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:240)
at
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:280)
at
org.eclipse.gmf.runtime.notation.impl.RoutingStyleImpl.setRo uting(RoutingStyleImpl.java:361)
at
br.puc.molic.diagram.edit.parts.UtteranceEditPart.createConn ectionFigure(UtteranceEditPart.java:104)

Olivier Marot escreveu:
> Hi Ugo,
> You can modify the routing style directly in your connection's EditPart.
> Here is an example :
>
> /**
> * @generated NOT
> */
> protected Connection createConnectionFigure() {
> ConnectionFigure figure = new ConnectionFigure();
> RoutingStyle style = (RoutingStyle) ((View)
> getModel()).getStyle(NotationPackage.Literals.ROUTING_STYLE) ;
> style.setRouting(Routing.RECTILINEAR_LITERAL);
> return figure;
> }
Re: Rectilinear Routing as Default in GMF 2.1.1 + [message #502113 is a reply to message #502108] Sat, 05 December 2009 16:08 Go to previous messageGo to next message
Ugo Sangiorgi is currently offline Ugo Sangiorgi
Messages: 44
Registered: July 2009
Member
i'd finally came across a solution, here is how i did:

protected Connection createConnectionFigure() {
ConnectionFigure figure = new ConnectionFigure();

AbstractEMFOperation emfOp = new AbstractEMFOperation(getEditingDomain(), "line routing setting") {
@Override
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
RoutingStyle style = (RoutingStyle) ((View) getModel()).getStyle(NotationPackage.Literals.ROUTING_STYLE) ;
style.setRouting(Routing.RECTILINEAR_LITERAL);
return Status.OK_STATUS;
}
};

try {
OperationHistoryFactory.getOperationHistory().execute(emfOp, null, null);
} catch (ExecutionException e) {}

return figure;
}

Enjoy!

Ugo Sangiorgi escreveu:
> Thank you Olivier, but now im getting an IllegalStateException, is there
> another way of doing this?
>
> the exception:
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:348)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:302)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:284)
>
> at
> org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:240)
>
> at
> org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:280)
>
> at
> org.eclipse.gmf.runtime.notation.impl.RoutingStyleImpl.setRo uting(RoutingStyleImpl.java:361)
>
> at
> br.puc.molic.diagram.edit.parts.UtteranceEditPart.createConn ectionFigure(UtteranceEditPart.java:104)
>
>
> Olivier Marot escreveu:
>> Hi Ugo,
>> You can modify the routing style directly in your connection's EditPart.
>> Here is an example :
>>
>> /**
>> * @generated NOT
>> */
>> protected Connection createConnectionFigure() {
>> ConnectionFigure figure = new ConnectionFigure();
>> RoutingStyle style = (RoutingStyle) ((View)
>> getModel()).getStyle(NotationPackage.Literals.ROUTING_STYLE) ;
>> style.setRouting(Routing.RECTILINEAR_LITERAL);
>> return figure;
>> }
Re: Rectilinear Routing as Default in GMF 2.1.1 + [message #534327 is a reply to message #502113] Tue, 18 May 2010 12:48 Go to previous message
Erik Englund is currently offline Erik Englund
Messages: 49
Registered: July 2009
Member
I tried the proposed "final" solution but I still get an Illegal State exception. Mine however is that "Can not activate read/write transaction in read-only transaction context"

Any ideas?
Previous Topic:GMF and Copy & Paste
Next Topic:DND from view to editor
Goto Forum:
  


Current Time: Sat Apr 19 06:06:05 EDT 2014

Powered by FUDForum. Page generated in 0.02042 seconds