/** Starts the {@link UserAction} and updates the action label. */ private void startAction(final UserAction action) { if (action.canStart()) { // System.out.println("Starting: " + action.getActionName()); // show the action name String txt = "Action: " + action.getActionName() + " "; tool.setOutputText(txt); // run this later to let the above output be painted to the GUI first SwingUtilities.invokeLater( new Runnable() { public void run() { // call actionPerformed() instead of startAction() to fire the events action.actionPerformed(new ActionEvent(action, 0, action.getActionName())); // clear the output after 1 second tool.clearOutputText(1000); } }); } }
/** This method handles all of the mouse events first */ public boolean handleAnyMouseEvent(ShrimpMouseEvent e) { if (tool == null) { return false; } // tool.clearOutputText(); try { selectorBean = (SelectorBean) tool.getBean(ShrimpTool.SELECTOR_BEAN); } catch (BeanNotFoundException bnfe) { bnfe.printStackTrace(); return false; } // in case the system didn't throw all the events, this clears the modifiers for us if (e.getModifiers() == 0) { isCtrlPressed = false; isShiftPressed = false; isAltPressed = false; } // set the current target Object targetObj = e.getTarget(); if (targetObj != null) { selectorBean.setSelected(SelectorBeanConstants.TARGET_OBJECT, targetObj); } else { selectorBean.clearSelected(SelectorBeanConstants.TARGET_OBJECT); } // set the current mouse coordinates Vector coords = new Vector(); coords.addElement(new Double(e.getX())); coords.addElement(new Double(e.getY())); selectorBean.setSelected(SelectorBeanConstants.MOUSE_COORDINATES, coords); return true; }