All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.base.gui.plugin.SJCC Maven / Gradle / Ivy

package jadex.base.gui.plugin;

import java.awt.Component;

import jadex.bridge.IComponentIdentifier;
import jadex.bridge.IExternalAccess;
import jadex.bridge.service.RequiredServiceInfo;
import jadex.bridge.service.search.SServiceProvider;
import jadex.bridge.service.types.cms.IComponentManagementService;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
import jadex.commons.gui.future.SwingDefaultResultListener;
import jadex.commons.gui.future.SwingDelegationResultListener;
import jadex.commons.gui.future.SwingExceptionDelegationResultListener;

/**
 *  Static helper methods for JCC plugins.
 */
public class SJCC
{
	public static void	killPlattform(IExternalAccess exta, Component ui)
	{
		getRootAccess(exta).addResultListener(new SwingDefaultResultListener(ui)
		{
			public void customResultAvailable(IExternalAccess ea)
			{
				ea.killComponent();
			}
		});
	}
	
	/**
	 *  Method to get an external access for the platform component (i.e. root component).
	 *  @param access	Any component on the platform.
	 */
	public static IFuture	getRootAccess(final IExternalAccess access)
	{
		final Future	ret	= new Future();
		SServiceProvider.getService(access, IComponentManagementService.class, RequiredServiceInfo.SCOPE_PLATFORM)
			.addResultListener(new SwingExceptionDelegationResultListener(ret)
		{
			public void customResultAvailable(IComponentManagementService cms)
			{
				cms.getExternalAccess((IComponentIdentifier)access.getComponentIdentifier().getRoot())
					.addResultListener(new SwingDelegationResultListener(ret));
			}
		});
		return ret;
	}	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy