Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-dev] How can an object determine which plugin it was instantiated?

Hi.

 

I’ve created a generic plugin with a couple of abstract classes. Specialized plugins are using this generic plugin’s functionality. Sometimes the classes in generic plugin have to know in which specialized pligin they were instantiated. Let me clarify the concrete problem:

 

public abstract class GenericPlugin extends AbstractUIPlugin {

                private CommandMapping commandMapping;

 

                public void start( BundleContext context ) {

                               commandMapping = instantiateCommandMapping();

                }

 

                public CommandMapping getCommandMapping() { return commandMapping; }

 

                publc static GenericPlugin getInstance( String pluginName ) { return PlguinRegistry.get( pluginName ); }

               

                protected CommandMapping instantiateCommandMapping();

}

 

public class SpecificPlugin extends GenericPlugin {

                protected CommandMapping instantiateCommandMapping() {

                               return new SpecificCommandMapping();

                }

}

 

public abstract class ActionDelegate implements IWorkbenchWindowActionDelegate {

                private CommandMapping commandMapping;

 

                public void init( IWorkbenchWindow window ) {

                               commandMapping = GenericPlugin.getInstance( pluginName ).getCommandMapping();

                }

}

 

public class SpecificActionDelegate extends GenericActionDelegate {

                public void init(IWorkbenchWindow window ) {

                               super( window );

                }

}

 

The line: GenericPlugin.getInstance( pluginName ) is crucial because I don’t know how can I determine the plugin’s name within which the object SpecificActionDelegate was instantiated.

 

Do you have any idea?

 

Zsolt



__________ Information from ESET NOD32 Antivirus, version of virus signature database 2985 (20080330) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Back to the top