Examples of WeakReference


Examples of java.lang.ref.WeakReference

        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

Examples of java.lang.ref.WeakReference

     * 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

Examples of java.lang.ref.WeakReference

    Class c = null;
    synchronized (peersLoaders)
    {
      for (int i = 0; i < peersLoaders.size() && c == null; i++)
      {
        WeakReference ref = (WeakReference) peersLoaders.get(i);
        SecondaryClassLoader loader = (SecondaryClassLoader) ref.get();
        if (loader != null)
          c = loader.findLoadedClassHelper(className);
        else
          peersLoaders.remove(i--);
      }
View Full Code Here

Examples of java.lang.ref.WeakReference

    Class c = null;
    synchronized (peersLoaders)
    {
      for(int i=0;i<peersLoaders.size()&&c==null;i++)
      {
        WeakReference ref = (WeakReference)peersLoaders.get(i);
        SecondaryClassLoader loader = (SecondaryClassLoader)ref.get();
        if(loader != null) // no removal here, peerFindLoadedClass should take care of that anyway
          c = loader.findClassHelper(className);
      }
     
    }
View Full Code Here

Examples of java.lang.ref.WeakReference

 
  void registerSecondaryClassloader(SecondaryClassLoader loader)
  {
    synchronized (peersLoaders)
    {
      peersLoaders.add(new WeakReference(loader));
    }
   
  }
View Full Code Here

Examples of java.lang.ref.WeakReference

        public int refcount = 1; // has ref count of one at creation
        public WeakReference manager;
       
        public ReferenceCountedPointer(ListenerManager mgr, Object o) {
            super(o);
            manager = new WeakReference(mgr);
        }
View Full Code Here

Examples of java.lang.ref.WeakReference

   /**
    * @param testsuite If != null your update() variant will be called as well
    */
   public MsgInterceptor(Global glob, Logger log, I_Callback testsuite) {
      this.weakglob = new WeakReference(glob);
      this.weaklog = new WeakReference(log);
      this.testsuite = testsuite;
      //this.msgs = new Msgs();
   }
View Full Code Here

Examples of java.lang.ref.WeakReference

      }
      if (referent == null || ((MsgUnitWrapper)referent).isSwapped()) {  // message was swapped away
         this.weakMsgUnitWrapper = null;
         referent = lookup();
         if (referent == null) return null;
         this.weakMsgUnitWrapper = new WeakReference(referent);
      }
      MsgUnitWrapper msgUnitWrapper = (MsgUnitWrapper)referent;
      if (msgUnitWrapper == null) {
         if (!isForceDestroy()) {
            log.severe(getInfoWithoutMeat()+" No meat found but forceDestroy=false " + Global.getStackTraceAsString(null));
View Full Code Here

Examples of java.lang.ref.WeakReference

   }

   public void setMsgUnitWrapper(MsgUnitWrapper msgUnitWrapper) throws XmlBlasterException {
      if (msgUnitWrapper == null)
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Given msgUnitWrapper is null");
      this.weakMsgUnitWrapper = new WeakReference(msgUnitWrapper);
      this.keyOid = msgUnitWrapper.getMsgUnit().getKeyData().getOid();
      this.msgUnitWrapperUniqueId = msgUnitWrapper.getUniqueId();
   }
View Full Code Here

Examples of java.lang.ref.WeakReference

   * @param uri    DOCUMENT ME!
   * @return the namespace for the given prefix and uri
   */
  public Namespace get(String prefix, String uri) {
    Map uriCache = getURICache(uri);
    WeakReference ref = (WeakReference) uriCache.get(prefix);
    Namespace answer = null;

    if (ref != null) {
      answer = (Namespace) ref.get();
    }

    if (answer == null) {
      synchronized (uriCache) {
        ref = (WeakReference) uriCache.get(prefix);

        if (ref != null) {
          answer = (Namespace) ref.get();
        }

        if (answer == null) {
          answer = createNamespace(prefix, uri);
          uriCache.put(prefix, new WeakReference(answer));
        }
      }
    }

    return answer;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.