Esempio n. 1
0
 private static void processWidgetDefaultSelectedEvent(final Tree tree) {
   HttpServletRequest request = ContextProvider.getRequest();
   String eventName = JSConst.EVENT_WIDGET_DEFAULT_SELECTED;
   if (WidgetLCAUtil.wasEventSent(tree, eventName)) {
     String itemId = request.getParameter(eventName + ".item");
     Item treeItem = (Item) WidgetUtil.find(tree, itemId);
     int eventType = SelectionEvent.WIDGET_DEFAULT_SELECTED;
     SelectionEvent event = new SelectionEvent(tree, treeItem, eventType);
     event.stateMask = EventLCAUtil.readStateMask(JSConst.EVENT_WIDGET_SELECTED_MODIFIER);
     event.processEvent();
   }
 }
Esempio n. 2
0
 private static void processWidgetSelectedEvent(final Tree tree) {
   HttpServletRequest request = ContextProvider.getRequest();
   String eventName = JSConst.EVENT_WIDGET_SELECTED;
   if (WidgetLCAUtil.wasEventSent(tree, eventName)) {
     Rectangle bounds = new Rectangle(0, 0, 0, 0);
     String itemId = request.getParameter(eventName + ".item");
     Item treeItem = (Item) WidgetUtil.find(tree, itemId);
     String detailStr = request.getParameter(eventName + ".detail");
     int detail = "check".equals(detailStr) ? SWT.CHECK : SWT.NONE;
     int eventType = SelectionEvent.WIDGET_SELECTED;
     int stateMask = EventLCAUtil.readStateMask(JSConst.EVENT_WIDGET_SELECTED_MODIFIER);
     SelectionEvent event =
         new SelectionEvent(tree, treeItem, eventType, bounds, stateMask, null, true, detail);
     event.processEvent();
   }
 }
Esempio n. 3
0
 private static void updateSelectionListener(final Tree tree) throws IOException {
   Boolean newValue = Boolean.valueOf(SelectionEvent.hasListener(tree));
   String prop = PROP_SELECTION_LISTENERS;
   if (WidgetLCAUtil.hasChanged(tree, prop, newValue, Boolean.FALSE)) {
     JSWriter writer = JSWriter.getWriterFor(tree);
     writer.set("selectionListeners", newValue);
   }
 }
Esempio n. 4
0
 public void preserveValues(final Widget widget) {
   Tree tree = (Tree) widget;
   ControlLCAUtil.preserveValues((Control) widget);
   IWidgetAdapter adapter = WidgetUtil.getAdapter(tree);
   adapter.preserve(PROP_SELECTION_LISTENERS, Boolean.valueOf(SelectionEvent.hasListener(tree)));
   adapter.preserve(PROP_HEADER_HEIGHT, new Integer(tree.getHeaderHeight()));
   adapter.preserve(PROP_HEADER_VISIBLE, Boolean.valueOf(tree.getHeaderVisible()));
   int[] values = tree.getColumnOrder();
   Integer[] columnOrder = new Integer[values.length];
   for (int i = 0; i < values.length; i++) {
     columnOrder[i] = new Integer(values[i]);
   }
   adapter.preserve(PROP_COLUMN_ORDER, columnOrder);
   adapter.preserve(PROP_SCROLL_LEFT, getScrollLeft(tree));
   adapter.preserve(PROP_HAS_H_SCROLL_BAR, hasHScrollBar(tree));
   adapter.preserve(PROP_HAS_V_SCROLL_BAR, hasVScrollBar(tree));
   WidgetLCAUtil.preserveCustomVariant(tree);
 }
  @SuppressWarnings("unused")
  public static void main(String[] args) throws Exception {
    for (int i = 0; i < 1024; i++) {
      bufferPool.add(ByteBuffer.allocate(1024));
    }

    final ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
    serverSocketChannel.configureBlocking(false);
    serverSocketChannel.bind(new InetSocketAddress("127.0.0.1", 3000), 1024);

    Selector selector = Selector.open();
    serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);

    Long workerId = 0L;

    while (true) {
      int cnt = 0;
      try {
        cnt = selector.select();
      } catch (CancelledKeyException e) {
      }
      if (cnt > 0) {
        Iterator<SelectionKey> keys = selector.selectedKeys().iterator();
        while (keys.hasNext()) {
          SelectionKey key = keys.next();
          keys.remove();
          if (key.isValid()) {
            SelectionEvent event;
            if (key.isAcceptable()) {
              ServerSocket serverSocket = serverSocketChannel.socket();
              //							serverSocket.setReceiveBufferSize(bufferSize);
              //							serverSocket.setReuseAddress(true);

              boolean hasSocket = true;
              do {
                SocketChannel channel = serverSocketChannel.accept();
                if (null != channel) {
                  channel.configureBlocking(false);
                  //									channel.setOption(StandardSocketOptions.SO_KEEPALIVE, true);
                  //									channel.setOption(StandardSocketOptions.TCP_NODELAY, true);
                  //									channel.setOption(StandardSocketOptions.SO_RCVBUF, bufferSize);
                  //									channel.setOption(StandardSocketOptions.SO_SNDBUF, bufferSize);
                  SelectionKey readKey = channel.register(selector, SelectionKey.OP_READ);

                  //									// Allocate an Event object for dispatching
                  //									// to the handler
                  //									event = workerRing.get(workerId);
                  //									event.id = workerId;
                  //									channels.put(workerId, channel);
                  //									selectionKeys.put(workerId, readKey);
                  //									// Dispatch this event to a handler
                  //									workerRing.publish(workerId);
                  //									// Immediately allocate the next worker ID
                  //									workerId = workerRing.next();
                } else {
                  hasSocket = false;
                }
              } while (hasSocket);
            } else if (key.isReadable()) {

              event = new SelectionEvent();
              event.id = workerId;
              SocketChannel channel = (SocketChannel) key.channel();
              channels.put((Long) workerId, channel);
              selectionKeys.put(workerId, key);

              onEvent(event);
            }
          }
        }
      }
    }
  }