| Summary: | Custom figures in GraphViewer are not highlighted correctly | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Dale Swift <daleswift> |
| Component: | GEF-Legacy Zest | Assignee: | gef-inbox <gef-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | eclipse-bugs, m, nyssen, steeg |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
| Attachments: | |||
|
Description
Dale Swift
I have a similar issue: my implementation of ILabelProvider-let's call it "MyLabelProvider"-which is used as label provider for a GraphViewer, implements both IEntityStyleProvider and IFigureProvider as well. In my implementation of MyLabelProvider.getFigure(...) I return a custom IFigure for selected nodes. Furthermore, in MyLabelProvider.getBorderColor(...) I return a custom color. I would expect that my custom node figures would be highlighted in that custom color. However, these nodes are not highlighted at all. Created attachment 207305 [details]
Proposed patch to allow styling and labeling of custom figures
I have attached a proposal for solving this issue.
In short, my idea was to introduce two interfaces (for a figure supporting to be labeled or styled) and base the implementation of GraphNode.updateFigureForModel(...) on the interfaces instead of the GraphLabel class (GraphLabel implements both). CGraphNode uses the updateFigureForModel implementation of its super class.
Please let me know what you think of this solution and what might have to be changed to include it in the code base.
Created attachment 207307 [details]
Eclipse project with two example snippets
The attached eclipse project contains two snippets, the first (CustomFigureSample) for demonstrating the problem without the patch. The custom figures provided through the IFigureProvider don't change their style if they are selected (even the one that actually is a GraphLabel).
The second (CustomFigureSampleStylable) uses the changes made in the patch, the custom figures are updated when the selection changes.
Thanks a lot for your patch Simon, looks good to me. Could you resubmit with the following additions: - Legal file headers for the two new files (see [1] for a template) - Your CustomFigureSampleStyleable, with a legal header, in project org.eclipse.zest.examples (slimmed down a bit, e.g. without selection listener) - A statement (as a comment on this bug) confirming that you wrote 100% of the code yourself, and that you have the right to contribute it under the EPL [1] http://eclipse.org/legal/copyrightandlicensenotice.php Created attachment 208551 [details]
Proposed patch to allow styling and labeling of custom figures (v2)
Thank you very much for your feedback, Fabian.
I changed the patch according to your instructions and improved the example.
I will also add a second patch where I added a set of classes that are intended to make it easier to create a custom shaped figure/label for use in a graph. An example is also included.
Created attachment 208552 [details]
Patch adding base classes for implementing custom shaped figures/labels
The aforementioned second patch (depends on the first). Please take a look at it, if it makes sense for you to also include it.
Legal Message: I, Simon Templer, declare that I developed attached code from scratch, without referencing any 3rd party materials except material licensed under the EPL. I certify that I am the copyright owner and authorize this contribution. Thanks for your updated patch. Fixed in master, see CustomFigureJFaceSnippet. http://git.eclipse.org/c/gef/org.eclipse.zest.git/commit/?id=22efd6bd97a4df90a0 About the other patch: I'm generally reluctant to add new convenience-only API. Also, as a larger contribution (> 250 lines) it would need full legal review. If you'd like to discuss this, or prepare a smaller, example-only contribution (without introducing new API), feel free to open a new bug for this. Thanks again, Fabian. This being included in Zest helps a lot - not being able to really use custom figures would have been a real show-stopper for me. Keep up the good work! Comment on attachment 208552 [details]
Patch adding base classes for implementing custom shaped figures/labels
This patch does not seem to have been applied, thus marking obsolete.
|