Switching Diagram Label Icon during runtime on/off [message #1032956] |
Wed, 03 April 2013 13:21  |
Eclipse User |
|
|
|
Hi,
by default my diagram labels have no icon. But when the user change a specific property of the label node, the diagram label icon should appear. In my code, I've got access to the EditPart of the label as you can see below. I'm wondering now how I can change the element icon attribute from false to true - Is this possible?
if (graphicalEditPart.getChildren().get(0) instanceof FeatureName2EditPart) { FeatureName2EditPart featureLabel = (FeatureName2EditPart) graphicalEditPart .getChildren().get(0);
......
[Updated on: Wed, 03 April 2013 13:21] by Moderator
|
|
|
|
|
|
|
Re: Switching Diagram Label Icon during runtime on/off [message #1033805 is a reply to message #1033614] |
Thu, 04 April 2013 13:01   |
Eclipse User |
|
|
|
Hi Phil,
not sure, if the URI you are creating is correct.
Let Eclipse do the work and try the following:
ImageDescriptor myImage = ImageDescriptor.createFromURL(
FileLocator.find(Activator.getDefault().getBundle(),
new Path("icons/myicon.gif"),null));
where Activator is your AbstractUIPlugin-class and the Path-String is relative to your Plugin-root or use the more generic
ImageDescriptor.createFromURL(FileLocator.find(Platform.getBundle(plugin_id), new Path("icons/imageFileName.xxx"),null);
However the ExecutionException can also be a wrapped Exception, that results from possible other resources.
If the examples above don't work, please provide the wrapping code, where you embed the image update.
Regards
Thomas
|
|
|
Re: Switching Diagram Label Icon during runtime on/off [message #1034011 is a reply to message #1033805] |
Thu, 04 April 2013 19:05   |
Eclipse User |
|
|
|
Hi Thomas,
you're right about the URI. I implemented the following code and got no exception anymore:
FileLocator.find(Platform.getBundle(PldDiagramEditorPlugin.ID),new Path("icons/Feature.gif"), null)).createImage();
if (featureNode.getFilePath() != null) {
IFigure figure = getFigure();
if (!featureNode.getFilePath().isEmpty()) {
setLabelIconHelper(figure, image);
Unfortunately the icon isn't displayed in the diagram (I generated an editor with eugenia and tested the icon there and it worked - so the icon can't be the problem).
In case of the "Icon event", I noticed that the label went a little bit to the right (like the width of the icon). It seems that the icon is there, but invisible.

Furthermore, I manipulate the icon path so that it point to a non existing icon. Then a small red rectangle is displayed instead of the icon.

Maybe the setLabelIconHelper isn't the right method to set an icon? But I couldn't find any other method for this case.
Cheers,
Phil
Attachment: feature.png
(Size: 0.51KB, Downloaded 1074 times)
Attachment: red.JPG
(Size: 8.32KB, Downloaded 1129 times)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06819 seconds