From: Christoph F. <cf...@fo...> - 2004-11-06 06:53:07
|
HI Rinaldo Am Freitag, den 05.11.2004, 16:19 +1100 schrieb Rinalldo Yasahardja: > Hi all, > > does anyone know how i can get a reference to the topic map inside tmnav ? > or to get a copy of it ? I need to iterate through it to check whether a > particular topic is already contained inside the currently opened topic > map ? > Hm. There is no *official* way to access any TopicMapObject from inside of tmnav. TMnav operates on an AbstractModel provided by panckoucke. TMNav does not know anything about "TopicMapObjects". This was a design decission and I still think its ok, if you use TMNav as a Navigator, but since people start to implement editing features in tmnav, this turns out to be a rather severe issue. Maybe I should reconsider. Nevertheless, it is possible to access the topicmap. It is a sort of a hack and please keep in mind, that it is not part of the api and may be broken in future versions, especially in next versions of panckoucke. I paste you example code below. You need to create an instance of AccessTopicmapHack(NavContext) somewhere in your tmnav-initialisation code. Hope it helps bye c -------------------------------------------------------------------------- /** * LICENSE * ------------ * This file is distributed under the provisions of the TM4J license. See * http://tm4j.org/LICENSE.TXT for the details of this license. */ package org.tm4j.tmnav.app; import org.tm4j.panckoucke.impl.store.TopicMapReferenceImpl; import org.tm4j.panckoucke.notification.StateChangedNotification; import org.tm4j.panckoucke.store.TopicMapReference; import org.tm4j.tmnav.app.event.Event; import org.tm4j.tmnav.app.event.EventDispatcher; import org.tm4j.tmnav.app.event.EventListener; import org.tm4j.tmnav.app.event.EventType; import org.tm4j.tmnav.env.NavContext; import org.tm4j.topicmap.TopicMap; /** * Hack to access a topicmap from inside of tmnav * * @author cf */ public class AccessTopicmapHack implements EventListener { /** * */ public AccessTopicmapHack(NavContext ctx) { // registering for events EventDispatcher d = ctx.getEventDispatcher(); d.addListener(this, EventType.EV_TM_STATE_CHANGED); } /** * Access Topicmap */ public void tmnavEventFired(Event e) { if (e.getEventType() == EventType.EV_TM_STATE_CHANGED) { StateChangedNotification scn = (StateChangedNotification) e.getRelatedObject(); TopicMapReference tmr = scn.getTopicmapRef(); if(tmr instanceof TopicMapReferenceImpl){ TopicMap tm = ((TopicMapReferenceImpl)tmr).getTopicmap(); } } } } --------------------------------------------------------------------- > thanks in advance > > On Thu, 28 Oct 2004, Christoph Froehlich wrote: > > > Am Donnerstag, den 28.10.2004, 12:36 +1000 schrieb Rinalldo Yasahardja: > >> On Wed, 27 Oct 2004, Christoph Froehlich wrote: > >> > >>> Hi Rinalldo > >>> > >>> I'm pretty sure that the reason for this is the potential asynchronious > >>> behavior of the Preferences implementation. > >>> > >>> I guess you are still running TMNav-Applet with the -f option? And > >>> removed the call to System.exit(int); > >>> > >>> If so, please try to add a call to sync in TMNav.clearSessionData(): > >>> After that the try - block should look roughly like this: > >>> try { > >>> String path = tmnavRootNode.absolutePath(); > >>> tmnavRootNode.removeNode(); > >>> tmnavRootNode.sync(); // new call to sync > >>> System.out.println("Removed Session Data from path " + > >>> ... > >> > >> using this method causes TMNav to crash even on the first attempt to run > >> it (the message is still the same) > >> > >> > >>> > >>> If this does not help, try to add the sync call also to > >>> TMNav.closeInstance(int), just after the line: > >>> session.storeSession(); > >>> > >>> (For the latter case you need to access tmnavRootNode just as in > >>> clearSessionData().) > >>> > >> > >> > >> using this method still causes TMNav fail to load the second time. > >> > >> > >>> Hope that helps > >>> c > >>> > >> > >> any ideas ? > > > > ui. ui. > > not really. > > > > What happens, > > - if you're running the applet without the -f option? > > - if you're removing the line "session.storeSession();" from > > TMNav.closeInstance()? > > > > > > c > > > >> > >> > >> ------------------------------------------------------- > >> This SF.Net email is sponsored by: > >> Sybase ASE Linux Express Edition - download now for FREE > >> LinuxWorld Reader's Choice Award Winner for best database on Linux. > >> http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > >> _______________________________________________ > >> Tm4j-tmnav-dev mailing list > >> Tm4...@li... > >> https://lists.sourceforge.net/lists/listinfo/tm4j-tmnav-dev > > -- > > Christoph Froehlich <cf...@fo...> > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > Tm4j-tmnav-dev mailing list > Tm4...@li... > https://lists.sourceforge.net/lists/listinfo/tm4j-tmnav-dev -- Christoph Froehlich <cf...@fo...> |