Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Adding a ModalTool to the action bar

I'm sorry, I wouldn't have a clue. I don't even know where it came from. If you want to do have a look I have attached the gif for you. I would do it myself but I have run out of time. Sorry.

Thanks,
Mark

Jesse Eichar wrote:

I not really sure. Does you GIF have a transparency channel? Or at least a transparency value on the palette? It looks like that is what the problem is.

Jesse

Mark Presling wrote:

Unhandled event loop exception
Reason:
-1
!STACK 0
java.lang.ArrayIndexOutOfBoundsException: -1
at net.refractions.udig.ui.graphics.Glyph$1.getImageData(Glyph.java:54) at org.eclipse.jface.resource.ImageDescriptor.createImage(ImageDescriptor.java:279) at org.eclipse.jface.resource.ImageDescriptor.createResource(ImageDescriptor.java:171) at org.eclipse.jface.resource.DeviceResourceManager.allocate(DeviceResourceManager.java:56) at org.eclipse.jface.resource.AbstractResourceManager.create(AbstractResourceManager.java:87) at org.eclipse.jface.resource.ResourceManager.createImageWithDefault(ResourceManager.java:107) at org.eclipse.jface.resource.ImageRegistry.get(ImageRegistry.java:205) at net.refractions.udig.project.ui.internal.tool.display.ModalItem.getActiveImage(ModalItem.java:268) at net.refractions.udig.project.ui.internal.tool.display.ToolbarCurrentItem.setSelection(ToolbarCurrentItem.java:160) at net.refractions.udig.project.ui.internal.tool.display.ModalItem.setChecked(ModalItem.java:86) at net.refractions.udig.project.ui.internal.tool.display.ToolProxy.setActive(ToolProxy.java:470) at net.refractions.udig.project.ui.internal.tool.display.ModalItem.run(ModalItem.java:109) at net.refractions.udig.project.ui.internal.tool.display.ToolbarCurrentItem.runCurrentTool(ToolbarCurrentItem.java:188) at net.refractions.udig.project.ui.internal.tool.display.ToolbarCurrentItem$1.widgetDefaultSelected(ToolbarCurrentItem.java:90) at net.refractions.udig.project.ui.internal.tool.display.ToolbarCurrentItem$1.widgetSelected(ToolbarCurrentItem.java:61) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1021)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2867) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2572) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
    at nz.govt.transit.callcenter.Application.run(Application.java:18)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
    at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
    at org.eclipse.core.launcher.Main.run(Main.java:973)
    at org.eclipse.core.launcher.Main.main(Main.java:948)


Thanks for the pointer. That did the trick. That told me that the Glyph class didn't support the gif that I was using, even though it was displayed as the tool icon ok. I don't know why, but I replaced it with one of the uDig ones and everything works again. How frustrating is that! I thought it was my coding this whole time.

Do you know what the restrictions are for the Glyph class?

Thanks,
Mark




Jesse Eichar wrote:

Can you add -consoleLog to the list of program arguments and see if more info is printed out?

Jesse

Mark Presling wrote:

Jesse,

Adding the category certainly made my tool appear on the task bar. However, when I click on (selecting it, not using it) it I get on the console:

Unhandled event loop exception
Reason:
-1

Do you have any idea if there is something else I need to add to the configuration. Here is the source of my tool (it's basically just a copy of an existing tool that is supposed to draw a small rectangle on the screen for now, the same wasy that the info tool does)

public class PointEventTool extends AbstractModalTool implements ModalTool {
   /**
    * ID of the current tool.
    */
   public static final String ID = "xxx.PointEventTool";
   public static final String CATEGORY_ID = "xxx.roadevent";

   public static final String BLACKBOARD_KEY = ID;


   /**
    * Creates an PointEventTool Tool.
    */
   public PointEventTool() {
       super( MOUSE | MOTION );           }
      @Override
   public void mousePressed( MapMouseEvent e ) {
       //throw a coordinate onto the current map blackboard
              IMap map = ApplicationGIS.getActiveMap();
       if (map == null)
return; IBlackboard blackboard = map.getBlackboard(); List<Coordinate> points = (List<Coordinate>) blackboard.get(BLACKBOARD_KEY);
       if (points == null) {
           points = new ArrayList<Coordinate>();
           blackboard.put(BLACKBOARD_KEY,points);
       }
              points.add(new Coordinate(e.x,e.y));
Rectangle2D r = new Rectangle2D.Double(e.x,e.y,2,2);
       DrawCommandFactory dfactory = DrawCommandFactory.getInstance();
DrawShapeCommand command = dfactory.createDrawShapeCommand(r, Color.ORANGE, ViewportGraphics.LINE_DASH, 1);

       command.setValid(true);
              getContext().sendASyncCommand(command);
                  }

   @Override
   public void mouseDragged( MapMouseEvent e ) {
          }
         /**
* @see net.refractions.udig.project.ui.tool.AbstractTool#mouseReleased(MapMouseEvent)
    */
   public void mouseReleased(MapMouseEvent e) {
   }
      /**
    * @see net.refractions.udig.project.ui.tool.Tool#dispose()
    */
   public void dispose() {
       super.dispose();
   }

}


I have tried to debug it but it seems that the constructor or mousePressed() method isn't called.

Here's the plugin.xml extension def:

  <extension
        point="net.refractions.udig.project.ui.tool">
           <modalTool
                    cursor="crosshair"
categoryId="nz.govt.transit.callcenter.tool.roadevent" class="nz.govt.transit.callcenter.tool.PointEventTool"
                 icon="icons/calander_Icon.gif"
                 id="nz.govt.transit.callcenter.tool.PointEventTool"
                 name="name"
                 onToolbar="true"
                 tooltip="tooltip">
              <cursor
           hotspotY="10"
           hotspotX="10"
           image="icons/calander_Icon.gif"
           id="crosshair"/>
        </modalTool>
           <category
                 icon="icons/calander_Icon.gif"
                 id="nz.govt.transit.callcenter.tool.roadevent"
                 name="Road Event Tool Category"/>
  </extension>

Can you think of anything that I can try? Maybe a good debug point that I can use?

Thanks
Mark

Jesse Eichar wrote:

They are hidden hehe.

Most of them are in the project ui plugin.xml but 3 are in the tool.edit plugin.xml

Jesse

Mark Presling wrote:

You're a legend Jessie. I can't believe how quick you are to respond. Thanks heaps, that certainly was the problem. I didn't realise that you had to do that. Where are the others defined? I haven't seen them anywhere yet?

Thanks heaps,
Mark

Jesse Eichar wrote:

Are you defining a new category extension as well? It is another element in the same extension point.

Jesse

Mark Presling wrote:

Hi guys,

I am trying to add a new ModalTool to the action bar in my app and am coming across some problems around categories. If I specify one of the existing categories, such as net.refractions.udig.tool.category.zoom my tool appears in the zoom dropdown on the tool bar. If I specify my own category (such as net.refractions.udig.tool.category.test) it doesn't appear.

I've debugged the point in ToolManager where it's looping through the extensions (net.refractions.udig.project.ui.tool) and setting up the categories, but it never comes across my new category.

Here's the tool definition in my plugin.xml.

  <extension
        point="net.refractions.udig.project.ui.tool">
           <modalTool
categoryId="net.refractions.udig.tool.category.new" class="nz.govt.transit.callcenter.tool.PointEventTool"
                 icon="icons/calander_Icon.gif"
id="nz.govt.transit.callcenter.tool.PointEventTool"
                 name="name"
                 onToolbar="true"
                 tooltip="tooltip">
              <cursor
           hotspotY="10"
           hotspotX="10"
           image="icons/calander_Icon.gif"
           id="crosshair"/>
        </modalTool>
  </extension>


Apart from the fact that I am using a calendar icon, what is wrong with this? Why can't I define my own category? I can confirm that when I set the categoryId to net.refractions.udig.tool.category.zoom it appears under that dropdown. Do I need to define a category somewhere else?

Thanks,
Mark

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel





_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel


_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel




_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel


_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel


_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel


_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel


--
This message has been scanned for viruses and dangerous
content by MailScanner, and is believed to be clean.

GIF image

begin:vcard
fn:Mark Presling
n:Presling;Mark
email;internet:mark@xxxxxxxxxxxx
tel;home:+6442322774
tel;cell:+6421549540
version:2.1
end:vcard


Back to the top