gt: 			if (!classMenus.containsKey(cls)) {
context: package org.tzi.use.gui.views.selection.objectselection;
  
  import java.awt.BorderLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Comparator;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  import java.util.TreeSet;
  
  import javax.swing.AbstractAction;
  import javax.swing.JComponent;
  import javax.swing.JMenu;
  import javax.swing.JMenuItem;
  
  import org.tzi.use.gui.main.MainWindow;
  import org.tzi.use.gui.main.ViewFrame;
  import org.tzi.use.gui.views.diagrams.DiagramViewWithObjectNode;
  import org.tzi.use.gui.views.diagrams.ObjectNodeActivity;
  import org.tzi.use.gui.views.diagrams.elements.DiamondNode;
  import org.tzi.use.gui.views.diagrams.elements.PlaceableNode;
  import org.tzi.use.gui.views.diagrams.elements.edges.BinaryAssociationOrLinkEdge;
  import org.tzi.use.gui.views.diagrams.elements.edges.EdgeBase;
  import org.tzi.use.uml.mm.MAssociation;
  import org.tzi.use.uml.mm.MClass;
  import org.tzi.use.uml.mm.MNamedElementComparator;
  import org.tzi.use.uml.sys.MLink;
  import org.tzi.use.uml.sys.MObject;
  import org.tzi.use.uml.sys.MSystem;
  import org.tzi.use.util.collections.CollectionUtil;
  
  import com.google.common.collect.Sets;
  
  /**
   * ClassSelection is responsible for the new functions in the object diagram.
   * 
   * @author Jun Zhang
   * @author Jie Xu
   * @author Lars Hamann
   */
  public class ObjectSelection {
  
  	private final DiagramViewWithObjectNode diagram;
  
  	private final MSystem system;
  
  	/**
  	 * Constructor for ObjectSelection.
  	 */
  	public ObjectSelection(DiagramViewWithObjectNode diagram, MSystem system) {
  		this.diagram = diagram;
  		this.system = system;
  	}
  
  	@SuppressWarnings("serial")
  	class ActionShowSelectedLinkPathView extends AbstractAction {
  		private Set<MObject> selectedObjects;
  		private Set<MLink> selectedLinks;
  
  		ActionShowSelectedLinkPathView(Set<MObject> sc, Set<MLink> links) {
  			super("Selection by path length...");
  			this.selectedLinks = links;
  			selectedObjects = sc;
  		}
  
  		public void actionPerformed(ActionEvent e) {
  			SelectedLinkPathView opv = new SelectedLinkPathView(MainWindow.instance(), system, diagram, selectedObjects, selectedLinks);
  
  			ViewFrame f = new ViewFrame("Selection by path length", opv, "ObjectProperties.gif");
  			JComponent c = (JComponent) f.getContentPane();
  			c.setLayout(new BorderLayout());
  			c.add(opv, BorderLayout.CENTER);
  			MainWindow.instance().addNewViewFrame(f);
  			f.setSize(450, 200);
  		}
  	}
  
  	public ActionShowSelectedLinkPathView getSelectionByPathLengthView(Set<MObject> sc, Set<MLink> links) {
  		return new ActionShowSelectedLinkPathView(sc, links);
  	}
  
  	@SuppressWarnings("serial")
  	class ActionSelectedObjectPathView extends AbstractAction {
  		private Set<MObject> selectedObjects;
  
  		ActionSelectedObjectPathView(String text, Set<MObject> sc) {
  			super(text);
  			selectedObjects = sc;
  		}
  
  		public void actionPerformed(ActionEvent e) {
  			SelectedObjectPathView opv = new SelectedObjectPathView(MainWindow.instance(), system, diagram, selectedObjects);
  			ViewFrame f = new ViewFrame("Selection by path length", opv, "ObjectProperties.gif");
  			JComponent c = (JComponent) f.getContentPane();
  			c.setLayout(new BorderLayout());
  			c.add(opv, BorderLayout.CENTER);
  			MainWindow.instance().addNewViewFrame(f);
  			f.setSize(450, 200);
  		}
  	}
  
  	public ActionSelectedObjectPathView getSelectedObjectPathView(String text, Set<MObject> sc) {
  		return new ActionSelectedObjectPathView(text, sc);
  	}
  
  	@SuppressWarnings("serial")
  	class ActionSelectionObjectView extends AbstractAction {
  		ActionSelectionObjectView() {
  			super("With view...");
  		}
  
  		public void actionPerformed(ActionEvent e) {
  			SelectionObjectView opv = new SelectionObjectView(MainWindow.instance(), system, diagram);
  			ViewFrame f = new ViewFrame("Select objects", opv, "ObjectProperties.gif");
  			JComponent c = (JComponent) f.getContentPane();
  			c.setLayout(new BorderLayout());
  			c.add(opv, BorderLayout.CENTER);
  			MainWindow.instance().addNewViewFrame(f);
  
  			f.setSize(530, 230);
  		}
  	}
  
  	public ActionSelectionObjectView getSelectionObjectView() {
  		return new ActionSelectionObjectView();
  	}
  
  	/**
  	 * Show Selection OCL View
  	 */
  	@SuppressWarnings("serial")
  	class ActionSelectionOCLView extends AbstractAction {
  		ActionSelectionOCLView() {
  			super("With OCL...");
  		}
  
  		public void actionPerformed(ActionEvent e) {
  			SelectionOCLView opv = new SelectionOCLView(MainWindow.instance(), system, diagram);
  			ViewFrame f = new ViewFrame("Selection by OCL expression", opv, "ObjectProperties.gif");
  			JComponent c = (JComponent) f.getContentPane();
  
  			c.setLayout(new BorderLayout());
  			c.add(opv, BorderLayout.CENTER);
  			MainWindow.instance().addNewViewFrame(f);
  			f.setSize(370, 250);
  		}
  	}
  
  	public ActionSelectionOCLView getSelectionWithOCLViewAction() {
  		return new ActionSelectionOCLView();
  	}
  
      /**
       * Method getSelectedObjectsofAssociation returns all relevant objects,
       * which are connected with the Association selected by the user.
       */
      public Set<MObject> getSelectedObjectsofAssociation(MAssociation node, Set<MObject> selectedObjectsOfAssociation) {
  		HashSet<MObject> objects = new HashSet<MObject>();
  		Iterator<EdgeBase> it = this.diagram.getGraph().edgeIterator();
  		String name = node.name();
  	
  		while (it.hasNext()) {
  		    EdgeBase o = it.next();
  	
  		    if (o instanceof BinaryAssociationOrLinkEdge) {
  				BinaryAssociationOrLinkEdge edge = (BinaryAssociationOrLinkEdge) o;
  		
  				if (edge.getAssociation() != null && edge.getAssociation().equals(node)) {
  				    MObject mo = ((ObjectNodeActivity) (edge.source())).object();
  				    if (!selectedObjectsOfAssociation.contains(mo)) {
  					objects.add(mo);
  				    }
  				    mo = ((ObjectNodeActivity) (edge.target())).object();
  				    if (!selectedObjectsOfAssociation.contains(mo) && !objects.contains(mo)) {
  					objects.add(mo);
  				    }
  				    return objects;
  				}
  		    }
  		}
  	
  		Iterator<PlaceableNode> nodeIter = diagram.getGraph().iterator();
  		
  		while (it.hasNext()) {
  		    PlaceableNode o = nodeIter.next();
  		    if (o instanceof DiamondNode) {
  				if (((DiamondNode) o).name().equalsIgnoreCase(name)) {
  				    DiamondNode dnode = (DiamondNode) o;
  		
  				    for (MObject mo : dnode.link().linkedObjects()) {
  						if (!selectedObjectsOfAssociation.contains(mo) && !objects.contains(mo)) {
  						    objects.add(mo);
  						}
  				    }
  				    return objects;
  				}
  		    }
  		}
  		return objects;
      }
  
      private class ObjectNodeActivityComparator implements Comparator<ObjectNodeActivity> {
  		@Override
  		public int compare(ObjectNodeActivity o1, ObjectNodeActivity o2) {
  			return o1.object().name().compareTo(o2.object().name());
  		}
      }
      
  	/**
  	 * Method getSubMenuHideObject supplies a list of the sorted objects in the
  	 * context menu. which are not hidden.
  	 * 
  	 * @return JMenu
  	 */
  	public JMenu getSubMenuHideObject() {
  		Set<PlaceableNode> visibleNodes = Sets.newHashSet(diagram.getGraph().getVisibleNodesIterator());
  		Set<ObjectNodeActivity> visibleObjectNodes = CollectionUtil.filterByType(visibleNodes, ObjectNodeActivity.class);
  		
  		JMenu subMenuHideObject = new JMenu("Hide object");
  		final JMenuItem hideAllObjects = new JMenuItem("Hide all objects");
  		hideAllObjects.setEnabled(diagram.getVisibleData().hasNodes());
  		hideAllObjects.addActionListener(new ActionListener() {
  			public void actionPerformed(ActionEvent ev) {
  				diagram.hideAll();
  				diagram.repaint();
  			}
  		});
  		subMenuHideObject.add(hideAllObjects);
  		subMenuHideObject.addSeparator();
  
  		TreeSet<ObjectNodeActivity> sortedObjectNodes = new TreeSet<ObjectNodeActivity>(new ObjectNodeActivityComparator());
  		sortedObjectNodes.addAll(visibleObjectNodes);
  
  		Map<MClass, JMenu> classMenus = new HashMap<MClass, JMenu>();
  		for (ObjectNodeActivity objNode : sortedObjectNodes) {
  			final MClass cls = objNode.cls();
  			final MObject obj = objNode.object();
  
  