jadex.base.gui.modeltree.RemovePathAction 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.modeltree;
import java.awt.event.ActionEvent;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import javax.swing.UIDefaults;
import javax.swing.tree.TreePath;
import jadex.commons.gui.SGUI;
import jadex.commons.gui.ToolTipAction;
/**
* Action for removing a path.
*/
public class RemovePathAction extends ToolTipAction
{
//-------- constants --------
/** The image icons. */
protected static final UIDefaults icons = new UIDefaults(new Object[]
{
"removepath", SGUI.makeIcon(ModelTreePanel.class, "/jadex/base/gui/images/remove_folder424.png"),
});
//-------- attributes --------
/** The tree. */
protected ITreeAbstraction treepanel;
//-------- constructors --------
/**
* Create a new action.
*/
public RemovePathAction(ITreeAbstraction treepanel)
{
this(getName(), getIcon(), getTooltipText(), treepanel);
}
/**
* Create a new action.
*/
public RemovePathAction(String name, Icon icon, String desc, ITreeAbstraction treepanel)
{
super(name, icon, desc);
this.treepanel = treepanel;
}
//-------- methods --------
/**
* Test if action is available in current context.
* @return True, if available.
*/
public boolean isEnabled()
{
Object rm = treepanel.getTree().getLastSelectedPathComponent();
return rm!=null; //&& rm.getParent().equals(treepanel.getTree().getModel().getRoot());
}
/**
* Action performed.
*/
public void actionPerformed(ActionEvent e)
{
// Can be used from toolbar without considering enabled state.
if(!isEnabled())
{
JOptionPane.showMessageDialog(SGUI.getWindowParent(treepanel.getTree()), "Only root folders can be removed.");
return;
}
TreePath[] selected = treepanel.getTree().getSelectionPaths();
for(int i=0; selected!=null && i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy