Received: by 10.58.145.167 with SMTP id sv7mr2517337veb.11.1347894584068; Mon, 17 Sep 2012 08:09:44 -0700 (PDT) X-BeenThere: cytoscape-discuss@googlegroups.com Received: by 10.220.154.17 with SMTP id m17ls4702456vcw.1.gmail; Mon, 17 Sep 2012 08:09:43 -0700 (PDT) Received: by 10.52.90.109 with SMTP id bv13mr1605501vdb.1.1347894582983; Mon, 17 Sep 2012 08:09:42 -0700 (PDT) Received: by 10.52.90.109 with SMTP id bv13mr1605500vdb.1.1347894582969; Mon, 17 Sep 2012 08:09:42 -0700 (PDT) Return-Path: Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by gmr-mx.google.com with ESMTPS id ef10si419649vdb.3.2012.09.17.08.09.42 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 08:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of jrr...@gmail.com designates 209.85.212.42 as permitted sender) client-ip=209.85.212.42; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jrr...@gmail.com designates 209.85.212.42 as permitted sender) smtp.mail=jrr...@gmail.com; dkim=pass header...@gmail.com Received: by mail-vb0-f42.google.com with SMTP id fs19so3374094vbb.1 for ; Mon, 17 Sep 2012 08:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=/VuxE5Qqvr/5bT3AQqCXd2NWvN2POhh0EJc/BiNLu5o=; b=bdNTicccSeA6rXmWenFnd/6ZOK1GNq+u5IiO0Obmeiv6Sp8pE2wkGvA8eoC1jWjAn0 8JsJMzfXJXd1XmuOzV/Ic8Exq7cecaFolsQfcVaWjUu4b+1eNSkG+wNcANYcFtb7l/9Q UvvdgG+nsTiIlpcDIUtgvMjH6uhCcwrAcac3D/FqBMXPPjKGRmVmh0aOlKnFoyPwdsIh dmKKDkAxT7Nh+olncAjZJbvnw62HBfsttJU34FY9S+kSDkVcuuNRt9pvp8abtskiFLVV VTs+IyJ1J7UUfpUDiF6InzNAaT0Pz/eZphxZGeQr1pmNSr3hW3UfIjjY3wUvDl+8guAG FoPg== MIME-Version: 1.0 Received: by 10.52.97.130 with SMTP id ea2mr3642106vdb.109.1347894582787; Mon, 17 Sep 2012 08:09:42 -0700 (PDT) Received: by 10.59.7.138 with HTTP; Mon, 17 Sep 2012 08:09:42 -0700 (PDT) In-Reply-To: <7c044397-0ce1-4259-9771-965e4c84fc84@googlegroups.com> References: <7c044397-0ce1-4259-9771-965e4c84fc84@googlegroups.com> Date: Mon, 17 Sep 2012 11:09:42 -0400 Message-ID: Subject: Re: [Cytoscape-discuss] Unregistering listeners using CyServiceRegistrar From: Jason Montojo To: cytoscape-discuss@googlegroups.com Content-Type: multipart/alternative; boundary=20cf307cfc78cd3ee904c9e729a4 --20cf307cfc78cd3ee904c9e729a4 Content-Type: text/plain; charset=UTF-8 Hi Omar, I usually get around that issue by reusing the JFrame instance. For example, your menu item could be a CyAction that lazily instantiates the JFrame. If the JFrame already exists, it just re-displays it. That way, your JFrame is created exactly once and the services are registered only once. Hope this helps, Jason On Sat, Sep 15, 2012 at 7:28 PM, Omar Wagih wrote: > I have my custom event class which implements several listeners > The handleEvent methods of the class depends on a JTree which is created > after files are loaded through a custom JFrame. Thus, I can't register the > listeners in CyActivator. > I instantiated the class, and passed references of the class + a reference > of CyServiceRegistrar through to where my JFrame is being created. > After my files are loaded and my JTree is created, I set the JTree in my > custom event listener class like this: myListeners.setTree(myJTree) and > register the listeners. > > However, I run into this issue: > In the case that someone loads JFrame file loader from the app menu to > load the the files a *second* time, the listeners are registered again > and thus my handleEvent methods are called more than once. > > I tried unregistering all services when my custom file loader JFrame is > opened like this: serviceRegistrar.unregisterAllServices(myListeners);, but > it fails > > Any idea what's going on? > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "cytoscape-discuss" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/cytoscape-discuss/-/JrM2K7WTPQYJ. > To post to this group, send email to cytoscape-discuss@googlegroups.com. > To unsubscribe from this group, send email to > cytoscape-discuss+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/cytoscape-discuss?hl=en. > --20cf307cfc78cd3ee904c9e729a4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Omar,

I usually get around that issue by reusing the = JFrame instance. =C2=A0For example, your menu item could be a CyAction that= lazily instantiates the JFrame. =C2=A0If the JFrame already exists, it jus= t re-displays it. =C2=A0That way, your JFrame is created exactly once and t= he services are registered only once.

Hope this helps,
Jason

On Sat, Sep 15, 2012 at 7:28 PM, Omar Wagih &= lt;omarwagih@gmail= .com> wrote:
I have my custom event class which implement= s several listeners
The handleEvent methods of the class depends on a J= Tree which is created after files are loaded through a custom JFrame. Thus,= I can't register the listeners in CyActivator.
I instantiated the class, and passed references of the class + a refer= ence of CyServiceRegistrar through to where my JFrame is being created.=C2= =A0
After my files are loaded and my JTree is created, I set the = JTree in my custom event listener class like this:=C2=A0myListeners.setTree= (myJTree) and register the listeners.

However, I run into this issue:=C2=A0
In the = case that someone loads JFrame file loader from the app menu to load the th= e files a second time, the listeners are registered again and thus m= y handleEvent methods are called more than once.

I tried unregistering all services when my custom file = loader JFrame is opened like this:=C2=A0serviceRegistrar.unregisterAllServi= ces(myListeners);, but it fails

Any idea what'= s going on?

Thanks

--
You received this message because you are subscribed to the Google Groups &= quot;cytoscape-discuss" group.
To view this discussion on the web visit https://groups= .google.com/d/msg/cytoscape-discuss/-/JrM2K7WTPQYJ.
=20 To post to this group, send email to cytoscape-discuss@googlegroups.com. To unsubscribe from this group, send email to cytoscape-discuss+= unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/= group/cytoscape-discuss?hl=3Den.

--20cf307cfc78cd3ee904c9e729a4--