[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view PopupMenu.java, 1.52, 1.53
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2011-07-27 07:19:35
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view
In directory vz-cvs-4.sog:/tmp/cvs-serv14156/src/net/sourceforge/bprocessor/gl/view
Modified Files:
PopupMenu.java
Log Message:
Index: PopupMenu.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/PopupMenu.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** PopupMenu.java 18 May 2011 22:08:41 -0000 1.52
--- PopupMenu.java 27 Jul 2011 07:19:32 -0000 1.53
***************
*** 242,245 ****
--- 242,254 ----
}
+ private abstract class TargetAction extends AbstractAction {
+ protected Command target;
+
+ public TargetAction(Command command, String title) {
+ super(title);
+ this.target = command;
+ }
+ }
+
class CommandAction extends AbstractAction {
***************
*** 968,975 ****
return menu;
}
/** {@inheritDoc} */
public JPopupMenu menuFor(Collection<? extends Entity> geometrics) {
-
if (geometrics.isEmpty()) {
return getBackgroundMenu();
--- 977,1001 ----
return menu;
}
+
+ /**
+ *
+ * @param command Command
+ * @return menu
+ */
+ public JPopupMenu getCommandMenu(Command command) {
+ JPopupMenu menu = new JPopupMenu();
+ AbstractAction action = new TargetAction(command, "Toggle Panel") {
+ public void actionPerformed(ActionEvent arg0) {
+ if (target.getMonitor() != null) {
+ GUI.getInstance().togglePanel((java.awt.Component) target.getMonitor());
+ }
+ }
+ };
+ menu.add(action);
+ return menu;
+ }
/** {@inheritDoc} */
public JPopupMenu menuFor(Collection<? extends Entity> geometrics) {
if (geometrics.isEmpty()) {
return getBackgroundMenu();
***************
*** 1006,1012 ****
/** {@inheritDoc} */
public JPopupMenu menuFor(Entity entity) {
! Collection<Entity> c = new LinkedList<Entity>();
! c.add(entity);
! return menuFor(c);
}
}
--- 1032,1042 ----
/** {@inheritDoc} */
public JPopupMenu menuFor(Entity entity) {
! if (entity instanceof Command) {
! return getCommandMenu((Command) entity);
! } else {
! Collection<Entity> c = new LinkedList<Entity>();
! c.add(entity);
! return menuFor(c);
! }
}
}
|