From: <mwl...@us...> - 2008-09-04 17:56:07
|
Revision: 803 http://cishell.svn.sourceforge.net/cishell/?rev=803&view=rev Author: mwlinnem Date: 2008-09-04 17:56:05 +0000 (Thu, 04 Sep 2008) Log Message: ----------- New way of getting the config.ini file which seems to work on various platforms better than the old one. It works on at least one platform that didn't work before, so it's good enough to upload and hope it works in general. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-09-04 14:41:47 UTC (rev 802) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-09-04 17:56:05 UTC (rev 803) @@ -13,13 +13,13 @@ * ***************************************************************************/ package org.cishell.reference.gui.menumanager.menu; +import java.io.File; import java.io.IOException; -import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; -import java.net.URI; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -101,27 +101,40 @@ + public MenuAdapter(IMenuManager menu, Shell shell, BundleContext bContext,CIShellContext ciContext, IWorkbenchWindow window) { + //basic initialization this.menuBar = menu; this.shell = shell; this.bContext = bContext; this.ciContext = ciContext; this.window = window; + this.algorithmToItemMap = new HashMap(); this.itemToParentMap = new HashMap(); + pidToServiceReferenceMap = new HashMap(); pidToServiceReferenceMapCopy = new HashMap(); + //appears to add a listener which updates the menu item whenever a + //corresponding change occurs in the bundle (registers, unregisters, etc...) String filter = "(" + Constants.OBJECTCLASS + "=" + AlgorithmFactory.class.getName() + ")"; + listener = new ContextListener(); + try { - listener = new ContextListener(); + bContext.addServiceListener(listener, filter); preprocessServiceBundles(); String app_location = System.getProperty("osgi.configuration.area"); + + //Comments below refer to problems with earlier versions of this document. + //Keeping these around for now, as well as the system.out.printlns, + //until we are sure that the current fix works. + /* * This is a temporary fix. A bit complex to explain the observation * I got so far. On Windows XP @@ -141,19 +154,27 @@ * * This piece of code needs to be reviewed and refactored!!! */ + System.out.println(">>>app_location = "+app_location); - String fileFullpath = app_location.substring(6)+ DEFAULT_MENU_FILE_NAME; - String fullpath = app_location+ DEFAULT_MENU_FILE_NAME; - if (new File(fileFullpath).exists() || new File(fullpath).exists()){ - createMenuFromXML(fullpath); - processLeftServiceBundles(); - }else{ - initializeMenu(); - } + String fileFullPath = app_location + DEFAULT_MENU_FILE_NAME; + System.out.println(">>>fileFullPath = " + fileFullPath); + URI configurationDirectoryURI = new URI(fileFullPath); + System.out.println(">>>URI = " + configurationDirectoryURI.toString()); + System.out.println(">>> file at URI = " + new File(configurationDirectoryURI).toString()); + if (new File(configurationDirectoryURI).exists()) { + System.out.println("config.ini Exists!"); + String fullpath = app_location + DEFAULT_MENU_FILE_NAME; + createMenuFromXML(fullpath); + } else { + System.out.println("config.ini does not exist... Reverting to backup plan"); + processLeftServiceBundles(); + } Display.getDefault().asyncExec(updateAction); } catch (InvalidSyntaxException e) { getLog().log(LogService.LOG_DEBUG, "Invalid Syntax", e); + } catch (URISyntaxException e) { + getLog().log(LogService.LOG_DEBUG, "Invalid Syntax", e); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |