/** * Executes the specified action, repeating and recording it as * necessary. * @param listener The action listener * @param source The event source * @param actionCommand The action command */ public void executeAction(ActionListener listener, Object source, String actionCommand) { // create event ActionEvent evt = new ActionEvent(source, ActionEvent.ACTION_PERFORMED, actionCommand); // don't do anything if the action is a wrapper // (like EditAction.Wrapper) if(listener instanceof Wrapper) { listener.actionPerformed(evt); return; } // remember old values, in case action changes them boolean _repeat = repeat; int _repeatCount = getRepeatCount(); // execute the action if(listener instanceof InputHandler.NonRepeatable) listener.actionPerformed(evt); else { for(int i = 0; i < Math.max(1,repeatCount); i++) listener.actionPerformed(evt); } // do recording. Notice that we do no recording whatsoever // for actions that grab keys if(grabAction == null) { if(recorder != null) { if(!(listener instanceof InputHandler.NonRecordable)) { if(_repeatCount != 1) recorder.actionPerformed(REPEAT,String.valueOf(_repeatCount)); recorder.actionPerformed(listener,actionCommand); } } // If repeat was true originally, clear it // Otherwise it might have been set by the action, etc if(_repeat) { repeat = false; repeatCount = 0; } } }
public void _sendString(String text) { if (writeCommand == null) return; /* intercept sessions -i and deliver it to a listener within armitage */ if (sessionListener != null) { Matcher m = interact.matcher(text); if (m.matches()) { sessionListener.actionPerformed(new ActionEvent(this, 0, m.group(1))); return; } } Map read = null; try { synchronized (this) { if (window != null && echo) { window.append(window.getPromptText() + text); } } if ("armitage.push".equals(writeCommand)) { read = (Map) connection.execute(writeCommand, new Object[] {session, text}); } else { connection.execute(writeCommand, new Object[] {session, text}); read = readResponse(); } processRead(read); fireSessionWroteEvent(text); } catch (Exception ex) { ex.printStackTrace(); } }
/** * ** Invokes all listeners with an assciated command ** @param r a string that may specify a * command (possibly one ** of several) associated with the event */ protected void invokeListeners(String r) { if (this.actionListeners != null) { for (Iterator i = this.actionListeners.iterator(); i.hasNext(); ) { ActionListener al = (ActionListener) i.next(); ActionEvent ae = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, r); try { al.actionPerformed(ae); } catch (Throwable t) { Print.logError("Exception: " + t.getMessage()); } } } }
private void fireActionEvent(ActionEvent evt) { for (ActionListener l : actionListeners) { l.actionPerformed(evt); } }
private void signalAll(ActionEvent e) { for (ActionListener a : listeners) { a.actionPerformed(e); } }