[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview GenericTreeView.java,1.22,1.23
Status: Pre-Alpha
Brought to you by:
henryml
From: Nordholt <nor...@us...> - 2006-04-21 15:16:41
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18968 Modified Files: GenericTreeView.java Log Message: added popup-menu in the treeview to delete elements Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** GenericTreeView.java 12 Apr 2006 14:27:54 -0000 1.22 --- GenericTreeView.java 21 Apr 2006 15:16:38 -0000 1.23 *************** *** 19,26 **** --- 19,29 ---- import java.util.Set; + import java.awt.event.ActionEvent; + import javax.swing.ImageIcon; import javax.swing.JPopupMenu; import javax.swing.JTree; import javax.swing.SwingUtilities; + import javax.swing.AbstractAction; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; *************** *** 344,350 **** --- 347,395 ---- } } + + /** + * Context menu for this EntityNode + * @return the menu + */ + public JPopupMenu menu() { + JPopupMenu pm = new JPopupMenu(); + Object object = this.getUserObject(); + if (object instanceof Entity) { + pm.add(new EntityDeleteAction((Entity)object)); + } + return pm; + } } /** + * The Entity delete action + */ + public class EntityDeleteAction extends AbstractAction { + + /** + * The entity + */ + private Entity entity; + + /** + * The constructor + * @param ent the entity + */ + public EntityDeleteAction(Entity ent) { + super("Delte"); + this.entity = ent; + } + + /** + * Invoked when a action is performed + * @param event ActionEvent + */ + public void actionPerformed(ActionEvent event) { + info("deleting: " + entity); + entity.delete(); + } + } + + /** * SpaceNode */ |