From: <bh...@us...> - 2006-07-24 22:32:37
|
Revision: 99 Author: bh2 Date: 2006-07-24 15:32:30 -0700 (Mon, 24 Jul 2006) ViewCVS: http://svn.sourceforge.net/cishell/?rev=99&view=rev Log Message: ----------- did some slight code cleanup for the old cishell compatibility plugin Modified Paths: -------------- trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/algorithm/AlgorithmAdapter.java trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/guibuilder/ParameterMapAdapter.java trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/log/OSGiLogListener.java trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/menu/AlgorithmAction.java trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/menu/MenuAdapter.java Modified: trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/algorithm/AlgorithmAdapter.java =================================================================== --- trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/algorithm/AlgorithmAdapter.java 2006-07-24 22:32:01 UTC (rev 98) +++ trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/algorithm/AlgorithmAdapter.java 2006-07-24 22:32:30 UTC (rev 99) @@ -78,26 +78,21 @@ } protected void doDataModelConversion() { - String inDataText = (String) ref.getProperty(IN_DATA); + DataConversionService converter = (DataConversionService) + ciContext.getService(DataConversionService.class.getName()); + String inDataText = (String) ref.getProperty(IN_DATA); if (inDataText != null && !inDataText.equals(NULL_DATA)) { String[] inData = inDataText.split(","); if (dm != null && inData.length == dm.length) { for (int i=0; i < dm.length; i++) { - dm[i] = convert(dm[i], inData[i]); + dm[i] = converter.convert(dm[i], inData[i]); } } } } - protected DataModel convert(DataModel dm, String outFormat) { - DataConversionService converter = (DataConversionService) - ciContext.getService(DataConversionService.class.getName()); - - return converter.convert(dm, outFormat); - } - protected Dictionary makeDictionary() { if (parameterMap instanceof ParameterMapAdapter) { return ((ParameterMapAdapter) parameterMap).createDictionary(); Modified: trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/guibuilder/ParameterMapAdapter.java =================================================================== --- trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/guibuilder/ParameterMapAdapter.java 2006-07-24 22:32:01 UTC (rev 98) +++ trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/guibuilder/ParameterMapAdapter.java 2006-07-24 22:32:30 UTC (rev 99) @@ -33,9 +33,10 @@ protected ObjectClassDefinition ocd; public ParameterMapAdapter(MetaTypeProvider provider) { + ObjectClassDefinition ocd = null; + //String locale = Locale.getDefault().getDisplayName(); //TODO: better locale matching - ObjectClassDefinition ocd = null; if (ocd == null) { String[] locales = provider.getLocales(); @@ -63,8 +64,9 @@ } protected void createParameter(AttributeDefinition attr) { + int cardinality = attr.getCardinality(); + //TODO: support for arbitrary additions of types - int cardinality = attr.getCardinality(); if (cardinality == Integer.MAX_VALUE) { cardinality = 5; } else if (cardinality == Integer.MIN_VALUE) { @@ -236,7 +238,7 @@ } protected Object getValue(AttributeDefinition attr, Object value) { - //convert the speical types that aren't represented by the old GUI Builder + //convert the special types that aren't represented by the old GUI Builder switch (attr.getType()) { case AttributeDefinition.CHARACTER: if (value != null && value.toString().length() > 0) Modified: trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/log/OSGiLogListener.java =================================================================== --- trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/log/OSGiLogListener.java 2006-07-24 22:32:01 UTC (rev 98) +++ trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/log/OSGiLogListener.java 2006-07-24 22:32:30 UTC (rev 99) @@ -25,10 +25,7 @@ import edu.iu.iv.core.messaging.ConsoleLevel; import edu.iu.iv.core.messaging.ConsoleManager; -/** - * - * @author Bruce Herr - */ + public class OSGiLogListener implements LogListener { private BundleContext bContext; @@ -64,7 +61,6 @@ level = ConsoleLevel.ALGORITHM_INFORMATION; } - if (goodMessage(entry.getMessage())) { console.print(entry.getMessage() + "\n", level); } Modified: trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/menu/AlgorithmAction.java =================================================================== --- trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/menu/AlgorithmAction.java 2006-07-24 22:32:01 UTC (rev 98) +++ trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/menu/AlgorithmAction.java 2006-07-24 22:32:30 UTC (rev 99) @@ -79,6 +79,7 @@ console.printAlgorithmInformation(getText() + " was selected.\n"); + //TODO: Print Algorithm Information // String author = (String)ref.getProperty(AlgorithmProperty.AUTHOR); // String citation = (String) ref.getProperty(AlgorithmProperty.CITATION); // String docu = (String) ref.getProperty(AlgorithmProperty.DOCUMENTATION); @@ -106,13 +107,12 @@ if(models.size() == 0){ boolean supports; try{ - supports = supports(new BasicDataModel(null)); + supports = supports(new BasicDataModel(null)); } catch(NullPointerException e){ supports = false; } setEnabled(supports); - } - if(models.size() == 1){ + } else if(models.size() == 1){ setEnabled(supports((edu.iu.iv.core.datamodels.DataModel)models.toArray()[0])); } else { CompositeDataModel composite = new BasicCompositeDataModel(); @@ -164,7 +164,7 @@ if (validator != null) { List datamodels = new ArrayList(); - for (Iterator i=cdm.iterator(); i.hasNext();) { + for (Iterator i=cdm.iterator(); i.hasNext(); ) { datamodels.add(new NewDataModelAdapter( (edu.iu.iv.core.datamodels.DataModel) i.next())); } @@ -207,6 +207,7 @@ private Converter[] getDataConverters(String inFormat, String outFormat) { DataConversionService converter = (DataConversionService) ciContext.getService(DataConversionService.class.getName()); + return converter.findConverters(inFormat, outFormat); } Modified: trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/menu/MenuAdapter.java =================================================================== --- trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/menu/MenuAdapter.java 2006-07-24 22:32:01 UTC (rev 98) +++ trunk/clients/old-cishell-compatibility/org.cishell.compatibility/src/org/cishell/compatibility/menu/MenuAdapter.java 2006-07-24 22:32:30 UTC (rev 99) @@ -90,6 +90,22 @@ } } + private class ContextListener implements ServiceListener { + public void serviceChanged(ServiceEvent event) { + switch (event.getType()) { + case ServiceEvent.REGISTERED: + makeMenuItem(event.getServiceReference()); + break; + case ServiceEvent.UNREGISTERING: + removeMenuItem(event.getServiceReference()); + break; + case ServiceEvent.MODIFIED: + updateMenuItem(event.getServiceReference()); + break; + } + } + } + private void makeMenuItem(ServiceReference ref) { String path = (String)ref.getProperty(MENU_PATH); @@ -132,7 +148,8 @@ } private String getItemID(ServiceReference ref) { - return ref.getProperty(Constants.SERVICE_PID) + "-BID:" + ref.getBundle().getBundleId(); + return ref.getProperty("PID:" + Constants.SERVICE_PID) + "-SID:" + + ref.getProperty(Constants.SERVICE_ID); } private MenuManager createMenu(String name, String id){ @@ -143,22 +160,6 @@ return menu; } - private class ContextListener implements ServiceListener { - public void serviceChanged(ServiceEvent event) { - switch (event.getType()) { - case ServiceEvent.REGISTERED: - makeMenuItem(event.getServiceReference()); - break; - case ServiceEvent.UNREGISTERING: - removeMenuItem(event.getServiceReference()); - break; - case ServiceEvent.MODIFIED: - updateMenuItem(event.getServiceReference()); - break; - } - } - } - private void updateMenuItem(ServiceReference ref) { Action item = (Action) algorithmToItemMap.get(getItemID(ref)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |