Logo Search packages:      
Sourcecode: cdk version File versions  Download package

IChemObject org::openscience::cdk::applications::jchempaint::action::JCPAction::getSource ( ActionEvent  event  )  [inline, inherited]

Gets the source attribute of the JCPAction object

Parameters:
event Description of the Parameter
Returns:
The source value

Definition at line 225 of file JCPAction.java.

References org::openscience::cdk::tools::LoggingTool::debug(), org::openscience::cdk::tools::LoggingTool::error(), org::openscience::cdk::applications::jchempaint::action::JCPAction::logger, and org::openscience::cdk::tools::LoggingTool::warn().

Referenced by org::openscience::cdk::applications::jchempaint::action::WebLinkAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::ValidateAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::ShowChemObjectProperty::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::ShowChemObjectDumpAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::EditDictRefsAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::EditChemObjectPropsAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::EditAtomContainerPropsAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::EditAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::CreateReactionAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::ConvertToRadicalAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::ConvertToPseudoAtomAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::ConvertToAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::ChangeIsotopeAction::actionPerformed(), org::openscience::cdk::applications::jchempaint::action::ChangeAtomSymbolAction::actionPerformed(), and org::openscience::cdk::applications::jchempaint::action::AddHydrogenAction::actionPerformed().

      {
            Object source = event.getSource();
            logger.debug("event source: ", source);
            if (source instanceof JMenuItem)
            {
                  Container parent = ((JMenuItem) source).getComponent().getParent();
                  // logger.debug("event source parent: " + parent);
                  if (parent instanceof CDKPopupMenu)
                  {
                        return ((CDKPopupMenu) parent).getSource();
                  } else if (parent instanceof JPopupMenu)
                  {
                        // assume that the top menu is indeed a CDKPopupMenu
                        logger.debug("Submenu... need to recurse into CDKPopupMenu...");
                        while (!(parent instanceof CDKPopupMenu))
                        {
                              logger.debug("  Parent instanceof ", parent.getClass().getName());
                              if (parent instanceof JPopupMenu)
                              {
                                    parent = ((JPopupMenu) parent).getInvoker().getParent();
                              } else if (parent instanceof JChemPaintMenuBar)
                              {
                                    logger.warn(" Source is MenuBar. MenuBar items don't know about the source");
                                    return null;
                              } else
                              {
                                    logger.error(" Cannot get parent!");
                                    return null;
                              }
                        }
                        return ((CDKPopupMenu) parent).getSource();
                  }
            }
            return null;
      }


Generated by  Doxygen 1.6.0   Back to index