From: <mwl...@us...> - 2007-07-24 19:40:36
|
Revision: 432 http://svn.sourceforge.net/cishell/?rev=432&view=rev Author: mwlinnem Date: 2007-07-24 12:40:33 -0700 (Tue, 24 Jul 2007) Log Message: ----------- Initial import. Added Paths: ----------- trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/ trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/MANIFEST.MF trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/ trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/algorithm.properties trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/component.xml trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/l10n/ trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/l10n/bundle_en.properties trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/metatype/ trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/metatype/METADATA.XML trunk/testing/org.cishell.testing.convertertester.algorithm/build.properties trunk/testing/org.cishell.testing.convertertester.algorithm/src/ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java Added: trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/MANIFEST.MF =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/MANIFEST.MF (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/META-INF/MANIFEST.MF 2007-07-24 19:40:33 UTC (rev 432) @@ -0,0 +1,27 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: ConverterTester Algorithm +Bundle-SymbolicName: org.cishell.testing.convertertester.algorithm +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Bundle-Localization: plugin +Import-Package: org.cishell.app.service.datamanager, + org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.cishell.reference.gui.common, + org.cishell.reference.service.metatype, + org.cishell.service.conversion, + org.cishell.service.guibuilder, + org.osgi.framework;version="1.3.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 +Require-Bundle: org.eclipse.swt, + org.eclipse.ui, + edu.uci.ics.jung, + org.prefuse.lib, + org.cishell.testing.convertertester.core.new Added: trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/algorithm.properties =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/algorithm.properties (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/algorithm.properties 2007-07-24 19:40:33 UTC (rev 432) @@ -0,0 +1,7 @@ +menu_path=File/Test/additions +label=Converter Tester Algorithm +description=Tests Converters +in_data=null +out_data=null +service.pid=org.cishell.testing.convertertester.algorithm.ConverterTesterAlgorithm +remoteable=false Added: trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/component.xml =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/component.xml (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/component.xml 2007-07-24 19:40:33 UTC (rev 432) @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.testing.convertertester.algorithm.ConverterTesterAlgorithm.component" immediate="false"> + <implementation class="org.cishell.testing.convertertester.algorithm.ConverterTesterAlgorithmFactory"/> + <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"/> + </service> +</component> \ No newline at end of file Added: trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/l10n/bundle_en.properties =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/l10n/bundle_en.properties 2007-07-24 19:40:33 UTC (rev 432) @@ -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: trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/metatype/METADATA.XML =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/metatype/METADATA.XML (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/OSGI-INF/metatype/METADATA.XML 2007-07-24 19:40:33 UTC (rev 432) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + <OCD name="Converter Tester Algorithm" id="org.cishell.testing.convertertester.algorithm.ConverterTesterAlgorithm.OCD"> + <AD name="Number of nodes" description="Enter number of nodes in the network, must be > 0" id="networkSize" type="Integer" default="2" min="1"/> + </OCD> + <Designate pid="org.cishell.testing.convertertester.algorithm.ConverterTesterAlgorithm"> + <Object ocdref="org.cishell.testing.convertertester.algorithm.ConverterTesterAlgorithm.OCD" /> + </Designate> +</metatype:MetaData> + Added: trunk/testing/org.cishell.testing.convertertester.algorithm/build.properties =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/build.properties (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/build.properties 2007-07-24 19:40:33 UTC (rev 432) @@ -0,0 +1,5 @@ +source.. = src/ +output.. = build/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ Added: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithm.java 2007-07-24 19:40:33 UTC (rev 432) @@ -0,0 +1,123 @@ +package org.cishell.testing.convertertester.algorithm; + +import java.io.File; +import java.util.ArrayList; +import java.util.Dictionary; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.data.Data; +import org.cishell.testing.convertertester.core.tester.ConverterTester; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.osgi.framework.BundleContext; + +//TODO: OMG Fix this whole thing as soon as possible. + +public class ConverterTesterAlgorithm implements Algorithm { + private static File currentDir; + + Data[] data; + Dictionary parameters; + CIShellContext context; + ConverterTester tester; + + public ConverterTesterAlgorithm(Data[] data, Dictionary parameters, + CIShellContext csContext, BundleContext bContext ) { + this.data = data; + this.parameters = parameters; + this.context = csContext; + + this.tester = new ConverterTester(bContext, csContext); +// ServiceReference ctReference = bContext.getServiceReference(ConverterTester.class.getName()); +// this.tester = (ConverterTester) bContext.getService(ctReference); + } + + public Data[] execute() { + +// int counter = PlatformUI.getWorkbench().getWorkbenchWindowCount(); +// System.out.println("counter is "+counter); +// ?? why getActiveWorkbenchWindow() didn't work?? + Data[] returnDM; + + final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); + if (windows.length ==0){ + return null; + } + + Display display = PlatformUI.getWorkbench().getDisplay(); + DataUpdater dataUpdater = new DataUpdater (windows[0]); + + if (Thread.currentThread() != display.getThread()) { + display.syncExec(dataUpdater); + } else { + dataUpdater.run(); + } + + if (!dataUpdater.returnList.isEmpty()){ + int size = dataUpdater.returnList.size(); + returnDM = new Data[size]; + for(int index=0; index<size; index++){ + returnDM[index]=(Data)dataUpdater.returnList.get(index); + } + return returnDM; + } + else { + return null; + } + + } + + public static String getFileExtension(File theFile) { + String fileName = theFile.getName() ; + String extension ; + if (fileName.lastIndexOf(".") != -1) + extension = fileName.substring(fileName.lastIndexOf(".")+1) ; + else + extension = "" ; + return extension ; + } + + final class DataUpdater implements Runnable{ + boolean loadFileSuccess = false; + IWorkbenchWindow window; + ArrayList returnList = new ArrayList(); + + DataUpdater (IWorkbenchWindow window){ + this.window = window; + } + + public void run (){ + + FileDialog dialog = new FileDialog(window.getShell(), SWT.OPEN); + if (currentDir == null) { + currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata"); + + if (!currentDir.exists()) { + currentDir = new File(System.getProperty("user.home") + File.separator + "anything"); + } else { + currentDir = new File(System.getProperty("user.dir") + File.separator + "sampledata" + File.separator + "anything"); + } + } + dialog.setFilterPath(currentDir.getPath()); + dialog.setText("Select a File"); + String fileName = dialog.open(); + if (fileName == null) { + return; + } + + File file = new File(fileName); + + try { + tester.runTests(file); + } catch (Exception e) { + System.out.println("Why oh why am I catching type Exception?"); + System.out.println(e); + } + } + } + +} \ No newline at end of file Added: trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java =================================================================== --- trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java (rev 0) +++ trunk/testing/org.cishell.testing.convertertester.algorithm/src/org/cishell/testing/convertertester/algorithm/ConverterTesterAlgorithmFactory.java 2007-07-24 19:40:33 UTC (rev 432) @@ -0,0 +1,37 @@ +package org.cishell.testing.convertertester.algorithm; + +import java.util.Dictionary; + +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.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.metatype.MetaTypeProvider; +import org.osgi.service.metatype.MetaTypeService; + + +public class ConverterTesterAlgorithmFactory implements AlgorithmFactory { + private MetaTypeProvider provider; + private BundleContext bContext; + + protected void activate(ComponentContext ctxt) { + //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"); + this.bContext = ctxt.getBundleContext(); + provider = mts.getMetaTypeInformation(this.bContext.getBundle()); + } + protected void deactivate(ComponentContext ctxt) { + provider = null; + } + + public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { + return new ConverterTesterAlgorithm(data, parameters, context, bContext); + } + public MetaTypeProvider createParameters(Data[] data) { + return provider; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |