[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/actions EditMenuListener.java, NONE, 1.1
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2006-12-03 17:53:39
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11751/src/net/sourceforge/bprocessor/gui/actions Added Files: EditMenuListener.java Log Message: implemented copy, paste and delete in the menu and added a listener that enables and disables them, according to the content of the selection... Name is a bit misleading cause the object ain't listening to the editmenu, but the selection. --- NEW FILE: EditMenuListener.java --- //--------------------------------------------------------------------------------- // $Id: EditMenuListener.java,v 1.1 2006/12/03 17:53:17 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.actions; import java.awt.Component; import javax.swing.JMenu; import javax.swing.JMenuItem; import net.sourceforge.bprocessor.model.Observer; import net.sourceforge.bprocessor.model.Selection; /** * The Listener that enable and disable the elements in the edit menu * That a JManu, but assume that the menu is the editmenu layout wise */ public class EditMenuListener implements Observer { /** the corrosponding menu */ private JMenu menu; /** * Constructor * @param menu The edit menu object */ public EditMenuListener(JMenu menu) { this.menu = menu; } /** * Called when the Selection object changes * @param entity The changed object (The selection list in this case) */ public void update(Object entity) { if (entity instanceof Selection) { Selection s = (Selection) entity; if (!s.isEmpty()) { Component[] c = menu.getMenuComponents(); ((JMenuItem)c[3]).setEnabled(true); ((JMenuItem)c[4]).setEnabled(true); ((JMenuItem)c[5]).setEnabled(true); ((JMenuItem)c[7]).setEnabled(true); } else { Component[] c = menu.getMenuComponents(); ((JMenuItem)c[3]).setEnabled(false); ((JMenuItem)c[4]).setEnabled(false); ((JMenuItem)c[5]).setEnabled(false); ((JMenuItem)c[7]).setEnabled(false); } } } } |