From: <bh...@us...> - 2008-03-25 16:24:06
|
Revision: 701 http://cishell.svn.sourceforge.net/cishell/?rev=701&view=rev Author: bh2 Date: 2008-03-25 09:23:43 -0700 (Tue, 25 Mar 2008) Log Message: ----------- 'properly' handling new metatype id stuff and parameter mutators. Still need to add in support for in/out data exceptions and other badly needed refactorings. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-03-25 15:53:46 UTC (rev 700) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-03-25 16:23:43 UTC (rev 701) @@ -14,6 +14,7 @@ org.cishell.framework.algorithm;version="1.0.0", org.cishell.framework.data;version="1.0.0", org.cishell.reference.gui.workspace, + org.cishell.reference.service.metatype, org.cishell.service.conversion;version="1.0.0", org.cishell.service.guibuilder;version="1.0.0", org.osgi.service.log;version="1.3.0", Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java 2008-03-25 15:53:46 UTC (rev 700) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java 2008-03-25 16:23:43 UTC (rev 701) @@ -12,6 +12,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; /** * The activator class controls the plug-in life cycle @@ -24,6 +25,8 @@ // The shared instance private static Activator plugin; + private static BundleContext context; + MenuAdapter menuAdapter; /** @@ -39,6 +42,8 @@ public void start(BundleContext context) throws Exception { super.start(context); + this.context = context; + while (getWorkbench() == null) { Thread.sleep(500); } @@ -77,6 +82,16 @@ super.stop(context); } + + public static Object getService(String service_pid) { + ServiceReference ref = context.getServiceReference(service_pid); + + if (ref != null) { + return context.getService(ref); + } else { + return null; + } + } /** * Returns the shared instance Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-25 15:53:46 UTC (rev 700) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-25 16:23:43 UTC (rev 701) @@ -27,10 +27,13 @@ import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.algorithm.AlgorithmProperty; import org.cishell.framework.algorithm.DataValidator; +import org.cishell.framework.algorithm.ParameterMutator; import org.cishell.framework.algorithm.ProgressMonitor; import org.cishell.framework.algorithm.ProgressTrackable; import org.cishell.framework.data.Data; import org.cishell.framework.data.DataProperty; +import org.cishell.reference.gui.menumanager.Activator; +import org.cishell.reference.service.metatype.BasicMetaTypeProvider; import org.cishell.service.conversion.Converter; import org.cishell.service.guibuilder.GUIBuilderService; import org.osgi.framework.BundleContext; @@ -39,6 +42,7 @@ import org.osgi.service.log.LogService; import org.osgi.service.metatype.AttributeDefinition; import org.osgi.service.metatype.MetaTypeProvider; +import org.osgi.service.metatype.MetaTypeService; import org.osgi.service.metatype.ObjectClassDefinition; @@ -110,11 +114,34 @@ } } - //FIXME: - //this.provider = factory.createParameters(data); - this.provider = null; String pid = (String)ref.getProperty(Constants.SERVICE_PID); + String metatype_pid = (String) ref.getProperty(PARAMETERS_PID); + if (metatype_pid == null) { + metatype_pid = pid; + } + + this.provider = null; + + MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); + if (metaTypeService != null) { + provider = metaTypeService.getMetaTypeInformation(ref.getBundle()); + } + + if (factory instanceof ParameterMutator && provider != null) { + try { + ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatype_pid, null); + + ocd = ((ParameterMutator) factory).mutateParameters(data, ocd); + + if (ocd != null) { + provider = new BasicMetaTypeProvider(ocd); + } + } catch (IllegalArgumentException e) { + log(LogService.LOG_DEBUG, pid+" has an invalid metatype id: "+metatype_pid); + } + } + this.parameters = new Hashtable(); if (provider != null) { this.parameters = builder.createGUIandWait(pid, provider); @@ -167,6 +194,15 @@ } } + protected void log(int logLevel, String message) { + LogService log = (LogService) Activator.getService(LogService.class.getName()); + if (log != null) { + log.log(logLevel, message); + } else { + System.out.println(message); + } + } + protected void printParameters() { LogService logger = getLogService(); setupIdToLabelMap(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |