Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: irate/swt/plugin/SWTPluginUIFactory.java


1   // Copyright 2003 Stephen Blackheath
2   
3   package irate.swt.plugin;
4   
5   import irate.plugin.Plugin;
6   import irate.plugin.PluginApplication;
7   import irate.plugin.PluginUIFactory;
8   import org.eclipse.swt.widgets.Display;
9   
10  /**
11   * Base class for factory that finds user interface objects for plugins.
12   * Subclasses are for specific user-interface implementations.
13   *
14   * @author Stephen Blackheath
15   */
16  public class SWTPluginUIFactory
17    extends PluginUIFactory
18  {
19    private Display display;
20    private PluginApplication app;
21  
22    public SWTPluginUIFactory(Display display, PluginApplication app)
23    {
24      this.display = display;
25      this.app = app;
26    }
27  
28    /**
29     * Look up a UI object based on the class of the plugin and the specified
30     * type of object required.  The implementation should pass the plugin
31     * instance to the object.
32     * 
33     * @return null if a UI object can't be found for it.
34     */
35    public Object lookup(Plugin plugin, String type)
36    {
37        // Note: These names are chosen so we can later switch to an implementation
38        // that automatically converts
39        //   irate.plugin.lircremote.LircRemoteControlPlugin
40        // to
41        //   irate.swt.plugin.lircremote.LircRemoteControlConfigurator
42        // (by adding 'swt' before 'plugin' and type in place of 'Plugin')
43        //
44        // If we stick to this convention, then we can later support plugins that
45        // are downloaded automatically.
46        //
47      if (type.equals(CONFIGURATOR)) {
48        if (plugin instanceof irate.plugin.lircremote.LircRemoteControlPlugin)
49    return new irate.swt.plugin.lircremote.LircRemoteControlConfigurator(display, app, plugin);
50      }
51      return null;
52    }
53  }
54