Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » Change IModelElement icons (in outline, explorer, completion)
Change IModelElement icons (in outline, explorer, completion) [message #500932] Mon, 30 November 2009 10:43 Go to next message
David Largeteau is currently offline David LargeteauFriend
Messages: 35
Registered: July 2009
Location: Bordeaux - France
Member
Hi,

I would like to change IModelElement icons displayed in outline,
explorer and completion, but with no success :-(

I've tried to look around ModelElementLabelProvider class, but I still
have problems with icons size (those I changed are not displayed with
the right size), and I'm not sure to go the right way...

If someone could help ... (thanks in advance)

David
Re: Change IModelElement icons (in outline, explorer, completion) [message #501101 is a reply to message #500932] Tue, 01 December 2009 04:04 Go to previous messageGo to next message
Andrei Sobolev is currently offline Andrei SobolevFriend
Messages: 17
Registered: July 2009
Junior Member
Hi David,

Please look into org.eclipse.dltk.ui.modelLabelProvider extension point.
It's allow any customization of outline, etc by providing custom label provider.

You could check example implementation in TCL in class TclModelLabelProvider.

If you need to add some additional elements you also could use following extension points ( for customization of outline, script explorer content and element ordering)
org.eclipse.dltk.ui.modelCompareProvider
org.eclipse.dltk.ui.modelContentProvider


Best regards,
Andrei.
Re: Change IModelElement icons (in outline, explorer, completion) [message #501667 is a reply to message #501101] Thu, 03 December 2009 11:13 Go to previous messageGo to next message
David Largeteau is currently offline David LargeteauFriend
Messages: 35
Registered: July 2009
Location: Bordeaux - France
Member
Andrei Sobolev a écrit :
> Hi David,
>
> Please look into org.eclipse.dltk.ui.modelLabelProvider extension point.
> It's allow any customization of outline, etc by providing custom label
> provider.
>
> You could check example implementation in TCL in class
> TclModelLabelProvider.
>
> If you need to add some additional elements you also could use following
> extension points ( for customization of outline, script explorer content
> and element ordering)
> org.eclipse.dltk.ui.modelCompareProvider
> org.eclipse.dltk.ui.modelContentProvider
>
> Best regards,
> Andrei.


Hi Andrei,

Thank you for your answer.

I’ve tried to use org.eclipse.dltk.ui.modelLabelProvider extension
point, as in Tcl project. It works very well for all explorer part, but
I still have problems with icons size in Outline view : they are
displayed bigger than they are in explorer part.

In Tcl project, the only custom objects that are displayed are Tcl
Packages (tcl_packagefolder_obj.gif), and this kind of object is not
displayed in the Outline, so I can’t compare the behavior.

I also noticed that IModelElement objects displayed in completion
proposals do not react the same way : I mean that modelLabelProvider is
not used in this case (I need to override
CompletionProposalLabelProvider to do what I want). I think
modelLabelProvider extension point should also be used by completion.

Thanks in advance for your help,

David
Re: Change IModelElement icons (in outline, explorer, completion) [message #501849 is a reply to message #501667] Fri, 04 December 2009 04:05 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
Hi David,

The custom icons size in the Outline view was fixed in the last
integration build. Could you please test that it works for you?

We'll check what can be improved regarding completion proposals label
providers.

Regards,
Alex
Re: Change IModelElement icons (in outline, explorer, completion) [message #501886 is a reply to message #501849] Fri, 04 December 2009 09:59 Go to previous messageGo to next message
David Largeteau is currently offline David LargeteauFriend
Messages: 35
Registered: July 2009
Location: Bordeaux - France
Member
Hi Alex,

Thanks a lot, it works fine now in outline view.

Regards

David
Re: Change IModelElement icons (in outline, explorer, completion) [message #512862 is a reply to message #501849] Mon, 08 February 2010 03:52 Go to previous messageGo to next message
David Largeteau is currently offline David LargeteauFriend
Messages: 35
Registered: July 2009
Location: Bordeaux - France
Member
Alex Panchenko a écrit :
> Hi David,
>
> The custom icons size in the Outline view was fixed in the last
> integration build. Could you please test that it works for you?
>
> We'll check what can be improved regarding completion proposals label
> providers.
>
> Regards,
> Alex

Hi Alex,

I think there is the same problem of icon size in search view. I have
problem in my plugin search page, but I also see it in Ruby plugin.

Regards

David
Re: Change IModelElement icons (in outline, explorer, completion) [message #513224 is a reply to message #512862] Tue, 09 February 2010 12:34 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex PanchenkoFriend
Messages: 342
Registered: July 2009
Senior Member
Hi David,

Thank you for reporting this.

I've fixed in CVS HEAD the size of source module icons in Search view, so the next integration build should work correctly.

Regards,
Alex
Re: Change IModelElement icons (in outline, explorer, completion) [message #514399 is a reply to message #513224] Mon, 15 February 2010 08:43 Go to previous messageGo to next message
David Largeteau is currently offline David LargeteauFriend
Messages: 35
Registered: July 2009
Location: Bordeaux - France
Member
Alex Panchenko a écrit :
> Hi David,
>
> Thank you for reporting this.
>
> I've fixed in CVS HEAD the size of source module icons in Search view,
> so the next integration build should work correctly.
>
> Regards,
> Alex

Hi Alex,

I have downloaded the latest build, and it works fine now.

Thanks a lot for your reactivity.

David
Re: Change IModelElement icons (in outline, explorer, completion) [message #519986 is a reply to message #514399] Wed, 10 March 2010 17:22 Go to previous messageGo to next message
Kevin KIN-FOO is currently offline Kevin KIN-FOOFriend
Messages: 50
Registered: January 2010
Member
Hi,

Like dalar I wish to change change Images in quick outilne. In my case I would like to to hava an icon dor private classes. In java it is a non sense, but it's relevant in my language.

Anyway I tried to extend LabelProvider but when debugging, I've noticed that the getImage() function receive SourceType object and related objects. The behavior of my outline changed using an regular LabelProvider.

How can I keep the default DLTK outline behavior and just change one image ?

Regards
Re: Change IModelElement icons (in outline, explorer, completion) [message #520129 is a reply to message #519986] Thu, 11 March 2010 04:28 Go to previous messageGo to next message
David Largeteau is currently offline David LargeteauFriend
Messages: 35
Registered: July 2009
Location: Bordeaux - France
Member
Hi Kevin,

What I do is :

- extend LabelProvider class

- override "public Image getImage(Object element)" method in my
xxxLabelProvider class. In this class, check for element flags like
example below (you'll have to adapt it to your case).

@Override
public Image getImage(Object element)
{
IMember member = getMember(element);
if (member == null)
return null;
try
{
if (member.exists())
{
int flags = member.getFlags();
// Special icon for private type
if (member instanceof IType
&& (flags & Modifiers.AccPrivate) != 0)
return getPrivateMethodIcon(); // return your special icon
}
}
catch (ModelException e)
{
}
return null; // will enter default DLTK behavior
}

Hope this helps you

David

[Updated on: Thu, 11 March 2010 12:21]

Report message to a moderator

Re: Change IModelElement icons (in outline, explorer, completion) [message #521968 is a reply to message #520129] Fri, 19 March 2010 13:48 Go to previous message
Kevin KIN-FOO is currently offline Kevin KIN-FOOFriend
Messages: 50
Registered: January 2010
Member
Hi,

I had already manage to get the icon changed. Neither the less, what I was searching for was to recover DLTKs behavior on text labels going along with the outline's icons. It's deeply inpired from rour example Smile
public class YourLabelProvider extends LabelProvider {

    @Override
    public String getText(Object element) {
        /*
         * Override this method and return null activate DLTK's default
         * behavior. Else way, parent class just returns toString(), which is
         * less convenient
         */
        return null;
    }

    @Override
    public Image getImage(Object element) {
        IMember member = getMember(element);
        if (member == null)
            return null;
        try {
            if (member.exists()) {
            int flags = member.getFlags();
            // Special icon for private type
            if (member instanceof IType
                && (flags & Modifiers.AccPrivate) != 0)
                return getPrivateMethodIcon();
            }
        } catch (Exception e) {
        }
        // Stick to default DLTK behavior
        return null;
    }

    private IMember getMember(Object element) {
        if (element instanceof IMember) {
            return (IMember) element;
        }
        return null;
    }

    private Image getPrivateMethodIcon() throws IOException {
        return Activator.getImage("/img/class_obj.gif");
    }

}
Previous Topic:[BUILD] S-2.0M6-201003160541
Next Topic:DLTK 2.0 , Ruby ?
Goto Forum:
  


Current Time: Wed Nov 26 21:53:37 GMT 2014

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

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