You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(7) |
Aug
|
Sep
(46) |
Oct
(102) |
Nov
(10) |
Dec
(21) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
(3) |
Mar
(14) |
Apr
(9) |
May
(12) |
Jun
(4) |
Jul
(40) |
Aug
(60) |
Sep
(38) |
Oct
(2) |
Nov
(1) |
Dec
(42) |
2008 |
Jan
(23) |
Feb
(29) |
Mar
(107) |
Apr
(27) |
May
(3) |
Jun
(1) |
Jul
(15) |
Aug
(7) |
Sep
(19) |
Oct
|
Nov
(2) |
Dec
|
2009 |
Jan
(36) |
Feb
(4) |
Mar
(2) |
Apr
(1) |
May
(1) |
Jun
(15) |
Jul
(30) |
Aug
(32) |
Sep
(11) |
Oct
(21) |
Nov
(12) |
Dec
(15) |
2010 |
Jan
(29) |
Feb
(9) |
Mar
(25) |
Apr
|
May
(7) |
Jun
(5) |
Jul
(21) |
Aug
(32) |
Sep
(10) |
Oct
(8) |
Nov
(29) |
Dec
(8) |
2011 |
Jan
(9) |
Feb
(35) |
Mar
(11) |
Apr
(4) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(30) |
2012 |
Jan
(5) |
Feb
(7) |
Mar
(10) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mwl...@us...> - 2008-05-09 13:51:05
|
Revision: 777 http://cishell.svn.sourceforge.net/cishell/?rev=777&view=rev Author: mwlinnem Date: 2008-05-09 06:50:16 -0700 (Fri, 09 May 2008) Log Message: ----------- Added additional error handling. Modified Paths: -------------- 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/metatypewrapper/ParamAD.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 2008-05-08 17:51:48 UTC (rev 776) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-05-09 13:50:16 UTC (rev 777) @@ -100,7 +100,8 @@ printParameters(metatype_pid, provider, parameters); // create the algorithm - algorithm = factory.createAlgorithm(data, parameters, ciContext); + algorithm = createAlgorithm(factory, data, parameters, ciContext); + if (algorithm == null) return null; trackAlgorithmIfPossible(algorithm); // execute the algorithm @@ -115,6 +116,20 @@ return outData; } + protected Algorithm createAlgorithm(AlgorithmFactory factory, Data[] data, Dictionary parameters, CIShellContext ciContext) { + try { + return factory.createAlgorithm(data, parameters, ciContext); + } catch (Exception e) { + String errorMessage = "Unexpected error occurred while creating algorithm " + + " \""+ref.getProperty(AlgorithmProperty.LABEL)+".\""; + GUIBuilderService builder = (GUIBuilderService) + ciContext.getService(GUIBuilderService.class.getName()); + builder.showError("Error!", errorMessage, e); + log(LogService.LOG_ERROR, errorMessage, e); + return null; + } + } + protected Data[] removeNullData(Data[] outData) { if (outData != null) { List goodData = new ArrayList(); @@ -217,7 +232,6 @@ protected MetaTypeProvider getPossiblyMutatedMetaTypeProvider(String metatype_pid, String pid, AlgorithmFactory factory) { MetaTypeProvider provider = null; - MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); if (metaTypeService != null) { provider = metaTypeService.getMetaTypeInformation(ref.getBundle()); @@ -226,14 +240,20 @@ if (factory instanceof ParameterMutator && provider != null) { try { ObjectClassDefinition ocd = provider.getObjectClassDefinition(metatype_pid, null); - + if (ocd == null) logNullOCDWarning(pid, metatype_pid); 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); + } catch (Exception e) { + GUIBuilderService builder = (GUIBuilderService) + ciContext.getService(GUIBuilderService.class.getName()); + String errorMessage = "An error occurred while preparing to run the algorithm " + +ref.getProperty(AlgorithmProperty.LABEL)+".\""; + builder.showError("Error!", errorMessage, e); + log(LogService.LOG_ERROR, errorMessage, e); } } @@ -423,6 +443,11 @@ return ca; } + + private void logNullOCDWarning(String pid, String metatype_pid) { + this.log(LogService.LOG_WARNING, + "Warning: could not get object class definition '" + metatype_pid + "' from the algorithm '" + pid + "'"); + } public ProgressMonitor getProgressMonitor() { if (algorithm instanceof ProgressTrackable) { Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java 2008-05-08 17:51:48 UTC (rev 776) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java 2008-05-09 13:50:16 UTC (rev 777) @@ -61,6 +61,7 @@ private String[] replaceSpecialValues(String[] overrideValues) { try { String[] defaultValues = realAD.getDefaultValue(); + if (defaultValues == null) return new String[0]; String[] replacedValues = new String[defaultValues.length]; for (int i = 0; i < defaultValues.length; i++) { if (defaultValues[i] != null && defaultValues[i].contains(":") && overrideValues[i] != null && overrideValues[i].equals("")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-05-08 17:53:14
|
Revision: 776 http://cishell.svn.sourceforge.net/cishell/?rev=776&view=rev Author: mwlinnem Date: 2008-05-08 10:51:48 -0700 (Thu, 08 May 2008) Log Message: ----------- Added handling for null labels. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2008-04-23 18:08:19 UTC (rev 775) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/Save.java 2008-05-08 17:51:48 UTC (rev 776) @@ -79,7 +79,7 @@ } else { //result instanceof Exception Exception reasonForFailure = (Exception) firstAttemptResult; this.log.log(LogService.LOG_WARNING, "Exception occurred while attempting to save" + - " file using a validator. Attempting to save without validating."); + " file using a validator. Attempting to save without validating.", reasonForFailure); System.out.println("Exception"); } Modified: trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2008-04-23 18:08:19 UTC (rev 775) +++ trunk/clients/gui/org.cishell.reference.gui.persistence/src/org/cishell/reference/gui/persistence/save/SaveDataChooser.java 2008-05-08 17:51:48 UTC (rev 776) @@ -374,7 +374,18 @@ Converter c2 = (Converter) o2; String c2Label = getLabel(c2); - return c1Label.compareTo(c2Label); + if (c1Label != null && c2Label != null) { + return c1Label.compareTo(c2Label); + } else if (c1Label == null) { + //c1 > c2 + return 1; + } else if (c2Label == null) { + //c1 < c2 + return -1; + } else { + //c1 == c2 + return 0; + } } else { throw new IllegalArgumentException("Can only " + "compare Converters"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-04-23 18:09:49
|
Revision: 775 http://cishell.svn.sourceforge.net/cishell/?rev=775&view=rev Author: bh2 Date: 2008-04-23 11:08:19 -0700 (Wed, 23 Apr 2008) Log Message: ----------- Added some documentation and made the ant script no longer automatically build the dev_guide when called w/ no args since the dev guide is being done on the wiki now. Modified Paths: -------------- trunk/core/org.cishell.docs/build.xml Added Paths: ----------- trunk/core/org.cishell.docs/README Added: trunk/core/org.cishell.docs/README =================================================================== --- trunk/core/org.cishell.docs/README (rev 0) +++ trunk/core/org.cishell.docs/README 2008-04-23 18:08:19 UTC (rev 775) @@ -0,0 +1,23 @@ +CIShell Specification Project +----------------------------- +CIShell 1.0 specification and build system by Bruce Herr. The Javadoc->Latex +doclet (TexDoclet) originally from https://texdoclet.dev.java.net/ was +customized by Bruce Herr. + +The build system was originally set up so that we could create the specification, +developer guide, and other CIShell related documents. We are now doing the +developer guide at the CIShell Wiki ( https://cishell.org/?n=DevGuide.HomePage ). +The initial workings of the dev_guide using LaTeX is left here as an example of +how another document could be integrated. + +USING THE BUILD SYSTEM: +Using ant, you will typically just run 'ant' and it'll build the spec. +'ant clean' can be used to clean up the generated files. You can look at the +build.xml file for other possible commands. + +In order to inject the API docs into the specification, you must have the +org.cishell.framework bundle checked out in the same directory as this project. +If you are in eclipse, then just check it out into your workspace. 'ant +javadoc-tex' will invoke the javadoc command using the customized texdoclet +which will create an api.tex file in src/specification/tex/. + Modified: trunk/core/org.cishell.docs/build.xml =================================================================== --- trunk/core/org.cishell.docs/build.xml 2008-04-07 19:53:22 UTC (rev 774) +++ trunk/core/org.cishell.docs/build.xml 2008-04-23 18:08:19 UTC (rev 775) @@ -2,7 +2,7 @@ <project name="CIShell Documentation" default="all"> <property file="build.properties" /> - <target name="all" depends="javadoc-tex,build-spec,build-guide,setup"/> + <target name="all" depends="javadoc-tex,build-spec,setup"/> <target name="setup"> <mkdir dir="${build.dir}"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-07 19:54:30
|
Revision: 774 http://cishell.svn.sourceforge.net/cishell/?rev=774&view=rev Author: mwlinnem Date: 2008-04-07 12:53:22 -0700 (Mon, 07 Apr 2008) Log Message: ----------- Fixed a couple weird bugs. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java 2008-04-03 16:04:19 UTC (rev 773) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java 2008-04-07 19:53:22 UTC (rev 774) @@ -15,8 +15,7 @@ this.log = log; this.realAD = realAD; - - this.defaultValueOverride = defaultValueOverride; + this.defaultValueOverride = replaceSpecialValues(defaultValueOverride); } public int getCardinality() { @@ -58,5 +57,23 @@ public String validate(String value) { return this.realAD.validate(value); } + + private String[] replaceSpecialValues(String[] overrideValues) { + try { + String[] defaultValues = realAD.getDefaultValue(); + String[] replacedValues = new String[defaultValues.length]; + for (int i = 0; i < defaultValues.length; i++) { + if (defaultValues[i] != null && defaultValues[i].contains(":") && overrideValues[i] != null && overrideValues[i].equals("")) { + replacedValues[i] = defaultValues[i].substring(0, defaultValues[i].indexOf(":") + 1); + } else { + replacedValues[i] = overrideValues[i]; + } + } + return replacedValues; + } catch (Exception e) { + e.printStackTrace(); + return overrideValues; + } + } } Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java 2008-04-03 16:04:19 UTC (rev 773) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java 2008-04-07 19:53:22 UTC (rev 774) @@ -11,7 +11,9 @@ public class ParamOCD implements ObjectClassDefinition { private ObjectClassDefinition realOCD; - private ParamAD[] wrappedADs; + private ParamAD[] allWrappedADs; + private ParamAD[] requiredWrappedADs; + private ParamAD[] optionalWrappedADs; private LogService log; @@ -21,8 +23,9 @@ this.realOCD = realOCD; this.defaultOverrider = defaultOverrider; - //TODO: don't always return all attributeDefinitions, regardless of filter - this.wrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.ALL)); + this.allWrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.ALL)); + this.requiredWrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.REQUIRED)); + this.optionalWrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.OPTIONAL)); } private ParamAD[] wrapAttributeDefinitions(AttributeDefinition[] realAttributeDefinitions) { @@ -55,7 +58,17 @@ } public AttributeDefinition[] getAttributeDefinitions(int filter) { - return wrappedADs; + if (filter == ObjectClassDefinition.ALL) { + return allWrappedADs; + } else if (filter == ObjectClassDefinition.REQUIRED) { + return requiredWrappedADs; + } else if (filter == ObjectClassDefinition.OPTIONAL) { + return optionalWrappedADs; + } else { + this.log.log(LogService.LOG_WARNING, "Requested filter of unrecognized type " + filter + + " in getAttributeDefinitions in ParamOCD. Treating as if your meant to return all attributes"); + return allWrappedADs; + } } public String getDescription() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-04-03 16:05:19
|
Revision: 773 http://cishell.svn.sourceforge.net/cishell/?rev=773&view=rev Author: bh2 Date: 2008-04-03 09:04:19 -0700 (Thu, 03 Apr 2008) Log Message: ----------- * moved retrieving of ConfigurationAdmin to where it is actually used by using the bundle context * stopped creating a temporary thread in AlgorithmAction to put the algorithm directly into the scheduler. This used to be necessary when we did some data conversion before going to the scheduler * combined micah's putting stuff into functions and adding userprefs with the other bug fixes/"refactors" I had simultaneously applied At some point we do need to factor some of the 'good bits' out to something... Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 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/MenuAdapter.java Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-04-02 19:37:27 UTC (rev 772) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-04-03 16:04:19 UTC (rev 773) @@ -21,6 +21,7 @@ import org.cishell.app.service.datamanager.DataManagerService; import org.cishell.app.service.scheduler.SchedulerService; import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; import org.cishell.framework.algorithm.AlgorithmProperty; import org.cishell.framework.data.Data; import org.cishell.service.conversion.Converter; @@ -28,7 +29,6 @@ import org.eclipse.jface.action.Action; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; -import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.log.LogService; @@ -40,14 +40,10 @@ protected Data[] originalData; protected Converter[][] converters; - protected ConfigurationAdmin ca; - - //ConfigurationAdmin can be null - public AlgorithmAction(ServiceReference ref, BundleContext bContext, CIShellContext ciContext, ConfigurationAdmin ca) { + public AlgorithmAction(ServiceReference ref, BundleContext bContext, CIShellContext ciContext) { this.ref = ref; this.ciContext = ciContext; this.bContext = bContext; - this.ca = ca; setText((String)ref.getProperty(LABEL)); setToolTipText((String)ref.getProperty(AlgorithmProperty.DESCRIPTION)); @@ -58,7 +54,6 @@ dataManager.addDataManagerListener(this); dataSelected(dataManager.getSelectedData()); - } public AlgorithmAction(String label, ServiceReference ref, BundleContext bContext, CIShellContext ciContext) { @@ -76,34 +71,22 @@ dataManager.addDataManagerListener(this); dataSelected(dataManager.getSelectedData()); } - + public void run() { - //hmm... should probably change this.. maybe use the scheduler... - new Thread("Menu Item Runner") { - public void run() { - runTask(); - }}.start(); - } - - public void runTask() { try { - //save the current data - Data[] data = this.data; - Converter[][] converters = this.converters; - - SchedulerService scheduler = (SchedulerService) - bContext.getService(bContext.getServiceReference( - SchedulerService.class.getName())); - - printAlgorithmInformation(); + printAlgorithmInformation(ref, ciContext); - scheduler.schedule(new AlgorithmWrapper(ref, ciContext, bContext, originalData, data, converters, ca), ref); + Algorithm algorithm = new AlgorithmWrapper(ref, bContext, ciContext, originalData, data, converters); + SchedulerService scheduler = (SchedulerService) getService(SchedulerService.class); + + scheduler.schedule(algorithm, ref); } catch (Throwable e) { + //Just in case an uncaught exception occurs. Eclipse will swallow errors thrown here... e.printStackTrace(); } } - private void printAlgorithmInformation() { + private void printAlgorithmInformation(ServiceReference ref, CIShellContext ciContext) { //adjust to log the whole acknowledgement in one block LogService logger = (LogService) ciContext.getService(LogService.class.getName()); StringBuffer acknowledgement = new StringBuffer(); @@ -185,9 +168,8 @@ } else { originalData = null; } - - setEnabled(data != null); //&& isValid()); + setEnabled(data != null); } private boolean isAssignableFrom(String type, Data datum) { @@ -213,6 +195,15 @@ public void dataLabelChanged(Data data, String label) {} public void dataRemoved(Data data) {} + private Object getService(Class clas) { + ServiceReference ref = bContext.getServiceReference(clas.getName()); + if (ref != null) { + return bContext.getService(ref); + } + + return null; + } + public ServiceReference getServiceReference(){ return ref; } 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-04-02 19:37:27 UTC (rev 772) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-04-03 16:04:19 UTC (rev 773) @@ -25,6 +25,7 @@ import org.cishell.app.service.datamanager.DataManagerService; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.algorithm.AlgorithmProperty; import org.cishell.framework.algorithm.DataValidator; @@ -37,6 +38,7 @@ import org.cishell.reference.gui.menumanager.Activator; import org.cishell.reference.gui.menumanager.menu.metatypewrapper.ParamMetaTypeProvider; import org.cishell.reference.service.metatype.BasicMetaTypeProvider; +import org.cishell.service.conversion.ConversionException; import org.cishell.service.conversion.Converter; import org.cishell.service.guibuilder.GUIBuilderService; import org.osgi.framework.BundleContext; @@ -50,224 +52,221 @@ import org.osgi.service.metatype.MetaTypeService; import org.osgi.service.metatype.ObjectClassDefinition; + public class AlgorithmWrapper implements Algorithm, AlgorithmProperty, ProgressTrackable { - protected ServiceReference algFactoryRef; - protected BundleContext bContext; - protected CIShellContext ciContext; - protected Data[] originalData; - protected Data[] convertableData; - protected Converter[][] converters; - protected ProgressMonitor progressMonitor; + protected ServiceReference ref; + protected BundleContext bContext; + protected CIShellContext ciContext; + protected Data[] originalData; + protected Data[] data; + protected Converter[][] converters; + protected ProgressMonitor progressMonitor; + protected Algorithm algorithm; + + public AlgorithmWrapper(ServiceReference ref, BundleContext bContext, + CIShellContext ciContext, Data[] originalData, Data[] data, + Converter[][] converters) { + this.ref = ref; + this.bContext = bContext; + this.ciContext = ciContext; + this.originalData = originalData; + this.data = data; + this.converters = converters; + this.progressMonitor = null; + } - protected ConfigurationAdmin ca; - protected GUIBuilderService builder; - protected DataManagerService dataManager; + /** + * @see org.cishell.framework.algorithm.Algorithm#execute() + */ + public Data[] execute() { + AlgorithmFactory factory = (AlgorithmFactory) bContext.getService(ref); + String pid = (String)ref.getProperty(Constants.SERVICE_PID); + + // convert input data to the correct format + boolean conversionSuccessful = tryConvertingDataToRequiredFormat(data, converters); + if (!conversionSuccessful) return null; + boolean inputIsValid = testDataValidityIfPossible(factory, data); + if (!inputIsValid) return null; + + // create algorithm parameters + String metatype_pid = getMetaTypeID(ref); + + MetaTypeProvider provider = getPossiblyMutatedMetaTypeProvider(metatype_pid, pid, factory); + Dictionary parameters = getUserEnteredParameters(metatype_pid, provider); + + // check to see if the user cancelled the operation + if(parameters == null) return null; + + printParameters(metatype_pid, provider, parameters); + + // create the algorithm + algorithm = factory.createAlgorithm(data, parameters, ciContext); + trackAlgorithmIfPossible(algorithm); + + // execute the algorithm + Data[] outData = tryExecutingAlgorithm(algorithm); + if (outData == null) return null; + + // process and return the algorithm's output + doParentage(outData); + outData = removeNullData(outData); + addDataToDataManager(outData); - // ConfigurationAdmin may be null - public AlgorithmWrapper(ServiceReference ref, CIShellContext ciContext, BundleContext bContext, - Data[] originalData, Data[] data, Converter[][] converters, ConfigurationAdmin ca) { - this.algFactoryRef = ref; - this.bContext = bContext; - this.ciContext = ciContext; - this.originalData = originalData; - this.convertableData = data; - this.converters = converters; + return outData; + } + + protected Data[] removeNullData(Data[] outData) { + if (outData != null) { + List goodData = new ArrayList(); + for (int i=0; i < outData.length; i++) { + if (outData[i] != null) { + goodData.add(outData[i]); + } + } + + outData = (Data[]) goodData.toArray(new Data[0]); + } + + return outData; + } + + protected void addDataToDataManager(Data[] outData) { + if (outData != null) { + DataManagerService dataManager = (DataManagerService) + bContext.getService(bContext.getServiceReference( + DataManagerService.class.getName())); + + if (outData.length != 0) { + dataManager.setSelectedData(outData); + } + } + } + + protected Data[] tryExecutingAlgorithm(Algorithm algorithm) { + Data[] outData = null; + try { + outData = algorithm.execute(); + } catch (AlgorithmExecutionException e) { + log(LogService.LOG_ERROR, + "The Algorithm: \""+ref.getProperty(AlgorithmProperty.LABEL)+ + "\" had an error while executing: "+e.getMessage()); + } catch (RuntimeException e) { + GUIBuilderService builder = (GUIBuilderService) + ciContext.getService(GUIBuilderService.class.getName()); + + builder.showError("Error!", "An unexpected exception occurred while " + +"executing \""+ref.getProperty(AlgorithmProperty.LABEL)+".\"", e); + } + + return outData; + } + + protected boolean tryConvertingDataToRequiredFormat(Data[] data, Converter[][] converters) { + for (int i=0; i < data.length; i++) { + if (converters[i] != null) { + try { + data[i] = converters[i][0].convert(data[i]); + } catch (ConversionException e) { + log(LogService.LOG_ERROR,"The conversion of data to give" + + " the algorithm failed for this reason: "+e.getMessage(), e); + return false; + } - this.ca = ca; - this.progressMonitor = null; - this.builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); - this.dataManager = (DataManagerService) bContext.getService(bContext - .getServiceReference(DataManagerService.class.getName())); - } + if (data[i] == null && i < (data.length - 1)) { + log(LogService.LOG_ERROR, "The converter: " + + converters[i].getClass().getName() + + " returned a null result where data was expected when" + + " converting the data to give the algorithm."); + return false; + } + converters[i] = null; + } + } + + return true; + } + + protected boolean testDataValidityIfPossible(AlgorithmFactory factory, Data[] data) { + if (factory instanceof DataValidator) { + String validation = ((DataValidator) factory).validate(data); + + if (validation != null && validation.length() > 0) { + String label = (String) ref.getProperty(LABEL); + if (label == null) { + label = "Algorithm"; + } + + log(LogService.LOG_ERROR,"INVALID DATA: The data given to \""+label+"\" is incompatible for this reason: "+validation); + return false; + } + } + + return true; + } + + protected String getMetaTypeID(ServiceReference ref) { + String pid = (String)ref.getProperty(Constants.SERVICE_PID); + String metatype_pid = (String) ref.getProperty(PARAMETERS_PID); + + if (metatype_pid == null) { + metatype_pid = pid; + } + + return metatype_pid; + } + + protected MetaTypeProvider getPossiblyMutatedMetaTypeProvider(String metatype_pid, String pid, AlgorithmFactory factory) { + MetaTypeProvider provider = null; + + MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); + if (metaTypeService != null) { + provider = metaTypeService.getMetaTypeInformation(ref.getBundle()); + } - /** - * @see org.cishell.framework.algorithm.Algorithm#execute() - */ - public Data[] execute() { - try { - // prepare to run the algorithm - Data[] data = convertDataToRequiredFormat(this.convertableData, this.converters); - AlgorithmFactory algFactory = (AlgorithmFactory) bContext.getService(algFactoryRef); - boolean inputIsValid = testDataValidityIfPossible(algFactory, data); - if (!inputIsValid) return null; - - // create algorithm parameters - - MetaTypeProvider parameterSetupInfo = obtainParameterSetupInfo(algFactory, data); - Dictionary parameters = createParameters(parameterSetupInfo); - printParameters(parameters, parameterSetupInfo); - - // create the algorithm - - Algorithm algorithm = algFactory.createAlgorithm(data, parameters, ciContext); - trackAlgorithmProgressIfPossible(algorithm); - - // execute the algorithm - - Data[] rawOutData = algorithm.execute(); - - // return the algorithm's output - - Data[] processedOutData = processOutData(rawOutData); - return processedOutData; - - } catch (Throwable e) { - // show any errors to the user - - showGenericExecutionError(e); - return new Data[0]; - } - } - - // should return null if algorithm is not progress trackable - public ProgressMonitor getProgressMonitor() { - return progressMonitor; - } - - public void setProgressMonitor(ProgressMonitor monitor) { - progressMonitor = monitor; - } - - protected Data[] convertDataToRequiredFormat(Data[] data, Converter[][] converters) throws Exception { - // convert data into the in_data format of the algorithm we are trying to run - for (int i = 0; i < data.length; i++) { - if (converters[i] != null) { - // WARNING: arbitrarily chooses first converter out of a list of possible converters - data[i] = converters[i][0].convert(data[i]); - if (data[i] == null && i < (data.length - 1)) { - Exception e = new Exception("The converter " + converters[i].getClass().getName() - + " returned a null result where data was expected."); - throw e; - } - converters[i] = null; - } - } - - return data; - } - - protected boolean testDataValidityIfPossible(AlgorithmFactory algFactory, Data[] dataInQuestion) { - if (algFactory instanceof DataValidator) { - String validation = ((DataValidator) algFactory).validate(dataInQuestion); - - if (validation != null && validation.length() > 0) { - String label = (String) algFactoryRef.getProperty(LABEL); - if (label == null) { - label = "Algorithm"; - } - - builder.showError("Invalid Data", "The data given to \"" + label + "\" is incompatible for this reason: " - + validation, (String) null); - return false; - } - return true; - } else { - //counts as valid if there is no validator available. - return true; - } - } - - protected MetaTypeProvider obtainParameterSetupInfo(AlgorithmFactory algFactory, Data[] data) { - - MetaTypeProvider provider = null; - - // first, get the standard parameter setup info for the algorithm factory. - - MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); - if (metaTypeService != null) { - provider = metaTypeService.getMetaTypeInformation(algFactoryRef.getBundle()); - } - - // if the algorithm factory wants to mutate the parameter setup info, allow it to. - if (algFactory instanceof ParameterMutator && provider != null) { - String parameterPID = determineParameterPID(algFactoryRef, provider); - try { - ObjectClassDefinition ocd = provider.getObjectClassDefinition(parameterPID, null); - - ocd = ((ParameterMutator) algFactory).mutateParameters(data, ocd); - - if (ocd != null) { - provider = new BasicMetaTypeProvider(ocd); - } - } catch (IllegalArgumentException e) { - LogService logger = getLogService(); - logger.log(LogService.LOG_DEBUG, algFactoryRef.getProperty(Constants.SERVICE_PID) - + " has an invalid metatype parameter id: " + parameterPID); - } - } - - // wrap the parameter setup info so that default parameter values - // specified in the user preference service are filled in. - - if (provider != null) { - provider = wrapProvider(this.algFactoryRef, provider); - } - - return provider; - } - - protected Dictionary createParameters(MetaTypeProvider parameterSetupInfo) { - // ask the user to specify the values for algorithm's parameters - String parameterPID = determineParameterPID(algFactoryRef, parameterSetupInfo); - Dictionary parameters = new Hashtable(); - if (parameterSetupInfo != null) { - parameters = builder.createGUIandWait(parameterPID, parameterSetupInfo); - } - return parameters; - } - - protected void printParameters(Dictionary parameters, MetaTypeProvider parameterSetupInfo) { - LogService logger = getLogService(); - Map idToLabelMap = createIdToLabelMap(parameterSetupInfo); - - if (logger != null) { - if (parameters.isEmpty()) { - // adjust to log all input parameters in one block - StringBuffer inputParams = new StringBuffer("\n" + "Input Parameters:"); - - for (Enumeration e = parameters.keys(); e.hasMoreElements();) { - String key = (String) e.nextElement(); - Object value = parameters.get(key); - - key = (String) idToLabelMap.get(key); - inputParams.append("\n" + key + ": " + value); - - } - logger.log(LogService.LOG_INFO, inputParams.toString()); - } - } - } - - protected void trackAlgorithmProgressIfPossible(Algorithm algorithm) { - if (algorithm instanceof ProgressTrackable) { - ((ProgressTrackable) algorithm).setProgressMonitor(progressMonitor); - } - } - - protected Data[] processOutData(Data[] rawOutData) { - if (rawOutData != null) { - doParentage(rawOutData); - List goodData = new ArrayList(); - for (int i = 0; i < rawOutData.length; i++) { - if (rawOutData[i] != null) { - goodData.add(rawOutData[i]); - } - } - - Data[] processedOutData = (Data[]) goodData.toArray(new Data[goodData.size()]); - if (rawOutData.length != 0) { - dataManager.setSelectedData(rawOutData); - } - - return processedOutData; - } else { - return null; - } - } - + 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); + } + } + + if (provider != null) { + provider = wrapProvider(ref, provider); + } + + return provider; + } + + protected void trackAlgorithmIfPossible(Algorithm algorithm) { + if (progressMonitor != null && algorithm instanceof ProgressTrackable) { + ((ProgressTrackable)algorithm).setProgressMonitor(progressMonitor); + } + } + + protected Dictionary getUserEnteredParameters(String metatype_pid, MetaTypeProvider provider) { + Dictionary parameters = new Hashtable(); + if (provider != null) { + GUIBuilderService builder = (GUIBuilderService) + ciContext.getService(GUIBuilderService.class.getName()); + + parameters = builder.createGUIandWait(metatype_pid, provider); + } + + return parameters; + } + // wrap the provider to provide special functionality, such as overriding default values of attributes through // preferences. protected MetaTypeProvider wrapProvider(ServiceReference algRef, MetaTypeProvider unwrappedProvider) { + ConfigurationAdmin ca = getConfigurationAdmin(); + if (ca != null && hasParamDefaultPreferences(algRef)) { String standardServicePID = (String) algRef.getProperty(Constants.SERVICE_PID); String paramOverrideConfPID = standardServicePID + UserPrefsProperty.PARAM_PREFS_CONF_SUFFIX; @@ -285,107 +284,156 @@ return unwrappedProvider; } - - protected String determineParameterPID(ServiceReference ref, MetaTypeProvider provider) { - String overridePID = (String) ref.getProperty(AlgorithmProperty.PARAMETERS_PID); - if (overridePID != null) { - return overridePID; - } else { - return (String) ref.getProperty(Constants.SERVICE_PID); + + protected boolean hasParamDefaultPreferences(ServiceReference algRef) { + String prefsToPublish = (String) algRef.getProperty(UserPrefsProperty.PREFS_PUBLISHED_KEY); + if (prefsToPublish == null) { + return true; } - } - protected Map createIdToLabelMap(MetaTypeProvider parameterSetupInfo) { - Map idToLabelMap = new HashMap(); - if (parameterSetupInfo != null) { - ObjectClassDefinition ocd = null; - try { - String parameterPID = determineParameterPID(algFactoryRef, parameterSetupInfo); - ocd = parameterSetupInfo.getObjectClassDefinition(parameterPID, null); - - if (ocd != null) { - AttributeDefinition[] attr = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); - - for (int i = 0; i < attr.length; i++) { - String id = attr[i].getID(); - String label = attr[i].getName(); - - idToLabelMap.put(id, label); - } - } - } catch (IllegalArgumentException e) { - } - } - - return idToLabelMap; + return prefsToPublish.contains(UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE); } + + protected void log(int logLevel, String message) { + LogService log = (LogService) ciContext.getService(LogService.class.getName()); + if (log != null) { + log.log(logLevel, message); + } else { + System.out.println(message); + } + } - // only does anything if parentage=default so far... - protected void doParentage(Data[] outData) { - // make sure the parent set is the original Data and not the - // converted data... - if (outData != null && convertableData != null && originalData != null - && originalData.length == convertableData.length) { - for (int i = 0; i < outData.length; i++) { - if (outData[i] != null) { - Object parent = outData[i].getMetadata().get(DataProperty.PARENT); - - if (parent != null) { - for (int j = 0; j < convertableData.length; i++) { - if (parent == convertableData[j]) { - outData[i].getMetadata().put(DataProperty.PARENT, originalData[j]); - break; - } - } - } - } - } - } - - // check and act on parentage settings - String parentage = (String) algFactoryRef.getProperty("parentage"); - if (parentage != null) { - parentage = parentage.trim(); - if (parentage.equalsIgnoreCase("default")) { - if (originalData != null && originalData.length > 0 && originalData[0] != null) { - - for (int i = 0; i < outData.length; i++) { - // if they don't have a parent set already then we set one - if (outData[i] != null && outData[i].getMetadata().get(DataProperty.PARENT) == null) { - outData[i].getMetadata().put(DataProperty.PARENT, originalData[0]); - } - } - } - } - } - } - - protected LogService getLogService() { + protected void log(int logLevel, String message, Throwable exception) { + LogService log = (LogService) ciContext.getService(LogService.class.getName()); + if (log != null) { + log.log(logLevel, message, exception); + } else { + System.out.println(message); + exception.printStackTrace(); + } + } + + protected void printParameters(String metatype_pid, MetaTypeProvider provider, Dictionary parameters) { + LogService logger = getLogService(); + Map idToLabelMap = setupIdToLabelMap(metatype_pid, provider); + + if (logger != null && !parameters.isEmpty()) { + //adjust to log all input parameters in one block + StringBuffer inputParams = new StringBuffer("\n"+"Input Parameters:"); + + for (Enumeration e = parameters.keys(); e + .hasMoreElements();) { + String key = (String) e.nextElement(); + Object value = parameters.get(key); + + key = (String) idToLabelMap.get(key); + inputParams.append("\n"+key+": "+value); + + } + logger.log(LogService.LOG_INFO, inputParams.toString()); + } + } + + protected Map setupIdToLabelMap(String metatype_pid, MetaTypeProvider provider) { + Map idToLabelMap = new HashMap(); + if (provider != null) { + ObjectClassDefinition ocd = null; + try { + ocd = provider.getObjectClassDefinition(metatype_pid, null); + + if (ocd != null) { + AttributeDefinition[] attr = + ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); + + for (int i=0; i < attr.length; i++) { + String id = attr[i].getID(); + String label = attr[i].getName(); + + idToLabelMap.put(id, label); + } + } + } catch (IllegalArgumentException e) {} + } + + return idToLabelMap; + } + + //only does anything if parentage=default so far... + protected void doParentage(Data[] outData) { + //make sure the parent set is the original Data and not the + //converted data... + if (outData != null && data != null && originalData != null + && originalData.length == data.length) { + for (int i=0; i < outData.length; i++) { + if (outData[i] != null) { + Object parent = outData[i].getMetadata().get(DataProperty.PARENT); + + if (parent != null) { + for (int j=0; j < data.length; i++) { + if (parent == data[j]) { + outData[i].getMetadata().put(DataProperty.PARENT, + originalData[j]); + break; + } + } + } + } + } + } + + //check and act on parentage settings + String parentage = (String)ref.getProperty("parentage"); + if (parentage != null) { + parentage = parentage.trim(); + if (parentage.equalsIgnoreCase("default")) { + if (originalData != null && originalData.length > 0 && originalData[0] != null) { + + for (int i=0; i < outData.length; i++) { + //if they don't have a parent set already then we set one + if (outData[i] != null && + outData[i].getMetadata().get(DataProperty.PARENT) == null) { + outData[i].getMetadata().put(DataProperty.PARENT, originalData[0]); + } + } + } + } + } + } + + private LogService getLogService() { ServiceReference serviceReference = bContext.getServiceReference(DataManagerService.class.getName()); LogService log = null; - + if (serviceReference != null) { - log = (LogService) bContext.getService(bContext.getServiceReference(LogService.class.getName())); + log = (LogService) bContext.getService( + bContext.getServiceReference(LogService.class.getName())); } - + return log; } - - protected boolean hasParamDefaultPreferences(ServiceReference algRef) { - String prefsToPublish = (String) algRef.getProperty(UserPrefsProperty.PREFS_PUBLISHED_KEY); - if (prefsToPublish == null) { - return true; + + private ConfigurationAdmin getConfigurationAdmin() { + ServiceReference serviceReference = bContext.getServiceReference(ConfigurationAdmin.class.getName()); + ConfigurationAdmin ca = null; + + if (serviceReference != null) { + ca = (ConfigurationAdmin) bContext.getService( + bContext.getServiceReference(ConfigurationAdmin.class.getName())); } + + return ca; + } - if (prefsToPublish.contains(UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE)) { - return true; - } else { - return false; + public ProgressMonitor getProgressMonitor() { + if (algorithm instanceof ProgressTrackable) { + return progressMonitor; } + else { + return null; + } } - protected void showGenericExecutionError(Throwable e) { - builder.showError("Error!", "The Algorithm: \"" + algFactoryRef.getProperty(AlgorithmProperty.LABEL) - + "\" had an error while executing.", e); + public void setProgressMonitor(ProgressMonitor monitor) { + progressMonitor = monitor; } } 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-04-02 19:37:27 UTC (rev 772) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-04-03 16:04:19 UTC (rev 773) @@ -42,7 +42,6 @@ import org.osgi.framework.ServiceEvent; import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; -import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.log.LogService; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -62,7 +61,6 @@ private ContextListener listener; private IWorkbenchWindow window; - private ConfigurationAdmin ca; /* * This map holds a pid as a key and the corresponding * ServiceReference as a value. @@ -116,24 +114,8 @@ } catch (InvalidSyntaxException e) { getLog().log(LogService.LOG_DEBUG, "Invalid Syntax", e); } - - attemptToObtainConfigurationAdmin(bContext); } - - private void attemptToObtainConfigurationAdmin(BundleContext bContext) { - if (ca == null) { - try { - ServiceReference caRef = bContext.getServiceReference(ConfigurationAdmin.class.getName()); - if (caRef != null) { - ConfigurationAdmin ca = (ConfigurationAdmin) bContext.getService(caRef); - this.ca = ca; //may or may not be null, but if it is null, its the same as if we never tried to set it (that is to say, ok) - } - } catch (NoClassDefFoundError e) { - //do nothing - } - } - } - + /* * This method scans all service bundles. If a bundle specifies * menu_path, get service.pid of this bundle (key), let the service @@ -278,8 +260,7 @@ ServiceReference ref = (ServiceReference) pidToServiceReferenceMapCopy. get(pid.toLowerCase().trim()); pidToServiceReferenceMap.remove(pid.toLowerCase().trim()); - attemptToObtainConfigurationAdmin(bContext); - AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext, ca); + AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext); action.setId(getItemID(ref)); action.setText(menuName); parentMenuBar.add(action); @@ -365,8 +346,7 @@ String[] items = (path == null) ? null : path.split("/"); IMenuManager menu = null; if (items != null && items.length > 1) { - attemptToObtainConfigurationAdmin(bContext); - AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext, ca); + AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext); action.setId(getItemID(ref)); IMenuManager targetMenu = menuBar; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 19:37:40
|
Revision: 772 http://cishell.svn.sourceforge.net/cishell/?rev=772&view=rev Author: mwlinnem Date: 2008-04-02 12:37:27 -0700 (Wed, 02 Apr 2008) Log Message: ----------- oops, forgot "osgi.bundles=" Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini Modified: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-04-02 19:19:39 UTC (rev 771) +++ trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-04-02 19:37:27 UTC (rev 772) @@ -2,5 +2,5 @@ osgi.splashPath=platform:/base/plugins/org.cishell.reference.gui.brand.cishell eclipse.product=org.cishell.reference.gui.brand.cishell.cishell -org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start, org.eclipse.equinox.cm@3:start, org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start +osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start,org.eclipse.equinox.cm@3:start,org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start osgi.bundles.defaultStartLevel=4 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 19:19:41
|
Revision: 771 http://cishell.svn.sourceforge.net/cishell/?rev=771&view=rev Author: mwlinnem Date: 2008-04-02 12:19:39 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Added configuration admin plugin to the base equinox feature Modified Paths: -------------- trunk/deployment/org.cishell.environment.equinox.feature/feature.xml Modified: trunk/deployment/org.cishell.environment.equinox.feature/feature.xml =================================================================== --- trunk/deployment/org.cishell.environment.equinox.feature/feature.xml 2008-04-02 19:11:43 UTC (rev 770) +++ trunk/deployment/org.cishell.environment.equinox.feature/feature.xml 2008-04-02 19:19:39 UTC (rev 771) @@ -614,4 +614,11 @@ version="0.0.0" unpack="false"/> + <plugin + id="org.eclipse.equinox.cm" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + </feature> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 19:11:59
|
Revision: 770 http://cishell.svn.sourceforge.net/cishell/?rev=770&view=rev Author: mwlinnem Date: 2008-04-02 12:11:43 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Added user-adjustable preferences plugins to the build system Modified Paths: -------------- trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml Modified: trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml =================================================================== --- trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml 2008-04-02 19:05:43 UTC (rev 769) +++ trunk/deployment/org.cishell.reference.releng/build-files/fetchSvnAll.xml 2008-04-02 19:11:43 UTC (rev 770) @@ -44,6 +44,12 @@ </antcall> <antcall target="svn.co"> <param name="target" value="plugins"/> + <param name="element.id" value="org.cishell.reference.prefs.admin"/> + <param name="project.name" value="/core/org.cishell.reference.prefs.admin"/> + <param name="url" value="https://cishell.svn.sourceforge.net/svnroot/cishell/trunk"/> + </antcall> + <antcall target="svn.co"> + <param name="target" value="plugins"/> <param name="element.id" value="org.cishell.service.autostart"/> <param name="project.name" value="/core/org.cishell.service.autostart"/> <param name="url" value="https://cishell.svn.sourceforge.net/svnroot/cishell/trunk"/> @@ -116,6 +122,12 @@ </antcall> <antcall target="svn.co"> <param name="target" value="plugins"/> + <param name="element.id" value="org.cishell.reference.gui.prefs.swt"/> + <param name="project.name" value="/clients/gui/org.cishell.reference.gui.prefs.swt"/> + <param name="url" value="https://cishell.svn.sourceforge.net/svnroot/cishell/trunk"/> + </antcall> + <antcall target="svn.co"> + <param name="target" value="plugins"/> <param name="element.id" value="org.cishell.reference.gui.workspace"/> <param name="project.name" value="/clients/gui/org.cishell.reference.gui.workspace"/> <param name="url" value="https://cishell.svn.sourceforge.net/svnroot/cishell/trunk"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 19:06:00
|
Revision: 769 http://cishell.svn.sourceforge.net/cishell/?rev=769&view=rev Author: mwlinnem Date: 2008-04-02 12:05:43 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Added user-adjustable preferences plugins to their respective features Modified Paths: -------------- trunk/deployment/org.cishell.reference.feature/feature.xml trunk/deployment/org.cishell.reference.gui.feature/feature.xml Modified: trunk/deployment/org.cishell.reference.feature/feature.xml =================================================================== --- trunk/deployment/org.cishell.reference.feature/feature.xml 2008-04-02 18:56:25 UTC (rev 768) +++ trunk/deployment/org.cishell.reference.feature/feature.xml 2008-04-02 19:05:43 UTC (rev 769) @@ -100,4 +100,11 @@ install-size="0" version="0.0.0"/> + <plugin + id="org.cishell.reference.prefs.admin" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + </feature> Modified: trunk/deployment/org.cishell.reference.gui.feature/feature.xml =================================================================== --- trunk/deployment/org.cishell.reference.gui.feature/feature.xml 2008-04-02 18:56:25 UTC (rev 768) +++ trunk/deployment/org.cishell.reference.gui.feature/feature.xml 2008-04-02 19:05:43 UTC (rev 769) @@ -85,4 +85,11 @@ version="0.0.0" unpack="false"/> + <plugin + id="org.cishell.reference.gui.prefs.swt" + download-size="0" + install-size="0" + version="0.0.0" + unpack="false"/> + </feature> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:56:27
|
Revision: 768 http://cishell.svn.sourceforge.net/cishell/?rev=768&view=rev Author: mwlinnem Date: 2008-04-02 11:56:25 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Removed pref admin from startup. Not necessary apparently, and fixed bug with new declarative services. Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini Modified: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-04-02 18:22:51 UTC (rev 767) +++ trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-04-02 18:56:25 UTC (rev 768) @@ -2,5 +2,5 @@ osgi.splashPath=platform:/base/plugins/org.cishell.reference.gui.brand.cishell eclipse.product=org.cishell.reference.gui.brand.cishell.cishell -org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start, org.eclipse.equinox.cm@3:start, org.cishell.reference.prefs.admin@3:start, org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start +org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start, org.eclipse.equinox.cm@3:start, org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start osgi.bundles.defaultStartLevel=4 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:22:54
|
Revision: 767 http://cishell.svn.sourceforge.net/cishell/?rev=767&view=rev Author: mwlinnem Date: 2008-04-02 11:22:51 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Added Paths: ----------- trunk/examples/org.cishell.tests.userprefs.localandparam1/ Removed Paths: ------------- trunk/examples/org.cishell.testalgorithm4/ Copied: trunk/examples/org.cishell.tests.userprefs.localandparam1 (from rev 766, trunk/examples/org.cishell.testalgorithm4) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:22:02
|
Revision: 766 http://cishell.svn.sourceforge.net/cishell/?rev=766&view=rev Author: mwlinnem Date: 2008-04-02 11:21:59 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Added Paths: ----------- trunk/examples/org.cishell.tests.userprefs.global1/ Removed Paths: ------------- trunk/examples/org.cishell.testalgorithm3/ Copied: trunk/examples/org.cishell.tests.userprefs.global1 (from rev 765, trunk/examples/org.cishell.testalgorithm3) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:21:12
|
Revision: 765 http://cishell.svn.sourceforge.net/cishell/?rev=765&view=rev Author: mwlinnem Date: 2008-04-02 11:21:09 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Added Paths: ----------- trunk/examples/org.cishell.tests.userprefs.local1/ Removed Paths: ------------- trunk/examples/org.cishell.testalgorithm2/ Copied: trunk/examples/org.cishell.tests.userprefs.local1 (from rev 764, trunk/examples/org.cishell.testalgorithm2) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:19:32
|
Revision: 764 http://cishell.svn.sourceforge.net/cishell/?rev=764&view=rev Author: mwlinnem Date: 2008-04-02 11:19:30 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Example of local preferences in use. Added Paths: ----------- trunk/examples/org.cishell.testalgorithm4/ Copied: trunk/examples/org.cishell.testalgorithm4 (from rev 763, branches/user_prefs/org.cishell.testalgorithm4) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:19:13
|
Revision: 763 http://cishell.svn.sourceforge.net/cishell/?rev=763&view=rev Author: mwlinnem Date: 2008-04-02 11:19:07 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Example of local preferences in use. Added Paths: ----------- trunk/examples/org.cishell.testalgorithm3/ Copied: trunk/examples/org.cishell.testalgorithm3 (from rev 762, branches/user_prefs/org.cishell.testalgorithm3) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:18:43
|
Revision: 762 http://cishell.svn.sourceforge.net/cishell/?rev=762&view=rev Author: mwlinnem Date: 2008-04-02 11:18:40 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Example of local preferences in use. Added Paths: ----------- trunk/examples/org.cishell.testalgorithm2/ Copied: trunk/examples/org.cishell.testalgorithm2 (from rev 761, branches/user_prefs/org.cishell.testalgorithm2) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:17:37
|
Revision: 761 http://cishell.svn.sourceforge.net/cishell/?rev=761&view=rev Author: mwlinnem Date: 2008-04-02 11:17:35 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Added from user preferences branch. Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.prefs.swt/ Copied: trunk/clients/gui/org.cishell.reference.gui.prefs.swt (from rev 760, branches/user_prefs/org.cishell.reference.gui.prefs.swt) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:17:06
|
Revision: 760 http://cishell.svn.sourceforge.net/cishell/?rev=760&view=rev Author: mwlinnem Date: 2008-04-02 11:17:00 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Copied from user preferences branch. Added Paths: ----------- trunk/core/org.cishell.reference.prefs.admin/ Copied: trunk/core/org.cishell.reference.prefs.admin (from rev 759, branches/user_prefs/org.cishell.reference.prefs.admin) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:15:48
|
Revision: 759 http://cishell.svn.sourceforge.net/cishell/?rev=759&view=rev Author: mwlinnem Date: 2008-04-02 11:15:38 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Oops. Wrong location. Removed Paths: ------------- trunk/clients/gui/org.cishell.reference.prefs.admin/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:14:34
|
Revision: 758 http://cishell.svn.sourceforge.net/cishell/?rev=758&view=rev Author: mwlinnem Date: 2008-04-02 11:14:20 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Copied from user prefs branch to trunk. Added Paths: ----------- trunk/clients/gui/org.cishell.reference.prefs.admin/ Copied: trunk/clients/gui/org.cishell.reference.prefs.admin (from rev 757, branches/user_prefs/org.cishell.reference.prefs.admin) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:12:36
|
Revision: 757 http://cishell.svn.sourceforge.net/cishell/?rev=757&view=rev Author: mwlinnem Date: 2008-04-02 11:12:33 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Added user prefs stuff to main branch (includes major refactoring). 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/menu/AlgorithmAction.java 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/MenuAdapter.java Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java Removed Paths: ------------- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.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-04-02 18:06:52 UTC (rev 756) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-04-02 18:12:33 UTC (rev 757) @@ -12,9 +12,11 @@ org.cishell.framework;version="1.0.0", org.cishell.framework.algorithm;version="1.0.0", org.cishell.framework.data;version="1.0.0", + org.cishell.framework.userprefs;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.cm;version="1.2.0", org.osgi.service.log;version="1.3.0", org.osgi.service.metatype;version="1.1.0" Modified: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-04-02 18:06:52 UTC (rev 756) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-04-02 18:12:33 UTC (rev 757) @@ -28,6 +28,7 @@ import org.eclipse.jface.action.Action; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.log.LogService; @@ -39,10 +40,14 @@ protected Data[] originalData; protected Converter[][] converters; - public AlgorithmAction(ServiceReference ref, BundleContext bContext, CIShellContext ciContext) { + protected ConfigurationAdmin ca; + + //ConfigurationAdmin can be null + public AlgorithmAction(ServiceReference ref, BundleContext bContext, CIShellContext ciContext, ConfigurationAdmin ca) { this.ref = ref; this.ciContext = ciContext; this.bContext = bContext; + this.ca = ca; setText((String)ref.getProperty(LABEL)); setToolTipText((String)ref.getProperty(AlgorithmProperty.DESCRIPTION)); @@ -92,7 +97,7 @@ printAlgorithmInformation(); - scheduler.schedule(new AlgorithmWrapper(ref, bContext, ciContext, originalData, data, converters), ref); + scheduler.schedule(new AlgorithmWrapper(ref, ciContext, bContext, originalData, data, converters, ca), ref); } catch (Throwable e) { e.printStackTrace(); } @@ -150,7 +155,7 @@ Data datum = (Data) dataSet.get(j); if (datum != null) { - if (isAsignableFrom(inData[i], datum)) { + if (isAssignableFrom(inData[i], datum)) { dataSet.remove(j); data[i] = datum; converters[i] = null; @@ -185,7 +190,7 @@ setEnabled(data != null); //&& isValid()); } - private boolean isAsignableFrom(String type, Data datum) { + private boolean isAssignableFrom(String type, Data datum) { Object data = datum.getData(); boolean assignable = false; 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-04-02 18:06:52 UTC (rev 756) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-04-02 18:12:33 UTC (rev 757) @@ -13,6 +13,7 @@ * ***************************************************************************/ package org.cishell.reference.gui.menumanager.menu; +import java.io.IOException; import java.util.ArrayList; import java.util.Dictionary; import java.util.Enumeration; @@ -24,7 +25,6 @@ import org.cishell.app.service.datamanager.DataManagerService; import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; -import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.algorithm.AlgorithmFactory; import org.cishell.framework.algorithm.AlgorithmProperty; import org.cishell.framework.algorithm.DataValidator; @@ -33,302 +33,359 @@ import org.cishell.framework.algorithm.ProgressTrackable; import org.cishell.framework.data.Data; import org.cishell.framework.data.DataProperty; +import org.cishell.framework.userprefs.UserPrefsProperty; import org.cishell.reference.gui.menumanager.Activator; +import org.cishell.reference.gui.menumanager.menu.metatypewrapper.ParamMetaTypeProvider; import org.cishell.reference.service.metatype.BasicMetaTypeProvider; -import org.cishell.service.conversion.ConversionException; import org.cishell.service.conversion.Converter; import org.cishell.service.guibuilder.GUIBuilderService; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; 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; - public class AlgorithmWrapper implements Algorithm, AlgorithmProperty, ProgressTrackable { - protected ServiceReference ref; - protected BundleContext bContext; - protected CIShellContext ciContext; - protected Data[] originalData; - protected Data[] data; - protected Converter[][] converters; - 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, - Converter[][] converters) { - this.ref = ref; - this.bContext = bContext; - this.ciContext = ciContext; - this.originalData = originalData; - this.data = data; - this.converters = converters; + protected ServiceReference algFactoryRef; + protected BundleContext bContext; + protected CIShellContext ciContext; + protected Data[] originalData; + protected Data[] convertableData; + protected Converter[][] converters; + protected ProgressMonitor progressMonitor; - this.idToLabelMap = new HashMap(); - this.progressMonitor = null; - } + protected ConfigurationAdmin ca; + protected GUIBuilderService builder; + protected DataManagerService dataManager; - /** - * @see org.cishell.framework.algorithm.Algorithm#execute() - */ - public Data[] execute() { - for (int i=0; i < data.length; i++) { - if (converters[i] != null) { - try { - data[i] = converters[i][0].convert(data[i]); - } catch (ConversionException e) { - log(LogService.LOG_ERROR,"The conversion of data to give" + - " the algorithm failed for this reason: "+e.getMessage(), e); - return null; - } + // ConfigurationAdmin may be null + public AlgorithmWrapper(ServiceReference ref, CIShellContext ciContext, BundleContext bContext, + Data[] originalData, Data[] data, Converter[][] converters, ConfigurationAdmin ca) { + this.algFactoryRef = ref; + this.bContext = bContext; + this.ciContext = ciContext; + this.originalData = originalData; + this.convertableData = data; + this.converters = converters; - if (data[i] == null && i < (data.length - 1)) { - log(LogService.LOG_ERROR, "The converter: " + - converters[i].getClass().getName() + - " returned a null result where data was expected when" + - " converting the data to give the algorithm."); - return null; - } - converters[i] = null; - } - } - - GUIBuilderService builder = (GUIBuilderService) - ciContext.getService(GUIBuilderService.class.getName()); - - AlgorithmFactory factory = (AlgorithmFactory) bContext.getService(ref); - - if (factory instanceof DataValidator) { - String validation = ((DataValidator) factory).validate(data); - - if (validation != null && validation.length() > 0) { - String label = (String) ref.getProperty(LABEL); - if (label == null) { - label = "Algorithm"; - } - - log(LogService.LOG_ERROR,"INVALID DATA: The data given to \""+label+"\" is incompatible for this reason: "+validation); - return 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.ca = ca; + this.progressMonitor = null; + this.builder = (GUIBuilderService) ciContext.getService(GUIBuilderService.class.getName()); + this.dataManager = (DataManagerService) bContext.getService(bContext + .getServiceReference(DataManagerService.class.getName())); + } - this.provider = null; - - MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); - if (metaTypeService != null) { - provider = metaTypeService.getMetaTypeInformation(ref.getBundle()); - } + /** + * @see org.cishell.framework.algorithm.Algorithm#execute() + */ + public Data[] execute() { + try { + // prepare to run the algorithm + Data[] data = convertDataToRequiredFormat(this.convertableData, this.converters); + AlgorithmFactory algFactory = (AlgorithmFactory) bContext.getService(algFactoryRef); + boolean inputIsValid = testDataValidityIfPossible(algFactory, data); + if (!inputIsValid) return null; - 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(metatype_pid, provider); - } - - //check to see if the user cancelled the operation - if(this.parameters == null) { - return null; - } - - algorithm = factory.createAlgorithm(data, parameters, ciContext); - - printParameters(); - - if (progressMonitor != null && algorithm instanceof ProgressTrackable) { - ((ProgressTrackable)algorithm).setProgressMonitor(progressMonitor); - } - - Data[] outData = null; - try { - outData = algorithm.execute(); - } catch (AlgorithmExecutionException e) { - log(LogService.LOG_ERROR, - "The Algorithm: \""+ref.getProperty(AlgorithmProperty.LABEL)+ - "\" had an error while executing: "+e.getMessage()); - } catch (RuntimeException e) { - builder.showError("Error!", "An unexpected exception occurred while " - +"executing \""+ref.getProperty(AlgorithmProperty.LABEL)+".\"", e); - } - - if (outData != null) { - DataManagerService dataManager = (DataManagerService) - bContext.getService(bContext.getServiceReference( - DataManagerService.class.getName())); - - doParentage(outData); - - List goodData = new ArrayList(); - for (int i=0; i < outData.length; i++) { - if (outData[i] != null) { - goodData.add(outData[i]); - } - } - - outData = (Data[]) goodData.toArray(new Data[0]); - - if (outData.length != 0) { - dataManager.setSelectedData(outData); - } - } - - return outData; - } - - 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); - } - } + // create algorithm parameters - protected void log(int logLevel, String message, Throwable exception) { - LogService log = (LogService) Activator.getService(LogService.class.getName()); - if (log != null) { - log.log(logLevel, message, exception); - } else { - System.out.println(message); - exception.printStackTrace(); - } - } - - protected void printParameters() { - LogService logger = getLogService(); - setupIdToLabelMap(); - - if (logger != null) { - if (!this.parameters.isEmpty()) { - //adjust to log all input parameters in one block - StringBuffer inputParams = new StringBuffer("\n"+"Input Parameters:"); - - for (Enumeration e = this.parameters.keys(); e - .hasMoreElements();) { - String key = (String) e.nextElement(); - Object value = this.parameters.get(key); - - key = (String) idToLabelMap.get(key); - inputParams.append("\n"+key+": "+value); - - } - logger.log(LogService.LOG_INFO, inputParams.toString()); - } - } - } - - protected void setupIdToLabelMap() { - if (provider != null) { - ObjectClassDefinition ocd = null; - try { - String pid = (String) ref.getProperty(Constants.SERVICE_PID); - ocd = provider.getObjectClassDefinition(pid, null); - - if (ocd != null) { - AttributeDefinition[] attr = - ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); - - for (int i=0; i < attr.length; i++) { - String id = attr[i].getID(); - String label = attr[i].getName(); - - idToLabelMap.put(id, label); - } - } - } catch (IllegalArgumentException e) {} - } - } - - //only does anything if parentage=default so far... - protected void doParentage(Data[] outData) { - //make sure the parent set is the original Data and not the - //converted data... - if (outData != null && data != null && originalData != null - && originalData.length == data.length) { - for (int i=0; i < outData.length; i++) { - if (outData[i] != null) { - Object parent = outData[i].getMetadata().get(DataProperty.PARENT); - - if (parent != null) { - for (int j=0; j < data.length; i++) { - if (parent == data[j]) { - outData[i].getMetadata().put(DataProperty.PARENT, - originalData[j]); - break; - } - } - } - } - } - } - - //check and act on parentage settings - String parentage = (String)ref.getProperty("parentage"); - if (parentage != null) { - parentage = parentage.trim(); - if (parentage.equalsIgnoreCase("default")) { - if (originalData != null && originalData.length > 0 && originalData[0] != null) { - - for (int i=0; i < outData.length; i++) { - //if they don't have a parent set already then we set one - if (outData[i] != null && - outData[i].getMetadata().get(DataProperty.PARENT) == null) { - outData[i].getMetadata().put(DataProperty.PARENT, originalData[0]); - } - } - } - } - } - } - - private LogService getLogService() { + MetaTypeProvider parameterSetupInfo = obtainParameterSetupInfo(algFactory, data); + Dictionary parameters = createParameters(parameterSetupInfo); + printParameters(parameters, parameterSetupInfo); + + // create the algorithm + + Algorithm algorithm = algFactory.createAlgorithm(data, parameters, ciContext); + trackAlgorithmProgressIfPossible(algorithm); + + // execute the algorithm + + Data[] rawOutData = algorithm.execute(); + + // return the algorithm's output + + Data[] processedOutData = processOutData(rawOutData); + return processedOutData; + + } catch (Throwable e) { + // show any errors to the user + + showGenericExecutionError(e); + return new Data[0]; + } + } + + // should return null if algorithm is not progress trackable + public ProgressMonitor getProgressMonitor() { + return progressMonitor; + } + + public void setProgressMonitor(ProgressMonitor monitor) { + progressMonitor = monitor; + } + + protected Data[] convertDataToRequiredFormat(Data[] data, Converter[][] converters) throws Exception { + // convert data into the in_data format of the algorithm we are trying to run + for (int i = 0; i < data.length; i++) { + if (converters[i] != null) { + // WARNING: arbitrarily chooses first converter out of a list of possible converters + data[i] = converters[i][0].convert(data[i]); + if (data[i] == null && i < (data.length - 1)) { + Exception e = new Exception("The converter " + converters[i].getClass().getName() + + " returned a null result where data was expected."); + throw e; + } + converters[i] = null; + } + } + + return data; + } + + protected boolean testDataValidityIfPossible(AlgorithmFactory algFactory, Data[] dataInQuestion) { + if (algFactory instanceof DataValidator) { + String validation = ((DataValidator) algFactory).validate(dataInQuestion); + + if (validation != null && validation.length() > 0) { + String label = (String) algFactoryRef.getProperty(LABEL); + if (label == null) { + label = "Algorithm"; + } + + builder.showError("Invalid Data", "The data given to \"" + label + "\" is incompatible for this reason: " + + validation, (String) null); + return false; + } + return true; + } else { + //counts as valid if there is no validator available. + return true; + } + } + + protected MetaTypeProvider obtainParameterSetupInfo(AlgorithmFactory algFactory, Data[] data) { + + MetaTypeProvider provider = null; + + // first, get the standard parameter setup info for the algorithm factory. + + MetaTypeService metaTypeService = (MetaTypeService) Activator.getService(MetaTypeService.class.getName()); + if (metaTypeService != null) { + provider = metaTypeService.getMetaTypeInformation(algFactoryRef.getBundle()); + } + + // if the algorithm factory wants to mutate the parameter setup info, allow it to. + if (algFactory instanceof ParameterMutator && provider != null) { + String parameterPID = determineParameterPID(algFactoryRef, provider); + try { + ObjectClassDefinition ocd = provider.getObjectClassDefinition(parameterPID, null); + + ocd = ((ParameterMutator) algFactory).mutateParameters(data, ocd); + + if (ocd != null) { + provider = new BasicMetaTypeProvider(ocd); + } + } catch (IllegalArgumentException e) { + LogService logger = getLogService(); + logger.log(LogService.LOG_DEBUG, algFactoryRef.getProperty(Constants.SERVICE_PID) + + " has an invalid metatype parameter id: " + parameterPID); + } + } + + // wrap the parameter setup info so that default parameter values + // specified in the user preference service are filled in. + + if (provider != null) { + provider = wrapProvider(this.algFactoryRef, provider); + } + + return provider; + } + + protected Dictionary createParameters(MetaTypeProvider parameterSetupInfo) { + // ask the user to specify the values for algorithm's parameters + String parameterPID = determineParameterPID(algFactoryRef, parameterSetupInfo); + Dictionary parameters = new Hashtable(); + if (parameterSetupInfo != null) { + parameters = builder.createGUIandWait(parameterPID, parameterSetupInfo); + } + return parameters; + } + + protected void printParameters(Dictionary parameters, MetaTypeProvider parameterSetupInfo) { + LogService logger = getLogService(); + Map idToLabelMap = createIdToLabelMap(parameterSetupInfo); + + if (logger != null) { + if (parameters.isEmpty()) { + // adjust to log all input parameters in one block + StringBuffer inputParams = new StringBuffer("\n" + "Input Parameters:"); + + for (Enumeration e = parameters.keys(); e.hasMoreElements();) { + String key = (String) e.nextElement(); + Object value = parameters.get(key); + + key = (String) idToLabelMap.get(key); + inputParams.append("\n" + key + ": " + value); + + } + logger.log(LogService.LOG_INFO, inputParams.toString()); + } + } + } + + protected void trackAlgorithmProgressIfPossible(Algorithm algorithm) { + if (algorithm instanceof ProgressTrackable) { + ((ProgressTrackable) algorithm).setProgressMonitor(progressMonitor); + } + } + + protected Data[] processOutData(Data[] rawOutData) { + if (rawOutData != null) { + doParentage(rawOutData); + List goodData = new ArrayList(); + for (int i = 0; i < rawOutData.length; i++) { + if (rawOutData[i] != null) { + goodData.add(rawOutData[i]); + } + } + + Data[] processedOutData = (Data[]) goodData.toArray(new Data[goodData.size()]); + if (rawOutData.length != 0) { + dataManager.setSelectedData(rawOutData); + } + + return processedOutData; + } else { + return null; + } + } + + // wrap the provider to provide special functionality, such as overriding default values of attributes through + // preferences. + protected MetaTypeProvider wrapProvider(ServiceReference algRef, MetaTypeProvider unwrappedProvider) { + if (ca != null && hasParamDefaultPreferences(algRef)) { + String standardServicePID = (String) algRef.getProperty(Constants.SERVICE_PID); + String paramOverrideConfPID = standardServicePID + UserPrefsProperty.PARAM_PREFS_CONF_SUFFIX; + try { + Configuration defaultParamValueOverrider = ca.getConfiguration(paramOverrideConfPID, null); + Dictionary defaultParamOverriderDict = defaultParamValueOverrider.getProperties(); + MetaTypeProvider wrappedProvider = new ParamMetaTypeProvider(unwrappedProvider, + defaultParamOverriderDict); + return wrappedProvider; + } catch (IOException e) { + return unwrappedProvider; + } + } else { + } + + return unwrappedProvider; + } + + protected String determineParameterPID(ServiceReference ref, MetaTypeProvider provider) { + String overridePID = (String) ref.getProperty(AlgorithmProperty.PARAMETERS_PID); + if (overridePID != null) { + return overridePID; + } else { + return (String) ref.getProperty(Constants.SERVICE_PID); + } + } + + protected Map createIdToLabelMap(MetaTypeProvider parameterSetupInfo) { + Map idToLabelMap = new HashMap(); + if (parameterSetupInfo != null) { + ObjectClassDefinition ocd = null; + try { + String parameterPID = determineParameterPID(algFactoryRef, parameterSetupInfo); + ocd = parameterSetupInfo.getObjectClassDefinition(parameterPID, null); + + if (ocd != null) { + AttributeDefinition[] attr = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); + + for (int i = 0; i < attr.length; i++) { + String id = attr[i].getID(); + String label = attr[i].getName(); + + idToLabelMap.put(id, label); + } + } + } catch (IllegalArgumentException e) { + } + } + + return idToLabelMap; + } + + // only does anything if parentage=default so far... + protected void doParentage(Data[] outData) { + // make sure the parent set is the original Data and not the + // converted data... + if (outData != null && convertableData != null && originalData != null + && originalData.length == convertableData.length) { + for (int i = 0; i < outData.length; i++) { + if (outData[i] != null) { + Object parent = outData[i].getMetadata().get(DataProperty.PARENT); + + if (parent != null) { + for (int j = 0; j < convertableData.length; i++) { + if (parent == convertableData[j]) { + outData[i].getMetadata().put(DataProperty.PARENT, originalData[j]); + break; + } + } + } + } + } + } + + // check and act on parentage settings + String parentage = (String) algFactoryRef.getProperty("parentage"); + if (parentage != null) { + parentage = parentage.trim(); + if (parentage.equalsIgnoreCase("default")) { + if (originalData != null && originalData.length > 0 && originalData[0] != null) { + + for (int i = 0; i < outData.length; i++) { + // if they don't have a parent set already then we set one + if (outData[i] != null && outData[i].getMetadata().get(DataProperty.PARENT) == null) { + outData[i].getMetadata().put(DataProperty.PARENT, originalData[0]); + } + } + } + } + } + } + + protected LogService getLogService() { ServiceReference serviceReference = bContext.getServiceReference(DataManagerService.class.getName()); LogService log = null; - + if (serviceReference != null) { - log = (LogService) bContext.getService( - bContext.getServiceReference(LogService.class.getName())); + log = (LogService) bContext.getService(bContext.getServiceReference(LogService.class.getName())); } - + return log; } - public ProgressMonitor getProgressMonitor() { - if (algorithm instanceof ProgressTrackable) { - return progressMonitor; + protected boolean hasParamDefaultPreferences(ServiceReference algRef) { + String prefsToPublish = (String) algRef.getProperty(UserPrefsProperty.PREFS_PUBLISHED_KEY); + if (prefsToPublish == null) { + return true; } - else { - return null; + + if (prefsToPublish.contains(UserPrefsProperty.PUBLISH_PARAM_DEFAULT_PREFS_VALUE)) { + return true; + } else { + return false; } } - public void setProgressMonitor(ProgressMonitor monitor) { - progressMonitor = monitor; + protected void showGenericExecutionError(Throwable e) { + builder.showError("Error!", "The Algorithm: \"" + algFactoryRef.getProperty(AlgorithmProperty.LABEL) + + "\" had an error while executing.", e); } } 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-04-02 18:06:52 UTC (rev 756) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-04-02 18:12:33 UTC (rev 757) @@ -42,6 +42,7 @@ import org.osgi.framework.ServiceEvent; import org.osgi.framework.ServiceListener; import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.log.LogService; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -60,6 +61,8 @@ private Map itemToParentMap; private ContextListener listener; private IWorkbenchWindow window; + + private ConfigurationAdmin ca; /* * This map holds a pid as a key and the corresponding * ServiceReference as a value. @@ -113,8 +116,24 @@ } catch (InvalidSyntaxException e) { getLog().log(LogService.LOG_DEBUG, "Invalid Syntax", e); } + + attemptToObtainConfigurationAdmin(bContext); } + private void attemptToObtainConfigurationAdmin(BundleContext bContext) { + if (ca == null) { + try { + ServiceReference caRef = bContext.getServiceReference(ConfigurationAdmin.class.getName()); + if (caRef != null) { + ConfigurationAdmin ca = (ConfigurationAdmin) bContext.getService(caRef); + this.ca = ca; //may or may not be null, but if it is null, its the same as if we never tried to set it (that is to say, ok) + } + } catch (NoClassDefFoundError e) { + //do nothing + } + } + } + /* * This method scans all service bundles. If a bundle specifies * menu_path, get service.pid of this bundle (key), let the service @@ -259,7 +278,8 @@ ServiceReference ref = (ServiceReference) pidToServiceReferenceMapCopy. get(pid.toLowerCase().trim()); pidToServiceReferenceMap.remove(pid.toLowerCase().trim()); - AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext); + attemptToObtainConfigurationAdmin(bContext); + AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext, ca); action.setId(getItemID(ref)); action.setText(menuName); parentMenuBar.add(action); @@ -345,7 +365,8 @@ String[] items = (path == null) ? null : path.split("/"); IMenuManager menu = null; if (items != null && items.length > 1) { - AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext); + attemptToObtainConfigurationAdmin(bContext); + AlgorithmAction action = new AlgorithmAction(ref, bContext, ciContext, ca); action.setId(getItemID(ref)); IMenuManager targetMenu = menuBar; Copied: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper (from rev 756, branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper) Deleted: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java 2008-04-02 18:06:52 UTC (rev 756) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java 2008-04-02 18:12:33 UTC (rev 757) @@ -1,62 +0,0 @@ -package org.cishell.reference.gui.menumanager.menu.metatypewrapper; - -import org.osgi.service.log.LogService; -import org.osgi.service.metatype.AttributeDefinition; - -public class ParamAD implements AttributeDefinition { - - private LogService log; - - private AttributeDefinition realAD; - - private String[] defaultValueOverride; - - public ParamAD(LogService log, AttributeDefinition realAD, String[] defaultValueOverride) { - this.log = log; - - this.realAD = realAD; - - this.defaultValueOverride = defaultValueOverride; - } - - public int getCardinality() { - return this.realAD.getCardinality(); - } - - public String[] getDefaultValue() { - if (defaultValueOverride != null) { - return defaultValueOverride; - } else { - return realAD.getDefaultValue(); - } - } - - public String getDescription() { - return this.realAD.getDescription(); - } - - public String getID() { - return this.realAD.getID(); - } - - public String getName() { - return this.realAD.getName(); - } - - public String[] getOptionLabels() { - return this.realAD.getOptionLabels(); - } - - public String[] getOptionValues() { - return this.realAD.getOptionValues(); - } - - public int getType() { - return this.realAD.getType(); - } - - public String validate(String value) { - return this.realAD.validate(value); - } - -} Copied: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java (from rev 756, branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java) =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java 2008-04-02 18:12:33 UTC (rev 757) @@ -0,0 +1,62 @@ +package org.cishell.reference.gui.menumanager.menu.metatypewrapper; + +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.AttributeDefinition; + +public class ParamAD implements AttributeDefinition { + + private LogService log; + + private AttributeDefinition realAD; + + private String[] defaultValueOverride; + + public ParamAD(LogService log, AttributeDefinition realAD, String[] defaultValueOverride) { + this.log = log; + + this.realAD = realAD; + + this.defaultValueOverride = defaultValueOverride; + } + + public int getCardinality() { + return this.realAD.getCardinality(); + } + + public String[] getDefaultValue() { + if (defaultValueOverride != null) { + return defaultValueOverride; + } else { + return realAD.getDefaultValue(); + } + } + + public String getDescription() { + return this.realAD.getDescription(); + } + + public String getID() { + return this.realAD.getID(); + } + + public String getName() { + return this.realAD.getName(); + } + + public String[] getOptionLabels() { + return this.realAD.getOptionLabels(); + } + + public String[] getOptionValues() { + return this.realAD.getOptionValues(); + } + + public int getType() { + return this.realAD.getType(); + } + + public String validate(String value) { + return this.realAD.validate(value); + } + +} Deleted: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java 2008-04-02 18:06:52 UTC (rev 756) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java 2008-04-02 18:12:33 UTC (rev 757) @@ -1,33 +0,0 @@ -package org.cishell.reference.gui.menumanager.menu.metatypewrapper; - -import java.util.Dictionary; - -import org.osgi.service.metatype.MetaTypeProvider; -import org.osgi.service.metatype.ObjectClassDefinition; - -public class ParamMetaTypeProvider implements MetaTypeProvider { - - private MetaTypeProvider realMTP; - - private Dictionary defaultOverrider; - - public ParamMetaTypeProvider(MetaTypeProvider realMTP, Dictionary defaultOverrider) { - this.realMTP = realMTP; - this.defaultOverrider = defaultOverrider; - } - - public String[] getLocales() { - return this.realMTP.getLocales(); - } - - public ObjectClassDefinition getObjectClassDefinition(String id, - String locale) { - ObjectClassDefinition ocd = realMTP.getObjectClassDefinition(id, locale); - if (ocd != null) { - return new ParamOCD(realMTP.getObjectClassDefinition(id, locale), defaultOverrider); - } else { - return null; - } - } - -} Copied: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java (from rev 756, branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java) =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java 2008-04-02 18:12:33 UTC (rev 757) @@ -0,0 +1,33 @@ +package org.cishell.reference.gui.menumanager.menu.metatypewrapper; + +import java.util.Dictionary; + +import org.osgi.service.metatype.MetaTypeProvider; +import org.osgi.service.metatype.ObjectClassDefinition; + +public class ParamMetaTypeProvider implements MetaTypeProvider { + + private MetaTypeProvider realMTP; + + private Dictionary defaultOverrider; + + public ParamMetaTypeProvider(MetaTypeProvider realMTP, Dictionary defaultOverrider) { + this.realMTP = realMTP; + this.defaultOverrider = defaultOverrider; + } + + public String[] getLocales() { + return this.realMTP.getLocales(); + } + + public ObjectClassDefinition getObjectClassDefinition(String id, + String locale) { + ObjectClassDefinition ocd = realMTP.getObjectClassDefinition(id, locale); + if (ocd != null) { + return new ParamOCD(realMTP.getObjectClassDefinition(id, locale), defaultOverrider); + } else { + return null; + } + } + +} Deleted: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java 2008-04-02 18:06:52 UTC (rev 756) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java 2008-04-02 18:12:33 UTC (rev 757) @@ -1,77 +0,0 @@ -package org.cishell.reference.gui.menumanager.menu.metatypewrapper; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Dictionary; - -import org.osgi.service.log.LogService; -import org.osgi.service.metatype.AttributeDefinition; -import org.osgi.service.metatype.ObjectClassDefinition; - -public class ParamOCD implements ObjectClassDefinition { - - private ObjectClassDefinition realOCD; - private ParamAD[] wrappedADs; - - private LogService log; - - private Dictionary defaultOverrider; - - public ParamOCD(ObjectClassDefinition realOCD, Dictionary defaultOverrider) { - this.realOCD = realOCD; - this.defaultOverrider = defaultOverrider; - - //TODO: don't always return all attributeDefinitions, regardless of filter - this.wrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.ALL)); - } - - private ParamAD[] wrapAttributeDefinitions(AttributeDefinition[] realAttributeDefinitions) { - ParamAD[] wrappedADs = new ParamAD[realAttributeDefinitions.length]; - - for (int i = 0; i < realAttributeDefinitions.length; i++) { - AttributeDefinition realAD = realAttributeDefinitions[i]; - - String[] defaultOverrideValue = getDefaultOverrideValue(realAD.getID(), defaultOverrider); - - ParamAD wrappedAD = new ParamAD(this.log, realAD, defaultOverrideValue); - - wrappedADs[i] = wrappedAD; - } - - return wrappedADs; - } - - private String[] getDefaultOverrideValue(String overrideKey, Dictionary defaultOverrider) { - if (defaultOverrider != null) { - String defaultOverrideValue = (String) defaultOverrider.get(overrideKey); - if (defaultOverrideValue != null) { - return new String[]{defaultOverrideValue}; - } else { - return null; - } - } else { - return null; - } - } - - public AttributeDefinition[] getAttributeDefinitions(int filter) { - return wrappedADs; - } - - public String getDescription() { - return this.realOCD.getDescription(); - } - - public String getID() { - return this.realOCD.getID(); - } - - public InputStream getIcon(int size) throws IOException { - return this.realOCD.getIcon(size); - } - - public String getName() { - return this.realOCD.getName(); - } - -} Copied: trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java (from rev 756, branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java) =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java (rev 0) +++ trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java 2008-04-02 18:12:33 UTC (rev 757) @@ -0,0 +1,77 @@ +package org.cishell.reference.gui.menumanager.menu.metatypewrapper; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Dictionary; + +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.AttributeDefinition; +import org.osgi.service.metatype.ObjectClassDefinition; + +public class ParamOCD implements ObjectClassDefinition { + + private ObjectClassDefinition realOCD; + private ParamAD[] wrappedADs; + + private LogService log; + + private Dictionary defaultOverrider; + + public ParamOCD(ObjectClassDefinition realOCD, Dictionary defaultOverrider) { + this.realOCD = realOCD; + this.defaultOverrider = defaultOverrider; + + //TODO: don't always return all attributeDefinitions, regardless of filter + this.wrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.ALL)); + } + + private ParamAD[] wrapAttributeDefinitions(AttributeDefinition[] realAttributeDefinitions) { + ParamAD[] wrappedADs = new ParamAD[realAttributeDefinitions.length]; + + for (int i = 0; i < realAttributeDefinitions.length; i++) { + AttributeDefinition realAD = realAttributeDefinitions[i]; + + String[] defaultOverrideValue = getDefaultOverrideValue(realAD.getID(), defaultOverrider); + + ParamAD wrappedAD = new ParamAD(this.log, realAD, defaultOverrideValue); + + wrappedADs[i] = wrappedAD; + } + + return wrappedADs; + } + + private String[] getDefaultOverrideValue(String overrideKey, Dictionary defaultOverrider) { + if (defaultOverrider != null) { + String defaultOverrideValue = (String) defaultOverrider.get(overrideKey); + if (defaultOverrideValue != null) { + return new String[]{defaultOverrideValue}; + } else { + return null; + } + } else { + return null; + } + } + + public AttributeDefinition[] getAttributeDefinitions(int filter) { + return wrappedADs; + } + + public String getDescription() { + return this.realOCD.getDescription(); + } + + public String getID() { + return this.realOCD.getID(); + } + + public InputStream getIcon(int size) throws IOException { + return this.realOCD.getIcon(size); + } + + public String getName() { + return this.realOCD.getName(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 18:06:55
|
Revision: 756 http://cishell.svn.sourceforge.net/cishell/?rev=756&view=rev Author: mwlinnem Date: 2008-04-02 11:06:52 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Merging user prefs branch into trunk (starts configuration admin and user prefs admin). Modified Paths: -------------- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/META-INF/MANIFEST.MF trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini Modified: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/META-INF/MANIFEST.MF 2008-04-02 17:58:42 UTC (rev 755) +++ trunk/clients/gui/org.cishell.reference.gui.brand.cishell/META-INF/MANIFEST.MF 2008-04-02 18:06:52 UTC (rev 756) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: CIShell Branding Plug-in Bundle-SymbolicName: org.cishell.reference.gui.brand.cishell;singleton:=true -Bundle-Version: 1.0.0 +Bundle-Version: 0.4.0 Bundle-Activator: org.cishell.reference.gui.brand.cishell.Activator Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime, Modified: trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-04-02 17:58:42 UTC (rev 755) +++ trunk/clients/gui/org.cishell.reference.gui.brand.cishell/extra-files/configuration/config.ini 2008-04-02 18:06:52 UTC (rev 756) @@ -2,5 +2,5 @@ osgi.splashPath=platform:/base/plugins/org.cishell.reference.gui.brand.cishell eclipse.product=org.cishell.reference.gui.brand.cishell.cishell -osgi.bundles=org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start,org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start -osgi.bundles.defaultStartLevel=4 +org.eclipse.equinox.common@2:start,org.eclipse.update.configurator@3:start,org.eclipse.core.runtime@start,org.eclipse.equinox.ds@3:start,org.eclipse.equinox.log@3:start,org.eclipse.equinox.metatype@3:start, org.eclipse.equinox.cm@3:start, org.cishell.reference.prefs.admin@3:start, org.eclipse.equinox.event@3:start,org.cishell.service.autostart@4:start +osgi.bundles.defaultStartLevel=4 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 17:58:44
|
Revision: 755 http://cishell.svn.sourceforge.net/cishell/?rev=755&view=rev Author: mwlinnem Date: 2008-04-02 10:58:42 -0700 (Wed, 02 Apr 2008) Log Message: ----------- This never should have been here in the first place. Removed Paths: ------------- branches/user_prefs/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 17:57:26
|
Revision: 754 http://cishell.svn.sourceforge.net/cishell/?rev=754&view=rev Author: mwlinnem Date: 2008-04-02 10:57:22 -0700 (Wed, 02 Apr 2008) Log Message: ----------- This never should have been here in the first place. Removed Paths: ------------- trunk/clients/gui/org.cishell.reference.gui.brand.cishell/org.cishell.reference.gui.brand.cishell/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-04-02 17:48:45
|
Revision: 753 http://cishell.svn.sourceforge.net/cishell/?rev=753&view=rev Author: mwlinnem Date: 2008-04-02 10:48:33 -0700 (Wed, 02 Apr 2008) Log Message: ----------- Merging in preferences version. Added Paths: ----------- trunk/clients/gui/org.cishell.reference.gui.persistence/ Removed Paths: ------------- branches/user_prefs/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence/ Copied: trunk/clients/gui/org.cishell.reference.gui.persistence (from rev 752, branches/user_prefs/org.cishell.reference.gui.persistence/org.cishell.reference.gui.persistence) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |