Package java.lang.ref

Examples of java.lang.ref.WeakReference


   * Internally used by Frame/Dialogs to register themselves
   * when they are created. Needed for dynamic Look And Feel
   * changes
   */
  public static void register(Widget widget) {
    WeakReference reference = new WeakReference(widget);
    reference.enqueue();
    synchronized (widgets) {
      widgets.add(reference);
    }
    System.gc();
  }
View Full Code Here


   * changes
   */
  public static void unregister(Widget widget) {
    synchronized (widgets) {
      for (Iterator i = widgets.iterator(); i.hasNext(); ) {
        WeakReference ref = (WeakReference) i.next();
        Object referent = ref.get();
       
        if (referent == widget || referent == null) {
          i.remove();
        }
      }
View Full Code Here

       
        ByteBuffer[] raw_buffers   = (ByteBuffer[])rawBufferCache.get();
        if(raw_buffers == null)
        {
          raw_buffers = new ByteBuffer[buffer_limit];
          rawBufferCache = new WeakReference(raw_buffers);
        } else
        {
          Arrays.fill(raw_buffers, null);
        }
         
       
        int[] orig_positions  = (int[])origPositionsCache.get();
        if(orig_positions == null)
        {
          orig_positions = new int[buffer_limit];
          origPositionsCache = new WeakReference(orig_positions);
        } else
        {
          Arrays.fill(orig_positions, 0);
        }
         
View Full Code Here

   * @param i
   */
  public CopyOnWriteList(int initialCapacity) {
    this.initialCapacity = initialCapacity;
    if (stats != null) {
      stats.add(new WeakReference(this));
    }
  }
View Full Code Here

  public CopyOnWriteList() {
    // Smaller default initial capacity as most of our lists are small
    // Last check on 7/24/2008: 444 lists with 456 total entries
    this.initialCapacity = 1;
    if (stats != null) {
      stats.add(new WeakReference(this));
    }
  }
View Full Code Here

    }
    if (listeners == null)
    {
      listeners = new ArrayList(5);
    }
    listeners.add(new WeakReference(l));
  }
View Full Code Here

    }
    ArrayList removeList = null;

    for (int i = 0; i < listeners.size(); i++)
    {
      final WeakReference ref = (WeakReference) listeners.get(i);
      final StyleChangeListener l = (StyleChangeListener) ref.get();
      if (l != null)
      {
        l.styleChanged(source, key, value);
      }
      else
View Full Code Here

    }
    ArrayList removeList = null;

    for (int i = 0; i < listeners.size(); i++)
    {
      final WeakReference ref = (WeakReference) listeners.get(i);
      final StyleChangeListener l = (StyleChangeListener) ref.get();
      if (l != null)
      {
        l.styleRemoved(source, key);
      }
      else
View Full Code Here

        public void handleEvent(Event event) {
          btnHide.setEnabled(false);
          btnDetails.setEnabled(false);
         
          for (Iterator iter = viewStack.iterator(); iter.hasNext();) {
            WeakReference wr = (WeakReference) iter.next();
            MessagePopupShell popup = (MessagePopupShell) wr.get();
            iter.remove();

            if (popup == null)
              return;

            popup.shell.dispose();
            popup.detailsShell.dispose();
            if (popup.shellImg != null) {
              popup.shellImg.dispose();
            }
          }
        }
      });
    }
   
    shell.layout();
    shell.setTabList(new Control[] {btnDetails, btnHide});

    btnHide.addListener(SWT.MouseUp, new Listener() {
      public void handleEvent(Event arg0) {
          btnHide.setEnabled(false);
          btnDetails.setEnabled(false);
          hideShell();
      }
    });
   
    btnDetails.addListener(SWT.MouseUp, new Listener() {
      public void handleEvent(Event arg0) {
       detailsShell.setVisible(btnDetails.getSelection());
      }
    });
   
    Rectangle bounds = null;
    try {
      UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
      if (uiFunctions != null) {
        Shell mainShell = uiFunctions.getMainShell();
        bounds = mainShell.getMonitor().getClientArea();
      }
    } catch (Exception e) {
    }
    if (bounds == null) {
      bounds = display.getClientArea();
    }

    x0 = bounds.x + bounds.width - popupWidth - 5;
    x1 = bounds.x + bounds.width;

    y0 = bounds.y + bounds.height;
    y1 = bounds.y + bounds.height - popupHeight - 5;
   
      // currently always animate
   
    if ( true ){
      shell.setLocation(x0,y0);
      viewStack.addFirst(new WeakReference(this));
      detailsShell.setLocation(x1-detailsShell.getSize().x,y1-detailsShell.getSize().y);
      currentAnimator = new LinearAnimator(this,new Point(x0,y0),new Point(x0,y1),20,30);
      currentAnimator.start();
      shell.open();
    }else{
        shell.setLocation(x0,y1);
      viewStack.addFirst(new WeakReference(this));
      detailsShell.setLocation(x1-detailsShell.getSize().x,y1-detailsShell.getSize().y);
      currentAnimator = new LinearAnimator(this,new Point(x0,y1),new Point(x0,y1),20,30);
      animationStarted(currentAnimator);
      shell.open();
      animationEnded(currentAnimator);
View Full Code Here

     * holds a WeakReference, so that the object can still be garbage-collected.
     *
     * @param it the object that can be closed
     */
    public static synchronized void addClosable(Closable it) {
        closableList.addElement(new WeakReference(it));
    }
View Full Code Here

TOP

Related Classes of java.lang.ref.WeakReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.