Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Zest: #setLineStyle not honoring settings
Zest: #setLineStyle not honoring settings [message #245877] Wed, 22 October 2008 13:21 Go to next message
Tully Yates is currently offline Tully YatesFriend
Messages: 7
Registered: July 2009
Junior Member
In the small graph snippet examples (e.g.
http://wiki.eclipse.org/GEF_Zest_Visualization), where the Graph is first
instantiated, followed by GraphNodes and then GraphConnections, one can
call #setLineStyle() on the GraphConnection and the change will be
visualized correctly.

However, I am using a content provider and when I create my
GraphConnections and then call #setLineStyle, although the field has
changed, it is not being displayed in the visualization.

I have to admit that I hacked Zest to expose the functionality I needed
(custom node shapes) so I could well be bypassing a refresh hook
somewhere...
The changed 6 methods in AbstractStructuredGraphViewer from private to
protected, so that I could subclass GraphViewer. Specifically:

@Override
protected GraphNode addGraphModelNode(Object element) {
GraphNode node = this.getGraphModelNode(element);
if (node == null) {
node = nodeDecorator.createGraphNode((Graph) getControl(), element);
getNodesMap().put(element, node);
}
return node;
}

@Override
protected GraphConnection addGraphModelConnection(Object element,
GraphNode source, GraphNode target) {
GraphConnection connection = this.getGraphModelConnection(element);
if (connection == null) {
connection = arcDecorator.createGraphConnection((Graph) getControl(),
element, source, target);
getConnectionsMap().put(element, connection);
}
return connection;
}

My *Decorator classes contain logic to style the GraphNode and
GraphConnections. All calls to the GraphNode are being picked up on, all
but #setLineStyle work with the GraphConnection class!?
Re: Zest: #setLineStyle not honoring settings [message #245886 is a reply to message #245877] Thu, 23 October 2008 10:33 Go to previous messageGo to next message
Tully Yates is currently offline Tully YatesFriend
Messages: 7
Registered: July 2009
Junior Member
The solution to ensure the line style is displayed was to make
>LabelProvider< implement the >IConnectionStyleProvider< interface.

In the implemented method #getConnectionStyle, return the line style you
want the connection to have, for example:

public int getConnectionStyle(Object connection) {

if (connection == "foo") {
return ZestStyles.CONNECTIONS_DOT;
} else if (connection == "bar") {
return ZestStyles.CONNECTIONS_DASH;
} else {
return ZestStyles.CONNECTIONS_SOLID;
}
}

The line style is correctly displayed now it has been provided by the
>LabelProvider< and custom connection end and/or target decorations are
provided by my arcDecorator class (see previous post).

Not a particularly succinct solution but a solution nonetheless.

Note:
There are bugs registered for this kind of functionality (see bug#:
243452, 215040)
Re: Zest: #setLineStyle not honoring settings [message #245891 is a reply to message #245886] Thu, 23 October 2008 18:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

Thank-you for bringing this up. There is a bug related to borders that I
have been looking at today too, and I think this is related (in that
Zest is not honouring different styles).

I will get a fix in.

cheers,
ian

Tully Yates wrote:
> The solution to ensure the line style is displayed was to make
>> LabelProvider< implement the >IConnectionStyleProvider< interface.
>
> In the implemented method #getConnectionStyle, return the line style you
> want the connection to have, for example:
>
> public int getConnectionStyle(Object connection) {
>
> if (connection == "foo") {
> return ZestStyles.CONNECTIONS_DOT;
> } else if (connection == "bar") {
> return ZestStyles.CONNECTIONS_DASH;
> } else {
> return ZestStyles.CONNECTIONS_SOLID;
> }
> }
>
> The line style is correctly displayed now it has been provided by the
>> LabelProvider< and custom connection end and/or target decorations are
> provided by my arcDecorator class (see previous post).
>
> Not a particularly succinct solution but a solution nonetheless.
>
> Note:
> There are bugs registered for this kind of functionality (see bug#:
> 243452, 215040)
>
>
Re: Zest: #setLineStyle not honoring settings [message #245895 is a reply to message #245886] Thu, 23 October 2008 18:54 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: irbull.cs.uvic.ca

So just to clarify, is it working with the style provider?

Without the style provider, can you loop through the connections and set
the style you want? Does this work?

cheers,
Ian

Tully Yates wrote:
> The solution to ensure the line style is displayed was to make
>> LabelProvider< implement the >IConnectionStyleProvider< interface.
>
> In the implemented method #getConnectionStyle, return the line style you
> want the connection to have, for example:
>
> public int getConnectionStyle(Object connection) {
>
> if (connection == "foo") {
> return ZestStyles.CONNECTIONS_DOT;
> } else if (connection == "bar") {
> return ZestStyles.CONNECTIONS_DASH;
> } else {
> return ZestStyles.CONNECTIONS_SOLID;
> }
> }
>
> The line style is correctly displayed now it has been provided by the
>> LabelProvider< and custom connection end and/or target decorations are
> provided by my arcDecorator class (see previous post).
>
> Not a particularly succinct solution but a solution nonetheless.
>
> Note:
> There are bugs registered for this kind of functionality (see bug#:
> 243452, 215040)
>
>
Re: Zest: #setLineStyle not honoring settings [message #245900 is a reply to message #245895] Thu, 23 October 2008 19:52 Go to previous message
Tully Yates is currently offline Tully YatesFriend
Messages: 7
Registered: July 2009
Junior Member
Ian Bull wrote:

> So just to clarify, is it working with the style provider?

Yes it's working when my lLabelProvider implements the
IConnectionStyleProvider interface.

> Without the style provider, can you loop through the connections and set
> the style you want? Does this work?

No this isn't working for me. However I'm setting this in the overriden
AbstractStructuredGraphViewer (I exposed the methods to do this).

@Override
protected GraphConnection addGraphModelConnection(Object element,
GraphNode source, GraphNode target) {
GraphConnection connection = this.getGraphModelConnection(element);
if (connection == null) {
connection = arcDecorator.createGraphConnectionTargetDecoration((Graph)
getControl(), element, source, target);
// TRIED SETTING LINE STYLE HERE
// ALL OTHER STYLE ATTRIBUTES VISUALIZED - i.e: COLOURS, TARGET
DECORATION
getConnectionsMap().put(element, connection);
}
this.getFactory().refresh((Graph) getControl(), element);
return connection;
}


Cheers,

Tully
Previous Topic:Changing SelectionTool to ConnectionCreationTool
Next Topic:GEF v 3.5 versus v 3.4
Goto Forum:
  


Current Time: Thu Apr 25 06:20:38 GMT 2024

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

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

Back to the top