001 package nl.cwi.sen1.util; 002 003 import java.awt.event.MouseEvent; 004 import javax.swing.SwingUtilities; 005 006 007 import nl.cwi.sen1.configapi.types.ActionDescriptionList; 008 import toolbus.AbstractTool; 009 import aterm.ATerm; 010 011 public class DefaultPopupImpl { 012 private AbstractTool bridge; 013 014 public DefaultPopupImpl(AbstractTool bridge) { 015 this.bridge = bridge; 016 } 017 018 public void showPopup(final ATerm id, final ActionDescriptionList menuList) { 019 SwingUtilities.invokeLater(new Runnable() { 020 public void run() { 021 MouseEvent popupEvent = MouseAdapter.getPreviousPopupEvent(); 022 023 if (popupEvent != null) { 024 StudioPopupMenu popup = new StudioPopupMenu(id, bridge, menuList, 025 null); 026 try { 027 popup.show(popupEvent.getComponent(), popupEvent.getX(), 028 popupEvent.getY()); 029 } catch (IllegalStateException e) { 030 // Happens when user selects another tab, so that the original 031 // component is not visible anymore 032 } 033 } else { 034 System.err.println("Popup got lost!"); 035 } 036 } 037 }); 038 } 039 }