Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Use of different view ids for the same view part instance class(Use of different view ids for the same view part instance class)
Use of different view ids for the same view part instance class [message #690614] Wed, 29 June 2011 20:29 Go to next message
eclipsefan  is currently offline eclipsefan Friend
Messages: 11
Registered: June 2011
Junior Member
Hello Experts!

I have two oracle tables namely EMPLOYEE and ORGANIZATION. My RCP application allows searching for both employee and organization. I have defined a class called ResultsViewPart (this inherits from the org.eclipse.ui.part.ViewPart). Whether the search yields employee objects or organization objects, they are a result of my query and hence I planned to defined one view part class to show results. However I want to open an instance of ResultsViewPart when i search for employee and another instance of ResultsViewPart when I search for organization. Both the instances need to present in the workbench at the same time.

Eclipse allows multiple instances of a view part (with one id) as well it allows different ids to be associated with the same view part class.

Approach 1-

<extension point="org.eclipse.ui.views">
<view
allowMultiple="true"
class="in.dev.ui.views.ResultsViewPart"
id="in.dev.ui.views.resultsview"
name="Results View">
</view>
</extension>

Approach 2 -

<extension point="org.eclipse.ui.views">
<view
allowMultiple="false"
class="in.dev.ui.views.ResultsViewPart"
id="in.dev.ui.views.employee"
name="Results View">
</view>
<view
allowMultiple="false"
class="in.dev.ui.views.ResultsViewPart"
id="in.dev.ui.views.organization"
name="Results View">
</view>
</extension>

Based on if the results are employee or organization I may want to display different actions/menus in the view toolbar meaning, in the results view that has employees will show a different set of menus/commands on the toolbar than when the results view has organizations.

My question is out of approach 1 and approach 2 which is preferable and why ?

Regards.


Re: Use of different view ids for the same view part instance class [message #691047 is a reply to message #690614] Thu, 30 June 2011 15:45 Go to previous messageGo to next message
mousa.alsulaimi is currently offline mousa.alsulaimiFriend
Messages: 18
Registered: June 2011
Junior Member
if you go for approach 1 then you can use expresions and testers to use multiple commands and command handlers for deferent contexts ( employees and orginizations ) where you can disable a command or a handler for one context and enable them (or another set of commands and handlers) for another context
Re: Use of different view ids for the same view part instance class [message #691051 is a reply to message #690614] Thu, 30 June 2011 15:50 Go to previous messageGo to next message
mousa.alsulaimi is currently offline mousa.alsulaimiFriend
Messages: 18
Registered: June 2011
Junior Member
if you go for approach 1 then you can use expresions and testers to use multiple commands and command handlers for deferent contexts ( employees and orginizations ) where you can disable a command or a handler for one context and enable them (or another set of commands and handlers) for another context
Re: Use of different view ids for the same view part instance class [message #698082 is a reply to message #690614] Mon, 18 July 2011 18:21 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

If you use option 2, you can pass in data that tells the instance which kind of view it is working for:

ex:

<view
allowMultiple="false"
class="in.dev.ui.views.ResultsViewPart:employee"
id="in.dev.ui.views.employee"
name="Results View">
</view>
<view
allowMultiple="false"
class="in.dev.ui.views.ResultsViewPart:organization"
id="in.dev.ui.views.organization"
name="Results View">
</view>


In your ViewPart, extend the org.eclipse.ui.part.ViewPart.setInitializationData(IConfigurationElement, String, Object) method and check the data Object parameter.

PW



Re: Use of different view ids for the same view part instance class [message #701630 is a reply to message #698082] Mon, 25 July 2011 11:02 Go to previous messageGo to next message
eclipsefan  is currently offline eclipsefan Friend
Messages: 11
Registered: June 2011
Junior Member
Paul - Thank you very much for the reply. I understand that whenever a view part (in this case) is getting created for the first time, it will call this method and we then have a hook to set some information (model related) to display properties in the view or change the view toolbars. I will try this at my end. Thanks again.
Re: Use of different view ids for the same view part instance class [message #701634 is a reply to message #701630] Mon, 25 July 2011 11:09 Go to previous message
eclipsefan  is currently offline eclipsefan Friend
Messages: 11
Registered: June 2011
Junior Member
Paul - With this second approach where we have different view ids for the same view part class definition, and if I need to display different icons on the respective view instance toolbar, I can easily achieve that using the menu contributions and the expressions that can be fed the unique ids. Would this approach be better than using the org.eclipse.ui.part.ViewPart.setInitializationData(IConfigurationElement, String, Object) to store the requisite attribute and then later do something to manipulate the toolbars ? Please advice.
Previous Topic:propertyTester crashes on different objects
Next Topic:Setting Bookmark from CommandLine
Goto Forum:
  


Current Time: Thu Apr 25 14:32:55 GMT 2024

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

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

Back to the top