jadex.base.gui.componentviewer.DefaultComponentServiceViewerPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-tools-base-swing Show documentation
Show all versions of jadex-tools-base-swing Show documentation
GUI-dependent classes for jadex-tools-base.
package jadex.base.gui.componentviewer;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import jadex.base.gui.plugin.AbstractJCCPlugin;
import jadex.base.gui.plugin.IControlCenter;
import jadex.bridge.IExternalAccess;
import jadex.bridge.service.IService;
import jadex.bridge.service.search.SServiceProvider;
import jadex.commons.SReflect;
import jadex.commons.future.CounterResultListener;
import jadex.commons.future.DelegationResultListener;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
import jadex.commons.future.IResultListener;
import jadex.commons.gui.future.SwingDefaultResultListener;
/**
* Default panel for viewing BDI agents that include viewable capabilities.
*/
public class DefaultComponentServiceViewerPanel extends AbstractComponentViewerPanel
{
//-------- attributes --------
/** The constant for the optional component viewerclass. */
public static final String PROPERTY_COMPONENTVIEWERCLASS = "viewerpanel.componentviewerclass";
//-------- attributes --------
/** The panel. */
protected JPanel panel;
//-------- methods --------
/**
* Called once to initialize the panel.
* Called on the swing thread.
* @param jcc The jcc.
* @param component The component.
*/
public IFuture init(final IControlCenter jcc, final IExternalAccess component)
{
this.panel = new JPanel(new BorderLayout());
final Future ret = new Future();
// Init interface is asynchronous but super implementation is not.
IFuture fut = super.init(jcc, component);
assert fut.isDone();
SServiceProvider.getDeclaredServices(component)
.addResultListener(new IResultListener>()
{
public void resultAvailable(Collection result)
{
createPanels(component, result).addResultListener(new DelegationResultListener(ret));
}
public void exceptionOccurred(Exception exception)
{
ret.setException(exception);
}
});
return ret;
}
/**
* Create the panels.
*/
protected IFuture createPanels(final IExternalAccess exta, final Collection services)
{
final Future ret = new Future();
AbstractJCCPlugin.getClassLoader(exta.getComponentIdentifier(), jcc)
.addResultListener(new SwingDefaultResultListener()
{
public void customResultAvailable(final ClassLoader cl)
{
final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy