From: <bea...@us...> - 2006-11-21 22:05:32
|
Revision: 336 http://svn.sourceforge.net/cishell/?rev=336&view=rev Author: bearsfan Date: 2006-11-21 14:05:30 -0800 (Tue, 21 Nov 2006) Log Message: ----------- Implemented the ProcessTrackable interface for the AlgorithmWrapper Modified Paths: -------------- 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/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 2006-11-21 22:04:58 UTC (rev 335) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2006-11-21 22:05:30 UTC (rev 336) @@ -25,6 +25,8 @@ import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.algorithm.AlgorithmProperty; +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.service.conversion.Converter; @@ -38,7 +40,7 @@ import org.osgi.service.metatype.ObjectClassDefinition; -public class AlgorithmWrapper implements Algorithm, AlgorithmProperty { +public class AlgorithmWrapper implements Algorithm, AlgorithmProperty, ProgressTrackable { protected ServiceReference ref; protected BundleContext bContext; protected CIShellContext ciContext; @@ -48,6 +50,8 @@ protected Dictionary parameters; protected Map idToLabelMap; protected MetaTypeProvider provider; + protected ProgressMonitor progressMonitor; + protected Algorithm algorithm; public AlgorithmWrapper(ServiceReference ref, BundleContext bContext, CIShellContext ciContext, Data[] originalData, Data[] data, @@ -62,6 +66,10 @@ this.parameters = parameters; this.provider = provider; this.idToLabelMap = new HashMap(); + this.progressMonitor = null; + + AlgorithmFactory factory = (AlgorithmFactory) bContext.getService(ref); + algorithm = factory.createAlgorithm(data, parameters, ciContext); } /** @@ -75,14 +83,15 @@ converters[i] = null; } } + + printParameters(); - AlgorithmFactory factory = (AlgorithmFactory) bContext.getService(ref); - Algorithm alg = factory.createAlgorithm(data, parameters, ciContext); + if (progressMonitor != null && algorithm instanceof ProgressTrackable) { + ((ProgressTrackable)algorithm).setProgressMonitor(progressMonitor); + } - printParameters(); + Data[] outData = algorithm.execute(); - Data[] outData = alg.execute(); - if (outData != null) { DataManagerService dataManager = (DataManagerService) bContext.getService(bContext.getServiceReference( @@ -212,4 +221,17 @@ return log; } + + public ProgressMonitor getProgressMonitor() { + if (algorithm instanceof ProgressTrackable) { + return progressMonitor; + } + else { + return null; + } + } + + public void setProgressMonitor(ProgressMonitor monitor) { + progressMonitor = monitor; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |