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

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Wed, 4 Feb 2009 21:30:41 -0500

No, that menu is active when the drawing tool is active. The
getItemsForOMGraphic menu gets called when the right mouse button is
clicked before the drawing tool gets activated with the left mouse
button.

If you are looking at code, try tracing what happens in the
StandardMapMouseInterpretor when a right click is detected.

-- Don

On Feb 4, 2009, at 9:16 PM, Adams Tan <nikida78_at_gmail.com> wrote:

> So that must be the reason why my getItemsForOMGraphicMenu doesn't
> work? Since the control are in the DrawingTool. So should I override
> the DrawingTool instead?
>
> Adams Tan
>
> On Wed, Feb 4, 2009 at 8:22 PM, Don Dietrick <dfdietrick_at_gmail.com>
> wrote:
> Those options are from the drawing tool which is still in control of
> the OMGraphic at that point.
>
> -- Don
>
> On Feb 4, 2009, at 2:45 AM, Adams Tan <nikida78_at_gmail.com> wrote:
>
>> Today I was doing some testing on com.bbn.openmap.layer.DemoLayer.
>> I tried to use the DrawingToolLauncher to create some graphic on
>> the DemoLayer.
>>
>> Upon right click on the created graphic, I see a popup menu, which
>> listed 2 items (Change Appearance/Delete). However, inspecting the
>> DemoLayer class shows that the getItemsForOMGraphicMenu should list
>> 2 items (Which/Why) instead. Why are the menu items shown
>> differently?
>>
>> Adams
>>
>> On Tue, Feb 3, 2009 at 12:51 AM, Don Dietrick <dietrick_at_bbn.com>
>> wrote:
>> 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 Wed Feb 04 2009 - 21:31:33 EST

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