/** * Creates a plugin hosts given its class name. Use PluginHostManager.HOST_* constants. * * @param pluginHostClass Class name of plugin host to create. * @param props Properties map. * @throws PluginException on plugin error. */ public void setPluginHost(String pluginHostClass, Map props) throws PluginException { boolean firstTime = (current_ == null); PluginHost previous = current_; try { current_ = (PluginHost) Class.forName(pluginHostClass).newInstance(); } catch (InstantiationException e) { throw new PluginException(e); } catch (IllegalAccessException e) { throw new PluginException(e); } catch (ClassNotFoundException e) { throw new PluginException(e); } if (firstTime) { try { current_.initialize(props); } catch (ServiceException se) { throw new PluginException(se); } } else { try { transferAssets(previous, current_); } catch (ServiceException e1) { throw new PluginException(e1); } recepticle_.remove(previous.getView()); } recepticle_.add(current_.getView()); }
/** @see toolbox.util.ui.SmartAction#runAction( java.awt.event.ActionEvent) */ public void runAction(ActionEvent e) throws Exception { String selected = newPluginHost_.getClass().getName(); if (selected.equals(current_.getClass().getName())) { JSmartOptionPane.showMessageDialog(null, "Plugin host " + selected + " is already active."); } recepticle_.remove(current_.getView()); transferAssets(current_, newPluginHost_); recepticle_.add(newPluginHost_.getView()); current_ = newPluginHost_; recepticle_.validate(); current_.applyPrefs(workspace_.getPreferences()); }