I need some more help with my Super Select tool. :] I've got the menu
name showing finally and when the menu item is clicked the toolbox
displays and properly paints all of its buttons. I can then click on
the buttons, but...nothing happens.
I've been pooring over the code that creates the JButtons and adds
them to the toolbox, but I can't figure out what is going on. I put
some logging code in my actionPerformed method, but it never gets
called.
To make a long story short, the buttons get clicked but the
actionPerformed method on my Plug-In never gets called. (My plug-in is
the event listener registered with the buttons in the toolbox.)
Is there a reason why the plug-in can't be the event listener? Maybe
the event listener has to be the toolbox object instead?
I've attached the source code for the methods in my plub-in that
initialize the toolbox and handle the button clicks.
I appreciate any assistance or tips that can be provided. :]
The Sunburned Surveyor
protected void initializeToolbox(ToolboxDialog argToolBoxDialog)
{
/* Get the WorkbenchToolbar from the ToolbarDialog. */
toolBar = argToolBoxDialog.getToolBar();
/* Create the Super Select Button */
java.net.URL imageURL1 =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_icon.png");
Log4JSetUp setUpLogger = new Log4JSetUp();
setUpLogger.setLogFile("C://Temp/logs/log.txt");
setUpLogger.setUpLog4J(net.surveyos.sourceforge.openjump.plugins.cursorTools.superSelect.SuperSelectToolboxPlugIn.class);
Logger logger = setUpLogger.getLogger();
logger.debug("Made it to the actionPerformed method.");
if (imageURL1 != null)
{
ImageIcon superSelectIcon = new ImageIcon(imageURL1);
JButton superSelectActivateButton = new
JButton(superSelectIcon);
superSelectActivateButton.setToolTipText("Click to activate
the Super Select Tool.");
logger.debug("Just registered the event listener for the
activate button.");
superSelectActivateButton.addActionListener(this);
superSelectActivateButton.setActionCommand("activate");
toolBar.add(superSelectActivateButton);
toolBar.addSeparator();
}
/* Create the Super Select Add Button */
java.net.URL imageURL2A =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_add_icon.png");
java.net.URL imageURL2B =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_add_icon.png");
if (imageURL2A != null && imageURL2B != null)
{
superSelectAddIcon = new ImageIcon(imageURL2A);
JButton superSelectAddButton = new
JButton(superSelectAddIcon);
superSelectAddButton.setToolTipText("Click to add items to
the set of selected items when the super select tool is used.");
superSelectAddButton.addActionListener(this);
superSelectAddButton.setActionCommand("add");
toolBar.add(superSelectAddButton);
superSelectAddActiveIcon = new ImageIcon(imageURL2B);
}
/* Create the Super Select Remove Button */
java.net.URL imageURL3A =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_remove_icon.png");
java.net.URL imageURL3B =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_remove_selected_icon.png");
if (imageURL3A != null && imageURL3B != null)
{
superSelectRemoveIcon = new ImageIcon(imageURL3A);
JButton superSelectRemoveButton = new
JButton(superSelectRemoveIcon);
superSelectRemoveButton.setToolTipText("Click to remove
items from the set of selected items when the super select tool is used.");
superSelectRemoveButton.addActionListener(this);
superSelectRemoveButton.setActionCommand("remove");
toolBar.add(superSelectRemoveButton);
superSelectRemoveActiveIcon = new ImageIcon(imageURL3B);
}
/* Create the Super Select Clear All Button */
java.net.URL imageURL4 =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_clear_all_icon.png");
if (imageURL4 != null)
{
ImageIcon superSelectClearAllIcon = new
ImageIcon(imageURL4);
JButton superSelectClearAllButton = new
JButton(superSelectClearAllIcon);
superSelectClearAllButton.setToolTipText("Click to clear
all items that are currently selected fromt the set of selected items.");
superSelectClearAllButton.addActionListener(this);
superSelectClearAllButton.setActionCommand("clear_all");
toolBar.add(superSelectClearAllButton);
toolBar.addSeparator();
}
/* Create the Super Select Use Selected Layers Only Button */
java.net.URL imageURL5A =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_use_selected_layers_icon.png");
java.net.URL imageURL5B =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_use_selected_layers_active_icon.png");
if (imageURL5A != null && imageURL5B != null)
{
superSelectUseSelectedLayersIcon = new
ImageIcon(imageURL5A);
JButton superSelectUseSelectedLayersButton = new
JButton(superSelectUseSelectedLayersIcon);
superSelectUseSelectedLayersButton.setToolTipText("Click to
select only features in selected Layers when the Super Select Tool is used.");
superSelectUseSelectedLayersButton.addActionListener(this);
superSelectUseSelectedLayersButton.setActionCommand("use_selected_only");
toolBar.add(superSelectUseSelectedLayersButton);
superSelectUseSelectedLayersOnlyActiveIcon = new
ImageIcon(imageURL5B);
}
/* Create the Super Select Sent To Layer Button */
java.net.URL imageURL6 =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_send_to_layer_icon.png");
if (imageURL6 != null)
{
ImageIcon superSelectSendToSelectedLayerIcon = new
ImageIcon(imageURL6);
JButton superSelectSendToSelectedLayerButton = new
JButton(superSelectSendToSelectedLayerIcon);
superSelectSendToSelectedLayerButton.setToolTipText("Click
to send currently selected features to the target layer.");
superSelectSendToSelectedLayerButton.addActionListener(this);
superSelectSendToSelectedLayerButton.setActionCommand("send");
toolBar.add(superSelectSendToSelectedLayerButton);
}
/* Create the Super Select Configure Button */
java.net.URL imageURL7 =
SuperSelectCursorTool.class.getResource("/net/surveyos/sourceforge/openjump/plugins/cursorTools/superSelect/forms/icons/super_select_configure_icon.png");
if (imageURL7 != null)
{
ImageIcon superSelectConfigureIcon = new
ImageIcon(imageURL7);
JButton superSelectConfigureButton = new
JButton(superSelectConfigureIcon);
superSelectConfigureButton.setToolTipText("Click to send
currently selected features to the target layer.");
superSelectConfigureButton.addActionListener(this);
superSelectConfigureButton.setActionCommand("configure");
toolBar.add(superSelectConfigureButton);
}
}
public void actionPerformed(ActionEvent argEvent)
{
/*
* Set up switch statements to handle the event from each of the
* buttons in the toolbar that we are "listening" to.
*/
Log4JSetUp setUp = new Log4JSetUp();
setUp.setLogFile("C:/Temp/log.txt");
Logger logger = setUp.getLogger();
logger.debug("Made it to the actionPerformed method.");
/* Get the event source object and cast it to a JButton. */
JButton sender = (JButton) argEvent.getSource();
/*
* Get the ActionCommand for the JButton that sent the event.
* We will use this to call the appropriate method in this class
* to handle the event.
*/
String actionCommand = sender.getActionCommand();
if(actionCommand.equals("activate"))
{
this.activate();
}
else if(actionCommand.equals("add"))
{
this.setAddSelectionModeActive();
}
else if(actionCommand.equals("remove"))
{
this.setRemoveSelectionModeActive();
}
else if(actionCommand.equals("clear_all"))
{
this.clearAll();
}
else if(actionCommand.equals("use_selected_only"))
{
this.setUseSelectedLayersOnly();
}
else if(actionCommand.equals("configure"))
{
this.configure();
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel