[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| Re: [udig-devel] Adding a ModalTool to the action bar | 
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
--
This message has been scanned for viruses and dangerous
content by MailScanner, and is believed to be clean.
begin:vcard
fn:Mark Presling
n:Presling;Mark
email;internet:mark@xxxxxxxxxxxx
tel;home:+6442322774
tel;cell:+6421549540
version:2.1
end:vcard