Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Parameterized view or editor
Parameterized view or editor [message #459719] Wed, 06 December 2006 15:48 Go to next message
Eclipse UserFriend
Is it possible to create a parameterized view or editor? I want to
define a view that extends ViewPart that has a setter method on it that
takes in a factory like so:

public class MyView extends ViewPart
{

public void setPartFactory(PartFactory factory)
{
this.factory = factory;
}

private void doSomething()
{
Parts parts = factory.createParts();
...

}


The idea is that I want to use the default version of the PartFactory
internally (if not provided by the extension), but if the extension
wants, it can provide an alternate PartFactory.

I have been using spring, and in spring it is really very simple to
define multiple beans (in our case that implement PartFactory) and plug
them into generic parameterized classes to get different behavior.

Whats the easiest way the same "pluggable bean mechanism" that Spring
uses going in the Eclipse platform?

Thanks,
Nik
Re: Parameterized view or editor [message #459825 is a reply to message #459719] Thu, 07 December 2006 07:44 Go to previous message
Eclipse UserFriend
Any executable extension (a class that can be instantiated) in
plugin.xml can be parameterized. The attribute that instantiates the
class can become a subelement. For example, take this definition:

<view name="Mock View 1"
icon="icons\view.gif"
class="org.eclipse.ui.tests.api.MockViewPart"
id="org.eclipse.ui.tests.api.MockViewPart">
</view>

I can change it to:

<view name="Mock View 1"
icon="icons\view.gif"
id="org.eclipse.ui.tests.api.MockViewPart">
<class class="org.eclipse.ui.tests.api.MockViewPart">
<parameter name="info" value="one"/>
<parameter name="readonly" value="false"/>
</class>
</view>

ViewPart already implements IExecutableExtension, so you can get the
IConfigurationElement from getConfigurationElement(). You can also
extend setInitializationData(*) (don't forget to call super) to retrieve
the parameter list. Check out the javadoc for IExecutableExtension.

Later,
PW
Previous Topic:GMF with RCP
Next Topic:Spring plugin and the classpath
Goto Forum:
  


Current Time: Mon Mar 17 14:22:44 EDT 2025

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

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

Back to the top