Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to enable Format Line Type, Line Width for connections
How to enable Format Line Type, Line Width for connections [message #207818] Fri, 03 October 2008 15:44 Go to next message
Eclipse UserFriend
Originally posted by: mklinchin.yahoo.com

Hello,

In my diagram when I right click on connection line (polyline connection
in graphical model) and select Format / Line Width all possible selections
are disabled. Same thing happens when I select Line Type or Arrow Type.
However Line Style as well as Line Color options are enabled.

I checked LineWidthAction.calculateEnabled() and found that
style.getLineWidth() there is -1. I also checked
LineTypeAction.calculateEnabled() and found that style there is null. But
I have line width in my graphical model set to 1.

Thank you for helping me
Igor
Re: How to enable Format Line Type, Line Width for connections [message #207899 is a reply to message #207818] Mon, 06 October 2008 21:42 Go to previous messageGo to next message
Anthony Hunter is currently offline Anthony HunterFriend
Messages: 446
Registered: July 2009
Senior Member
Hi Igor,

1) in your XXXXConnectionViewFactory, you already likely have the
ConnectorStyle installed, set the default line width and add arrow and line
type styles.
Add:
ConnectorStyle style = (ConnectorStyle) styles.get(0);
if (style != null) {
style.setLineWidth(1);
}

styles.add(NotationFactory.eINSTANCE.createArrowStyle());
styles.add(NotationFactory.eINSTANCE.createLineTypeStyle());

2) in your XXXXConnectionEditPart, I will assume you want to place an arrow
on both source and target. You will need to remove the local
ConnectionFigure and replace with

/**
* @generated NOT
*/
protected Connection createConnectionFigure() {
return new PolylineConnectionEx();
}

/**
* @generated NOT
*/
public PolylineConnectionEx getPrimaryShape() {
return (PolylineConnectionEx) getFigure();
}

/*
* @see
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeE ditPart#handleNotificationEvent(org.eclipse.emf.common.notif y.Notification)
*/
protected void handleNotificationEvent(Notification notification) {
Object feature = notification.getFeature();
if (NotationPackage.Literals.LINE_STYLE__LINE_WIDTH.equals(feat ure)) {
refreshLineWidth();
refreshArrowSource();
refreshArrowTarget();
} else if (NotationPackage.Literals.LINE_TYPE_STYLE__LINE_TYPE
.equals(feature)) {
refreshLineType();
} else if (NotationPackage.Literals.ARROW_STYLE__ARROW_SOURCE
.equals(feature)) {
refreshArrowSource();
} else if (NotationPackage.Literals.ARROW_STYLE__ARROW_TARGET
.equals(feature)) {
refreshArrowTarget();
} else {
super.handleNotificationEvent(notification);
}
}

/*
* @see
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#refreshVisuals()
*/
protected void refreshVisuals() {
super.refreshVisuals();
refreshLineWidth();
refreshLineType();
refreshArrowSource();
refreshArrowTarget();
}

/*
* @see
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setLineWidth(int)
*/
protected void setLineWidth(int width) {
getPrimaryShape().setLineWidth(getMapMode().DPtoLP(width));
}

/*
* @see
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setLineType(int)
*/
protected void setLineType(int lineType) {
getPrimaryShape().setLineStyle(lineType);
}

/*
* @see
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setArrowSource(org.eclipse.draw2d.RotatableDecoration)
*/
protected void setArrowSource(RotatableDecoration arrowDecoration) {
getPrimaryShape().setSourceDecoration(arrowDecoration);
}

/*
* @see
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setArrowTarget(org.eclipse.draw2d.RotatableDecoration)
*/
protected void setArrowTarget(RotatableDecoration arrowDecoration) {
getPrimaryShape().setTargetDecoration(arrowDecoration);
}

Hope this helps.

Cheers...
Anthony


"Igor Klinchin" <mklinchin@yahoo.com> wrote in message
news:pan.2008.10.03.15.44.21.464431@yahoo.com...
> Hello,
>
> In my diagram when I right click on connection line (polyline connection
> in graphical model) and select Format / Line Width all possible selections
> are disabled. Same thing happens when I select Line Type or Arrow Type.
> However Line Style as well as Line Color options are enabled.
>
> I checked LineWidthAction.calculateEnabled() and found that
> style.getLineWidth() there is -1. I also checked
> LineTypeAction.calculateEnabled() and found that style there is null. But
> I have line width in my graphical model set to 1.
>
> Thank you for helping me
> Igor
>
Re: How to enable Format Line Type, Line Width for connections [message #207906 is a reply to message #207899] Mon, 06 October 2008 22:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mklinchin.yahoo.com

Hi Anthony,

Thank you very much for your answer. I found the classes you refer to. My
XXXXConnectionViewFactory.createStyles contains the code you mention. It
looks like this:

List styles = new ArrayList();
styles.add(NotationFactory.eINSTANCE.createConnectorStyle()) ;
styles.add(NotationFactory.eINSTANCE.createFontStyle());

But this code is never called. I set up a breakpoint there and it is never
reached. Actually, it seems to be a reason why these styles are not
defined. How can I make this code run?

Thank you agian,
Igor

On Mon, 06 Oct 2008 17:42:20 -0400, Anthony Hunter wrote:

> Hi Igor,
>
> 1) in your XXXXConnectionViewFactory, you already likely have the
> ConnectorStyle installed, set the default line width and add arrow and line
> type styles.
> Add:
> ConnectorStyle style = (ConnectorStyle) styles.get(0);
> if (style != null) {
> style.setLineWidth(1);
> }
>
> styles.add(NotationFactory.eINSTANCE.createArrowStyle());
> styles.add(NotationFactory.eINSTANCE.createLineTypeStyle());
>
> 2) in your XXXXConnectionEditPart, I will assume you want to place an arrow
> on both source and target. You will need to remove the local
> ConnectionFigure and replace with
>
> /**
> * @generated NOT
> */
> protected Connection createConnectionFigure() {
> return new PolylineConnectionEx();
> }
>
> /**
> * @generated NOT
> */
> public PolylineConnectionEx getPrimaryShape() {
> return (PolylineConnectionEx) getFigure();
> }
>
> /*
> * @see
> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeE ditPart#handleNotificationEvent(org.eclipse.emf.common.notif y.Notification)
> */
> protected void handleNotificationEvent(Notification notification) {
> Object feature = notification.getFeature();
> if (NotationPackage.Literals.LINE_STYLE__LINE_WIDTH.equals(feat ure)) {
> refreshLineWidth();
> refreshArrowSource();
> refreshArrowTarget();
> } else if (NotationPackage.Literals.LINE_TYPE_STYLE__LINE_TYPE
> .equals(feature)) {
> refreshLineType();
> } else if (NotationPackage.Literals.ARROW_STYLE__ARROW_SOURCE
> .equals(feature)) {
> refreshArrowSource();
> } else if (NotationPackage.Literals.ARROW_STYLE__ARROW_TARGET
> .equals(feature)) {
> refreshArrowTarget();
> } else {
> super.handleNotificationEvent(notification);
> }
> }
>
> /*
> * @see
> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#refreshVisuals()
> */
> protected void refreshVisuals() {
> super.refreshVisuals();
> refreshLineWidth();
> refreshLineType();
> refreshArrowSource();
> refreshArrowTarget();
> }
>
> /*
> * @see
> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setLineWidth(int)
> */
> protected void setLineWidth(int width) {
> getPrimaryShape().setLineWidth(getMapMode().DPtoLP(width));
> }
>
> /*
> * @see
> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setLineType(int)
> */
> protected void setLineType(int lineType) {
> getPrimaryShape().setLineStyle(lineType);
> }
>
> /*
> * @see
> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setArrowSource(org.eclipse.draw2d.RotatableDecoration)
> */
> protected void setArrowSource(RotatableDecoration arrowDecoration) {
> getPrimaryShape().setSourceDecoration(arrowDecoration);
> }
>
> /*
> * @see
> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setArrowTarget(org.eclipse.draw2d.RotatableDecoration)
> */
> protected void setArrowTarget(RotatableDecoration arrowDecoration) {
> getPrimaryShape().setTargetDecoration(arrowDecoration);
> }
>
> Hope this helps.
>
> Cheers...
> Anthony
>
>
> "Igor Klinchin" <mklinchin@yahoo.com> wrote in message
> news:pan.2008.10.03.15.44.21.464431@yahoo.com...
>> Hello,
>>
>> In my diagram when I right click on connection line (polyline connection
>> in graphical model) and select Format / Line Width all possible selections
>> are disabled. Same thing happens when I select Line Type or Arrow Type.
>> However Line Style as well as Line Color options are enabled.
>>
>> I checked LineWidthAction.calculateEnabled() and found that
>> style.getLineWidth() there is -1. I also checked
>> LineTypeAction.calculateEnabled() and found that style there is null. But
>> I have line width in my graphical model set to 1.
>>
>> Thank you for helping me
>> Igor
>>
Re: How to enable Format Line Type, Line Width for connections [message #207954 is a reply to message #207906] Tue, 07 October 2008 14:59 Go to previous message
Eclipse UserFriend
Originally posted by: mklinchin.yahoo.com

Hi Anthony,

I regenerated Diagram and Edit and everything works now. Thank you
very much for advice.

Igor

On Mon, 06 Oct 2008 18:41:30 -0400, Igor Klinchin wrote:

> Hi Anthony,
>
> Thank you very much for your answer. I found the classes you refer to. My
> XXXXConnectionViewFactory.createStyles contains the code you mention. It
> looks like this:
>
> List styles = new ArrayList();
> styles.add(NotationFactory.eINSTANCE.createConnectorStyle()) ;
> styles.add(NotationFactory.eINSTANCE.createFontStyle());
>
> But this code is never called. I set up a breakpoint there and it is never
> reached. Actually, it seems to be a reason why these styles are not
> defined. How can I make this code run?
>
> Thank you agian,
> Igor
>
> On Mon, 06 Oct 2008 17:42:20 -0400, Anthony Hunter wrote:
>
>> Hi Igor,
>>
>> 1) in your XXXXConnectionViewFactory, you already likely have the
>> ConnectorStyle installed, set the default line width and add arrow and line
>> type styles.
>> Add:
>> ConnectorStyle style = (ConnectorStyle) styles.get(0);
>> if (style != null) {
>> style.setLineWidth(1);
>> }
>>
>> styles.add(NotationFactory.eINSTANCE.createArrowStyle());
>> styles.add(NotationFactory.eINSTANCE.createLineTypeStyle());
>>
>> 2) in your XXXXConnectionEditPart, I will assume you want to place an arrow
>> on both source and target. You will need to remove the local
>> ConnectionFigure and replace with
>>
>> /**
>> * @generated NOT
>> */
>> protected Connection createConnectionFigure() {
>> return new PolylineConnectionEx();
>> }
>>
>> /**
>> * @generated NOT
>> */
>> public PolylineConnectionEx getPrimaryShape() {
>> return (PolylineConnectionEx) getFigure();
>> }
>>
>> /*
>> * @see
>> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeE ditPart#handleNotificationEvent(org.eclipse.emf.common.notif y.Notification)
>> */
>> protected void handleNotificationEvent(Notification notification) {
>> Object feature = notification.getFeature();
>> if (NotationPackage.Literals.LINE_STYLE__LINE_WIDTH.equals(feat ure)) {
>> refreshLineWidth();
>> refreshArrowSource();
>> refreshArrowTarget();
>> } else if (NotationPackage.Literals.LINE_TYPE_STYLE__LINE_TYPE
>> .equals(feature)) {
>> refreshLineType();
>> } else if (NotationPackage.Literals.ARROW_STYLE__ARROW_SOURCE
>> .equals(feature)) {
>> refreshArrowSource();
>> } else if (NotationPackage.Literals.ARROW_STYLE__ARROW_TARGET
>> .equals(feature)) {
>> refreshArrowTarget();
>> } else {
>> super.handleNotificationEvent(notification);
>> }
>> }
>>
>> /*
>> * @see
>> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#refreshVisuals()
>> */
>> protected void refreshVisuals() {
>> super.refreshVisuals();
>> refreshLineWidth();
>> refreshLineType();
>> refreshArrowSource();
>> refreshArrowTarget();
>> }
>>
>> /*
>> * @see
>> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setLineWidth(int)
>> */
>> protected void setLineWidth(int width) {
>> getPrimaryShape().setLineWidth(getMapMode().DPtoLP(width));
>> }
>>
>> /*
>> * @see
>> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setLineType(int)
>> */
>> protected void setLineType(int lineType) {
>> getPrimaryShape().setLineStyle(lineType);
>> }
>>
>> /*
>> * @see
>> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setArrowSource(org.eclipse.draw2d.RotatableDecoration)
>> */
>> protected void setArrowSource(RotatableDecoration arrowDecoration) {
>> getPrimaryShape().setSourceDecoration(arrowDecoration);
>> }
>>
>> /*
>> * @see
>> org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditP art#setArrowTarget(org.eclipse.draw2d.RotatableDecoration)
>> */
>> protected void setArrowTarget(RotatableDecoration arrowDecoration) {
>> getPrimaryShape().setTargetDecoration(arrowDecoration);
>> }
>>
>> Hope this helps.
>>
>> Cheers...
>> Anthony
>>
>>
>> "Igor Klinchin" <mklinchin@yahoo.com> wrote in message
>> news:pan.2008.10.03.15.44.21.464431@yahoo.com...
>>> Hello,
>>>
>>> In my diagram when I right click on connection line (polyline connection
>>> in graphical model) and select Format / Line Width all possible selections
>>> are disabled. Same thing happens when I select Line Type or Arrow Type.
>>> However Line Style as well as Line Color options are enabled.
>>>
>>> I checked LineWidthAction.calculateEnabled() and found that
>>> style.getLineWidth() there is -1. I also checked
>>> LineTypeAction.calculateEnabled() and found that style there is null. But
>>> I have line width in my graphical model set to 1.
>>>
>>> Thank you for helping me
>>> Igor
>>>
Previous Topic:CheckboxTreeViewer with Checkboxes only on top level?
Next Topic:Context Menu Action validate
Goto Forum:
  


Current Time: Sat Apr 20 03:47:03 GMT 2024

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

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

Back to the top