//-------------------------------------------------------------------------
	void
	PluginRegistry::selectPlugin( AbstractPlugin* plugin )
	{
		AbstractPlugin* selectedPlugin( getSelectedPlugin() );
		if( plugin == selectedPlugin )
		{
			return;
		}
		if( selectedPlugin != nullptr )
		{
			selectedPlugin->close();
		}

		// reset camera and selected vehicle
		Camera::accessInstance().reset ();
		SteeringVehicle::setSelectedVehicle( nullptr );

		setSelectedPlugin( plugin );
		if( getSelectedPlugin() != nullptr )
		{
			getSelectedPlugin()->prepareOpen();
			// note: call the application
			//       might initialize the gui
			if( _on_plugin_selected_func != nullptr )
			{
				_on_plugin_selected_func( getSelectedPlugin() );
			}
			getSelectedPlugin()->open();
		}
	}
	//-------------------------------------------------------------------------
	// handle function keys an a per-plug-in basis
	void
	PluginRegistry::functionKeyForPlugin( int keyNumber ) const
	{
		if( getSelectedPlugin() == nullptr )
		{
			return;
		}
		getSelectedPlugin()->handleFunctionKeys (keyNumber);
	}
	//-------------------------------------------------------------------------
	// select the "next" plug-in, cycling through "plug-in selection order"
	void
	PluginRegistry::selectNextPlugin (void)
	{
		if( getSelectedPlugin() == nullptr )
		{
			return;
		}
		selectPlugin( getSelectedPlugin()->next () );
	}
	//-------------------------------------------------------------------------
	// return a group (an STL vector of AbstractVehicle pointers) of all
	// vehicles(/agents/characters) defined by the currently selected Plugin
	const AVGroup&
	PluginRegistry::allVehiclesOfSelectedPlugin (void) const
	{
		static AVGroup kTrash;
		if(getSelectedPlugin() )
			return getSelectedPlugin()->allVehicles ();
		else
			return kTrash;
	}
	//-------------------------------------------------------------------------
	// reset the currently selected plug-in
	void
	PluginRegistry::resetSelectedPlugin (void)
	{
		if( getSelectedPlugin() == nullptr )
		{
			return;
		}
		// reset camera and selected vehicle
		Camera::accessInstance().reset ();
		SteeringVehicle::setSelectedVehicle( nullptr );

		getSelectedPlugin()->reset ();
	}
	//-------------------------------------------------------------------------
	// select the plug-in by index
	void PluginRegistry::selectPluginByIndex (size_t idx)
	{
		AbstractPlugin* p = getPluginAt( idx );
		if( ( p != nullptr ) && (p != getSelectedPlugin()) )
		{
			selectPlugin( p );
		}
	}
void ossimQtPluginsDialog::updateDescription()
{
   if (thePluginList && theDescription)
   {
      QString text = "";
      ossimPluginLibrary* pi = getSelectedPlugin();
      if (pi)
      {
         text = pi->getDescription().c_str();
      }
      theDescription->setPlainText(text);
   }
}
void ossimQtPluginsDialog::removeButtonPressed()
{
   ossimPluginLibrary* pi = getSelectedPlugin();
   if(pi)
   {
      int answer = QMessageBox::question(
         this,
         tr("Remove selected plugin:\n"),
         tr(pi->getName().c_str(), "\n yes or no"),
         QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);
      if (answer == QMessageBox::Yes)
      {
         ossimQtQueryObjectAllocationEvent event;
         std::vector<ossimString> queryList;
         pi->getClassNames(queryList);
         event.setQueryList(queryList);
         
         ossimQtApplicationUtility::sendEventToRoot(this, &event);
         
         if(event.getObjectsAllocated() == false)
         {
            ossim_uint32 pluginIdx = ossimSharedPluginRegistry::instance()->
               getIndex(pi);
            ossimSharedPluginRegistry::instance()->unregisterPlugin(pluginIdx);
         }
         else
         {
            QMessageBox::critical(this,
                                  "ERROR",
                                  "Can't remove plugin, please remove any object allocated by this plugin");
         }
         updateDialog();
         
      } // End of "if (answer == QMessageBox::Yes)"
      
   } // End of "if (pi)"
}
	//-------------------------------------------------------------------------
	// return name of currently selected plug-in
	const char*
	PluginRegistry::nameOfSelectedPlugin (void) const
	{
		return (getSelectedPlugin() ? getSelectedPlugin()->pluginName() : "no Plugin");
	}