Re: [OpenMap Users] getItemsForOMGraphicMenu doesn't work on EditorLayer

From: Don Dietrick <dietrick_at_bbn.com>
Date: Mon, 2 Feb 2009 11:51:17 -0500

What OS and jdk version are you running? Trying to think of things
that may be different between our setups that would let this work for
me but not for you.

-- Don

On Feb 2, 2009, at 3:47 AM, Adams Tan <nikida78_at_gmail.com> wrote:

> Basically, i created the following class...
>
> // Start of file
>
> package test;
>
> import com.bbn.openmap.event.MapMouseEvent;
> import com.bbn.openmap.layer.editor.EditorLayer;
> import com.bbn.openmap.omGraphics.OMGraphic;
> import java.util.ArrayList;
> import java.util.List;
> import javax.swing.JMenuItem;
>
> public class TestDTLayer extends EditorLayer {
>
> _at_Override
> public String getToolTipTextFor(OMGraphic omgr) {
> return "Test";
> }
>
> _at_Override
> public List getItemsForMapMenu(MapMouseEvent mme) {
> System.out.println("getItemsForMapMenu");
> return super.getItemsForMapMenu(mme);
> }
>
> _at_Override
> public List getItemsForOMGraphicMenu(OMGraphic omg) {
> System.out.println("getItemsForOMGraphicMenu");
> List<JMenuItem> items = new ArrayList<JMenuItem>();
> items.add(new JMenuItem("Test"));
> return items;
> }
> }
>
> // End of file
>
> 1. After starting the openmap app, I drew a Rectangle.
> 2. I make sure I off-click on the map before i do the next step.
> 3. I mouse over the rectangle, the tooltip "Test" appears.
> 4. I right click, expecting a popup menu. However, the rectangle is
> selected (edit mode) instead.
>
> I've tried your solution with the same dismal results.
>
> Any ideas?
>
> Adams
>
> On 1/21/09, Don Dietrick <dietrick_at_bbn.com> wrote:
>> Hi Adams,
>>
>> I can't reproduce this behavior. If I add, say, this method from the
>> com.bbn.openmap.layer.learning.InteractionLayer to EditorLayer:
>>
>> public List getItemsForOMGraphicMenu(OMGraphic omg) {
>> final OMGraphic chosen = omg;
>> List l = new ArrayList();
>> JMenuItem which = new JMenuItem("Which");
>> which.addActionListener(new ActionListener() {
>> public void actionPerformed(ActionEvent ae) {
>> String classname = chosen.getClass().getName();
>> fireRequestMessage("Which was chosen over "
>> +
>> classname.substring(classname.lastIndexOf('.') + 1));
>> }
>> });
>> JMenuItem why = new JMenuItem("Why");
>> why.addActionListener(new ActionListener() {
>> public void actionPerformed(ActionEvent ae) {
>> String classname = chosen.getClass().getName();
>> fireRequestMessage("Why was chosen over "
>> +
>> classname.substring(classname.lastIndexOf('.') + 1));
>> }
>> });
>>
>> l.add(which);
>> l.add(why);
>> return l;
>> }
>>
>> The menu pops up when I right click on the object, when gestures mode
>> is active. Are you trying to get a pop up menu when you are trying
>> to
>> define or edit an OMGraphic, i.e when one of the OMGraphic buttons is
>> activated on the toolbar?
>>
>> - Don
>>
>>
>> On Jan 19, 2009, at 1:10 AM, Adams Tan wrote:
>>
>>> Hi,
>>>
>>> I am trying to get the method getItemsForOMGraphicMenu working for
>>> EditorLayer.
>>>
>>> What I want to achieve is a popup menu shown upon right-click on an
>>> OMGraphic (drawn by EditorLayer).
>>>
>>> After overriding the abovementioned method, the menu doesn't show
>>> up.
>>> In fact, the method wasn't even called (I put some print line
>>> statements).
>>>
>>> Incidentally, the getItemsForOMGraphicMenu method works with the
>>> parent class of EditorLayer (which is DrawingToolLayer). So somehow,
>>> the EditorLayer has some implementation that voided the
>>> getItemsForOMGraphicMenu method.
>>>
>>> Please help, thank you.
>>>
>>> Adams Tan
>>>
>>> --
>>> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
>>> with the following text in the BODY of the message "unsubscribe
>>> openmap-users"]
>>
>>
>
> --
> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe
> openmap-users"]

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Feb 02 2009 - 11:54:11 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT