From: <mwl...@us...> - 2008-03-21 16:26:47
|
Revision: 672 http://cishell.svn.sourceforge.net/cishell/?rev=672&view=rev Author: mwlinnem Date: 2008-03-21 09:26:11 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Added Paths: ----------- branches/user_prefs/org.cishell.testalgorithm3/.classpath branches/user_prefs/org.cishell.testalgorithm3/.project branches/user_prefs/org.cishell.testalgorithm3/.settings/ branches/user_prefs/org.cishell.testalgorithm3/META-INF/ branches/user_prefs/org.cishell.testalgorithm3/META-INF/MANIFEST.MF branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/algorithm.properties branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/component.xml branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/bundle_en.properties branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/METADATA.XML branches/user_prefs/org.cishell.testalgorithm3/build.properties branches/user_prefs/org.cishell.testalgorithm3/src/ branches/user_prefs/org.cishell.testalgorithm3/src/org/ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithm.java branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithmFactory.java Added: branches/user_prefs/org.cishell.testalgorithm3/.classpath =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/.classpath (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/.classpath 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="build"/> +</classpath> Added: branches/user_prefs/org.cishell.testalgorithm3/.project =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/.project (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/.project 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.testalgorithm3</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: branches/user_prefs/org.cishell.testalgorithm3/META-INF/MANIFEST.MF =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/META-INF/MANIFEST.MF (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/META-INF/MANIFEST.MF 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Test Algorithm 3 +Bundle-SymbolicName: org.cishell.testalgorithm3 +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Import-Package: org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.osgi.framework;version="1.3.0", + org.osgi.service.cm;version="1.2.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0", + org.osgi.service.prefs;version="1.1.0" +X-AutoStart: true +Service-Component: OSGI-INF/component.xml Added: branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/algorithm.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/algorithm.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/algorithm.properties 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,9 @@ +menu_path=File/additions +label=Test Algorithm 3 (Global) +description=Tests preference stuff +in_data=null +out_data=null +service.pid=org.cishell.testalgorithm3.TestAlgorithm +remoteable=false +prefs_published=global +receive_prefs=true Added: branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/component.xml =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/component.xml (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/component.xml 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.testalgorithm3.TestAlgorithm.component" immediate="true"> + <implementation class="org.cishell.testalgorithm3.TestAlgorithmFactory"/> + <properties entry="OSGI-INF/algorithm.properties"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + + <service> + <provide interface= + "org.cishell.framework.algorithm.AlgorithmFactory"/> + <provide interface= + "org.osgi.service.cm.ManagedService"/> + </service> +</component> \ No newline at end of file Added: branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/bundle_en.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/bundle_en.properties 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,7 @@ +#Localization variables for OSGI-INF/metatatype/METADATA.XML +# +#Samples: +#input=Input +#desc=Enter an integer (that will be converted to a string) +#name=Input->String +#name_desc=Converts inputted integer to string Added: branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/METADATA.XML =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/METADATA.XML (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/METADATA.XML 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + + <OCD name="General" id="org.cishell.testalgorithm3.prefs.global.OCD" + description=" "> + <AD name="Save data files to" id="saveDataDir" type="String" default="directory:/home/mwlinnem/"/> + <AD name="Open .txt files with" id="txtFileProg" type="String" default="file:"/> + <AD name="Open .csv files with" id="csvFileProg" type="String" default="file:"/> + <AD name="Prompt to save on exit?" id="promptSave" type="Boolean" default="true"/> + </OCD> + + <OCD name="Logging" id="org.cishell.testalgorithm3.prefs.global2.OCD" + description=" "> + <AD name="Set default logging level" id="logLevel" type="String" default="Normal"> + <Option label="Minimal" value="Minimal"/> + <Option label="Normal" value="Normal"/> + <Option label="Verbose" value="Verbose"/> + </AD> + + <AD name="Class Path" id="cp" type="String" default="path:"> + </AD> + + <AD name="Save log files to" id="logFileSaveDir" type="String" default="directory:/tmp/"/> + </OCD> + + <Designate pid="org.cishell.testalgorithm3.TestAlgorithm.prefs.global"> + <Object ocdref="org.cishell.testalgorithm3.prefs.global.OCD"/> + </Designate> + + <Designate pid="org.cishell.testalgorithm3.TestAlgorithm.prefs.global2"> + <Object ocdref="org.cishell.testalgorithm3.prefs.global2.OCD"/> + </Designate> +</metatype:MetaData> Added: branches/user_prefs/org.cishell.testalgorithm3/build.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/build.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/build.properties 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,5 @@ +source.. = src/ +output.. = build/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ Added: branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithm.java =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithm.java (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithm.java 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,44 @@ +package org.cishell.testalgorithm3; + +import java.util.Dictionary; +import java.util.Enumeration; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.data.Data; + +public class TestAlgorithm implements Algorithm { + Data[] data; + Dictionary parameters; + CIShellContext context; + + private Dictionary preferences; + + public TestAlgorithm(Data[] data, Dictionary parameters, CIShellContext context, Dictionary preferences) { + this.data = data; + this.parameters = parameters; + this.context = context; + this.preferences = preferences; + } + + public Data[] execute() { + printPreferences(this.preferences); + return null; + } + + private void printPreferences(Dictionary preferences) { + System.out.println(" Preferences are as follows:"); + if (preferences == null) { + System.out.println(" Dictionary is null!"); + } else { + Enumeration propertiesKeys = preferences.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = preferences.get(propertiesKey); + System.out.println(" " + propertiesKey + ":" + propertiesValue); + } + } +} +} \ No newline at end of file Added: branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithmFactory.java =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithmFactory.java (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithmFactory.java 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,76 @@ +package org.cishell.testalgorithm3; + +import java.util.Dictionary; +import java.util.Enumeration; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.metatype.MetaTypeProvider; +import org.osgi.service.metatype.MetaTypeService; + + +public class TestAlgorithmFactory implements AlgorithmFactory, ManagedService { + private MetaTypeProvider provider; + private Dictionary preferences; + + protected void activate(ComponentContext ctxt) { + // System.out.println("TestAlgorithm 3 beginning activation"); + //You may delete all references to metatype service if + //your algorithm does not require parameters and return + //null in the createParameters() method + MetaTypeService mts = (MetaTypeService)ctxt.locateService("MTS"); + provider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle()); + + Dictionary properties = ctxt.getProperties(); + + Enumeration propertiesKeys = properties.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = properties.get(propertiesKey); + + } + + // System.out.println("TestAlgorithm 3 done activating"); + } + protected void deactivate(ComponentContext ctxt) { + provider = null; + } + + public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { + System.out.println("TestAlgorithm3 executed!"); + return new TestAlgorithm(data, parameters, context, this.preferences); + } + public MetaTypeProvider createParameters(Data[] data) { + return provider; + } + + private void printPreferences(Dictionary properties) { + System.out.println(" Preferences are as follows:"); + if (properties == null) { + System.out.println(" Dictionary is null!"); + } else { + Enumeration propertiesKeys = properties.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = properties.get(propertiesKey); + System.out.println(" " + propertiesKey + ":" + propertiesValue); + } + } + } + + public void updated(Dictionary properties) throws ConfigurationException { + + this.preferences = properties; + //System.out.println("TestAlgorithm 3 updated!"); + //printPreferences(properties); + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |