Java 类java.util.TooManyListenersException 实例源码

项目:spring-serial-port-connector    文件:AbstractSpringSerialPortConnector.java   
@PostConstruct
public void connect() throws TooManyListenersException, NoSuchPortException {
    log.info("Connection PostConstruct callback: connecting ...");

    serial = new NRSerialPort(serialPortProperties.getPortName(), serialPortProperties.getBaudRate());
    serial.connect();

    if (serial.isConnected()) {
        log.info("Connection opened!");
    } else {
        throw new RuntimeException("Is not possible to open connection in " + serialPortProperties.getPortName() + " port");
    }
    serial.addEventListener(this);
    serial.notifyOnDataAvailable(true);
    input = new BufferedReader(new InputStreamReader(serial.getInputStream()));
}
项目:incubator-netbeans    文件:ExplorerDragSupport.java   
/** Activates or deactivates Drag support on asociated JTree
* component
* @param active true if the support should be active, false
* otherwise
*/
public void activate(boolean active) {
    if (this.active == active) {
        return;
    }

    this.active = active;

    DragGestureRecognizer dgr = getDefaultGestureRecognizer();
    if (dgr == null) {
        return;
    }

    if (active) {
        dgr.setSourceActions(getAllowedDragActions());

        try {
            dgr.removeDragGestureListener(this);
            dgr.addDragGestureListener(this);
        } catch (TooManyListenersException exc) {
            throw new IllegalStateException("Too many listeners for drag gesture."); // NOI18N
        }
    } else {
        dgr.removeDragGestureListener(this);
    }
}
项目:blackbird    文件:PJCSerialPort.java   
public void connect(CommPortIdentifier portIdentifier, int baudRate, int timeout) throws IOException {
    if (portIdentifier.isCurrentlyOwned())
        throw new IOException(
                portIdentifier.getName() + " is currently in use (" + portIdentifier.getCurrentOwner() + ")");

    if (portIdentifier.getPortType() != CommPortIdentifier.PORT_SERIAL)
        throw new IOException(portIdentifier.getName() + " is not a serial port");

    try {
        serialPort = (SerialPort) portIdentifier.open("blackbird", timeout);
        serialPort.setSerialPortParams(
                baudRate,
                SerialPort.DATABITS_8,
                SerialPort.STOPBITS_1,
                SerialPort.PARITY_NONE);
        serialPort.notifyOnDataAvailable(true);
        serialPort.addEventListener(this);
    } catch (PortInUseException | TooManyListenersException | UnsupportedCommOperationException e) {
        throw new IOException(e);
    }
}
项目:LightSIP    文件:SipClient.java   
public void init() throws PeerUnavailableException, InvalidArgumentException, TransportNotSupportedException, ObjectInUseException, TooManyListenersException {
    SipFactory sipFactory = null;
    mSipStack = null;
    sipFactory = SipFactory.getInstance();
    sipFactory.setPathName("gov.nist");

    Properties properties = new Properties();
    properties.setProperty("javax.sip.STACK_NAME", "SIP_CLIENT");
    properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
    properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "sip_client/out/log/debug.txt");
    properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "sip_client/out/log/server.txt");
    properties.setProperty("javax.sip.IP_ADDRESS",mIPAddress);
    mSipStack = (SipStackExt) sipFactory.createSipStack(properties);


    mHeaderFactory = sipFactory.createHeaderFactory();
    mAddressFactory = sipFactory.createAddressFactory();
    mMessageFactory = sipFactory.createMessageFactory();
    ListeningPoint lp = mSipStack.createListeningPoint(mIPAddress, mUdpPort, "udp");


    mSipProvider = mSipStack.createSipProvider(lp);
    mSipProvider.addSipListener(this);

}
项目:SerialAssistant    文件:RXTXPort.java   
public void addEventListener(
    SerialPortEventListener lsnr ) throws TooManyListenersException
{
    /*  Don't let and notification requests happen until the
        Eventloop is ready
    */

    if (debug)
        z.reportln( "RXTXPort:addEventListener()");
    if( SPEventListener != null )
    {
        throw new TooManyListenersException();
    }
    SPEventListener = lsnr;
    if( !MonitorThreadAlive )
    {
        MonitorThreadLock = true;
        monThread = new MonitorThread();
        monThread.start();
        waitForTheNativeCodeSilly();
        MonitorThreadAlive=true;
    }
    if (debug)
        z.reportln( "RXTXPort:Interrupt=false");
}
项目:TrabalhoFinalEDA2    文件:mxGraphHandler.java   
/**
 * 
 */
protected void installDropTargetHandler()
{
    DropTarget dropTarget = graphComponent.getDropTarget();

    try
    {
        if (dropTarget != null)
        {
            dropTarget.addDropTargetListener(this);
            currentDropTarget = dropTarget;
        }
    }
    catch (TooManyListenersException tmle)
    {
        // should not happen... swing drop target is multicast
    }
}
项目:Tarski    文件:EditorRuler.java   
/**
 * Constructs a new ruler for the specified graph and orientation.
 * 
 * @param graph The graph to create the ruler for.
 * @param orientation The orientation to use for the ruler.
 */
public EditorRuler(mxGraphComponent graphComponent, int orientation) {
  this.orientation = orientation;
  this.graphComponent = graphComponent;
  updateIncrementAndUnits();

  graphComponent.getGraph().getView().addListener(mxEvent.SCALE, repaintHandler);
  graphComponent.getGraph().getView().addListener(mxEvent.TRANSLATE, repaintHandler);
  graphComponent.getGraph().getView().addListener(mxEvent.SCALE_AND_TRANSLATE, repaintHandler);

  graphComponent.getGraphControl().addMouseMotionListener(this);

  DropTarget dropTarget = graphComponent.getDropTarget();

  try {
    if (dropTarget != null) {
      dropTarget.addDropTargetListener(this);
    }
  } catch (TooManyListenersException tmle) {
    // should not happen... swing drop target is multicast
  }

  setBorder(BorderFactory.createLineBorder(Color.black));
}
项目:scorekeeperfrontend    文件:SerialDataInterface.java   
public void open() throws PortInUseException, UnsupportedCommOperationException, TooManyListenersException, IOException
{
    if (open)
    {
        log.info(commId.getName() + " already open, skipping");
        return;
    }

    log.info("Opening port " + commId.getName());
    buffer = new ByteBuffer();

    port = (SerialPort)commId.open("TimerInterface-"+commId.getName(), 30000);
    port.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);

    port.addEventListener(this);
    port.notifyOnDataAvailable(true);
    port.enableReceiveTimeout(30);

    os = port.getOutputStream();
    is = port.getInputStream();
    open = true;
   }
项目:pega-tracerviewer    文件:TraceTabbedPane.java   
public TraceTabbedPane(TracerViewerSetting tracerViewerSetting, RecentFileContainer recentFileContainer) {
    super();

    this.tracerViewerSetting = tracerViewerSetting;
    this.recentFileContainer = recentFileContainer;

    fileTabIndexMap = new LinkedHashMap<String, Integer>();

    setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    normalBorder = getBorder();

    try {
        DropTarget dt = new DropTarget();
        dt.addDropTargetListener(this);
        setDropTarget(dt);
    } catch (TooManyListenersException e) {
        LOG.error("Error adding drag drop listener", e);
    }
}
项目:OWLAx    文件:mxGraphHandler.java   
/**
 * 
 */
protected void installDropTargetHandler()
{
    DropTarget dropTarget = graphComponent.getDropTarget();

    try
    {
        if (dropTarget != null)
        {
            dropTarget.addDropTargetListener(this);
            currentDropTarget = dropTarget;
        }
    }
    catch (TooManyListenersException tmle)
    {
        // should not happen... swing drop target is multicast
    }
}
项目:pega-logviewer    文件:LogTabbedPane.java   
public LogTabbedPane(LogViewerSetting logViewerSetting, RecentFileContainer recentFileContainer) {
    super();

    this.logViewerSetting = logViewerSetting;
    this.recentFileContainer = recentFileContainer;

    fileTabIndexMap = new LinkedHashMap<String, Integer>();

    tailingFileList = new ArrayList<>();

    setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    normalBorder = getBorder();

    try {
        DropTarget dt = new DropTarget();
        dt.addDropTargetListener(this);
        setDropTarget(dt);
    } catch (TooManyListenersException e) {
        LOG.error("Error initialising LogTabbedPane.", e);
    }
}
项目:wifepos    文件:ScaleComm.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto                   
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto       

            m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura   
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(4800, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_ODD); // Configuramos el puerto
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:wifepos    文件:ScaleSamsungEsp.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto                   
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto       

            m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura   
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(4800, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_ODD); // Configuramos el puerto
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:wifepos    文件:ScaleCasioPD1.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale);                  
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000);      

            m_out = m_CommPortPrinter.getOutputStream();  
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(9600, 
                    SerialPort.DATABITS_7, 
                    SerialPort.STOPBITS_1, 
                    SerialPort.PARITY_EVEN);
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:micro-Blagajna    文件:ScaleComm.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto                   
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto       

            m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura   
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(4800, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_ODD); // Configuramos el puerto
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:micro-Blagajna    文件:ScaleSamsungEsp.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto                   
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto       

            m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura   
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(4800, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_ODD); // Configuramos el puerto
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:micro-Blagajna    文件:ScaleCasioPD1.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale);                  
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000);      

            m_out = m_CommPortPrinter.getOutputStream();  
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(9600, 
                    SerialPort.DATABITS_7, 
                    SerialPort.STOPBITS_1, 
                    SerialPort.PARITY_EVEN);
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:VarJ    文件:DropTarget.java   
/**
    * Creates a new DropTarget given the <code>Component</code> 
    * to associate itself with, an <code>int</code> representing
    * the default acceptable action(s) to 
    * support, a <code>DropTargetListener</code>
    * to handle event processing, a <code>boolean</code> indicating 
    * if the <code>DropTarget</code> is currently accepting drops, and 
    * a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
    * <P>
    * The Component will receive drops only if it is enabled.
    * @param c  The <code>Component</code> with which this <code>DropTarget</code> is associated
    * @param ops    The default acceptable actions for this <code>DropTarget</code>
    * @param dtl    The <code>DropTargetListener</code> for this <code>DropTarget</code>
    * @param act    Is the <code>DropTarget</code> accepting drops.
    * @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE> 
    * @exception HeadlessException if GraphicsEnvironment.isHeadless()
    *            returns true
    * @see java.awt.GraphicsEnvironment#isHeadless
    */
   public DropTarget(Component c, int ops, DropTargetListener dtl,
          boolean act, FlavorMap fm)
       throws HeadlessException
   {
       if (GraphicsEnvironment.isHeadless()) {
           throw new HeadlessException();
       }

component = c;

setDefaultActions(ops);

if (dtl != null) try {
    addDropTargetListener(dtl);
} catch (TooManyListenersException tmle) {
    // do nothing!
}

if (c != null) {
    c.setDropTarget(this);
    setActive(act);
}

       if (fm != null) flavorMap = fm;
   }
项目:LunaBot    文件:SerialClient.java   
public void initListener() {
    try
    {
        serialPort.addEventListener(this);
        serialPort.notifyOnDataAvailable(true);
        System.out.println("Listener started.");
    }
    catch (TooManyListenersException e)
    {
        logText = "Too many listeners. (" + e.toString() + ")";
        if(window == null){
                System.out.println(logText);
            }
            else{
                //window.txtLog.setForeground(Color.RED);
                window.txtLog.append(logText + "\n");
            }
    }
}
项目:LunaBot    文件:SerialClient.java   
public void initListener() {
    try
    {
        serialPort.addEventListener(this);
        serialPort.notifyOnDataAvailable(true);
        System.out.println("Listener started.");
    }
    catch (TooManyListenersException e)
    {
        logText = "Too many listeners. (" + e.toString() + ")";
        if(window == null){
                System.out.println(logText);
            }
            else{
                //window.txtLog.setForeground(Color.RED);
                window.txtLog.append(logText + "\n");
            }
    }
}
项目:unicenta    文件:ScaleComm.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto                   
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto       

            m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura   
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(4800, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_ODD); // Configuramos el puerto
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:unicenta    文件:ScaleSamsungEsp.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale); // Tomamos el puerto                   
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000); // Abrimos el puerto       

            m_out = m_CommPortPrinter.getOutputStream(); // Tomamos el chorro de escritura   
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(4800, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_ODD); // Configuramos el puerto
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:unicenta    文件:ScaleCasioPD1.java   
private void write(byte[] data) {
    try {  
        if (m_out == null) {
            m_PortIdPrinter = CommPortIdentifier.getPortIdentifier(m_sPortScale);                  
            m_CommPortPrinter = (SerialPort) m_PortIdPrinter.open("PORTID", 2000);      

            m_out = m_CommPortPrinter.getOutputStream();  
            m_in = m_CommPortPrinter.getInputStream();

            m_CommPortPrinter.addEventListener(this);
            m_CommPortPrinter.notifyOnDataAvailable(true);

            m_CommPortPrinter.setSerialPortParams(9600, 
                    SerialPort.DATABITS_7, 
                    SerialPort.STOPBITS_1, 
                    SerialPort.PARITY_EVEN);
        }
        m_out.write(data);
    } catch (NoSuchPortException | PortInUseException | UnsupportedCommOperationException | TooManyListenersException | IOException e) {
    }        
}
项目:arduino-remote-uploader    文件:SerialSketchUploader.java   
public void openSerial(String serialPortName, int speed) throws PortInUseException, IOException, UnsupportedCommOperationException, TooManyListenersException {

    CommPortIdentifier commPortIdentifier = findPort(serialPortName);

    // initalize serial port
    serialPort = (SerialPort) commPortIdentifier.open("Arduino", 2000);
    inputStream = serialPort.getInputStream();
    serialPort.addEventListener(this);

    // activate the DATA_AVAILABLE notifier
    serialPort.notifyOnDataAvailable(true);

    serialPort.setSerialPortParams(speed, SerialPort.DATABITS_8, 
            SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
    serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
}
项目:In-the-Box-Fork    文件:TooManyListenersExceptionTest.java   
/**
 * @tests java.util.TooManyListenersException#TooManyListenersException()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "TooManyListenersException",
    args = {}
)
public void test_Constructor() {
    // Test for method java.util.TooManyListenersException()
    try {
        throw new TooManyListenersException();
    } catch (TooManyListenersException e) {
        assertNull(
                "Message thrown with exception constructed with no message",
                e.getMessage());
    }
}
项目:In-the-Box-Fork    文件:TooManyListenersExceptionTest.java   
/**
 * @tests java.util.TooManyListenersException#TooManyListenersException(java.lang.String)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "TooManyListenersException",
    args = {java.lang.String.class}
)
public void test_ConstructorLjava_lang_String() {
    // Test for method java.util.TooManyListenersException(java.lang.String)
    try {
        throw new TooManyListenersException("Gah");
    } catch (TooManyListenersException e) {
        assertEquals("Incorrect message thrown with exception", "Gah", e
                .getMessage());
    }
}
项目:appengine-imaging    文件:DragGestureRecognizer.java   
protected DragGestureRecognizer(DragSource ds, Component c, int sa, DragGestureListener dgl) {
    if (ds == null) {
        // awt.172=Drag source is null.
        throw new IllegalArgumentException(Messages.getString("awt.172")); //$NON-NLS-1$
    }

    dragSource = ds;
    component = c;
    sourceActions = sa;

    try {
        addDragGestureListener(dgl);
    } catch (TooManyListenersException e) {
    }

    events = null;
}
项目:ant    文件:Xalan2TraceSupport.java   
public void configureTrace(final Transformer t,
                           final XSLTProcess.TraceConfiguration conf) {
    if (t instanceof TransformerImpl && conf != null) {
        final PrintWriter w = new PrintWriter(conf.getOutputStream(), false);
        final PrintTraceListener tl = new PrintTraceListener(w);
        tl.m_traceElements = conf.getElements();
        tl.m_traceExtension = conf.getExtension();
        tl.m_traceGeneration = conf.getGeneration();
        tl.m_traceSelection = conf.getSelection();
        tl.m_traceTemplates = conf.getTemplates();
        try {
            ((TransformerImpl) t).getTraceManager().addTraceListener(tl);
        } catch (final TooManyListenersException tml) {
            throw new BuildException(tml);
        }
    }
}
项目:WP3    文件:EditorRuler.java   
/**
 * Constructs a new ruler for the specified graph and orientation.
 * 
 * @param graph The graph to create the ruler for.
 * @param orientation The orientation to use for the ruler.
 */
public EditorRuler(mxGraphComponent graphComponent, int orientation) {
  this.orientation = orientation;
  this.graphComponent = graphComponent;
  updateIncrementAndUnits();

  graphComponent.getGraph().getView().addListener(mxEvent.SCALE, repaintHandler);
  graphComponent.getGraph().getView().addListener(mxEvent.TRANSLATE, repaintHandler);
  graphComponent.getGraph().getView().addListener(mxEvent.SCALE_AND_TRANSLATE, repaintHandler);

  graphComponent.getGraphControl().addMouseMotionListener(this);

  DropTarget dropTarget = graphComponent.getDropTarget();

  try {
    if (dropTarget != null) {
      dropTarget.addDropTargetListener(this);
    }
  } catch (TooManyListenersException tmle) {
    // should not happen... swing drop target is multicast
  }

  setBorder(BorderFactory.createLineBorder(Color.black));
}
项目:yada    文件:RXTXPort.java   
public void addEventListener(
    SerialPortEventListener lsnr ) throws TooManyListenersException
{
    /*  Don't let and notification requests happen until the
        Eventloop is ready
    */

    if (debug)
        z.reportln( "RXTXPort:addEventListener()");
    if( SPEventListener != null )
    {
        throw new TooManyListenersException();
    }
    SPEventListener = lsnr;
    if( !MonitorThreadAlive )
    {
        MonitorThreadLock = true;
        monThread = new MonitorThread();
        monThread.start();
        waitForTheNativeCodeSilly();
        MonitorThreadAlive=true;
    }
    if (debug)
        z.reportln( "RXTXPort:Interrupt=false");
}
项目:cn1    文件:BeanContextServicesSupportTest.java   
public void testChildJustRemovedHook() throws TooManyListenersException {
    MockBeanContextServicesSupport support = new MockBeanContextServicesSupport();
    MockBeanContextChild child = new MockBeanContextChild();
    support.add(child);
    MockBeanContextServiceProvider provider = new MockBeanContextServiceProvider();
    support.addService(Collection.class, provider);

    MockBeanContextServiceRevokedListener rl = new MockBeanContextServiceRevokedListener();
    Object service = support.getService(child, child, Collection.class,
            null, rl);
    assertSame(Collections.EMPTY_SET, service);
    assertNull(rl.lastEvent);
    support.records.clear();
    provider.records.clear();

    support.remove(child);
    support.records.assertRecord("childJustRemovedHook", child,
            MethodInvocationRecords.IGNORE, null);
    support.records.assertEndOfRecords();
    provider.records.assertRecord("releaseService", support, child,
            service, null);
    provider.records.assertEndOfRecords();
    assertNull(rl.lastEvent);
}
项目:studio    文件:ExplorerDragSupport.java   
/** Activates or deactivates Drag support on asociated JTree
* component
* @param active true if the support should be active, false
* otherwise
*/
public void activate (boolean active) {
    if (this.active == active)
        return;
    this.active = active;
    DragGestureRecognizer dgr = getDefaultGestureRecognizer();
    if (active) {
        dgr.setSourceActions (exDnD.getSupportedDragActions ());
        try {
            dgr.removeDragGestureListener(this);
            dgr.addDragGestureListener(this);
        } catch (TooManyListenersException exc) {
            throw new IllegalStateException("Too many listeners for drag gesture."); // NOI18N
        }
    } else {
        dgr.removeDragGestureListener(this);
    }
}
项目:NotifyTools    文件:EventSetDescriptor.java   
private static boolean isUnicastByDefault(Method addMethod) {
    if (addMethod != null) {
        Class<?>[] exceptionTypes = addMethod.getExceptionTypes();
        for (Class<?> element : exceptionTypes) {
            if (element.equals(TooManyListenersException.class)) {
                return true;
            }
        }
    }
    return false;
}
项目:NotifyTools    文件:BeanContextServicesSupport.java   
/**
 * Delegate to the wrapped <code>BeanContextServices</code>.
 */
Object getService(BeanContextServices bcs, Object requestor,
        Class serviceClass, Object serviceSelector,
        BeanContextServiceRevokedListener listener)
        throws TooManyListenersException {
    return backBCS.getService(BeanContextServicesSupport.this
            .getBeanContextServicesPeer(), requestor, serviceClass,
            serviceSelector, new ServiceRevokedListenerDelegator(
                    listener));
}
项目:SerialPortDemo    文件:SerialPortManager.java   
/**
 * 添加监听器
 * 
 * @param port
 *            串口对象
 * @param listener
 *            串口监听器
 * @throws TooManyListeners
 *             监听类对象过多
 */
public static void addListener(SerialPort port,
        SerialPortEventListener listener) throws TooManyListeners {
    try {
        // 给串口添加监听器
        port.addEventListener(listener);
        // 设置当有数据到达时唤醒监听接收线程
        port.notifyOnDataAvailable(true);
        // 设置当通信中断时唤醒中断线程
        port.notifyOnBreakInterrupt(true);
    } catch (TooManyListenersException e) {
        throw new TooManyListeners();
    }
}
项目:incubator-netbeans    文件:MenuEditLayer.java   
private void configureGlassLayer() {
    try {
        glassLayer.setDropTarget(new DropTarget());
        glassLayer.getDropTarget().addDropTargetListener(new GlassLayerDropTargetListener());
    } catch (TooManyListenersException ex) {
        ex.printStackTrace();
    }
}
项目:rapidminer    文件:ProcessRendererDropTarget.java   
public ProcessRendererDropTarget(final ProcessRendererView view, final DropTargetListener dropTargetListener) {
    super(view, TransferHandler.COPY_OR_MOVE | TransferHandler.LINK, null);
    this.view = view;
    try {
        super.addDropTargetListener(dropTargetListener);
    } catch (TooManyListenersException tmle) {
    }
}
项目:rapidminer    文件:AbstractPatchedTransferHandler.java   
@Override
public void exportAsDrag(JComponent comp, InputEvent e, int action) {
    int srcActions = getSourceActions(comp);

    // only mouse events supported for drag operations
    if (!(e instanceof MouseEvent)
    // only support known actions
            || !(action == COPY || action == MOVE || action == LINK)
            // only support valid source actions
            || (srcActions & action) == 0) {

        action = NONE;
    }

    if (action != NONE && !GraphicsEnvironment.isHeadless()) {
        if (recognizer == null) {
            recognizer = new SwingDragGestureRecognizer();

        }
        DragHandler dgl = new DragHandler();
        try {
            recognizer.addDragGestureListener(dgl);
        } catch (TooManyListenersException e1) {
            e1.printStackTrace();
        }
        recognizer.gestured(comp, (MouseEvent) e, srcActions, action);
        recognizer.removeDragGestureListener(dgl);
    } else {
        exportDone(comp, null, NONE);
    }
}
项目:LightSIP    文件:SipProviderImpl.java   
public void addSipListener(SipListener sipListener)
        throws TooManyListenersException {

    if (sipStack.sipListener == null) {
        sipStack.sipListener = sipListener;
    } else if (sipStack.sipListener != sipListener) {
        throw new TooManyListenersException(
                "Stack already has a listener. Only one listener per stack allowed");
    }

    if (logger.isLoggingEnabled(LogLevels.TRACE_DEBUG))
        logger.logDebug("add SipListener " + sipListener);
    this.sipListener = sipListener;

}
项目:LightSIP    文件:Test.java   
private void initStack() throws SipException, TooManyListenersException,
        NumberFormatException, InvalidArgumentException, ParseException {
    this.sipFactory = SipFactory.getInstance();
    this.sipFactory.setPathName("gov.nist");
    this.sipStack = this.sipFactory.createSipStack(Test.properties);
    this.sipStack.start();
    this.listeningPoint = this.sipStack.createListeningPoint(properties.getProperty(
            SIP_BIND_ADDRESS, "127.0.0.1"), Integer.valueOf(properties
            .getProperty(SIP_PORT_BIND, "5060")), properties.getProperty(
            TRANSPORTS_BIND, "udp"));
    this.provider = this.sipStack.createSipProvider(this.listeningPoint);
    this.provider.addSipListener(this);
    this.headerFactory = sipFactory.createHeaderFactory();
    this.messageFactory = sipFactory.createMessageFactory();
}