@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())); }
/** 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); } }
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); } }
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); }
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"); }
/** * */ 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 } }
/** * 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)); }
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; }
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); } }
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); } }
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) { } }
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) { } }
/** * 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; }
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"); } } }
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); }
/** * @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()); } }
/** * @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()); } }
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; }
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); } } }
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); }
/** 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); } }
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; }
/** * 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)); }
/** * 添加监听器 * * @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(); } }
private void configureGlassLayer() { try { glassLayer.setDropTarget(new DropTarget()); glassLayer.getDropTarget().addDropTargetListener(new GlassLayerDropTargetListener()); } catch (TooManyListenersException ex) { ex.printStackTrace(); } }
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) { } }
@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); } }
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; }
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(); }