tags:

views:

23

answers:

1

I have a plugin where for a particular type of file i will enable some options to perform. so now i have requirement where i need to decide the type of a file dynamically and apply a particular options for that type of file.

Is it possible to do that? if yes, need some help about the same.

Thanks.

+1  A: 

So I guess you want to show the context menu for something that represents a file in a view. Determine the file type based on custom rules (file extension is the easiest rule, looking inside the file the most complex) and create the popup or distribute content to an existing one.

If it's your own view, maybe a list or tree that shows a folder structure, then you have to register the Viewer as a SelectionProvider, listen to selection events, evaluate the selection (maybe a String or a File object) and create the popup menu.

Contributing actions to existing popup menus (like the navigator view context menus) is possible as well but a bit more challenging.

Andreas_D
Thanks andreas_D. is it possible for you to explain with some lines of code. or with some example.
GK
Sorry, no, not that I didn't want but it can't be explained with 'just a few lines of code'. But at least I can recommend a book: Eclipse Building Commercial Plug-In (Clayberg, Eric; Rubel, Dan).
Andreas_D