[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui PopupMenu.java, 1.39, 1.40
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-08-28 07:00:59
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18534/src/net/sourceforge/bprocessor/gui Modified Files: PopupMenu.java Log Message: made the popupmenu work with multiselcetion instead of just single entities... Some of the menuActions still lack multiple object handling Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/PopupMenu.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** PopupMenu.java 19 Jul 2007 12:23:23 -0000 1.39 --- PopupMenu.java 28 Aug 2007 07:00:52 -0000 1.40 *************** *** 426,435 **** if (ent instanceof Space) { interior.add((Space) ent); } } ! if (interior.isEmpty()) { ! //Do nothing ! return; ! } for (Space space : interior) { surfaces.addAll(space.getEnvelope()); --- 426,434 ---- if (ent instanceof Space) { interior.add((Space) ent); + } else if (ent instanceof Surface) { + surfaces.add((Surface)ent); } } ! for (Space space : interior) { surfaces.addAll(space.getEnvelope()); *************** *** 462,466 **** Map<Geometric, Geometric> map = new HashMap<Geometric, Geometric>(); ! for (Space space : interior) { Space copy = space.simpleCopy(); map.put(space, copy); --- 461,465 ---- Map<Geometric, Geometric> map = new HashMap<Geometric, Geometric>(); ! for (Space space : spaces) { Space copy = space.simpleCopy(); map.put(space, copy); *************** *** 515,519 **** geometric.delete(); } ! for (Space space : interior) { space.delete(); } --- 514,518 ---- geometric.delete(); } ! for (Space space : spaces) { space.delete(); } *************** *** 546,548 **** --- 545,578 ---- return menu; } + + /** + * Create a popupMenu for the selection + * @return The popupmenu or null if the selection is empty + */ + public static JPopupMenu makeSelectionMenu() { + if (Selection.primary().isEmpty()) { + return null; + } else { + Iterator sel = Selection.primary().iterator(); + Class<? extends Object> type = null; + while (sel.hasNext()) { + Object next = sel.next(); + if (type == null) { + type = next.getClass(); + } else if (type == next.getClass()) { + // do nothing just continue; + continue; + } else { + return PopupMenu.getEntiesMenu(new LinkedList(Selection.primary())); + } + } + if (type == Space.class) { + return PopupMenu.getSpaceMenu(Selection.primary()); + } else if (type == Surface.class) { + return PopupMenu.getSurfaceMenu(Selection.primary()); + } else { + return PopupMenu.getEntiesMenu(new LinkedList(Selection.primary())); + } + } + } } |