jadex.base.gui.filetree.DefaultNodeHandler 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.filetree;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JTree;
import javax.swing.UIDefaults;
import jadex.base.gui.asynctree.ISwingNodeHandler;
import jadex.base.gui.asynctree.ISwingTreeNode;
import jadex.base.gui.asynctree.ITreeNode;
import jadex.commons.gui.CombiIcon;
import jadex.commons.gui.SGUI;
/**
* The default node handler offers two refresh actions.
* The node handler is responsible for popup menu on nodes.
*/
public class DefaultNodeHandler implements ISwingNodeHandler
{
//-------- constants --------
/** The image icons. */
protected static final UIDefaults icons = new UIDefaults(new Object[]
{
RefreshAction.getName(), SGUI.makeIcon(FileTreePanel.class, "/jadex/base/gui/images/overlay_refresh.png"),
RefreshSubtreeAction.getName(), SGUI.makeIcon(FileTreePanel.class, "/jadex/base/gui/images/overlay_refresh.png"),
});
//-------- attributes --------
/** The actions. */
protected List actions;
/** The overlay icons. */
protected UIDefaults overlays;
//-------- constructors --------
/**
* Create a new node handler.
*/
public DefaultNodeHandler(JTree tree)
{
overlays = new UIDefaults();
overlays.putAll(icons);
actions = new ArrayList();
actions.add(new RefreshAction(tree));
actions.add(new RefreshSubtreeAction(tree));
}
/**
* Create a new node handler.
*/
public DefaultNodeHandler(JTree tree, List actions, UIDefaults overlays)
{
this.actions = actions!=null? actions: new ArrayList();
this.overlays = overlays!=null? overlays: new UIDefaults();
}
//-------- methods --------
/**
* Get the overlay.
* @param node The node.
* @return The icon.
*/
public Icon getSwingOverlay(ISwingTreeNode node)
{
return null;
}
@Override
public byte[] getOverlay(ITreeNode node)
{
return null;
}
/**
* Get the popup actions.
* @param nodes The nodes.
* @return The actions.
*/
public Action[] getPopupActions(ISwingTreeNode[] nodes)
{
List ret = new ArrayList();
Icon base = nodes[0].getSwingIcon();
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy