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

jadex.base.gui.filetree.RootNode Maven / Gradle / Ivy

There is a newer version: 2.4
Show newest version
package jadex.base.gui.filetree;

import jadex.base.gui.asynctree.AbstractTreeNode;
import jadex.base.gui.asynctree.AsyncTreeModel;
import jadex.base.gui.asynctree.ITreeNode;
import jadex.base.gui.componenttree.ComponentProperties;

import java.util.ArrayList;
import java.util.List;

import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JTree;
import javax.swing.SwingUtilities;

/**
 *  The root node.
 */
public class RootNode extends AbstractTreeNode
{
	//-------- attributes --------
	
	/** The list of child nodes. */
	protected List children;
	
	/** The properties component (if any). */
	protected ComponentProperties	propcomp;
		
	//-------- constructors --------
	
	/**
	 *  Create a new service container node.
	 */
	public RootNode(AsyncTreeModel model, JTree tree)
	{
		super(null, model, tree);
		
//		System.out.println("node: "+getClass()+" "+desc.getName());
		this.children = new ArrayList();
		
		model.registerNode(this);
	}
	
	//-------- AbstractComponentTreeNode methods --------
	
	/**
	 *  Set the children.
	 */
	// Made public to support external refresh in deployer.
	public void setChildren(List newchildren)
	{
		this.children	= newchildren;
		super.setChildren(newchildren);
	}
	
	/**
	 *  Get the id used for lookup.
	 */
	public Object	getId()
	{
		return "root";
	}

	/**
	 *  Get the icon for a node.
	 */
	public Icon	getIcon()
	{
		return null;
	}
	
	/**
	 *  Refresh the node.
	 *  @param recurse	Recursively refresh subnodes, if true.
	 */
	public void refresh(boolean recurse)
	{
		assert SwingUtilities.isEventDispatchThread();
		
//		cms.getComponentDescription(desc.getName()).addResultListener(new SwingDefaultResultListener()
//		{
//			public void customResultAvailable(Object result)
//			{
//				FileTreeNode.this.desc	= (IComponentDescription)result;
//				getModel().fireNodeChanged(FileTreeNode.this);
//			}
//			public void customExceptionOccurred(Exception exception)
//			{
//				// ignore
//			}
//		});

		super.refresh(recurse);
	}
	
	/**
	 *  Asynchronously search for children.
	 *  Should call setChildren() once children are found.
	 */
	protected void	searchChildren()
	{
		setChildren(children);
	}
	
	/**
	 *  Add a child node.
	 *  @param child The child node.
	 */
	public void addChild(ITreeNode child)
	{
		assert SwingUtilities.isEventDispatchThread();
		
		children.add(child);
		setChildren(children);
	}
	
	/**
	 *  Remove a path entry from the tree.
	 *  @param child The child node.
	 */
	public void removeChild(ITreeNode child)
	{
		assert SwingUtilities.isEventDispatchThread();
//		super.removeChild(child);
		children.remove(child);
		setChildren(children);
	}
	
	/**
	 *  Remove a path entry from the tree.
	 */
	public void removeAll()
	{
		assert SwingUtilities.isEventDispatchThread();
		
//		for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy