Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Decorate TreeItem(is it possible to decorate TreeItem?)
Decorate TreeItem [message #898261] Thu, 26 July 2012 05:32 Go to next message
Nir Zinger is currently offline Nir ZingerFriend
Messages: 5
Registered: July 2012
Junior Member
Hi,
I wanted to use ControlDecoration and ControlDecorator to my TreeItem, but its not possible, because TreeItem is a widget while the decorator accept in its constructor a Control type.

Are there any other objects I can use to decorate my TreeItem?

I have a tree with some elements (each element has an image + name), which may have several statuses (like "Up/Down/etc'").
and i want to put an extra image on the image i have.
for example if my element status is "Down", I would want to add a small image of Red X at the top left of my TreeItem's Image+label.
exactly like the behavior of the control decorator:

ControlDecoration decoration = new ControlDecoration( text, SWT.TOP | SWT.LEFT );
decoration.setImage( image );


any ideas or tips how to implement please?
Re: Decorate TreeItem [message #898327 is a reply to message #898261] Thu, 26 July 2012 08:30 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
Hi.
> and i want to put an extra image on the image i have.
> for example if my element status is "Down", I would want to add a small
> image of Red X at the top left of my TreeItem's Image+label.

If you have a limited number of combinations, could you not just create
images that already have this additional icon?

Otherwise, if you are on 1.5, you might be able to achieve this using
the Trees markup support. However, since the markup is on the label, it
is not possible to put something on the left of the image, unless you
render the image also with markup.


Greetings,
Tim


--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Decorate TreeItem [message #901444 is a reply to message #898327] Sun, 12 August 2012 12:47 Go to previous messageGo to next message
Nir Zinger is currently offline Nir ZingerFriend
Messages: 5
Registered: July 2012
Junior Member
Hi,
First of all, thank you for the reply Smile
Second of all, sorry I didnt reply untill today, just had more important tasks to handle before this.

the solution of creating the images is the last thing i'll try to do, as we have 5 images, with 3-5 states on each one. and more then one icon can be on the main image.
its many combinations bottom line.

Well, I looked at the Markup system, and tried it. It seemed like saving the space for the image, but it didnt display it. (probably I had issues with the path to the image, although i tried many combinations, even like "c:\blabla.gif").

I thought about merging the images, found a code via google, but it didnt work well. it almost did the trick, but not perfectly. the images where "merged" togather, but the colors of the second image were corrupted.. instead of red (down status icon)..
it all became gray/black. is there a different way to merge the images? below is the code that I tried.

in RWT there is no way to use GC on image anymore (image not implementing drawable).
if there was, i could try to create image from main image, and draw the other images on it. anyways its not possible due to the issue below, btw I saw a bug on it, will it be solved some day ? (https://bugs.eclipse.org/bugs/show_bug.cgi?id=318900)

Edited:
I understood the code below not working well for me because the palette. the palette im using is the one from main image, thats why it looks ok on main image but not on icon, if i use the icon palette, its the opposite of course (although not sure I really understood how this Pallete works)

*sigh*
Any ideas maybe please?

public Image getImage(Object element) {
		EntityData nodeData = (EntityData) element;
		Image mainImage = NODE_IMAGES.get(nodeData.getType());
		Image downImg = ImageConsts.Images.DOWN_IMG;
		ImageData mainImageData = mainImage.getImageData();
		ImageData iconImageData = downImg.getImageData();
		ImageData targetData = targetData = new ImageData(mainImageData.width, mainImageData.height,
				mainImageData.depth, mainImageData.palette);
		merge(mainImageData, iconImageData, targetData, mainImageData.width-8, mainImageData.height-8);

		Image returnedImage = new Image(InsitePlugin.getDisplay(), targetData);
		
		return returnedImage;
	}
private static void merge(ImageData sourceData1, ImageData sourceData2,
			ImageData targetData, int startX, int startY) {
		// Merge the 1st Image
		merge(sourceData1, targetData, sourceData1.x, sourceData1.x);

		// Merge the 2nd Image
		merge(sourceData2, targetData, startX, startY);
	}

	private static void merge(ImageData sourceData, ImageData targetData, int startX, int startY) {
		int i;
		i = sourceData.x;

		for (; i < sourceData.width; i++) {
			int j = sourceData.y;
			for (; j < sourceData.height; j++) {
				targetData.setPixel(startX + i, startY + j, sourceData.getPixel(i, j));
			}
		}
	}

not working well, the colors not stay as the original image.

[Updated on: Sun, 12 August 2012 13:15]

Report message to a moderator

Re: Decorate TreeItem [message #901517 is a reply to message #901444] Mon, 13 August 2012 08:39 Go to previous messageGo to next message
Nir Zinger is currently offline Nir ZingerFriend
Messages: 5
Registered: July 2012
Junior Member
Ok,
I found a solution. so Im sharing with you all, incase someone will need it in the future.
this can be done with the DecorationOverlayIcon Object Smile

Enjoy and thank you!
Re: Decorate TreeItem [message #901526 is a reply to message #901444] Mon, 13 August 2012 08:51 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
Hi.

Am 12.08.2012 14:47, schrieb Nir Zinger:

> Well, I looked at the Markup system, and tried it. It seemed like saving
> the space for the image, but it didnt display it. (probably I had issues
> with the path to the image, although i tried many combinations, even
> like "c:\blabla.gif").

You need to register the images first. For 1.5 there is no one ideal way
to do that yet. However, it's basically the same as when you register
images for use with a custom widget, which is mentioned here:

http://www.eclipse.org/rap/developers-guide/devguide.php?topic=rwt/custom-widget.html#browserResources

I hope that helps.

Greetings,
Tim

--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Decorate TreeItem [message #901732 is a reply to message #901526] Tue, 14 August 2012 12:00 Go to previous message
Nir Zinger is currently offline Nir ZingerFriend
Messages: 5
Registered: July 2012
Junior Member
Like i said above, i found different solution at the end.
but thank you very much (!!!)Tim for help and the study Smile

much appreciated!

[Updated on: Tue, 14 August 2012 12:01]

Report message to a moderator

Previous Topic:Focus on a Text in a Dialog
Next Topic:Language of session timeout message.
Goto Forum:
  


Current Time: Wed Oct 20 02:03:18 GMT 2021

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

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

Back to the top