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: <bh...@us...> - 2008-03-25 14:06:42
|
Revision: 677 http://cishell.svn.sourceforge.net/cishell/?rev=677&view=rev Author: bh2 Date: 2008-03-25 07:06:32 -0700 (Tue, 25 Mar 2008) Log Message: ----------- tagging the pre 1.0 code before major changes are made Added Paths: ----------- tags/pre-v1.0.0/ Copied: tags/pre-v1.0.0 (from rev 676, trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-03-21 17:40:26
|
Revision: 676 http://cishell.svn.sourceforge.net/cishell/?rev=676&view=rev Author: mwlinnem Date: 2008-03-21 10:39:47 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Preference Service needs this. Added Paths: ----------- branches/user_prefs/org.eclipse.equinox.cm/.classpath branches/user_prefs/org.eclipse.equinox.cm/.cvsignore branches/user_prefs/org.eclipse.equinox.cm/.project branches/user_prefs/org.eclipse.equinox.cm/.settings/ branches/user_prefs/org.eclipse.equinox.cm/META-INF/ branches/user_prefs/org.eclipse.equinox.cm/META-INF/MANIFEST.MF branches/user_prefs/org.eclipse.equinox.cm/about.html branches/user_prefs/org.eclipse.equinox.cm/build.properties branches/user_prefs/org.eclipse.equinox.cm/plugin.properties branches/user_prefs/org.eclipse.equinox.cm/src/ branches/user_prefs/org.eclipse.equinox.cm/src/org/ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceTracker.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/PluginManager.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/SerializedTaskQueue.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFile.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFileInputStream.java branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/reliablefile/ReliableFileOutputStream.java Added: branches/user_prefs/org.eclipse.equinox.cm/.classpath =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/.classpath (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/.classpath 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/OSGi%Minimum-1.1"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> Property changes on: branches/user_prefs/org.eclipse.equinox.cm/.classpath ___________________________________________________________________ Name: svn:executable + * Added: branches/user_prefs/org.eclipse.equinox.cm/.cvsignore =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/.cvsignore (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/.cvsignore 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1 @@ +bin Property changes on: branches/user_prefs/org.eclipse.equinox.cm/.cvsignore ___________________________________________________________________ Name: svn:executable + * Added: branches/user_prefs/org.eclipse.equinox.cm/.project =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/.project (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/.project 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.equinox.cm</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Property changes on: branches/user_prefs/org.eclipse.equinox.cm/.project ___________________________________________________________________ Name: svn:executable + * Added: branches/user_prefs/org.eclipse.equinox.cm/META-INF/MANIFEST.MF =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/META-INF/MANIFEST.MF (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/META-INF/MANIFEST.MF 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %bundleName +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-SymbolicName: org.eclipse.equinox.cm +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.equinox.internal.cm.Activator +Import-Package: org.osgi.framework;version="1.3.0", + org.osgi.service.cm;version="1.2.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.event;version="1.0"; resolution:=optional, + org.osgi.util.tracker;version="1.3.1" +Export-Package: org.eclipse.equinox.internal.cm;x-internal:=true, + org.eclipse.equinox.internal.cm.reliablefile;x-internal:=true +Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.1, + CDC-1.0/Foundation-1.0, + J2SE-1.3 Property changes on: branches/user_prefs/org.eclipse.equinox.cm/META-INF/MANIFEST.MF ___________________________________________________________________ Name: svn:executable + * Added: branches/user_prefs/org.eclipse.equinox.cm/about.html =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/about.html (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/about.html 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>January 30, 2007</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p> + +</body> +</html> \ No newline at end of file Property changes on: branches/user_prefs/org.eclipse.equinox.cm/about.html ___________________________________________________________________ Name: svn:executable + * Added: branches/user_prefs/org.eclipse.equinox.cm/build.properties =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/build.properties (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/build.properties 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties +src.includes = about.html Property changes on: branches/user_prefs/org.eclipse.equinox.cm/build.properties ___________________________________________________________________ Name: svn:executable + * Added: branches/user_prefs/org.eclipse.equinox.cm/plugin.properties =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/plugin.properties (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/plugin.properties 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,12 @@ +############################################################################### +# Copyright (c) 2007 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +bundleName = Configuration Admin (Incubation) +providerName = Eclipse.org Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/Activator.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2006, 2007 Cognos Incorporated, IBM Corporation + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cognos Incorporated - initial API and implementation + * Chris Aniszczyk <zx...@us...> - bug 209294 + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import org.osgi.framework.*; +import org.osgi.service.cm.ConfigurationAdmin; + +/** + * Activator start the ConfigurationAdminFactory but also handles passing in the Service + * Registration needed by Asynch threads. Asynch threads are controlled by ConfigurationAdminFactory + * start and stop. It requires some care to handle pending events as the service is registered before + * activating the threads. (see EventDispatcher) + */ +public class Activator implements BundleActivator { + private static final String EVENT_ADMIN_CLASS = "org.osgi.service.event.EventAdmin"; //$NON-NLS-1$ + private LogTracker logTracker; + private ServiceRegistration registration; + private ConfigurationAdminFactory factory; + private ConfigurationEventAdapter eventAdapter; + private static BundleContext bundleContext; + + private static synchronized void setBundleContext(BundleContext context) { + bundleContext = context; + } + + public static synchronized String getProperty(String key) { + if (bundleContext != null) + return bundleContext.getProperty(key); + + return null; + } + + public void start(BundleContext context) throws Exception { + setBundleContext(context); + logTracker = new LogTracker(context, System.err); + logTracker.open(); + if (checkEventAdmin()) { + eventAdapter = new ConfigurationEventAdapter(context); + eventAdapter.start(); + } + factory = new ConfigurationAdminFactory(context, logTracker); + factory.start(); + context.addBundleListener(factory); + registration = context.registerService(ConfigurationAdmin.class.getName(), factory, null); + } + + public void stop(BundleContext context) throws Exception { + registration.unregister(); + registration = null; + context.removeBundleListener(factory); + factory.stop(); + factory = null; + if (eventAdapter != null) { + eventAdapter.stop(); + eventAdapter = null; + } + logTracker.close(); + logTracker = null; + setBundleContext(null); + } + + private static boolean checkEventAdmin() { + // cannot support scheduling without the event admin package + try { + Class.forName(EVENT_ADMIN_CLASS); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } +} Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminFactory.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 Cognos Incorporated, IBM Corporation and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cognos Incorporated - initial API and implementation + * IBM Corporation - bug fixes and enhancements + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import java.security.Permission; +import java.util.Dictionary; +import org.osgi.framework.*; +import org.osgi.service.cm.ConfigurationPermission; +import org.osgi.service.log.LogService; + +/** + * ConfigurationAdminFactory provides a Configuration Admin ServiceFactory but more significantly + * launches the whole implementation. + */ + +public class ConfigurationAdminFactory implements ServiceFactory, BundleListener { + + private final Permission configurationPermission = new ConfigurationPermission("*", ConfigurationPermission.CONFIGURE); //$NON-NLS-1$ + private final EventDispatcher eventDispatcher; + private final PluginManager pluginManager; + private final LogService log; + private final ManagedServiceTracker managedServiceTracker; + private final ManagedServiceFactoryTracker managedServiceFactoryTracker; + private final ConfigurationStore configurationStore; + + public ConfigurationAdminFactory(BundleContext context, LogService log) { + this.log = log; + configurationStore = new ConfigurationStore(this, context); + eventDispatcher = new EventDispatcher(context, log); + pluginManager = new PluginManager(context); + managedServiceTracker = new ManagedServiceTracker(this, configurationStore, context); + managedServiceFactoryTracker = new ManagedServiceFactoryTracker(this, configurationStore, context); + } + + void start() { + eventDispatcher.start(); + pluginManager.start(); + managedServiceTracker.open(); + managedServiceFactoryTracker.open(); + } + + void stop() { + managedServiceTracker.close(); + managedServiceFactoryTracker.close(); + eventDispatcher.stop(); + pluginManager.stop(); + } + + public Object getService(Bundle bundle, ServiceRegistration registration) { + ServiceReference reference = registration.getReference(); + eventDispatcher.setServiceReference(reference); + return new ConfigurationAdminImpl(this, configurationStore, bundle); + } + + public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { + // do nothing + } + + public void bundleChanged(BundleEvent event) { + if (event.getType() == BundleEvent.UNINSTALLED) + configurationStore.unbindConfigurations(event.getBundle()); + } + + public void checkConfigurationPermission() throws SecurityException { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkPermission(configurationPermission); + } + + void log(int level, String message) { + log.log(level, message); + } + + void log(int level, String message, Throwable exception) { + log.log(level, message, exception); + } + + void dispatchEvent(int type, String factoryPid, String pid) { + eventDispatcher.dispatchEvent(type, factoryPid, pid); + } + + void notifyConfigurationUpdated(ConfigurationImpl config, boolean isFactory) { + if (isFactory) + managedServiceFactoryTracker.notifyUpdated(config); + else + managedServiceTracker.notifyUpdated(config); + } + + void notifyConfigurationDeleted(ConfigurationImpl config, boolean isFactory) { + if (isFactory) + managedServiceFactoryTracker.notifyDeleted(config); + else + managedServiceTracker.notifyDeleted(config); + } + + void modifyConfiguration(ServiceReference reference, Dictionary properties) { + pluginManager.modifyConfiguration(reference, properties); + } +} \ No newline at end of file Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationAdminImpl.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 Cognos Incorporated, IBM Corporation and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cognos Incorporated - initial API and implementation + * IBM Corporation - bug fixes and enhancements + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import java.io.IOException; +import org.osgi.framework.*; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; + +/** + * ConfigurationAdminImpl provides the ConfigurationAdmin service implementation + */ +class ConfigurationAdminImpl implements ConfigurationAdmin { + + private final ConfigurationAdminFactory configurationAdminFactory; + private final Bundle bundle; + private final ConfigurationStore configurationStore; + + public ConfigurationAdminImpl(ConfigurationAdminFactory configurationAdminFactory, ConfigurationStore configurationStore, Bundle bundle) { + this.configurationAdminFactory = configurationAdminFactory; + this.configurationStore = configurationStore; + this.bundle = bundle; + } + + public Configuration createFactoryConfiguration(String factoryPid) throws IOException { + checkPID(factoryPid); + return configurationStore.createFactoryConfiguration(factoryPid, bundle.getLocation()); + } + + public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException { + checkPID(factoryPid); + this.configurationAdminFactory.checkConfigurationPermission(); + return configurationStore.createFactoryConfiguration(factoryPid, location); + } + + public Configuration getConfiguration(String pid) throws IOException { + checkPID(pid); + Configuration config = configurationStore.getConfiguration(pid, bundle.getLocation()); + if (config.getBundleLocation() != null && !config.getBundleLocation().equals(bundle.getLocation())) + this.configurationAdminFactory.checkConfigurationPermission(); + return config; + } + + public Configuration getConfiguration(String pid, String location) throws IOException { + checkPID(pid); + this.configurationAdminFactory.checkConfigurationPermission(); + return configurationStore.getConfiguration(pid, location); + } + + public Configuration[] listConfigurations(String filterString) throws IOException, InvalidSyntaxException { + if (filterString == null) + filterString = "(" + Constants.SERVICE_PID + "=*)"; //$NON-NLS-1$ //$NON-NLS-2$ + + try { + this.configurationAdminFactory.checkConfigurationPermission(); + } catch (SecurityException e) { + filterString = "(&(" + ConfigurationAdmin.SERVICE_BUNDLELOCATION + "=" + bundle.getLocation() + ")" + filterString + ")"; //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ + } + return configurationStore.listConfigurations(FrameworkUtil.createFilter(filterString)); + } + + private void checkPID(String pid) { + if (pid == null) + throw new IllegalArgumentException("PID cannot be null"); //$NON-NLS-1$ + } +} \ No newline at end of file Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationDictionary.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,151 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 Cognos Incorporated, IBM Corporation and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cognos Incorporated - initial API and implementation + * IBM Corporation - bug fixes and enhancements + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import java.io.Serializable; +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeMap; +import java.util.Vector; +import java.util.Map.Entry; + +/** + * ConfigurationDictionary holds the actual configuration data and meets the various comparison + * requirements of the Configuration Admin Service specification. + */ + +public class ConfigurationDictionary extends Dictionary implements Serializable { + + private static final long serialVersionUID = -3583299578203095532L; + private static final Collection simples = Arrays.asList(new Class[] {String.class, Integer.class, Long.class, Float.class, Double.class, Byte.class, Short.class, Character.class, Boolean.class}); + private static final Collection simpleArrays = Arrays.asList(new Class[] {String[].class, Integer[].class, Long[].class, Float[].class, Double[].class, Byte[].class, Short[].class, Character[].class, Boolean[].class}); + private static final Collection primitiveArrays = Arrays.asList(new Class[] {long[].class, int[].class, short[].class, char[].class, byte[].class, double[].class, float[].class, boolean[].class}); + + static class CaseInsensitiveStringComparator implements Comparator, Serializable { + private static final long serialVersionUID = 6501536810492374044L; + + public int compare(Object o1, Object o2) { + return ((String) o1).compareToIgnoreCase((String) o2); + } + } + + protected final Map configurationProperties = Collections.synchronizedMap(new TreeMap(new CaseInsensitiveStringComparator())); + + private static void validateValue(Object value) { + Class clazz = value.getClass(); + + // Is it in the set of simple types + if (simples.contains(clazz)) + return; + + // Is it an array of primitives or simples + if (simpleArrays.contains(clazz) || primitiveArrays.contains(clazz)) + return; + + // Is it a vector of simples + if (clazz == Vector.class) { + Vector valueVector = (Vector) value; + for (Iterator it = valueVector.iterator(); it.hasNext();) { + Class containedClazz = it.next().getClass(); + if (!simples.contains(containedClazz)) { + throw new IllegalArgumentException(containedClazz.getName() + " in " + Vector.class.getName()); //$NON-NLS-1$ + } + } + return; + } + throw new IllegalArgumentException(clazz.getName()); + } + + public Enumeration elements() { + return new Enumeration() { + final Iterator valuesIterator = configurationProperties.values().iterator(); + + public boolean hasMoreElements() { + return valuesIterator.hasNext(); + } + + public Object nextElement() { + return valuesIterator.next(); + } + }; + } + + public Object get(Object key) { + if (key == null) + throw new NullPointerException(); + return configurationProperties.get(key); + } + + public boolean isEmpty() { + return configurationProperties.isEmpty(); + } + + public Enumeration keys() { + return new Enumeration() { + Iterator keysIterator = configurationProperties.keySet().iterator(); + + public boolean hasMoreElements() { + return keysIterator.hasNext(); + } + + public Object nextElement() { + return keysIterator.next(); + } + }; + } + + public Object put(Object key, Object value) { + if (key == null || value == null) + throw new NullPointerException(); + + // Will throw an illegal argument exception if not a valid configuration property type + validateValue(value); + + return configurationProperties.put(key, value); + } + + public Object remove(Object key) { + if (key == null) + throw new NullPointerException(); + return configurationProperties.remove(key); + } + + public int size() { + return configurationProperties.size(); + } + + ConfigurationDictionary copy() { + ConfigurationDictionary result = new ConfigurationDictionary(); + for (Iterator it = configurationProperties.entrySet().iterator(); it.hasNext();) { + Entry entry = (Entry) it.next(); + Object key = entry.getKey(); + Object value = entry.getValue(); + if (value.getClass().isArray()) { + int arrayLength = Array.getLength(value); + Object copyOfArray = Array.newInstance(value.getClass().getComponentType(), arrayLength); + System.arraycopy(value, 0, copyOfArray, 0, arrayLength); + result.configurationProperties.put(key, copyOfArray); + } else if (value instanceof Vector) + result.configurationProperties.put(key, ((Vector) value).clone()); + else + result.configurationProperties.put(key, value); + } + return result; + } +} Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationEventAdapter.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import java.util.Hashtable; +import org.osgi.framework.*; +import org.osgi.service.cm.ConfigurationEvent; +import org.osgi.service.cm.ConfigurationListener; +import org.osgi.service.event.Event; +import org.osgi.service.event.EventAdmin; +import org.osgi.util.tracker.ServiceTracker; + +public class ConfigurationEventAdapter implements ConfigurationListener { + // constants for Event topic substring + public static final String TOPIC = "org/osgi/service/cm/ConfigurationEvent"; //$NON-NLS-1$ + public static final char TOPIC_SEPARATOR = '/'; + // constants for Event types + public static final String CM_UPDATED = "CM_UPDATED"; //$NON-NLS-1$ + public static final String CM_DELETED = "CM_DELETED"; //$NON-NLS-1$ + // constants for Event properties + public static final String CM_FACTORY_PID = "cm.factoryPid"; //$NON-NLS-1$ + public static final String CM_PID = "cm.pid"; //$NON-NLS-1$ + public static final String SERVICE = "service"; //$NON-NLS-1$ + public static final String SERVICE_ID = "service.id"; //$NON-NLS-1$ + public static final String SERVICE_OBJECTCLASS = "service.objectClass"; //$NON-NLS-1$ + public static final String SERVICE_PID = "service.pid"; //$NON-NLS-1$ + + private final BundleContext context; + private ServiceRegistration configListenerRegistration; + private final ServiceTracker eventAdminTracker; + + public ConfigurationEventAdapter(BundleContext context) { + this.context = context; + eventAdminTracker = new ServiceTracker(context, EventAdmin.class.getName(), null); + } + + public void start() throws Exception { + eventAdminTracker.open(); + configListenerRegistration = context.registerService(ConfigurationListener.class.getName(), this, null); + } + + public void stop() throws Exception { + configListenerRegistration.unregister(); + configListenerRegistration = null; + eventAdminTracker.close(); + } + + public void configurationEvent(ConfigurationEvent event) { + EventAdmin eventAdmin = (EventAdmin) eventAdminTracker.getService(); + if (eventAdmin == null) { + return; + } + String typename = null; + switch (event.getType()) { + case ConfigurationEvent.CM_UPDATED : + typename = CM_UPDATED; + break; + case ConfigurationEvent.CM_DELETED : + typename = CM_DELETED; + break; + default : // do nothing + return; + } + String topic = TOPIC + TOPIC_SEPARATOR + typename; + ServiceReference ref = event.getReference(); + if (ref == null) { + throw new RuntimeException("ServiceEvent.getServiceReference() is null"); //$NON-NLS-1$ + } + Hashtable properties = new Hashtable(); + properties.put(CM_PID, event.getPid()); + if (event.getFactoryPid() != null) { + properties.put(CM_FACTORY_PID, event.getFactoryPid()); + } + putServiceReferenceProperties(properties, ref); + Event convertedEvent = new Event(topic, properties); + eventAdmin.postEvent(convertedEvent); + } + + public void putServiceReferenceProperties(Hashtable properties, ServiceReference ref) { + properties.put(SERVICE, ref); + properties.put(SERVICE_ID, ref.getProperty(org.osgi.framework.Constants.SERVICE_ID)); + Object o = ref.getProperty(org.osgi.framework.Constants.SERVICE_PID); + if ((o != null) && (o instanceof String)) { + properties.put(SERVICE_PID, o); + } + Object o2 = ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS); + if ((o2 != null) && (o2 instanceof String[])) { + properties.put(SERVICE_OBJECTCLASS, o2); + } + } +} Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationImpl.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,286 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 Cognos Incorporated, IBM Corporation and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cognos Incorporated - initial API and implementation + * IBM Corporation - bug fixes and enhancements + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import java.io.IOException; +import java.util.Dictionary; +import java.util.Enumeration; +import org.osgi.framework.Bundle; +import org.osgi.framework.Constants; +import org.osgi.service.cm.*; + +/** + * ConfigurationImpl provides the Configuration implementation. + * The lock and unlock methods are used for synchronization. Operations outside of + * ConfigurationImpl that expect to have control of the lock should call checkLocked + */ +class ConfigurationImpl implements Configuration { + + private final ConfigurationAdminFactory configurationAdminFactory; + private final ConfigurationStore configurationStore; + /** @GuardedBy this*/ + private String bundleLocation; + private final String factoryPid; + private final String pid; + private ConfigurationDictionary dictionary; + /** @GuardedBy this*/ + private boolean deleted = false; + /** @GuardedBy this*/ + private Bundle boundBundle; + /** @GuardedBy this*/ + private int lockedCount = 0; + /** @GuardedBy this*/ + private Thread lockHolder = null; + + public ConfigurationImpl(ConfigurationAdminFactory configurationAdminFactory, ConfigurationStore configurationStore, String factoryPid, String pid, String bundleLocation) { + this.configurationAdminFactory = configurationAdminFactory; + this.configurationStore = configurationStore; + this.factoryPid = factoryPid; + this.pid = pid; + this.bundleLocation = bundleLocation; + } + + public ConfigurationImpl(ConfigurationAdminFactory configurationAdminFactory, ConfigurationStore configurationStore, Dictionary dictionary) { + this.configurationAdminFactory = configurationAdminFactory; + this.configurationStore = configurationStore; + pid = (String) dictionary.get(Constants.SERVICE_PID); + factoryPid = (String) dictionary.get(ConfigurationAdmin.SERVICE_FACTORYPID); + bundleLocation = (String) dictionary.get(ConfigurationAdmin.SERVICE_BUNDLELOCATION); + updateDictionary(dictionary); + } + + protected synchronized void lock() { + Thread current = Thread.currentThread(); + if (lockHolder != current) { + boolean interrupted = false; + try { + while (lockedCount != 0) + try { + wait(); + } catch (InterruptedException e) { + // although we don't handle an interrupt we should still + // save and restore the interrupt for others further up the stack + interrupted = true; + } + } finally { + if (interrupted) + current.interrupt(); // restore interrupted status + } + } + lockedCount++; + lockHolder = current; + } + + protected synchronized void unlock() { + Thread current = Thread.currentThread(); + if (lockHolder != current) + throw new IllegalStateException("Thread not lock owner"); //$NON-NLS-1$ + + lockedCount--; + if (lockedCount == 0) { + lockHolder = null; + notify(); + } + } + + protected synchronized void checkLocked() { + Thread current = Thread.currentThread(); + if (lockHolder != current) + throw new IllegalStateException("Thread not lock owner"); //$NON-NLS-1$ + } + + protected boolean bind(Bundle bundle) { + try { + lock(); + if (boundBundle == null && (bundleLocation == null || bundleLocation.equals(bundle.getLocation()))) + boundBundle = bundle; + return (boundBundle == bundle); + } finally { + unlock(); + } + } + + protected void unbind(Bundle bundle) { + try { + lock(); + if (boundBundle == bundle) + boundBundle = null; + } finally { + unlock(); + } + } + + public void delete() throws IOException { + try { + lock(); + checkDeleted(); + deleted = true; + configurationAdminFactory.notifyConfigurationDeleted(this, factoryPid != null); + configurationAdminFactory.dispatchEvent(ConfigurationEvent.CM_DELETED, factoryPid, pid); + } finally { + unlock(); + } + configurationStore.removeConfiguration(pid); + } + + private void checkDeleted() { + if (deleted) + throw new IllegalStateException("deleted"); //$NON-NLS-1$ + } + + public String getBundleLocation() { + try { + lock(); + checkDeleted(); + if (bundleLocation != null) + return bundleLocation; + if (boundBundle != null) + return boundBundle.getLocation(); + return null; + } finally { + unlock(); + } + } + + protected String getFactoryPid(boolean checkDeleted) { + try { + lock(); + if (checkDeleted) + checkDeleted(); + return factoryPid; + } finally { + unlock(); + } + } + + public String getFactoryPid() { + return getFactoryPid(true); + } + + protected String getPid(boolean checkDeleted) { + try { + lock(); + if (checkDeleted) + checkDeleted(); + return pid; + } finally { + unlock(); + } + } + + public String getPid() { + return getPid(true); + } + + public Dictionary getProperties() { + try { + lock(); + checkDeleted(); + if (dictionary == null) + return null; + + Dictionary copy = dictionary.copy(); + copy.put(Constants.SERVICE_PID, pid); + if (factoryPid != null) + copy.put(ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid); + + return copy; + } finally { + unlock(); + } + } + + protected Dictionary getAllProperties() { + try { + lock(); + if (deleted) + return null; + Dictionary copy = getProperties(); + if (copy != null && bundleLocation != null) + copy.put(ConfigurationAdmin.SERVICE_BUNDLELOCATION, getBundleLocation()); + return copy; + } finally { + unlock(); + } + } + + public void setBundleLocation(String bundleLocation) { + try { + lock(); + checkDeleted(); + configurationAdminFactory.checkConfigurationPermission(); + this.bundleLocation = bundleLocation; + } finally { + unlock(); + } + } + + public void update() throws IOException { + try { + lock(); + checkDeleted(); + if (dictionary == null) + dictionary = new ConfigurationDictionary(); + configurationStore.saveConfiguration(pid, this); + configurationAdminFactory.notifyConfigurationUpdated(this, factoryPid != null); + } finally { + unlock(); + } + } + + public void update(Dictionary properties) throws IOException { + try { + lock(); + checkDeleted(); + updateDictionary(properties); + configurationStore.saveConfiguration(pid, this); + configurationAdminFactory.notifyConfigurationUpdated(this, factoryPid != null); + configurationAdminFactory.dispatchEvent(ConfigurationEvent.CM_UPDATED, factoryPid, pid); + } finally { + unlock(); + } + } + + private void updateDictionary(Dictionary properties) { + ConfigurationDictionary newDictionary = new ConfigurationDictionary(); + Enumeration keys = properties.keys(); + while (keys.hasMoreElements()) { + Object key = keys.nextElement(); + if (newDictionary.get(key) == null) + newDictionary.put(key, properties.get(key)); + else + throw new IllegalArgumentException(key + " is already present or is a case variant."); //$NON-NLS-1$ + } + newDictionary.remove(Constants.SERVICE_PID); + newDictionary.remove(ConfigurationAdmin.SERVICE_FACTORYPID); + newDictionary.remove(ConfigurationAdmin.SERVICE_BUNDLELOCATION); + + dictionary = newDictionary; + } + + public boolean equals(Object obj) { + return pid.equals(((Configuration) obj).getPid()); + } + + public int hashCode() { + return pid.hashCode(); + } + + protected boolean isDeleted() { + try { + lock(); + return deleted; + } finally { + unlock(); + } + } +} \ No newline at end of file Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ConfigurationStore.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,178 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 Cognos Incorporated, IBM Corporation and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cognos Incorporated - initial API and implementation + * IBM Corporation - bug fixes and enhancements + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import java.io.*; +import java.util.*; +import org.eclipse.equinox.internal.cm.reliablefile.*; +import org.osgi.framework.*; +import org.osgi.service.cm.Configuration; +import org.osgi.service.log.LogService; + +/** + * ConfigurationStore manages all active configurations along with persistence. The current + * implementation uses a filestore and serialization of the configuration dictionaries to files + * identified by their pid. Persistence details are in the constructor, saveConfiguration, and + * deleteConfiguration and can be factored out separately if required. + */ +class ConfigurationStore { + + private final ConfigurationAdminFactory configurationAdminFactory; + private static final String STORE_DIR = "store"; //$NON-NLS-1$ + private static final String PID_EXT = ".pid"; //$NON-NLS-1$ + private final Map configurations = new HashMap(); + private int createdPidCount = 0; + private final File store; + + public ConfigurationStore(ConfigurationAdminFactory configurationAdminFactory, BundleContext context) { + this.configurationAdminFactory = configurationAdminFactory; + store = context.getDataFile(STORE_DIR); + if (store == null) + return; // no persistent store + + store.mkdir(); + File[] configurationFiles = store.listFiles(); + for (int i = 0; i < configurationFiles.length; ++i) { + String configurationFileName = configurationFiles[i].getName(); + if (!configurationFileName.endsWith(PID_EXT)) + continue; + + InputStream ris = null; + ObjectInputStream ois = null; + boolean deleteFile = false; + try { + ris = new ReliableFileInputStream(configurationFiles[i]); + ois = new ObjectInputStream(ris); + Dictionary dictionary = (Dictionary) ois.readObject(); + ConfigurationImpl config = new ConfigurationImpl(configurationAdminFactory, this, dictionary); + configurations.put(config.getPid(), config); + } catch (IOException e) { + String message = e.getMessage(); + String pid = configurationFileName.substring(0, configurationFileName.length() - 4); + String errorMessage = "{Configuration Admin - pid = " + pid + "} could not be restored." + ((message == null) ? "" : " " + message); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + configurationAdminFactory.log(LogService.LOG_ERROR, errorMessage); + deleteFile = true; + } catch (ClassNotFoundException e) { + configurationAdminFactory.log(LogService.LOG_ERROR, e.getMessage()); + } finally { + if (ois != null) { + try { + ois.close(); + } catch (IOException e) { + // ignore + } + } + if (ris != null) { + try { + ris.close(); + } catch (IOException e) { + // ignore + } + } + } + if (deleteFile) { + ReliableFile.delete(configurationFiles[i]); + configurationFiles[i].delete(); + } + } + } + + public void saveConfiguration(String pid, ConfigurationImpl config) throws IOException { + if (store == null) + return; // no persistent store + + config.checkLocked(); + File configFile = new File(store, pid + PID_EXT); + OutputStream ros = null; + ObjectOutputStream oos = null; + try { + configFile.createNewFile(); + ros = new ReliableFileOutputStream(configFile); + oos = new ObjectOutputStream(ros); + oos.writeObject(config.getAllProperties()); + } finally { + if (oos != null) { + try { + oos.close(); + } catch (IOException e) { + // ignore + } + } + if (ros != null) { + try { + ros.close(); + } catch (IOException e) { + // ignore + } + } + } + } + + public synchronized void removeConfiguration(String pid) { + configurations.remove(pid); + if (store == null) + return; // no persistent store + File configFile = new File(store, pid + PID_EXT); + ReliableFile.delete(configFile); + configFile.delete(); + } + + public synchronized Configuration getConfiguration(String pid, String location) { + Configuration config = (Configuration) configurations.get(pid); + if (config == null) { + config = new ConfigurationImpl(configurationAdminFactory, this, null, pid, location); + configurations.put(pid, config); + } + return config; + } + + public synchronized Configuration createFactoryConfiguration(String factoryPid, String location) { + String pid = factoryPid + "-" + new Date().getTime() + "-" + createdPidCount++; //$NON-NLS-1$ //$NON-NLS-2$ + ConfigurationImpl config = new ConfigurationImpl(configurationAdminFactory, this, factoryPid, pid, location); + configurations.put(pid, config); + return config; + } + + public synchronized ConfigurationImpl findConfiguration(String pid) { + return (ConfigurationImpl) configurations.get(pid); + } + + public synchronized ConfigurationImpl[] getFactoryConfigurations(String factoryPid) { + List resultList = new ArrayList(); + for (Iterator it = configurations.values().iterator(); it.hasNext();) { + ConfigurationImpl config = (ConfigurationImpl) it.next(); + String otherFactoryPid = config.getFactoryPid(); + if (otherFactoryPid != null && otherFactoryPid.equals(factoryPid)) + resultList.add(config); + } + return (ConfigurationImpl[]) resultList.toArray(new ConfigurationImpl[0]); + } + + public synchronized Configuration[] listConfigurations(Filter filter) { + List resultList = new ArrayList(); + for (Iterator it = configurations.values().iterator(); it.hasNext();) { + ConfigurationImpl config = (ConfigurationImpl) it.next(); + Dictionary properties = config.getAllProperties(); + if (properties != null && filter.match(properties)) + resultList.add(config); + } + int size = resultList.size(); + return size == 0 ? null : (Configuration[]) resultList.toArray(new Configuration[size]); + } + + public synchronized void unbindConfigurations(Bundle bundle) { + for (Iterator it = configurations.values().iterator(); it.hasNext();) { + ConfigurationImpl config = (ConfigurationImpl) it.next(); + config.unbind(bundle); + } + } +} \ No newline at end of file Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/EventDispatcher.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 Cognos Incorporated, IBM Corporation and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cognos Incorporated - initial API and implementation + * IBM Corporation - bug fixes and enhancements + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.ConfigurationEvent; +import org.osgi.service.cm.ConfigurationListener; +import org.osgi.service.log.LogService; +import org.osgi.util.tracker.ServiceTracker; + +/** + * EventDispatcher is responsible for delivering Configuration Events to ConfigurationListeners. + * The originating ConfigAdmin ServiceReference is needed when delivering events. This reference + * is made available by the service factory before returning the service object. + */ + +public class EventDispatcher { + final ServiceTracker tracker; + private final SerializedTaskQueue queue = new SerializedTaskQueue("ConfigurationListener Event Queue"); //$NON-NLS-1$ + /** @GuardedBy this */ + private ServiceReference configAdminReference; + final LogService log; + + public EventDispatcher(BundleContext context, LogService log) { + this.log = log; + tracker = new ServiceTracker(context, ConfigurationListener.class.getName(), null); + } + + public void start() { + tracker.open(); + } + + public void stop() { + tracker.close(); + synchronized (this) { + configAdminReference = null; + } + } + + synchronized void setServiceReference(ServiceReference reference) { + if (configAdminReference == null) + configAdminReference = reference; + } + + public void dispatchEvent(int type, String factoryPid, String pid) { + final ConfigurationEvent event = createConfigurationEvent(type, factoryPid, pid); + if (event == null) + return; + + ServiceReference[] refs = tracker.getServiceReferences(); + if (refs == null) + return; + + for (int i = 0; i < refs.length; ++i) { + final ServiceReference ref = refs[i]; + queue.put(new Runnable() { + public void run() { + ConfigurationListener listener = (ConfigurationListener) tracker.getService(ref); + if (listener == null) { + return; + } + try { + listener.configurationEvent(event); + } catch (Throwable t) { + log.log(LogService.LOG_ERROR, t.getMessage(), t); + } + } + }); + } + } + + private synchronized ConfigurationEvent createConfigurationEvent(int type, String factoryPid, String pid) { + if (configAdminReference == null) + return null; + + return new ConfigurationEvent(configAdminReference, type, factoryPid, pid); + } +} Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/LogTracker.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,169 @@ +/******************************************************************************* + * Copyright (c) 1998, 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import java.io.PrintStream; +import java.util.Calendar; +import java.util.Date; + +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.service.log.LogService; +import org.osgi.util.tracker.ServiceTracker; + +/** + * LogTracker class. This class encapsulates the LogService + * and handles all issues such as the service coming and going. + */ + +public class LogTracker extends ServiceTracker implements LogService { + /** LogService interface class name */ + protected final static String clazz = "org.osgi.service.log.LogService"; //$NON-NLS-1$ + + /** PrintStream to use if LogService is unavailable */ + private final PrintStream out; + + /** + * Create new LogTracker. + * + * @param context BundleContext of parent bundle. + * @param out Default PrintStream to use if LogService is unavailable. + */ + public LogTracker(BundleContext context, PrintStream out) { + super(context, clazz, null); + this.out = out; + } + + /* + * ---------------------------------------------------------------------- + * LogService Interface implementation + * ---------------------------------------------------------------------- + */ + + public void log(int level, String message) { + log(null, level, message, null); + } + + public void log(int level, String message, Throwable exception) { + log(null, level, message, exception); + } + + public void log(ServiceReference reference, int level, String message) { + log(reference, level, message, null); + } + + public synchronized void log(ServiceReference reference, int level, String message, Throwable exception) { + ServiceReference[] references = getServiceReferences(); + + if (references != null) { + int size = references.length; + + for (int i = 0; i < size; i++) { + LogService service = (LogService) getService(references[i]); + if (service != null) { + try { + service.log(reference, level, message, exception); + } catch (Exception e) { + // TODO: consider printing to System Error + } + } + } + + return; + } + + noLogService(level, message, exception, reference); + } + + /** + * The LogService is not available so we write the message to a PrintStream. + * + * @param level Logging level + * @param message Log message. + * @param throwable Log exception or null if none. + * @param reference ServiceReference associated with message or null if none. + */ + protected void noLogService(int level, String message, Throwable throwable, ServiceReference reference) { + if (out != null) { + synchronized (out) { + // Bug #113286. If no log service present and messages are being + // printed to stdout, prepend message with a timestamp. + String timestamp = getDate(new Date()); + out.print(timestamp + " "); //$NON-NLS-1$ + + switch (level) { + case LOG_DEBUG : { + out.print("Debug"); //$NON-NLS-1$ + break; + } + case LOG_INFO : { + out.print("Info"); //$NON-NLS-1$ + break; + } + case LOG_WARNING : { + out.print("Warning"); //$NON-NLS-1$ + break; + } + case LOG_ERROR : { + out.print("Error"); //$NON-NLS-1$ + break; + } + default : { + out.print("["); //$NON-NLS-1$ + out.print("Unknown Log Level"); //$NON-NLS-1$ + out.print("]"); //$NON-NLS-1$ + break; + } + } + out.print(": "); //$NON-NLS-1$ + out.println(message); + + if (reference != null) { + out.println(reference); + } + + if (throwable != null) { + throwable.printStackTrace(out); + } + } + } + } + + // from EclipseLog to avoid using DateFormat -- see bug 149892#c10 + private String getDate(Date date) { + Calendar c = Calendar.getInstance(); + c.setTime(date); + StringBuffer sb = new StringBuffer(); + appendPaddedInt(c.get(Calendar.YEAR), 4, sb).append('-'); + appendPaddedInt(c.get(Calendar.MONTH) + 1, 2, sb).append('-'); + appendPaddedInt(c.get(Calendar.DAY_OF_MONTH), 2, sb).append(' '); + appendPaddedInt(c.get(Calendar.HOUR_OF_DAY), 2, sb).append(':'); + appendPaddedInt(c.get(Calendar.MINUTE), 2, sb).append(':'); + appendPaddedInt(c.get(Calendar.SECOND), 2, sb).append('.'); + appendPaddedInt(c.get(Calendar.MILLISECOND), 3, sb); + return sb.toString(); + } + + private StringBuffer appendPaddedInt(int value, int pad, StringBuffer buffer) { + pad = pad - 1; + if (pad == 0) + return buffer.append(Integer.toString(value)); + int padding = (int) Math.pow(10, pad); + if (value >= padding) + return buffer.append(Integer.toString(value)); + while (padding > value && padding > 1) { + buffer.append('0'); + padding = padding / 10; + } + buffer.append(value); + return buffer; + } +} Added: branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java =================================================================== --- branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java (rev 0) +++ branches/user_prefs/org.eclipse.equinox.cm/src/org/eclipse/equinox/internal/cm/ManagedServiceFactoryTracker.java 2008-03-21 17:39:47 UTC (rev 676) @@ -0,0 +1,188 @@ +/******************************************************************************* + * Copyright (c) 2006-2007 Cognos Incorporated, IBM Corporation and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cognos Incorporated - initial API and implementation + * IBM Corporation - bug fixes and enhancements + *******************************************************************************/ +package org.eclipse.equinox.internal.cm; + +import java.util.*; +import java.util.Map.Entry; +import org.osgi.framework.*; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedServiceFactory; +import org.osgi.service.log.LogService; +import org.osgi.util.tracker.ServiceTracker; + +/** + * ManagedServiceFactoryTracker tracks... ManagedServiceFactory(s) and notifies them about related configuration changes + */ +class ManagedServiceFactoryTracker extends ServiceTracker { + + final ConfigurationAdminFactory configurationAdminFactory; + private final ConfigurationStore configurationStore; + private final Map managedServiceFactories = new HashMap(); + private final Map managedServiceFactoryReferences = new HashMap(); + private final SerializedTaskQueue queue = new SerializedTaskQueue("ManagedServiceFactory Update Queue"); //$NON-NLS-1$ + + public ManagedServiceFactoryTracker(ConfigurationAdminFactory configurationAdminFactory, ConfigurationStore configurationStore, BundleContext context) { + super(context, ManagedServiceFactory.class.getName(), null); + this.configurationAdminFactory = configurationAdminFactory; + this.configurationStore = configurationStore; + } + + protected void notifyDeleted(ConfigurationImpl config) { + config.checkLocked(); + String factoryPid = config.getFactoryPid(false); + ServiceReference reference = getManagedServiceFactoryReference(factoryPid); + if (reference != null && config.bind(reference.getBundle())) + asynchDeleted(getManagedServiceFactory(factoryPid), config.getPid(false)); + } + + protected void notifyUpdated(ConfigurationImpl config) { + config.checkLocked(); + String factoryPid = config.getFactoryPid(); + ServiceReference reference = getManagedServiceFactoryReference(factoryPid); + if (reference != null && config.bind(reference.getBundle())) { + Dictionary properties = config.getProperties(); + configurationAdminFactory.modifyConfiguration(reference, properties); + asynchUpdated(getManagedServiceFactory(factoryPid), config.getPid(), properties); + } + } + + public Object addingService(ServiceReference reference) { + String factoryPid = (String) reference.getProperty(Constants.SERVICE_PID); + if (factoryPid == null) + return null; + + ManagedServiceFactory service = (... [truncated message content] |
From: <mwl...@us...> - 2008-03-21 17:36:38
|
Revision: 675 http://cishell.svn.sourceforge.net/cishell/?rev=675&view=rev Author: mwlinnem Date: 2008-03-21 10:36:26 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Added Paths: ----------- branches/user_prefs/org.eclipse.equinox.cm/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-03-21 16:30:44
|
Revision: 674 http://cishell.svn.sourceforge.net/cishell/?rev=674&view=rev Author: mwlinnem Date: 2008-03-21 09:30:04 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Added Paths: ----------- branches/user_prefs/org.cishell.testalgorithm4/.classpath branches/user_prefs/org.cishell.testalgorithm4/.project branches/user_prefs/org.cishell.testalgorithm4/.settings/ branches/user_prefs/org.cishell.testalgorithm4/META-INF/ branches/user_prefs/org.cishell.testalgorithm4/META-INF/MANIFEST.MF branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/ branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/algorithm.properties branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/component.xml branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/l10n/ branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/l10n/bundle_en.properties branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/metatype/ branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/metatype/METADATA.XML branches/user_prefs/org.cishell.testalgorithm4/build.properties branches/user_prefs/org.cishell.testalgorithm4/src/ branches/user_prefs/org.cishell.testalgorithm4/src/org/ branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/ branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/ branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/TestAlgorithm4.java branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/TestAlgorithm4Factory.java Added: branches/user_prefs/org.cishell.testalgorithm4/.classpath =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/.classpath (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/.classpath 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="build"/> +</classpath> Added: branches/user_prefs/org.cishell.testalgorithm4/.project =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/.project (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/.project 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.testalgorithm4</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: branches/user_prefs/org.cishell.testalgorithm4/META-INF/MANIFEST.MF =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/META-INF/MANIFEST.MF (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/META-INF/MANIFEST.MF 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Test Algorithm 4 +Bundle-SymbolicName: org.cishell.testalgorithm4 +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Import-Package: org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.osgi.framework;version="1.3.0", + org.osgi.service.cm;version="1.2.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0", + org.osgi.service.prefs;version="1.1.0" +X-AutoStart: true +Service-Component: OSGI-INF/component.xml Added: branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/algorithm.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/algorithm.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/algorithm.properties 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,9 @@ +menu_path=Visualization/SubMenu/additions +label=Test Algorithm 4 (Vis) +description=sdpfkspofk +in_data=null +out_data=null +service.pid=org.cishell.testalgorithm4.TestAlgorithm4 +remoteable=false +prefs_published=local,param-defaults +receive_prefs=true Added: branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/component.xml =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/component.xml (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/component.xml 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.testalgorithm4.TestAlgorithm4.component" immediate="true"> + <implementation class="org.cishell.testalgorithm4.TestAlgorithm4Factory"/> + <properties entry="OSGI-INF/algorithm.properties"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + <reference name="CA" interface="org.osgi.service.cm.ConfigurationAdmin"/> + + <service> + <provide interface= + "org.cishell.framework.algorithm.AlgorithmFactory"/> + <provide interface= + "org.osgi.service.cm.ManagedService"/> + </service> +</component> \ No newline at end of file Added: branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/l10n/bundle_en.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/l10n/bundle_en.properties 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,7 @@ +#Localization variables for OSGI-INF/metatatype/METADATA.XML +# +#Samples: +#input=Input +#desc=Enter an integer (that will be converted to a string) +#name=Input->String +#name_desc=Converts inputted integer to string Added: branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/metatype/METADATA.XML =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/metatype/METADATA.XML (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/OSGI-INF/metatype/METADATA.XML 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + + <OCD name="Imaginary Visualization Algorithm" id="org.cishell.testalgorithm4.TestAlgorithm4.OCD" + description=" "> + <AD name="Made up param number go!" id="madeUpNum" type="Double" default="33.33"/> + </OCD> + + <OCD name="Imaginary Visualization Algorithm" id="org.cishell.testalgorithm4.TestAlgorithm4.prefs.local.OCD" + description=" "> + <AD name="Background color" id="backgroundColor" type="String" default="color:130,220,130"/> + <AD name="Label font" id="labelFont" type="String" default="font:"/> + <AD name="Made up numeric value" id="numericVal" type="Double" default="1.234"/> + </OCD> + <Designate pid="org.cishell.testalgorithm4.TestAlgorithm4.prefs.local"> + <Object ocdref="org.cishell.testalgorithm4.TestAlgorithm4.prefs.local.OCD" /> + </Designate> + <Designate pid="org.cishell.testalgorithm4.TestAlgorithm4"> + <Object ocdref="org.cishell.testalgorithm4.TestAlgorithm4.OCD" /> + </Designate> +</metatype:MetaData> Added: branches/user_prefs/org.cishell.testalgorithm4/build.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/build.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/build.properties 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,5 @@ +source.. = src/ +output.. = build/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ Added: branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/TestAlgorithm4.java =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/TestAlgorithm4.java (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/TestAlgorithm4.java 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,44 @@ +package org.cishell.testalgorithm4; + +import java.util.Dictionary; +import java.util.Enumeration; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.data.Data; + +public class TestAlgorithm4 implements Algorithm { + Data[] data; + Dictionary parameters; + CIShellContext context; + + private Dictionary preferences; + + public TestAlgorithm4(Data[] data, Dictionary parameters, CIShellContext context, Dictionary preferences) { + this.data = data; + this.parameters = parameters; + this.context = context; + this.preferences = preferences; + } + + public Data[] execute() { + printPreferences(this.preferences); + return null; + } + + private void printPreferences(Dictionary preferences) { + System.out.println(" Preferences are as follows:"); + if (preferences == null) { + System.out.println(" Dictionary is null!"); + } else { + Enumeration propertiesKeys = preferences.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = preferences.get(propertiesKey); + System.out.println(" " + propertiesKey + ":" + propertiesValue); + } + } +} +} \ No newline at end of file Added: branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/TestAlgorithm4Factory.java =================================================================== --- branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/TestAlgorithm4Factory.java (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm4/src/org/cishell/testalgorithm4/TestAlgorithm4Factory.java 2008-03-21 16:30:04 UTC (rev 674) @@ -0,0 +1,76 @@ +package org.cishell.testalgorithm4; + +import java.io.IOException; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.Hashtable; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.MetaTypeProvider; +import org.osgi.service.metatype.MetaTypeService; + + +public class TestAlgorithm4Factory implements AlgorithmFactory, ManagedService { + private MetaTypeProvider provider; + private ConfigurationAdmin ca; + private Dictionary preferences; + private LogService log; + String pid; + + protected void activate(ComponentContext ctxt) { + //System.out.println("TestAlgorithm 4 beginning activation"); + //You may delete all references to metatype service if + //your algorithm does not require parameters and return + //null in the createParameters() method + MetaTypeService mts = (MetaTypeService)ctxt.locateService("MTS"); + + this.log = (LogService) ctxt.locateService("LOG"); + this.ca = (ConfigurationAdmin) ctxt.locateService("CA"); + provider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle()); + this.pid = (String) ctxt.getProperties().get("service.pid"); + // System.out.println("TestAlgorithm 4 done activating"); + } + protected void deactivate(ComponentContext ctxt) { + provider = null; + } + + public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { + + System.out.println("TestAlgorithm4 executed!"); + return new TestAlgorithm4(data, parameters, context, this.preferences); + } + public MetaTypeProvider createParameters(Data[] data) { + return provider; + } + public void updated(Dictionary preferences) throws ConfigurationException { + + this.preferences = preferences; +// //System.out.println("TestAlgorithm4 updated!"); +// printProperties(this.preferences); + } + + private void printProperties(Dictionary properties) { + System.out.println(" Preferences are as follows:"); + if (properties == null) { + System.out.println(" Dictionary is null!"); + } else { + Enumeration propertiesKeys = properties.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = properties.get(propertiesKey); + System.out.println(" " + propertiesKey + ":" + propertiesValue); + } + } + } +} \ 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-03-21 16:29:50
|
Revision: 673 http://cishell.svn.sourceforge.net/cishell/?rev=673&view=rev Author: mwlinnem Date: 2008-03-21 09:29:42 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Added Paths: ----------- 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-03-21 16:26:47
|
Revision: 672 http://cishell.svn.sourceforge.net/cishell/?rev=672&view=rev Author: mwlinnem Date: 2008-03-21 09:26:11 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Added Paths: ----------- branches/user_prefs/org.cishell.testalgorithm3/.classpath branches/user_prefs/org.cishell.testalgorithm3/.project branches/user_prefs/org.cishell.testalgorithm3/.settings/ branches/user_prefs/org.cishell.testalgorithm3/META-INF/ branches/user_prefs/org.cishell.testalgorithm3/META-INF/MANIFEST.MF branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/algorithm.properties branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/component.xml branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/bundle_en.properties branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/METADATA.XML branches/user_prefs/org.cishell.testalgorithm3/build.properties branches/user_prefs/org.cishell.testalgorithm3/src/ branches/user_prefs/org.cishell.testalgorithm3/src/org/ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithm.java branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithmFactory.java Added: branches/user_prefs/org.cishell.testalgorithm3/.classpath =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/.classpath (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/.classpath 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="build"/> +</classpath> Added: branches/user_prefs/org.cishell.testalgorithm3/.project =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/.project (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/.project 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.testalgorithm3</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: branches/user_prefs/org.cishell.testalgorithm3/META-INF/MANIFEST.MF =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/META-INF/MANIFEST.MF (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/META-INF/MANIFEST.MF 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Test Algorithm 3 +Bundle-SymbolicName: org.cishell.testalgorithm3 +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Import-Package: org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.osgi.framework;version="1.3.0", + org.osgi.service.cm;version="1.2.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0", + org.osgi.service.prefs;version="1.1.0" +X-AutoStart: true +Service-Component: OSGI-INF/component.xml Added: branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/algorithm.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/algorithm.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/algorithm.properties 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,9 @@ +menu_path=File/additions +label=Test Algorithm 3 (Global) +description=Tests preference stuff +in_data=null +out_data=null +service.pid=org.cishell.testalgorithm3.TestAlgorithm +remoteable=false +prefs_published=global +receive_prefs=true Added: branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/component.xml =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/component.xml (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/component.xml 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.testalgorithm3.TestAlgorithm.component" immediate="true"> + <implementation class="org.cishell.testalgorithm3.TestAlgorithmFactory"/> + <properties entry="OSGI-INF/algorithm.properties"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + + <service> + <provide interface= + "org.cishell.framework.algorithm.AlgorithmFactory"/> + <provide interface= + "org.osgi.service.cm.ManagedService"/> + </service> +</component> \ No newline at end of file Added: branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/bundle_en.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/l10n/bundle_en.properties 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,7 @@ +#Localization variables for OSGI-INF/metatatype/METADATA.XML +# +#Samples: +#input=Input +#desc=Enter an integer (that will be converted to a string) +#name=Input->String +#name_desc=Converts inputted integer to string Added: branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/METADATA.XML =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/METADATA.XML (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/OSGI-INF/metatype/METADATA.XML 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + + <OCD name="General" id="org.cishell.testalgorithm3.prefs.global.OCD" + description=" "> + <AD name="Save data files to" id="saveDataDir" type="String" default="directory:/home/mwlinnem/"/> + <AD name="Open .txt files with" id="txtFileProg" type="String" default="file:"/> + <AD name="Open .csv files with" id="csvFileProg" type="String" default="file:"/> + <AD name="Prompt to save on exit?" id="promptSave" type="Boolean" default="true"/> + </OCD> + + <OCD name="Logging" id="org.cishell.testalgorithm3.prefs.global2.OCD" + description=" "> + <AD name="Set default logging level" id="logLevel" type="String" default="Normal"> + <Option label="Minimal" value="Minimal"/> + <Option label="Normal" value="Normal"/> + <Option label="Verbose" value="Verbose"/> + </AD> + + <AD name="Class Path" id="cp" type="String" default="path:"> + </AD> + + <AD name="Save log files to" id="logFileSaveDir" type="String" default="directory:/tmp/"/> + </OCD> + + <Designate pid="org.cishell.testalgorithm3.TestAlgorithm.prefs.global"> + <Object ocdref="org.cishell.testalgorithm3.prefs.global.OCD"/> + </Designate> + + <Designate pid="org.cishell.testalgorithm3.TestAlgorithm.prefs.global2"> + <Object ocdref="org.cishell.testalgorithm3.prefs.global2.OCD"/> + </Designate> +</metatype:MetaData> Added: branches/user_prefs/org.cishell.testalgorithm3/build.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/build.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/build.properties 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,5 @@ +source.. = src/ +output.. = build/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ Added: branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithm.java =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithm.java (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithm.java 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,44 @@ +package org.cishell.testalgorithm3; + +import java.util.Dictionary; +import java.util.Enumeration; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.data.Data; + +public class TestAlgorithm implements Algorithm { + Data[] data; + Dictionary parameters; + CIShellContext context; + + private Dictionary preferences; + + public TestAlgorithm(Data[] data, Dictionary parameters, CIShellContext context, Dictionary preferences) { + this.data = data; + this.parameters = parameters; + this.context = context; + this.preferences = preferences; + } + + public Data[] execute() { + printPreferences(this.preferences); + return null; + } + + private void printPreferences(Dictionary preferences) { + System.out.println(" Preferences are as follows:"); + if (preferences == null) { + System.out.println(" Dictionary is null!"); + } else { + Enumeration propertiesKeys = preferences.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = preferences.get(propertiesKey); + System.out.println(" " + propertiesKey + ":" + propertiesValue); + } + } +} +} \ No newline at end of file Added: branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithmFactory.java =================================================================== --- branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithmFactory.java (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm3/src/org/cishell/testalgorithm3/TestAlgorithmFactory.java 2008-03-21 16:26:11 UTC (rev 672) @@ -0,0 +1,76 @@ +package org.cishell.testalgorithm3; + +import java.util.Dictionary; +import java.util.Enumeration; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.metatype.MetaTypeProvider; +import org.osgi.service.metatype.MetaTypeService; + + +public class TestAlgorithmFactory implements AlgorithmFactory, ManagedService { + private MetaTypeProvider provider; + private Dictionary preferences; + + protected void activate(ComponentContext ctxt) { + // System.out.println("TestAlgorithm 3 beginning activation"); + //You may delete all references to metatype service if + //your algorithm does not require parameters and return + //null in the createParameters() method + MetaTypeService mts = (MetaTypeService)ctxt.locateService("MTS"); + provider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle()); + + Dictionary properties = ctxt.getProperties(); + + Enumeration propertiesKeys = properties.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = properties.get(propertiesKey); + + } + + // System.out.println("TestAlgorithm 3 done activating"); + } + protected void deactivate(ComponentContext ctxt) { + provider = null; + } + + public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { + System.out.println("TestAlgorithm3 executed!"); + return new TestAlgorithm(data, parameters, context, this.preferences); + } + public MetaTypeProvider createParameters(Data[] data) { + return provider; + } + + private void printPreferences(Dictionary properties) { + System.out.println(" Preferences are as follows:"); + if (properties == null) { + System.out.println(" Dictionary is null!"); + } else { + Enumeration propertiesKeys = properties.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = properties.get(propertiesKey); + System.out.println(" " + propertiesKey + ":" + propertiesValue); + } + } + } + + public void updated(Dictionary properties) throws ConfigurationException { + + this.preferences = properties; + //System.out.println("TestAlgorithm 3 updated!"); + //printPreferences(properties); + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-03-21 16:24:35
|
Revision: 671 http://cishell.svn.sourceforge.net/cishell/?rev=671&view=rev Author: mwlinnem Date: 2008-03-21 09:24:22 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Added Paths: ----------- 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-03-21 16:23:41
|
Revision: 670 http://cishell.svn.sourceforge.net/cishell/?rev=670&view=rev Author: mwlinnem Date: 2008-03-21 09:23:25 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Test algorithm for user preference service. Added Paths: ----------- branches/user_prefs/org.cishell.testalgorithm2/.classpath branches/user_prefs/org.cishell.testalgorithm2/.project branches/user_prefs/org.cishell.testalgorithm2/.settings/ branches/user_prefs/org.cishell.testalgorithm2/META-INF/ branches/user_prefs/org.cishell.testalgorithm2/META-INF/MANIFEST.MF branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/algorithm.properties branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/component.xml branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/bundle_en.properties branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/METADATA.XML branches/user_prefs/org.cishell.testalgorithm2/build.properties branches/user_prefs/org.cishell.testalgorithm2/src/ branches/user_prefs/org.cishell.testalgorithm2/src/org/ branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/ branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/ branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2.java branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2Factory.java Added: branches/user_prefs/org.cishell.testalgorithm2/.classpath =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/.classpath (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/.classpath 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="build"/> +</classpath> Added: branches/user_prefs/org.cishell.testalgorithm2/.project =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/.project (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/.project 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.testalgorithm2</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: branches/user_prefs/org.cishell.testalgorithm2/META-INF/MANIFEST.MF =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/META-INF/MANIFEST.MF (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/META-INF/MANIFEST.MF 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Test Algorithm 2 +Bundle-SymbolicName: org.cishell.testalgorithm2 +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Import-Package: org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.osgi.framework;version="1.3.0", + org.osgi.service.cm;version="1.2.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0", + org.osgi.service.prefs;version="1.1.0" +X-AutoStart: true +Service-Component: OSGI-INF/component.xml Added: branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/algorithm.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/algorithm.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/algorithm.properties 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,9 @@ +menu_path=File/additions +label=Test Algorithm 2 (Load) +description=tests various things +in_data=null +out_data=null +service.pid=org.cishell.testalgorithm2.TestAlgorithm2 +remoteable=false +prefs_published=local +receive_prefs=true Added: branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/component.xml =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/component.xml (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/component.xml 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.testalgorithm2.TestAlgorithm2.component" immediate="false"> + <implementation class="org.cishell.testalgorithm2.TestAlgorithm2Factory"/> + <properties entry="OSGI-INF/algorithm.properties"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + + <service> + <provide interface= + "org.cishell.framework.algorithm.AlgorithmFactory"/> + <provide interface= + "org.osgi.service.cm.ManagedService"/> + </service> +</component> \ No newline at end of file Added: branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/bundle_en.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/l10n/bundle_en.properties 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,7 @@ +#Localization variables for OSGI-INF/metatatype/METADATA.XML +# +#Samples: +#input=Input +#desc=Enter an integer (that will be converted to a string) +#name=Input->String +#name_desc=Converts inputted integer to string Added: branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/METADATA.XML =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/METADATA.XML (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/OSGI-INF/metatype/METADATA.XML 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + + <OCD name="Imaginary Load Algorithm" id="org.cishell.testalgorithm2.TestAlgorithm2.prefs.local.OCD" + description="tests various things"> + <AD name="Default load directory" id="loadDir" type="String" default="directory:"/> + <AD name="Default separator characters" id="sepChars" type="String" default=",;"/> + </OCD> + + <OCD name="Test Algorithm2" id="org.cishell.testalgorithm2.TestAlgorithm2.old.OCD" + description="tests various things"> + <AD name="stringName" id="stringID" type="String" default="string default"/> + <AD name="boolName" id="boolID" type="Boolean" default="true"/> + <AD name="intName" id="intID" type="Integer" default="0"/> + <AD name="fontName" id="fontID" type="String" default="font:"/> + <AD name="directoryName" id="directoryID" type="String" default="directory:/home/"/> + <AD name="fileName" id="fileID" type="String" default="file:/home/mwlinnem/nwb/nwb"/> + <AD name="pathName" id="pathID" type="String" default="path:/home/mwlinnem/nwb/"/> + <AD name="radioName" id="radioID" type="String" default="radio default"> + <Option label="option 1" value="value 1"/> + <Option label="option 2" value="value 2"/> + <Option label="option 3" value="value 3"/> + </AD> + <AD name="floatName" id="floatID" type="Float" default="1.23"/> + <Ad name="doubleName" id="doubleID" type="Double" default="1.2345678675442"/> + </OCD> + + <Designate pid="org.cishell.testalgorithm2.TestAlgorithm2.prefs.local"> + <Object ocdref="org.cishell.testalgorithm2.TestAlgorithm2.prefs.local.OCD" /> + </Designate> + +</metatype:MetaData> Added: branches/user_prefs/org.cishell.testalgorithm2/build.properties =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/build.properties (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/build.properties 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,5 @@ +source.. = src/ +output.. = build/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ Added: branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2.java =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2.java (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2.java 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,44 @@ +package org.cishell.testalgorithm2; + +import java.util.Dictionary; +import java.util.Enumeration; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.data.Data; + +public class TestAlgorithm2 implements Algorithm { + Data[] data; + Dictionary parameters; + CIShellContext context; + + private Dictionary preferences; + + public TestAlgorithm2(Data[] data, Dictionary parameters, CIShellContext context, Dictionary preferences) { + this.data = data; + this.parameters = parameters; + this.context = context; + this.preferences = preferences; + } + + public Data[] execute() { + printPreferences(this.preferences); + return null; + } + + private void printPreferences(Dictionary preferences) { + System.out.println(" Preferences are as follows:"); + if (preferences == null) { + System.out.println(" Dictionary is null!"); + } else { + Enumeration propertiesKeys = preferences.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = preferences.get(propertiesKey); + System.out.println(" " + propertiesKey + ":" + propertiesValue); + } + } +} +} \ No newline at end of file Added: branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2Factory.java =================================================================== --- branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2Factory.java (rev 0) +++ branches/user_prefs/org.cishell.testalgorithm2/src/org/cishell/testalgorithm2/TestAlgorithm2Factory.java 2008-03-21 16:23:25 UTC (rev 670) @@ -0,0 +1,99 @@ +package org.cishell.testalgorithm2; + +import java.util.Dictionary; +import java.util.Enumeration; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmFactory; +import org.cishell.framework.data.Data; +import org.osgi.framework.BundleContext; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.metatype.MetaTypeProvider; +import org.osgi.service.metatype.MetaTypeService; +import org.osgi.service.metatype.ObjectClassDefinition; + + +public class TestAlgorithm2Factory implements AlgorithmFactory, ManagedService { + private MetaTypeProvider provider; + + private BundleContext bContext; + private Dictionary preferences; + + protected void activate(ComponentContext ctxt) { + //System.out.println("TestAlgorithm 2 beginning activation"); + //You may delete all references to metatype service if + //your algorithm does not require parameters and return + //null in the createParameters() method + MetaTypeService mts = (MetaTypeService)ctxt.locateService("MTS"); + provider = mts.getMetaTypeInformation(ctxt.getBundleContext().getBundle()); + + Dictionary properties = ctxt.getProperties(); + + Enumeration propertiesKeys = properties.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = properties.get(propertiesKey); + } + + this.bContext = ctxt.getBundleContext(); + + //System.out.println("TestAlgorithm 2 done activating"); + } + + protected void deactivate(ComponentContext ctxt) { + provider = null; + } + + public Algorithm createAlgorithm(Data[] data, Dictionary parameters, CIShellContext context) { + +// //not renaming everything parametersX for sake of ease +// +// Enumeration propertiesKeys = parameters.keys(); +// +// while (propertiesKeys.hasMoreElements()) { +// String propertiesKey = (String) propertiesKeys.nextElement(); +// +// Object propertiesValue = parameters.get(propertiesKey); +// } + + System.out.println("TestAlgorithm 2 executing!"); + return new TestAlgorithm2(data, parameters, context, this.preferences); + } + public MetaTypeProvider createParameters(Data[] data) { + return provider; + } + public void updated(Dictionary properties) throws ConfigurationException { + // System.out.println("TestAlgorithm 2 updated!"); + + + this.preferences = properties; + + // printPreferences(this.preferences); + } + + private void printPreferences(Dictionary properties) { + System.out.println(" Preferences are as follows:"); + if (properties == null) { + System.out.println(" Dictionary is null!"); + } else { + Enumeration propertiesKeys = properties.keys(); + + while (propertiesKeys.hasMoreElements()) { + String propertiesKey = (String) propertiesKeys.nextElement(); + + Object propertiesValue = properties.get(propertiesKey); + System.out.println(" " + propertiesKey + ":" + propertiesValue); + } + } + } + + public String[] getLocales() { + return null; + } +} \ 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-03-21 16:23:06
|
Revision: 669 http://cishell.svn.sourceforge.net/cishell/?rev=669&view=rev Author: mwlinnem Date: 2008-03-21 09:22:57 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Test algorithm for user preference service. Added Paths: ----------- 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-03-21 16:20:32
|
Revision: 668 http://cishell.svn.sourceforge.net/cishell/?rev=668&view=rev Author: mwlinnem Date: 2008-03-21 09:20:18 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Moved from NWB repository to the native homeland of the user preferences service. Added Paths: ----------- branches/user_prefs/org.cishell.reference.prefs.admin/.classpath branches/user_prefs/org.cishell.reference.prefs.admin/.project branches/user_prefs/org.cishell.reference.prefs.admin/.settings/ branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/ branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/MANIFEST.MF branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/ branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/algorithm.properties branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/component.xml branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/l10n/ branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/l10n/bundle_en.properties branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/metatype/ branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/metatype/METADATA.XML branches/user_prefs/org.cishell.reference.prefs.admin/build.properties branches/user_prefs/org.cishell.reference.prefs.admin/src/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefAdmin.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefPage.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefPageComparator.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PreferenceAD.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PreferenceOCD.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefsByService.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefAdminImpl.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefPageImpl.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PreferenceADImpl.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PreferenceOCDImpl.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/TypePrefixes.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/util/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/util/BasicTree.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/util/ListMap.java branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/service/ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/service/prefadmin/ Added: branches/user_prefs/org.cishell.reference.prefs.admin/.classpath =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/.classpath (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/.classpath 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="build"/> +</classpath> Added: branches/user_prefs/org.cishell.reference.prefs.admin/.project =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/.project (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/.project 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.reference.prefs.admin</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/MANIFEST.MF =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/MANIFEST.MF (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/META-INF/MANIFEST.MF 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: CIShell Pref Admin +Bundle-SymbolicName: org.cishell.reference.prefs.admin +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Import-Package: org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.cishell.framework.preference, + org.cishell.reference.service.metatype, + org.osgi.framework;version="1.3.0", + org.osgi.service.cm;version="1.2.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0", + org.osgi.service.prefs;version="1.1.0" +X-AutoStart: true +Service-Component: OSGI-INF/component.xml +Export-Package: org.cishell.reference.prefs.admin Added: branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/algorithm.properties =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/algorithm.properties (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/algorithm.properties 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,2 @@ +service.pid=org.cishell.reference.prefs.admin.PrefAdmin +remoteable=false Added: branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/component.xml =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/component.xml (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/component.xml 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.reference.prefs.admin.internal.PrefAdmin.component" immediate="true"> + <implementation class="org.cishell.reference.prefs.admin.internal.PrefAdminImpl"/> + <properties entry="OSGI-INF/algorithm.properties"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + <reference name="CS" interface="org.osgi.service.cm.ConfigurationAdmin" + cardinality="1..1"/> + + <reference name="PREF_HOLDERS" + interface="org.cishell.framework.algorithm.AlgorithmFactory" + cardinality="0..n" + policy="dynamic" + bind="prefHolderRegistered" + unbind="prefHolderUnregistered" + /> + + <service> + <provide interface= + "org.cishell.reference.prefs.admin.PrefAdmin"/> + <provide interface= + "org.osgi.service.cm.ConfigurationPlugin"/> + <provide interface= + "org.osgi.service.cm.ConfigurationListener"/> + </service> +</component> + + + \ No newline at end of file Added: branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/l10n/bundle_en.properties =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/l10n/bundle_en.properties 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,7 @@ +#Localization variables for OSGI-INF/metatatype/METADATA.XML +# +#Samples: +#input=Input +#desc=Enter an integer (that will be converted to a string) +#name=Input->String +#name_desc=Converts inputted integer to string Added: branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/metatype/METADATA.XML =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/metatype/METADATA.XML (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/OSGI-INF/metatype/METADATA.XML 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + <Designate pid="org.cishell.reference.prefs.admin.PrefAdmin"> + <Object ocdref="org.cishell.reference.prefs.admin.PrefAdmin.OCD" /> + </Designate> +</metatype:MetaData> Added: branches/user_prefs/org.cishell.reference.prefs.admin/build.properties =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/build.properties (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/build.properties 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,5 @@ +source.. = src/ +output.. = build/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefAdmin.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefAdmin.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefAdmin.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,11 @@ +package org.cishell.reference.prefs.admin; + +import org.osgi.service.cm.ConfigurationPlugin; + +public interface PrefAdmin extends ConfigurationPlugin { + public PrefPage[] getLocalPrefPages(); + public PrefPage[] getGlobalPrefPages(); + public PrefPage[] getParamPrefPages(); + + public PrefsByService[] getPrefsByService(); +} Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefPage.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefPage.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefPage.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,18 @@ +package org.cishell.reference.prefs.admin; + +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.Configuration; + +public interface PrefPage { + + public static final int LOCAL = 0; + public static final int GLOBAL = 1; + public static final int PARAM = 2; + + public abstract ServiceReference getServiceReference(); + + public abstract int getType(); + + public abstract Configuration getPrefConf(); + public abstract PreferenceOCD getPrefOCD(); +} \ No newline at end of file Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefPageComparator.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefPageComparator.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefPageComparator.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,28 @@ +package org.cishell.reference.prefs.admin; + +import java.util.Comparator; + +import org.osgi.service.metatype.ObjectClassDefinition; + +public class PrefPageComparator implements Comparator { + public int compare (Object o1, Object o2) { + if (! (o1 instanceof PrefPage) || ! (o2 instanceof PrefPage)) { + throw new ClassCastException("Cannot compare two objects that are not both PrefPages."); + } + PrefPage pp1 = (PrefPage) o1; + ObjectClassDefinition ocd1 = pp1.getPrefOCD(); + if (ocd1 == null) { + return -1; + } + String ocd1Name = ocd1.getName(); + + PrefPage pp2 = (PrefPage) o2; + ObjectClassDefinition ocd2 = pp2.getPrefOCD(); + if (ocd2 == null) { + return 1; + } + String ocd2Name = ocd2.getName(); + + return ocd1Name.compareTo(ocd2Name); + } +} Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PreferenceAD.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PreferenceAD.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PreferenceAD.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,35 @@ +package org.cishell.reference.prefs.admin; + +import org.osgi.service.metatype.AttributeDefinition; + +public interface PreferenceAD extends AttributeDefinition { + + public static final int TEXT = 19; + public static final int DIRECTORY = 20; + public static final int FILE = 21; + public static final int FONT = 22; + public static final int PATH = 23; + public static final int CHOICE = 24; + public static final int COLOR = 25; + + public abstract int getCardinality(); + + public abstract String[] getDefaultValue(); + + public abstract String getDescription(); + + public abstract String getID(); + + public abstract String getName(); + + public abstract String[] getOptionLabels(); + + public abstract String[] getOptionValues(); + + public abstract int getType(); + + public abstract int getPreferenceType(); + + public abstract String validate(String value); + +} \ No newline at end of file Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PreferenceOCD.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PreferenceOCD.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PreferenceOCD.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,26 @@ +package org.cishell.reference.prefs.admin; + +import java.io.IOException; +import java.io.InputStream; + +import org.osgi.service.metatype.AttributeDefinition; +import org.osgi.service.metatype.ObjectClassDefinition; + +public interface PreferenceOCD extends ObjectClassDefinition { + + //use in standard way + public abstract AttributeDefinition[] getAttributeDefinitions(int filter); + + //use to get at the special preference attribute goodness. + public abstract PreferenceAD[] getPreferenceAttributeDefinitions( + int filter); + + public abstract String getDescription(); + + public abstract String getID(); + + public abstract InputStream getIcon(int size) throws IOException; + + public abstract String getName(); + +} \ No newline at end of file Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefsByService.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefsByService.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/PrefsByService.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,33 @@ +package org.cishell.reference.prefs.admin; + +import org.osgi.framework.ServiceReference; + +public class PrefsByService { + + private ServiceReference prefHolder; + private PrefPage[] localPrefs; + private PrefPage[] globalPrefs; + private PrefPage[] paramPrefs; + public PrefsByService(ServiceReference prefHolder, PrefPage[] localPrefs, PrefPage[] globalPrefs, PrefPage[] paramPrefs) { + this.prefHolder = prefHolder; + this.localPrefs = localPrefs; + this.globalPrefs = globalPrefs; + this.paramPrefs = paramPrefs; + } + + public ServiceReference getServiceReference() { + return this.prefHolder; + } + + public PrefPage[] getGlobalPrefPages() { + return this.globalPrefs; + } + + public PrefPage[] getLocalPrefPages() { + return this.localPrefs; + } + + public PrefPage[] getParamPrefPages() { + return this.paramPrefs; + } +} Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefAdminImpl.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefAdminImpl.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefAdminImpl.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,171 @@ +package org.cishell.reference.prefs.admin.internal; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.List; + +import org.cishell.framework.preference.PreferenceProperty; +import org.cishell.reference.prefs.admin.PrefAdmin; +import org.cishell.reference.prefs.admin.PrefPage; +import org.cishell.reference.prefs.admin.PrefsByService; +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.cm.ConfigurationEvent; +import org.osgi.service.cm.ConfigurationListener; +import org.osgi.service.cm.ConfigurationPlugin; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.MetaTypeService; + +public class PrefAdminImpl implements PrefAdmin, ConfigurationPlugin, ConfigurationListener { + + private LogService log; + private MetaTypeService mts; + private ConfigurationAdmin ca; + + private PrefInfoGrabber prefInfoGrabber; + private PrefReferenceProcessor prefProcessor; + + private List prefReferencesToBeProcessed = new ArrayList(); + private List prefHolderReferences = new ArrayList(); + + private boolean hasBeenActivated = false; + + //PrefAdmin interface + + public PrefPage[] getLocalPrefPages() { + return prefProcessor.getAllLocalPrefPages(); + } + + + public PrefPage[] getGlobalPrefPages() { + return prefProcessor.getAllGlobalPrefPages(); + } + + public PrefPage[] getParamPrefPages() { + return prefProcessor.getAllParamPrefPages(); + } + + public PrefsByService[] getPrefsByService() { + return prefProcessor.getAllPrefsByService(); + } + + //Service Component Interface + + protected void activate(ComponentContext ctxt) { + + this.log = (LogService) ctxt.locateService("LOG"); + this.mts = (MetaTypeService) ctxt.locateService("MTS"); + this.ca = (ConfigurationAdmin) ctxt.locateService("CS"); + + this.prefInfoGrabber = new PrefInfoGrabber(log, mts, ca); + this.prefProcessor = new PrefReferenceProcessor(log, prefInfoGrabber); + + this.hasBeenActivated = true; + + //takes care of any prefHolders that may have been registered + //before the rest of these services were registered. + this.prefProcessor.processPrefReferences( + (ServiceReference[]) prefReferencesToBeProcessed.toArray(new ServiceReference[0])); + this.prefReferencesToBeProcessed.clear(); + } + + protected void deactivate(ComponentContext ctxt) { + } + + /** + * This method is called whenever a Service which potentially has preference + * information is registered. + * + * @param prefHolder The service reference for the service with preference information + */ + protected void prefHolderRegistered(ServiceReference prefHolder) { + this.prefReferencesToBeProcessed.add(prefHolder); + //(we must wait until this service is activated before we can properly process the preference holders) + if (this.hasBeenActivated == true) { + this.prefProcessor.processPrefReferences( + (ServiceReference[]) this.prefReferencesToBeProcessed.toArray(new ServiceReference[0])); + this.prefReferencesToBeProcessed.clear(); + } + + this.prefHolderReferences.add(prefHolder); + } + + protected void prefHolderUnregistered(ServiceReference prefHolder) { + this.prefHolderReferences.remove(prefHolder); + } + + // ConfigurationPlugin interface + + //injects global preferences into local preferences as they go from configuration service to the managed service + public void modifyConfiguration(ServiceReference reference, + Dictionary properties) { + PrefPage[] globalPrefPages = getGlobalPrefPages(); + for (int ii = 0; ii < globalPrefPages.length; ii++) { + PrefPage globalPrefPage = globalPrefPages[ii]; + Configuration globalPrefConf = globalPrefPage.getPrefConf(); + + String namespace = globalPrefConf.getPid(); + + Dictionary globalPrefDict = globalPrefConf.getProperties(); + + //the keys of each dictionary are the ids of global preference OCDs. + Enumeration ids = globalPrefDict.keys(); + while (ids.hasMoreElements()) { + String id = (String) ids.nextElement(); + String value = (String) globalPrefDict.get(id); + + String keyForConfiguration = namespace + "." + id; + + properties.put(keyForConfiguration, value); + } + } + } + + //ConfigurationListener interface + + public void configurationEvent(ConfigurationEvent event) { + if (event.getType() == ConfigurationEvent.CM_UPDATED) { + if (isFromGlobalConf(event.getPid())) { + sendGlobalPreferences(); + } else { + } + } else if (event.getType() == ConfigurationEvent.CM_DELETED) { + } + } + + /** + * Call when a global preference object is created or updated. + * Necessary because changes to global preference do not + * cause an update event for every ManagedService. + */ + private void sendGlobalPreferences() { + try { + for (int ii = 0; ii < this.prefHolderReferences.size(); ii++) { + ServiceReference prefHolder = (ServiceReference) this.prefHolderReferences.get(ii); + if (prefHolder.getProperty(PreferenceProperty.RECEIVE_PREFS_KEY) != null && + prefHolder.getProperty(PreferenceProperty.RECEIVE_PREFS_KEY).equals("true")) { + Configuration localPrefConf = ca.getConfiguration((String) prefHolder.getProperty(Constants.SERVICE_PID)); + try { + localPrefConf.update(); + } catch (IOException e) { + this.log.log(LogService.LOG_ERROR, "Unable to update configuration for " + localPrefConf.getPid(), e); + } + } + } + } catch (IOException e) { + this.log.log(LogService.LOG_ERROR, "Unable to obtain all configuration objects", e); + } + } + + private boolean isFromGlobalConf(String pid) { + return (pid.substring(0, pid.length() - 1).endsWith(PreferenceProperty.GLOBAL_PREFS_CONF_SUFFIX) + || pid.endsWith(PreferenceProperty.GLOBAL_PREFS_CONF_SUFFIX)); + } + + +} \ No newline at end of file Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefInfoGrabber.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,224 @@ +package org.cishell.reference.prefs.admin.internal; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.List; + +import org.cishell.framework.algorithm.AlgorithmProperty; +import org.cishell.framework.preference.PreferenceProperty; +import org.cishell.reference.prefs.admin.PreferenceOCD; +import org.osgi.framework.Bundle; +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.MetaTypeInformation; +import org.osgi.service.metatype.MetaTypeService; +import org.osgi.service.metatype.ObjectClassDefinition; + +//NOTE: methods that get configuration objects don't really need the ObjectClassDefinitions. We just use them (hackishly) to know how many configuration objects we should get +//Since, there are possibly an infinite number of Configuration objects for a service, we need the ObjectClassDefinitions to tell us when to stop trying to grab configuration objects +//(If we try to grab one that didn't previously exist, it will just make an empty one, sometimes we want this behaviour and sometimes we don't). +public class PrefInfoGrabber implements PreferenceProperty, AlgorithmProperty { + + private LogService log; + private MetaTypeService mts; + private ConfigurationAdmin ca; + + public PrefInfoGrabber(LogService log, MetaTypeService mts, ConfigurationAdmin ca) { + this.log = log; + this.mts = mts; + this.ca = ca; + } + + public PreferenceOCD[] getLocalPrefOCDs(ServiceReference prefHolder) { + String localPrefOCDID = getLocalPrefOCDID(prefHolder); + return extractOCDs(prefHolder, localPrefOCDID); + } + + public PreferenceOCD[] getGlobalPrefOCDs(ServiceReference prefHolder) { + String globalPrefOCDID = getGlobalPrefOCDID(prefHolder); + return extractOCDs(prefHolder, globalPrefOCDID); + } + + public PreferenceOCD[] getParamPrefOCDs(ServiceReference prefHolder) { + String paramPrefOCDID = getParamPrefOCDID(prefHolder); + return extractParamOCDs(prefHolder, paramPrefOCDID); + } + + private String getLocalPrefOCDID(ServiceReference prefHolder) { + String localPrefOCDID = (String) prefHolder.getProperty(PreferenceProperty.LOCAL_PREF_PID); + if (localPrefOCDID != null) { + return localPrefOCDID; + } else { + //no name defined. Use default name. + String defaultLocalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + + PreferenceProperty.LOCAL_PREFS_OCD_SUFFIX; + return defaultLocalPrefOCDID; + } + } + + private String getGlobalPrefOCDID(ServiceReference prefHolder) { + String globalPrefOCDID = (String) prefHolder.getProperty(PreferenceProperty.GLOBAL_PREF_PID); + if (globalPrefOCDID != null) { + return globalPrefOCDID; + } else { + //no names defined. Use default names. + String defaultGlobalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + + PreferenceProperty.GLOBAL_PREFS_OCD_SUFFIX; + return defaultGlobalPrefOCDID; + } + } + + private String getParamPrefOCDID(ServiceReference prefHolder) { + System.out.println(" Getting param pref OCD ID for " + prefHolder.getProperty("service.pid")); + String paramPrefOCDID = (String) prefHolder.getProperty(AlgorithmProperty.PARAMETER_PID); + if ( paramPrefOCDID != null) { + System.out.println(" RETURN override: " + paramPrefOCDID); + return paramPrefOCDID; + } else { + //no names defined. Use default names. + String defaultParamPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + PreferenceProperty.PARAM_PREFS_OCD_SUFFIX; + System.out.println(" RETURN default: " + defaultParamPrefOCDID); + return defaultParamPrefOCDID; + } + } + + private PreferenceOCD[] extractOCDs(ServiceReference prefHolder, String ocdID) { + Bundle bundle = prefHolder.getBundle(); + MetaTypeInformation bundleMetaTypeInfo = mts.getMetaTypeInformation(bundle); + List extractedOCDList = new ArrayList(); + //go through ocdID, ocdID + "2", ocdID + "3", etc..., until we try to get an OCD that doesn't exist. + PreferenceOCD extractedOCD = extractOCD(bundleMetaTypeInfo, ocdID); + int ii = 2; + while (extractedOCD != null) { + extractedOCDList.add(extractedOCD); + extractedOCD = extractOCD(bundleMetaTypeInfo, ocdID + ii); + ii++; + } + return (PreferenceOCD[]) extractedOCDList.toArray(new PreferenceOCD[extractedOCDList.size()]); + } + + //returns null if specified OCD does not exist. + private PreferenceOCD extractOCD(MetaTypeInformation bundleMetaTypeInfo, String ocdID) { + try { + ObjectClassDefinition requestedOCD = bundleMetaTypeInfo.getObjectClassDefinition(ocdID, null); + if (requestedOCD == null) return null; + PreferenceOCD wrappedOCD = new PreferenceOCDImpl(this.log, requestedOCD); + return wrappedOCD; + } catch (IllegalArgumentException e) { + //requested OCD does not exist + return null; + } + } + + //returning multiple OCDs just for the sake of symmetry, actually can only return 1 (or 0 on error) + private PreferenceOCD[] extractParamOCDs(ServiceReference prefHolder, String ocdID) { + Bundle bundle = prefHolder.getBundle(); + MetaTypeInformation bundleMetaTypeInfo = mts.getMetaTypeInformation(bundle); + PreferenceOCD paramOCD = extractOCD(bundleMetaTypeInfo, ocdID); + if (paramOCD != null) { + return new PreferenceOCD[]{paramOCD}; + } else { + return new PreferenceOCD[0]; + } + } + + public Configuration[] getLocalPrefConfs(ServiceReference prefHolder, PreferenceOCD[] prefOCDs) { + String localPrefConfID = getLocalPrefConfID(prefHolder); + return extractConfs(localPrefConfID, prefOCDs); + } + + public Configuration[] getGlobalPrefConfs(ServiceReference prefHolder, PreferenceOCD[] prefOCDs) { + String globalPrefConfID = getGlobalPrefConfID(prefHolder); + return extractConfs(globalPrefConfID, prefOCDs); + } + + public Configuration[] getParamPrefConfs(ServiceReference prefHolder, PreferenceOCD[] prefOCDs) { + String paramPrefConfID = getParamPrefConfID(prefHolder); + return extractConfs(paramPrefConfID, prefOCDs); + } + + public void ensurePrefsCanBeSentTo(ServiceReference serviceRef) { + try { + Configuration conf = ca.getConfiguration((String) serviceRef.getProperty(Constants.SERVICE_PID), null); + + Dictionary properties = conf.getProperties(); + if (properties == null) { + conf.update(new Hashtable()); + } + } catch (IOException e) { + return; + } + } + + + /** + * Gets all the configuration objects that correspond to the preference OCDs provided. + * @param confPID the PID that all the configuration objects start with, (confPID, confPID + "2", etc...) + * @param prefOCDs the OCDs associated with the configuration objects we are trying to get (puts a limit on # of Conf objects we try to extract) + * @return All the Configuration objects associated with the OCDs. + */ + private Configuration[] extractConfs(String confPID, PreferenceOCD[] prefOCDs) { + if (prefOCDs.length == 0) { + return new Configuration[0]; + } + List extractedConfList = new ArrayList(); + Configuration prefConf = extractConf(confPID); + if (prefConf != null) { + extractedConfList.add(prefConf); + for (int ii =2; ii < prefOCDs.length + 1; ii++) { + prefConf = extractConf(confPID + ii); + if (prefConf != null) { + extractedConfList.add(prefConf); + } else { + break; + } + } + } + + return (Configuration[]) extractedConfList.toArray(new Configuration[extractedConfList.size()]); + } + + //will return null on exception + private Configuration extractConf(String confPID) { + try { + return ca.getConfiguration(confPID, null); + } catch (IOException e) { + this.log.log(LogService.LOG_ERROR, "Unable to load configuration for " + confPID + " due to IO Error"); + return null; + } + } + + + private String getLocalPrefConfID(ServiceReference prefHolder) { + return (String) prefHolder.getProperty(Constants.SERVICE_PID); //has to be service.pid for configuration service to deliver updates to the right service + } + + private String getGlobalPrefConfID(ServiceReference prefHolder) { + String globalPrefOCDID = (String) prefHolder.getProperty(PreferenceProperty.GLOBAL_PREF_PID); + if (globalPrefOCDID != null) { + return globalPrefOCDID; + } else { + //no names defined. Use default names. + String defaultGlobalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + PreferenceProperty.GLOBAL_PREFS_CONF_SUFFIX; + return defaultGlobalPrefOCDID; + } + } + + private String getParamPrefConfID(ServiceReference prefHolder) { + String paramPrefOCDID = (String) prefHolder.getProperty(AlgorithmProperty.PARAMETER_PID); + if ( paramPrefOCDID != null) { + return paramPrefOCDID; + } else { + //no names defined. Use default names. + String defaultGlobalPrefOCDID = (String) prefHolder.getProperty(Constants.SERVICE_PID) + PreferenceProperty.PARAM_PREFS_CONF_SUFFIX; + return defaultGlobalPrefOCDID; + } + } + + +} Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefPageImpl.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefPageImpl.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefPageImpl.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,36 @@ +package org.cishell.reference.prefs.admin.internal; + +import org.cishell.reference.prefs.admin.PrefPage; +import org.cishell.reference.prefs.admin.PreferenceOCD; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.Configuration; + +public class PrefPageImpl implements PrefPage { + private ServiceReference prefHolder; + private Configuration prefConf; + private PreferenceOCD prefOCD; + private int type; + + public PrefPageImpl(ServiceReference prefHolder,PreferenceOCD prefOCD, Configuration prefConf, int type) { + this.prefHolder = prefHolder; + this.prefOCD = prefOCD; + this.prefConf = prefConf; + this.type = type; + } + + public ServiceReference getServiceReference() { + return this.prefHolder; + } + + public int getType() { + return this.type; + } + + public PreferenceOCD getPrefOCD() { + return this.prefOCD; + } + + public Configuration getPrefConf() { + return this.prefConf; + } +} Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PrefReferenceProcessor.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,288 @@ +package org.cishell.reference.prefs.admin.internal; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Dictionary; +import java.util.Hashtable; +import java.util.List; + +import org.cishell.framework.preference.PreferenceProperty; +import org.cishell.reference.prefs.admin.PrefPage; +import org.cishell.reference.prefs.admin.PreferenceAD; +import org.cishell.reference.prefs.admin.PreferenceOCD; +import org.cishell.reference.prefs.admin.PrefsByService; +import org.osgi.framework.Bundle; +import org.osgi.framework.Constants; +import org.osgi.framework.ServiceReference; +import org.osgi.service.cm.Configuration; +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.AttributeDefinition; +import org.osgi.service.metatype.ObjectClassDefinition; + +public class PrefReferenceProcessor{ + + private LogService log; + + private PrefInfoGrabber prefInfoGrabber; + + private List allLocalPrefPages = new ArrayList(); + private List allGlobalPrefPages = new ArrayList(); + private List allParamPrefPages = new ArrayList(); + + private List allPrefsByService = new ArrayList(); + + public PrefReferenceProcessor(LogService log, PrefInfoGrabber prefInfoGrabber) { + this.log = log; + + this.prefInfoGrabber = prefInfoGrabber; + } + + public void processPrefReferences(ServiceReference[] prefReferences) { + + //for each service that purports to hold preference information... + for (int ii = 0; ii < prefReferences.length; ii++) { + ServiceReference prefReference = prefReferences[ii]; + System.out.println("Processing " + prefReference.getProperty("service.pid")); + //get all preference pages from this service by type, and save them by type + + PrefPage[] localPrefPages = null; + if(isTurnedOn(prefReference, PreferenceProperty.PUBLISH_LOCAL_PREF_VALUE)) { + localPrefPages = getLocalPrefPages(prefReference); + initializeConfigurations(localPrefPages); + this.allLocalPrefPages.addAll(Arrays.asList(localPrefPages)); + warnIfReceivePrefsIsNotOn(prefReference); + } + + PrefPage[] globalPrefPages = null; + if (isTurnedOn(prefReference, PreferenceProperty.PUBLISH_GLOBAL_PREF_VALUE)) { + globalPrefPages = getGlobalPrefPages(prefReference); + initializeConfigurations(globalPrefPages); + this.allGlobalPrefPages.addAll(Arrays.asList(globalPrefPages)); + } + + PrefPage[] paramPrefPages = null; + if (isTurnedOn(prefReference,PreferenceProperty.PUBLISH_PARAM_DEFAULT_PREF_VALUE)) { + System.out.println(" Attempting to publish param default prefs for " + prefReference.getProperty("service.pid")); + paramPrefPages = getParamPrefPages(prefReference); + initializeConfigurations(paramPrefPages); + this.allParamPrefPages.addAll(Arrays.asList(paramPrefPages)); + } + + //save all the preferences by service as well + + PrefsByService allPrefsForThisService = new PrefsByService(prefReference, localPrefPages, globalPrefPages, paramPrefPages); + this.allPrefsByService.add(allPrefsForThisService); + + //make sure that preferences are sent to this service if it wants to see them. + + if (isTurnedOn(prefReference, PreferenceProperty.RECEIVE_PREFS_KEY)) { + prefInfoGrabber.ensurePrefsCanBeSentTo(prefReference); + } + } + } + + public PrefPage[] getAllLocalPrefPages() { + return getPrefPages(allLocalPrefPages); + } + + public PrefPage[] getAllGlobalPrefPages() { + return getPrefPages(allGlobalPrefPages); + } + + public PrefPage[] getAllParamPrefPages() { + return getPrefPages(allParamPrefPages); + } + + public PrefsByService[] getAllPrefsByService() { + return (PrefsByService[]) allPrefsByService.toArray(new PrefsByService[allPrefsByService.size()]); + } + + private PrefPage[] getLocalPrefPages(ServiceReference prefHolder) { + PreferenceOCD[] localPrefOCDs = prefInfoGrabber.getLocalPrefOCDs(prefHolder); + Configuration[] localPrefConfs = prefInfoGrabber.getLocalPrefConfs(prefHolder, localPrefOCDs); + PrefPage[] localPrefPages = composePrefPages(prefHolder, localPrefOCDs, localPrefConfs, PrefPage.LOCAL); + return localPrefPages; + } + + private PrefPage[] getGlobalPrefPages(ServiceReference prefHolder) { + PreferenceOCD[] globalPrefOCDs = prefInfoGrabber.getGlobalPrefOCDs(prefHolder); + Configuration[] globalPrefConfs = prefInfoGrabber.getGlobalPrefConfs(prefHolder, globalPrefOCDs); + PrefPage[] globalPrefPages = composePrefPages(prefHolder, globalPrefOCDs, globalPrefConfs, PrefPage.GLOBAL); + return globalPrefPages; + } + + private PrefPage[] getParamPrefPages(ServiceReference prefHolder) { + PreferenceOCD[] paramPrefOCDs = prefInfoGrabber.getParamPrefOCDs(prefHolder); + Configuration[] paramPrefConfs = prefInfoGrabber.getParamPrefConfs(prefHolder, paramPrefOCDs); + PrefPage[] paramPrefPages = composePrefPages(prefHolder, paramPrefOCDs, paramPrefConfs, PrefPage.PARAM); + return paramPrefPages; + } + + //prefOCD.length should == prefConfs.length + private PrefPage[] composePrefPages(ServiceReference prefHolder, PreferenceOCD[] prefOCDs, Configuration[] prefConfs, int type) { + int minLength = Math.min(prefOCDs.length, prefConfs.length); + List composedPrefPageList = new ArrayList(prefOCDs.length); + for (int ii = 0; ii < minLength; ii++) { + PrefPage composedPrefPage = new PrefPageImpl(prefHolder, prefOCDs[ii], prefConfs[ii], type); + composedPrefPageList.add(composedPrefPage); + } + + return (PrefPage[]) composedPrefPageList.toArray(new PrefPage[composedPrefPageList.size()]); + } + + private void initializeConfiguration(PrefPage prefPage) { + Configuration prefConf = prefPage.getPrefConf(); + Dictionary prefDict = prefConf.getProperties(); + PreferenceOCD prefOCD = prefPage.getPrefOCD(); + + //if there are no properties defined for this prefPages configuration... + if (prefDict == null || bundleHasBeenUpdated(prefPage)) { + + //create configuration properties for this pref based on the default values in its OCD. + prefDict = new Hashtable(); + + PreferenceAD[] prefADs = prefOCD.getPreferenceAttributeDefinitions(ObjectClassDefinition.ALL); + for (int ii = 0; ii < prefADs.length; ii++) { + AttributeDefinition prefAD = prefADs[ii]; + + + String id = prefAD.getID(); + String val = prefAD.getDefaultValue()[0]; + + try { + prefDict.put(id, val); + } catch (Throwable e) {; + e.printStackTrace(); + } + + } + + prefDict.put(PreferenceProperty.BUNDLE_VERSION_KEY, getCurrentBundleVersion(prefPage)); + + try { + prefConf.update(prefDict); + } catch (IOException e) { + this.log.log(LogService.LOG_ERROR, "Unable to update configuration with PID " + prefConf.getPid(), e); + } + } else { + //update it anyway, because if it is a global conf it needs to be propogated. + //(if it is a global preference, this update will be caught by our ConfigurationListener, + //and the global preference data will be propagated. + try { + prefConf.update(prefDict); + } catch (IOException e) { + this.log.log(LogService.LOG_ERROR, "Unable to update configuration with PID " + prefConf.getPid(), e); + } + } + + //TODO: does not worry about old version of bundles for now + } + + private void initializeConfigurations(PrefPage[] prefPages) + { + for (int ii = 0; ii < prefPages.length; ii++) { + PrefPage prefPage = prefPages[ii]; + initializeConfiguration(prefPage); + } + } + + //only supports 3 publish keys and receive_prefs key + private boolean isTurnedOn(ServiceReference prefReference, String processingKey) { + if (processingKey.equals(PreferenceProperty.RECEIVE_PREFS_KEY)) { + String receivePrefsValue = (String) prefReference.getProperty(PreferenceProperty.RECEIVE_PREFS_KEY); + return receivePrefsValue != null && receivePrefsValue.equals("true"); + } else { + String unparsedPublishedPrefsValues = (String) prefReference.getProperty(PreferenceProperty.PREFS_PUBLISHED_KEY); + if (unparsedPublishedPrefsValues == null) { + if (processingKey ==PreferenceProperty.PUBLISH_PARAM_DEFAULT_PREF_VALUE) { + return true; + } else { + return false; + } + } + + String[] publishedPrefsValues = unparsedPublishedPrefsValues.split(","); + for (int ii = 0; ii < publishedPrefsValues.length; ii++) { + if (publishedPrefsValues[ii].equals(processingKey)) { + return true; + } + } + + //makes it so parameter prefs are published by default + if (publishedPrefsValues.length == 0 && processingKey ==PreferenceProperty.PUBLISH_PARAM_DEFAULT_PREF_VALUE) { + return true; + } + + return false; + } + } + + private boolean bundleHasBeenUpdated(PrefPage prefPage) { + String currentBundleVersion = getCurrentBundleVersion(prefPage); + String savedBundleVersion = getSavedBundleVersion(prefPage); + + if (savedBundleVersion == null) { + return false; + } + + if (currentBundleVersion.equals(savedBundleVersion)) { + return false; + } else { + logBundleWasUpdated(prefPage); + return true; + } + } + + private String getCurrentBundleVersion(PrefPage prefPage) { + Bundle b = prefPage.getServiceReference().getBundle(); + String currentBundleVersion = (String) b.getHeaders().get(PreferenceProperty.BUNDLE_VERSION_KEY); + return currentBundleVersion; + } + + private String getSavedBundleVersion(PrefPage prefPage) { + Dictionary prefDict = prefPage.getPrefConf().getProperties(); + if (prefDict == null) { + return null; + } + //no namespace in front of bundle version + String bundleVersionForLocalsAndParams = (String) prefDict.get(PreferenceProperty.BUNDLE_VERSION_KEY); + if (bundleVersionForLocalsAndParams != null) { + return bundleVersionForLocalsAndParams; + } else { + //try global kind, with namespace in front + String servicePID = (String) prefPage.getServiceReference().getProperty(Constants.SERVICE_PID); + String bundleVersionForGlobals = (String) prefDict.get(servicePID + "." + PreferenceProperty.BUNDLE_VERSION_KEY); + + if (bundleVersionForGlobals != null) { + return bundleVersionForGlobals; + } else { + return null; + } + } + } + + private void logBundleWasUpdated(PrefPage prefPage) { + String servicePID = (String) prefPage.getServiceReference().getProperty(Constants.SERVICE_PID); + String prefOCDName = prefPage.getPrefOCD().getName(); + this.log.log(LogService.LOG_WARNING, "The Bundle for the service " + servicePID + + " was updated, so the preferences for " + prefOCDName + + " will be set to the new defaults."); + } + + private PrefPage[] getPrefPages(List prefPageList) { + return (PrefPage[]) prefPageList.toArray(new PrefPage[prefPageList.size()]); + } + + private void warnIfReceivePrefsIsNotOn(ServiceReference prefHolder) { + if (! isTurnedOn(prefHolder, PreferenceProperty.RECEIVE_PREFS_KEY)) { + String servicePID = (String) prefHolder.getProperty(Constants.SERVICE_PID); + log.log(LogService.LOG_WARNING, "Algorithm Developer Error: \r\n" + + "The algorithm " + servicePID + " has published local preferences without requested to receive preferences. \r\n" + + " Algorithms that want to see preferences (both local and global) " + + "need to set receive_prefs=true in their .properties file, but since there is no purpose in defining local preferences " + + "without being able to receive preferences, we will turn it on for you. You must also implement the ManagedService" + + "interface for the AlgorithmFactory if you have not already done so."); + } + } +} Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PreferenceADImpl.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PreferenceADImpl.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PreferenceADImpl.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,205 @@ +package org.cishell.reference.prefs.admin.internal; + +import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; + +import org.cishell.reference.prefs.admin.PreferenceAD; +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.AttributeDefinition; + +public class PreferenceADImpl implements AttributeDefinition, PreferenceAD { + + private static final String URI_FILE_PREFIX = "file:"; + + private LogService log; + + private AttributeDefinition realAD; + + private int preferenceType; + private String[] interpretedDefaultValue; + + private String platformIndepInstallDirPath; + + public PreferenceADImpl(LogService log, AttributeDefinition realAD) { + this.log = log; + + this.realAD = realAD; + + this.preferenceType = inferPreferenceType(realAD); + + this.platformIndepInstallDirPath = generateIndepInstallDirPath(); + this.interpretedDefaultValue = interpretDefaultValue(this.realAD.getDefaultValue()); + } + + private int inferPreferenceType(AttributeDefinition realAD) { + int preferenceType; + if (realAD.getType() == AttributeDefinition.STRING) { + String defaultVal = realAD.getDefaultValue()[0]; + + if (defaultVal.startsWith(TypePrefixes.DIRECTORY_PREFIX)) { + preferenceType = DIRECTORY; + } else if (defaultVal.startsWith(TypePrefixes.FILE_PREFIX)) { + preferenceType = FILE; + } else if (defaultVal.startsWith(TypePrefixes.FONT_PREFIX)) { + preferenceType = FONT; + } else if (defaultVal.startsWith(TypePrefixes.PATH_PREFIX)) { + preferenceType = PATH; + } else if (realAD.getOptionLabels() != null) { + preferenceType = CHOICE; + } else if (defaultVal.startsWith(TypePrefixes.COLOR_PREFIX)) { + preferenceType = COLOR; + } else { + preferenceType = TEXT; + } + } else { + preferenceType = realAD.getType(); + } + + return preferenceType; + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getCardinality() + */ + public int getCardinality() { + return this.realAD.getCardinality(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getDefaultValue() + */ + public String[] getDefaultValue() { + + return interpretedDefaultValue; + } + + private String generateIndepInstallDirPath() { + String installDirPath = System.getProperty("osgi.install.area").replace(URI_FILE_PREFIX, ""); + File installDirFile = new File(installDirPath); + URI platformIndependentFile = installDirFile.toURI(); + String platformIndepInstallDirPath = platformIndependentFile.toString(); + return platformIndepInstallDirPath; + } + + private String[] interpretDefaultValue(String[] rawDefaultValues) { + String[] interpretedDefaultValues = new String[rawDefaultValues.length]; + for (int i = 0; i < rawDefaultValues.length; i++) { + String rawDefaultValue = rawDefaultValues[i]; + + interpretedDefaultValues[i] = interpretDefaultValue(rawDefaultValue); + } + + return interpretedDefaultValues; + } + private String interpretDefaultValue(String rawDefaultValue) { + int preferenceType = getPreferenceType(); + + if (preferenceType == DIRECTORY) { + String uriFormattedDefaultValue = rawDefaultValue.replace(TypePrefixes.DIRECTORY_PREFIX, URI_FILE_PREFIX); + return makePlatformSpecificPath(uriFormattedDefaultValue); + } else if (preferenceType == FILE) { + if (rawDefaultValue.equals("file:")) { + //allows empty values + return ""; + } + String uriFormattedDefaultValue = rawDefaultValue; //already in URI form, semi-coincidentally + return makePlatformSpecificPath(uriFormattedDefaultValue); + } else if (preferenceType == FONT) { + return rawDefaultValue.replace(TypePrefixes.FONT_PREFIX, ""); + } else if (preferenceType == PATH) { + return rawDefaultValue.replace(TypePrefixes.PATH_PREFIX, ""); + } else if (preferenceType == TEXT) { + return rawDefaultValue; + } else if (preferenceType == COLOR) { + return rawDefaultValue.replace(TypePrefixes.COLOR_PREFIX, ""); + }else { + return rawDefaultValue; + } + } + + private String makePlatformSpecificPath(String platformIndependentPath) { + //if the original platformIndependentPath is relative, stick the home directory on to it. + + if (! platformIndependentPath.startsWith("file:/")) { + //it's a relative path + //make it absolute + platformIndependentPath = platformIndepInstallDirPath + platformIndependentPath.replace(URI_FILE_PREFIX, ""); + } + //make the whole platformIndependentPath platform specific + + try { + URI uriInterpretation = new URI(platformIndependentPath); + File platformSpecificInterpretation = new File(uriInterpretation); + + /* + * may need to change to canonical path at some point, but that throws an IOException + * (and may cause performance problems), so skipping for now + */ + String platformSpecificDirectory = platformSpecificInterpretation.getAbsolutePath(); + return platformSpecificDirectory; + } catch (URISyntaxException e) { + this.log.log(LogService.LOG_WARNING, "Invalid syntax in preference AD " + realAD.getName()); + return System.getProperty("osgi.install.area").replace(URI_FILE_PREFIX, ""); + } + + //return it + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getDescription() + */ + public String getDescription() { + return this.realAD.getDescription(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getID() + */ + public String getID() { + return this.realAD.getID(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getName() + */ + public String getName() { + return this.realAD.getName(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getOptionLabels() + */ + public String[] getOptionLabels() { + return this.realAD.getOptionLabels(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getOptionValues() + */ + public String[] getOptionValues() { + return this.realAD.getOptionValues(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getType() + */ + public int getType() { + return this.realAD.getType(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#getPreferenceType() + */ + public int getPreferenceType() { + return this.preferenceType; + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceAttributeDefinition#validate(java.lang.String) + */ + public String validate(String value) { + return this.realAD.validate(value); + } + +} Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PreferenceOCDImpl.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PreferenceOCDImpl.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/PreferenceOCDImpl.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,93 @@ +package org.cishell.reference.prefs.admin.internal; + +import java.io.IOException; +import java.io.InputStream; + +import org.cishell.reference.prefs.admin.PreferenceAD; +import org.cishell.reference.prefs.admin.PreferenceOCD; +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.AttributeDefinition; +import org.osgi.service.metatype.ObjectClassDefinition; + +public class PreferenceOCDImpl implements ObjectClassDefinition, PreferenceOCD { + + private ObjectClassDefinition realOCD; + private PreferenceAD[] allWrappedADs; + private PreferenceAD[] optionalWrappedADs; + private PreferenceAD[] requiredWrappedADs; + + private LogService log; + + public PreferenceOCDImpl(LogService log, ObjectClassDefinition realOCD) { + this.log = log; + this.realOCD = realOCD; + //TODO: don't always return all attributeDefinitions, regardless of filter + this.allWrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.ALL)); + this.optionalWrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.OPTIONAL)); + this.requiredWrappedADs = wrapAttributeDefinitions(realOCD.getAttributeDefinitions(ObjectClassDefinition.REQUIRED)); + } + + private PreferenceAD[] wrapAttributeDefinitions(AttributeDefinition[] realAttributeDefinitions) { + PreferenceAD[] wrappedADs = new PreferenceAD[realAttributeDefinitions.length]; + + for (int i = 0; i < realAttributeDefinitions.length; i++) { + AttributeDefinition realAD = realAttributeDefinitions[i]; + PreferenceAD wrappedAD = new PreferenceADImpl(this.log, realAD); + + wrappedADs[i] = wrappedAD; + } + + return wrappedADs; + } + + + //use in standard way + public AttributeDefinition[] getAttributeDefinitions(int filter) { + return this.realOCD.getAttributeDefinitions(filter); + + } + + //use to get at the special preference attribute goodness. + public PreferenceAD[] getPreferenceAttributeDefinitions(int filter) { + if (filter == ObjectClassDefinition.ALL) { + return this.allWrappedADs; + } else if (filter == ObjectClassDefinition.OPTIONAL) { + return this.optionalWrappedADs; + } else if (filter == ObjectClassDefinition.REQUIRED) { + return this.requiredWrappedADs; + } else { + log.log(LogService.LOG_WARNING, + "Programmer Error: attempted to get preference attribute definitions with invalid filter " + filter); + return new PreferenceAD[0]; + } + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceObjectClassDefinition#getDescription() + */ + public String getDescription() { + return this.realOCD.getDescription(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceObjectClassDefinition#getID() + */ + public String getID() { + return this.realOCD.getID(); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceObjectClassDefinition#getIcon(int) + */ + public InputStream getIcon(int size) throws IOException { + return this.realOCD.getIcon(size); + } + + /* (non-Javadoc) + * @see org.cishell.service.prefadmin.shouldbeelsewhere.PreferenceObjectClassDefinition#getName() + */ + public String getName() { + return this.realOCD.getName(); + } + +} Added: branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/TypePrefixes.java =================================================================== --- branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/TypePrefixes.java (rev 0) +++ branches/user_prefs/org.cishell.reference.prefs.admin/src/org/cishell/reference/prefs/admin/internal/TypePrefixes.java 2008-03-21 16:20:18 UTC (rev 668) @@ -0,0 +1,17 @@ +package org.cishell.reference.prefs.admin.internal; + +import org.osgi.service.metatype.AttributeDefinition; + +public class TypePrefixes { + + public static final String FONT_PREFIX = "font:"; + public static final String DIRECTORY_PREFIX = "directory:"; + public static final String FILE_PREFIX = "file:"; + public static final String PATH_PREFIX = "path:"; + public static final String COLOR_PREFIX = "color:"; + + + public static boolean hasPrefix(AttributeDefinition prefAD, String prefix) { + return prefAD.getDefaultValue()[0... [truncated message content] |
From: <mwl...@us...> - 2008-03-21 16:19:58
|
Revision: 667 http://cishell.svn.sourceforge.net/cishell/?rev=667&view=rev Author: mwlinnem Date: 2008-03-21 09:19:54 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Moved from NWB repository to the native homeland of the user preferences service. Added Paths: ----------- 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-03-21 16:16:37
|
Revision: 666 http://cishell.svn.sourceforge.net/cishell/?rev=666&view=rev Author: mwlinnem Date: 2008-03-21 09:15:36 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Update of framework for preference stuff. Added various new constants. Modified Paths: -------------- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmProperty.java Modified: branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmProperty.java =================================================================== --- branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmProperty.java 2008-03-21 16:11:49 UTC (rev 665) +++ branches/user_prefs/org.cishell.framework/src/org/cishell/framework/algorithm/AlgorithmProperty.java 2008-03-21 16:15:36 UTC (rev 666) @@ -33,11 +33,11 @@ public static final String ADDITIONS_GROUP = "additions"; public static final String START_GROUP = "start"; public static final String END_GROUP = "end"; - public static final String METATYPE_ID = "metatype-id"; public static final String REMOTEABLE = "remoteable"; public static final String REMOTE = "remote"; public static final String ALGORITHM_TYPE = "type"; public static final String TYPE_CONVERTER = "converter"; public static final String TYPE_ALGORITHM = "algorithm"; public static final String TYPE_DATASET = "dataset"; + public static final String PARAMETER_PID = "parameter_pid"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-03-21 16:11:51
|
Revision: 665 http://cishell.svn.sourceforge.net/cishell/?rev=665&view=rev Author: mwlinnem Date: 2008-03-21 09:11:49 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Branching for the user preferences stuff. Added Paths: ----------- branches/user_prefs/org.cishell.framework/ Copied: branches/user_prefs/org.cishell.framework (from rev 664, trunk/core/org.cishell.framework) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-03-21 16:07:33
|
Revision: 664 http://cishell.svn.sourceforge.net/cishell/?rev=664&view=rev Author: mwlinnem Date: 2008-03-21 09:07:14 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Moved from NWB repository (shouldn't have been there in the first place). Added Paths: ----------- branches/user_prefs/org.cishell.reference.gui.prefs.swt/.classpath branches/user_prefs/org.cishell.reference.gui.prefs.swt/.project branches/user_prefs/org.cishell.reference.gui.prefs.swt/.settings/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/META-INF/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/META-INF/MANIFEST.MF branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/algorithm.properties branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/component.xml branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/l10n/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/l10n/bundle_en.properties branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/METADATA.XML branches/user_prefs/org.cishell.reference.gui.prefs.swt/build.properties branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/ComboFieldEditor.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/LabelFieldEditor.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/SpacerFieldEditor.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/TabbedFieldEditorPreferencePage.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/DoubleFieldEditor.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/FloatFieldEditor.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/BlankPreferencePage.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/CIShellPreferencePage.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/CIShellPreferenceStore.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/PreferenceGuiAlgorithm.java branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/PreferenceGuiAlgorithmFactory.java Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/.classpath =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/.classpath (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/.classpath 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="build"/> +</classpath> Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/.project =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/.project (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/.project 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.cishell.reference.gui.prefs.swt</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/META-INF/MANIFEST.MF =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/META-INF/MANIFEST.MF (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/META-INF/MANIFEST.MF 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,30 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Preference GUI +Bundle-SymbolicName: org.cishell.reference.gui.prefs.swt +Bundle-Version: 0.0.1 +Bundle-ClassPath: . +Import-Package: org.cishell.framework, + org.cishell.framework.algorithm, + org.cishell.framework.data, + org.cishell.service.guibuilder, + org.cishell.reference.prefs.admin, + org.eclipse.jface.dialogs, + org.eclipse.jface.preference, + org.eclipse.jface.resource, + org.eclipse.jface.util, + org.eclipse.jface.window, + org.eclipse.swt, + org.eclipse.swt.events, + org.eclipse.swt.graphics, + org.eclipse.swt.layout, + org.eclipse.swt.widgets, + org.eclipse.ui, + org.osgi.framework;version="1.3.0", + org.osgi.service.cm;version="1.2.0", + org.osgi.service.component;version="1.0.0", + org.osgi.service.log;version="1.3.0", + org.osgi.service.metatype;version="1.1.0", + org.osgi.service.prefs;version="1.1.0" +X-AutoStart: true +Service-Component: OSGI-INF/component.xml Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/algorithm.properties =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/algorithm.properties (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/algorithm.properties 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,7 @@ +menu_path=File/additions +label=Preferences +description=Lets you view and edit CIShell preferences +in_data=null +out_data=null +service.pid=org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithm +remoteable=false Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/component.xml =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/component.xml (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/component.xml 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<component name="org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithm.component" immediate="true"> + <implementation class="org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithmFactory"/> + <properties entry="OSGI-INF/algorithm.properties"/> + <reference name="LOG" interface="org.osgi.service.log.LogService"/> + <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> + <reference name="PREF_ADMIN" interface="org.cishell.reference.prefs.admin.PrefAdmin"/> + + <service> + <provide interface= + "org.cishell.framework.algorithm.AlgorithmFactory"/> + </service> +</component> \ No newline at end of file Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/l10n/bundle_en.properties =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/l10n/bundle_en.properties (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/l10n/bundle_en.properties 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,7 @@ +#Localization variables for OSGI-INF/metatatype/METADATA.XML +# +#Samples: +#input=Input +#desc=Enter an integer (that will be converted to a string) +#name=Input->String +#name_desc=Converts inputted integer to string Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/METADATA.XML =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/METADATA.XML (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/OSGI-INF/metatype/METADATA.XML 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0"> + <OCD name="Preferences" id="org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithm.OCD" + description="Lets you view and edit CIShell preferences "> + <AD name="what" id="ever" type="String" default="work"/> + </OCD> + <Designate pid="org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithm"> + <Object ocdref="org.cishell.reference.gui.prefs.swt.PreferenceGuiAlgorithm.OCD" /> + </Designate> +</metatype:MetaData> Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/build.properties =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/build.properties (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/build.properties 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,5 @@ +source.. = src/ +output.. = build/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/ComboFieldEditor.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/ComboFieldEditor.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/ComboFieldEditor.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,540 @@ +/* ==================================================================== + * Copyright 2003-2004 Fabrizio Giustina. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package net.sf.commonclipse.preferences; + +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.FocusAdapter; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; + + +/** + * Implementation identical to StringFieldEditor but using a combo instead of a Text field. + * @author fgiust + * @version $Revision: 1.4 $ ($Author: fgiust $) + */ +public class ComboFieldEditor extends FieldEditor +{ + + /** + * Text limit constant (value <code>-1</code>) indicating unlimited text limit and width. + */ + public static final int UNLIMITED = -1; + + /** + * The text field, or <code>null</code> if none. + */ + Combo textField; + + /** + * predefined values to be shown in list. + */ + private String[] predefinedValues; + + /** + * Cached valid state. + */ + private boolean isValid; + + /** + * Old text value. + */ + private String oldValue; + + /** + * Width of text field in characters; initially unlimited. + */ + private int widthInChars = UNLIMITED; + + /** + * Text limit of text field in characters; initially unlimited. + */ + private int textLimit = UNLIMITED; + + /** + * The error message, or <code>null</code> if none. + */ + private String errorMessage; + + /** + * Indicates whether the empty string is legal; <code>true</code> by default. + */ + private boolean emptyStringAllowed = true; + + /** + * Creates a new string field editor. + */ + protected ComboFieldEditor() + { + } + + /** + * Creates a string field editor. Use the method <code>setTextLimit</code> to limit the text. + * @param name the name of the preference this field editor works on + * @param labelText the label text of the field editor + * @param width the width of the text input field in characters, or <code>UNLIMITED</code> for no limit + * @param parent the parent of the field editor's control + */ + public ComboFieldEditor(String name, String labelText, int width, Composite parent) + { + init(name, labelText); + this.widthInChars = width; + this.isValid = false; + this.errorMessage = JFaceResources.getString("StringFieldEditor.errorMessage"); //$NON-NLS-1$ + createControl(parent); + } + + /** + * Creates a string field editor of unlimited width. Use the method <code>setTextLimit</code> to limit the text. + * @param name the name of the preference this field editor works on + * @param labelText the label text of the field editor + * @param parent the parent of the field editor's control + */ + public ComboFieldEditor(String name, String labelText, Composite parent) + { + this(name, labelText, UNLIMITED, parent); + } + + /** + * Checks whether the text input field contains a valid value or not. + * @return <code>true</code> if the field value is valid, and <code>false</code> if invalid + */ + protected boolean checkState() + { + boolean result = false; + if (this.emptyStringAllowed) + { + result = true; + } + + if (this.textField == null) + { + result = false; + } + + String txt = this.textField.getText(); + + if (txt == null) + { + result = false; + } + + result = (txt.trim().length() > 0) || this.emptyStringAllowed; + + // call hook for subclasses + result = result && doCheckState(); + + if (result) + { + clearErrorMessage(); + } + else + { + showErrorMessage(this.errorMessage); + } + + return result; + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#doLoad() + */ + protected void doLoad() + { + if (this.textField != null) + { + + addDefaultOptions(); + String value = getPreferenceStore().getString(getPreferenceName()); + this.textField.setText(value); + this.oldValue = value; + + } + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault() + */ + protected void doLoadDefault() + { + if (this.textField != null) + { + addDefaultOptions(); + String value = getPreferenceStore().getDefaultString(getPreferenceName()); + this.textField.setText(value); + + } + valueChanged(); + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#doStore() + */ + protected void doStore() + { + getPreferenceStore().setValue(getPreferenceName(), this.textField.getText()); + } + + /** + * Returns the error message that will be displayed when and if an error occurs. + * @return the error message, or <code>null</code> if none + */ + public String getErrorMessage() + { + return this.errorMessage; + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls() + */ + public int getNumberOfControls() + { + return 2; + } + + /** + * Returns the field editor's value. + * @return the current value + */ + public String getStringValue() + { + if (this.textField != null) + { + return this.textField.getText(); + } + return getPreferenceStore().getString(getPreferenceName()); + } + + /** + * Returns this field editor's text control. + * @return the text control, or <code>null</code> if no text field is created yet + */ + protected Combo getTextControl() + { + return this.textField; + } + + /** + * Returns this field editor's text control. + * <p> + * The control is created if it does not yet exist + * </p> + * @param parent the parent + * @return the text control + */ + public Combo getTextControl(Composite parent) + { + if (this.textField == null) + { + this.textField = new Combo(parent, SWT.SINGLE | SWT.BORDER); + + this.textField.setFont(parent.getFont()); + + this.textField.addKeyListener(new KeyAdapter() + { + + public void keyReleased(KeyEvent e) + { + valueChanged(); + } + }); + this.textField.addSelectionListener(new SelectionListener() + { + + public void widgetSelected(SelectionEvent e) + { + valueChanged(); + } + + public void widgetDefaultSelected(SelectionEvent e) + { + valueChanged(); + } + + }); + this.textField.addFocusListener(new FocusAdapter() + { + + public void focusGained(FocusEvent e) + { + refreshValidState(); + } + + public void focusLost(FocusEvent e) + { + valueChanged(); + clearErrorMessage(); + } + }); + + this.textField.addDisposeListener(new DisposeListener() + { + + public void widgetDisposed(DisposeEvent event) + { + ComboFieldEditor.this.textField = null; + } + }); + if (this.textLimit > 0) + { // Only set limits above 0 - see SWT spec + this.textField.setTextLimit(this.textLimit); + } + } + else + { + checkParent(this.textField, parent); + } + return this.textField; + } + + /** + * Returns whether an empty string is a valid value. + * @return <code>true</code> if an empty string is a valid value, and <code>false</code> if an empty string is + * invalid + * @see #setEmptyStringAllowed + */ + public boolean isEmptyStringAllowed() + { + return this.emptyStringAllowed; + } + + /** + * @see org.eclipse.jface.preference.FieldEditor # isValid() + */ + public boolean isValid() + { + return this.isValid; + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#refreshValidState() + */ + protected void refreshValidState() + { + this.isValid = checkState(); + } + + /** + * Sets whether the empty string is a valid value or not. + * @param b <code>true</code> if the empty string is allowed, and <code>false</code> if it is considered invalid + */ + public void setEmptyStringAllowed(boolean b) + { + this.emptyStringAllowed = b; + } + + /** + * Sets the error message that will be displayed when and if an error occurs. + * @param message the error message + */ + public void setErrorMessage(String message) + { + this.errorMessage = message; + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#setFocus() + */ + public void setFocus() + { + if (this.textField != null) + { + this.textField.setFocus(); + } + } + + /** + * Sets this field editor's value. + * @param value the new value, or <code>null</code> meaning the empty string + */ + public void setStringValue(String value) + { + if (this.textField != null) + { + String newValue = value; + if (newValue == null) + { + newValue = ""; //$NON-NLS-1$ + } + + this.oldValue = this.textField.getText(); + + if (!this.oldValue.equals(newValue)) + { + this.textField.setText(newValue); + + valueChanged(); + } + } + } + + /** + * Sets this text field's text limit. + * @param limit the limit on the number of character in the text input field, or <code>UNLIMITED</code> for no + * limit + */ + public void setTextLimit(int limit) + { + this.textLimit = limit; + if (this.textField != null) + { + this.textField.setTextLimit(limit); + } + } + + /** + * Shows the error message set via <code>setErrorMessage</code>. + */ + public void showErrorMessage() + { + showErrorMessage(this.errorMessage); + } + + /** + * Informs this field editor's listener, if it has one, about a change to the value (<code>VALUE</code> property) + * provided that the old and new values are different. + * <p> + * This hook is <em>not</em> called when the text is initialized (or reset to the default value) from the + * preference store. + * </p> + */ + protected void valueChanged() + { + setPresentsDefaultValue(false); + boolean oldState = this.isValid; + refreshValidState(); + + if (this.isValid != oldState) + { + fireStateChanged(IS_VALID, oldState, this.isValid); + } + + String newValue = this.textField.getText(); + if (!newValue.equals(this.oldValue)) + { + fireValueChanged(VALUE, this.oldValue, newValue); + this.oldValue = newValue; + } + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#setEnabled(boolean,Composite). + */ + public void setEnabled(boolean enabled, Composite parent) + { + super.setEnabled(enabled, parent); + getTextControl(parent).setEnabled(enabled); + } + + /** + * Hook for subclasses to do specific state checks. + * <p> + * The default implementation of this framework method does nothing and returns <code>true</code>. Subclasses + * should override this method to specific state checks. + * </p> + * @return <code>true</code> if the field value is valid, and <code>false</code> if invalid + */ + protected boolean doCheckState() + { + return true; + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int) + */ + protected void adjustForNumColumns(int numColumns) + { + GridData gd = (GridData) this.textField.getLayoutData(); + gd.horizontalSpan = numColumns - 1; + // We only grab excess space if we have to + // If another field editor has more columns then + // we assume it is setting the width. + gd.grabExcessHorizontalSpace = gd.horizontalSpan == 1; + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(Composite, int) + */ + protected void doFillIntoGrid(Composite parent, int numColumns) + { + getLabelControl(parent); + + this.textField = getTextControl(parent); + GridData gd = new GridData(); + gd.horizontalSpan = numColumns - 1; + if (this.widthInChars != UNLIMITED) + { + GC gc = new GC(this.textField); + try + { + Point extent = gc.textExtent("X"); //$NON-NLS-1$ + gd.widthHint = this.widthInChars * extent.x; + } + finally + { + gc.dispose(); + } + } + else + { + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + } + this.textField.setLayoutData(gd); + } + + /** + * Sets a list of predefined values that must be shown in the combo. + * @param strings array of Strings added to the combo + */ + public void setPredefinedValues(String[] strings) + { + this.predefinedValues = strings; + } + + /** + * Adds predefined options to the combo. + */ + private void addDefaultOptions() + { + if (this.textField != null && this.predefinedValues != null) + { + this.textField.setItems(this.predefinedValues); + } + } + + /** + * @see org.eclipse.jface.preference.FieldEditor#clearErrorMessage() + */ + protected void clearErrorMessage() + { + super.clearErrorMessage(); + } + +} Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/LabelFieldEditor.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/LabelFieldEditor.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/LabelFieldEditor.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,104 @@ +/* ==================================================================== + * Copyright 2003-2004 Fabrizio Giustina. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package net.sf.commonclipse.preferences; + +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +/** + * A field editor for displaying labels not associated with other widgets. + * @author fgiust + * @version $Revision: 1.3 $ ($Author: fgiust $) + */ +public class LabelFieldEditor extends FieldEditor +{ + + /** + * Label for this field editor. + */ + private Label label; + + /** + * All labels can use the same preference name since they don't store any preference. + * @param labelText text for the label + * @param parent Composite + */ + public LabelFieldEditor(String labelText, Composite parent) + { + super("label", labelText, parent); //$NON-NLS-1$ + } + + /** + * Adjusts the field editor to be displayed correctly for the given number of columns. + * @param numColumns number of columns + */ + protected void adjustForNumColumns(int numColumns) + { + ((GridData) this.label.getLayoutData()).horizontalSpan = numColumns; + } + + /** + * Fills the field editor's controls into the given parent. + * @param parent Composite + * @param numColumns cumber of columns + */ + protected void doFillIntoGrid(Composite parent, int numColumns) + { + this.label = getLabelControl(parent); + + GridData gridData = new GridData(); + gridData.horizontalSpan = numColumns; + gridData.horizontalAlignment = GridData.FILL; + gridData.grabExcessHorizontalSpace = false; + gridData.verticalAlignment = GridData.CENTER; + gridData.grabExcessVerticalSpace = false; + + this.label.setLayoutData(gridData); + } + + /** + * Returns the number of controls in the field editor. + * @return 1 + */ + public int getNumberOfControls() + { + return 1; + } + + /** + * Labels do not persist any preferences, so this method is empty. + */ + protected void doLoad() + { + } + + /** + * Labels do not persist any preferences, so this method is empty. + */ + protected void doLoadDefault() + { + } + + /** + * Labels do not persist any preferences, so this method is empty. + */ + protected void doStore() + { + } +} Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/SpacerFieldEditor.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/SpacerFieldEditor.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/SpacerFieldEditor.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,36 @@ +/* ==================================================================== + * Copyright 2003-2004 Fabrizio Giustina. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package net.sf.commonclipse.preferences; + +import org.eclipse.swt.widgets.Composite; + +/** + * A field editor for adding space to a preference page. + * @author fgiust + * @version $Revision: 1.3 $ ($Author: fgiust $) + */ +public class SpacerFieldEditor extends LabelFieldEditor +{ + /** + * Implemented as an empty label field editor. + * @param parent Composite + */ + public SpacerFieldEditor(Composite parent) + { + super("", parent); //$NON-NLS-1$ + } +} Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/TabbedFieldEditorPreferencePage.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/TabbedFieldEditorPreferencePage.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/net/sf/commonclipse/preferences/TabbedFieldEditorPreferencePage.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,138 @@ +package net.sf.commonclipse.preferences; + +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; + + +/** + * @author fgiust + * @version $Revision $ ($Author $) + */ +public abstract class TabbedFieldEditorPreferencePage extends FieldEditorPreferencePage +{ + + /** + * Tab folder. + */ + private TabFolder folder; + + /** + * Maximum number of columns for field editors. + */ + private int maxNumOfColumns; + + /** + * Creates a new field editor preference page with the given style, an empty title, and no image. + * @param style either <code>GRID</code> or <code>FLAT</code> + */ + protected TabbedFieldEditorPreferencePage(int style) + { + super(style); + } + + /** + * Creates a new field editor preference page with the given title and style, but no image. + * @param title the title of this preference page + * @param style either <code>GRID</code> or <code>FLAT</code> + */ + protected TabbedFieldEditorPreferencePage(String title, int style) + { + super(title, style); + } + + /** + * Creates a new field editor preference page with the given title, image, and style. + * @param title the title of this preference page + * @param image the image for this preference page, or <code>null</code> if none + * @param style either <code>GRID</code> or <code>FLAT</code> + */ + protected TabbedFieldEditorPreferencePage(String title, ImageDescriptor image, int style) + { + super(title, image, style); + } + + /** + * Adds the given field editor to this page. + * @param editor the field editor + */ + protected void addField(FieldEditor editor) + { + // needed for layout, since there is no way to get fields editor from parent + this.maxNumOfColumns = Math.max(this.maxNumOfColumns, editor.getNumberOfControls()); + super.addField(editor); + } + + /** + * Adjust the layout of the field editors so that they are properly aligned. + */ + protected void adjustGridLayout() + { + if (folder != null) + { + TabItem[] items = folder.getItems(); + for (int j = 0; j < items.length; j++) + { + GridLayout layout = ((GridLayout) ((Composite) items[j].getControl()).getLayout()); + layout.numColumns = this.maxNumOfColumns; + layout.marginHeight = 5; + layout.marginWidth = 5; + } + } + + // need to call super.adjustGridLayout() since fieldEditor.adjustForNumColumns() is protected + super.adjustGridLayout(); + + // reset the main container to a single column + ((GridLayout) super.getFieldEditorParent().getLayout()).numColumns = 1; + } + + /** + * Returns a parent composite for a field editor. + * <p> + * This value must not be cached since a new parent may be created each time this method called. Thus this method + * must be called each time a field editor is constructed. + * </p> + * @return a parent + */ + protected Composite getFieldEditorParent() + { + if (folder == null || folder.getItemCount() == 0) + { + return super.getFieldEditorParent(); + } + return (Composite) folder.getItem(folder.getItemCount() - 1).getControl(); + } + + /** + * Adds a tab to the page. + * @param text the tab label + */ + public void addTab(String text) + { + if (folder == null) + { + // initialize tab folder + folder = new TabFolder(super.getFieldEditorParent(), SWT.NONE); + folder.setLayoutData(new GridData(GridData.FILL_BOTH)); + } + + TabItem item = new TabItem(folder, SWT.NONE); + item.setText(text); + + Composite currentTab = new Composite(folder, SWT.NULL); + GridLayout layout = new GridLayout(); + currentTab.setLayout(layout); + currentTab.setFont(super.getFieldEditorParent().getFont()); + currentTab.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + item.setControl(currentTab); + } + +} \ No newline at end of file Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/DoubleFieldEditor.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/DoubleFieldEditor.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/DoubleFieldEditor.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,52 @@ +package org.cishell.gui.prefgui.customfields; + +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; + +public class DoubleFieldEditor extends StringFieldEditor { + + public DoubleFieldEditor(String name, String labelText, Composite parent) { + super(name, labelText, parent); + setEmptyStringAllowed(false); + } + + protected void doLoad() { + Text text = getTextControl(); + if (text != null) { + double value = getPreferenceStore().getDouble(getPreferenceName()); + text.setText("" + value); + } + } + + protected void doLoadDefault() { + Text text = getTextControl(); + if (text != null) { + double value = getPreferenceStore().getDefaultDouble(getPreferenceName()); + text.setText("" + value);//$NON-NLS-1$ + } + valueChanged(); + } + + protected void doStore() { + Text text = getTextControl(); + if (text != null) { + Double i = Double.valueOf(text.getText()); + getPreferenceStore().setValue(getPreferenceName(), i.doubleValue()); + } + } + + public double getDoubleValue() { + return Double.parseDouble(this.getStringValue()); + } + + public boolean checkState() { + try { + Double.parseDouble(this.getStringValue()); + return true; + } catch (NumberFormatException e) { + //if parsing throws an error, it's invalid. + return false; + } + } +} Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/FloatFieldEditor.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/FloatFieldEditor.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/customfields/FloatFieldEditor.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,52 @@ +package org.cishell.gui.prefgui.customfields; + +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; + +public class FloatFieldEditor extends StringFieldEditor { + + public FloatFieldEditor(String name, String labelText, Composite parent) { + super(name, labelText, parent); + setEmptyStringAllowed(false); + } + + protected void doLoad() { + Text text = getTextControl(); + if (text != null) { + float value = getPreferenceStore().getFloat(getPreferenceName()); + text.setText("" + value); + } + } + + protected void doLoadDefault() { + Text text = getTextControl(); + if (text != null) { + float value = getPreferenceStore().getDefaultFloat(getPreferenceName()); + text.setText("" + value);//$NON-NLS-1$ + } + valueChanged(); + } + + protected void doStore() { + Text text = getTextControl(); + if (text != null) { + Float i = Float.valueOf(text.getText()); + getPreferenceStore().setValue(getPreferenceName(), i.floatValue()); + } + } + + public float getFloatValue() { + return Float.parseFloat(this.getStringValue()); + } + + public boolean checkState() { + try { + Float.parseFloat(this.getStringValue()); + return true; + } catch (NumberFormatException e) { + //if parsing throws an error, it's invalid. + return false; + } + } +} Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/BlankPreferencePage.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/BlankPreferencePage.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/BlankPreferencePage.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,22 @@ +package org.cishell.gui.prefgui.preferencepages; + +import net.sf.commonclipse.preferences.LabelFieldEditor; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; + +public class BlankPreferencePage extends FieldEditorPreferencePage { + + private String description; + + public BlankPreferencePage(int style, String title, String description) { + super(style); + this.setTitle(title); + this.description = description; + } + + protected void createFieldEditors() { + LabelFieldEditor label = new LabelFieldEditor(description, this.getFieldEditorParent()); + this.addField(label); + } + +} Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/CIShellPreferencePage.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/CIShellPreferencePage.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/gui/prefgui/preferencepages/CIShellPreferencePage.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,133 @@ +package org.cishell.gui.prefgui.preferencepages; + +import java.io.IOException; + +import org.cishell.gui.prefgui.customfields.DoubleFieldEditor; +import org.cishell.gui.prefgui.customfields.FloatFieldEditor; +import org.cishell.reference.gui.prefs.swt.CIShellPreferenceStore; +import org.cishell.reference.prefs.admin.PreferenceAD; +import org.cishell.reference.prefs.admin.PreferenceOCD; +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.ColorFieldEditor; +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.FileFieldEditor; +import org.eclipse.jface.preference.FontFieldEditor; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.jface.preference.PathEditor; +import org.eclipse.jface.preference.RadioGroupFieldEditor; +import org.eclipse.jface.preference.StringFieldEditor; +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.ObjectClassDefinition; + +public class CIShellPreferencePage extends FieldEditorPreferencePage { + + private PreferenceOCD prefOCD; + + private LogService log; + + public CIShellPreferencePage(LogService log, PreferenceOCD prefOCD, + CIShellPreferenceStore prefStore) { + super(FieldEditorPreferencePage.FLAT); + this.setTitle(prefOCD.getName()); + + this.prefOCD = prefOCD; + + this.setPreferenceStore(prefStore); + } + + protected void createFieldEditors() { + PreferenceAD[] prefADs = + prefOCD.getPreferenceAttributeDefinitions(ObjectClassDefinition.ALL); + + for (int ii = 0; ii < prefADs.length; ii++) { + PreferenceAD prefAD = prefADs[ii]; + + int attrType = prefAD.getPreferenceType(); + if (attrType == PreferenceAD.BOOLEAN) { + BooleanFieldEditor bField = + new BooleanFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + addField(bField); + } else if (attrType == PreferenceAD.INTEGER) { + IntegerFieldEditor iField = + new IntegerFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + addField(iField); + } else if (attrType == PreferenceAD.CHOICE) { + String[] optionLabels = prefAD.getOptionLabels(); + String[] optionValues = prefAD.getOptionValues(); + String [][] labelAndValues = new String[optionLabels.length][2]; + + for (int jj = 0; jj < labelAndValues.length; jj++) { + labelAndValues[jj][0] = optionLabels[jj]; + labelAndValues[jj][1] = optionValues[jj]; + } + + RadioGroupFieldEditor rgField + = new RadioGroupFieldEditor( + prefAD.getID(), + prefAD.getName(), + 1, + labelAndValues, + getFieldEditorParent(), + true); + addField(rgField); + } else if (attrType == PreferenceAD.FONT) { + FontFieldEditor foField = + new FontFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + addField(foField); + } else if (attrType == PreferenceAD.DIRECTORY) { + DirectoryFieldEditor dField = + new DirectoryFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + dField.setEmptyStringAllowed(true); + addField(dField); + } else if (attrType == PreferenceAD.FILE) { + FileFieldEditor fiField = + new FileFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + fiField.setEmptyStringAllowed(true); + addField(fiField); + } else if (attrType == PreferenceAD.PATH) { + PathEditor pField = + new PathEditor(prefAD.getID(), prefAD.getName(), prefAD.getName(), getFieldEditorParent()); + addField(pField); + } else if (attrType == PreferenceAD.TEXT) { + StringFieldEditor sField = + new StringFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + addField(sField); + } else if (attrType == PreferenceAD.DOUBLE) { + DoubleFieldEditor dField = + new DoubleFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + addField(dField); + } else if (attrType == PreferenceAD.FLOAT) { + FloatFieldEditor fField = + new FloatFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + addField(fField); + } else if (attrType == PreferenceAD.COLOR) { + ColorFieldEditor cField = + new ColorFieldEditor(prefAD.getID(), prefAD.getName(), getFieldEditorParent()); + addField(cField); + } + } + } + + public void performApply() { + super.performApply(); + //WARNING: this will not work if the PreferenceStore is ever not the CIShellPreferenceStore + + /* + * necessary because we need the preference store to actually save in order to + * distribute the changes we have made, unlike the usual way a preferenceStore operates + * where you can simply set the changes to the preference store and they propagate correctly. + */ + + try { + if (this.getPreferenceStore() instanceof CIShellPreferenceStore) { + CIShellPreferenceStore realPrefStore = (CIShellPreferenceStore) this.getPreferenceStore(); + realPrefStore.save(); + } + } catch (ClassCastException e) { + super.performApply(); + } catch (IOException e) { + this.log.log(LogService.LOG_WARNING, "Unable to save preferences due to I/O Exception", e); + } + } +} Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/CIShellPreferenceStore.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/CIShellPreferenceStore.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/CIShellPreferenceStore.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,194 @@ +package org.cishell.reference.gui.prefs.swt; + +import java.io.IOException; +import java.util.Dictionary; +import java.util.HashMap; +import java.util.Map; + +import org.cishell.reference.prefs.admin.PreferenceAD; +import org.cishell.reference.prefs.admin.PreferenceOCD; +import org.eclipse.jface.preference.IPersistentPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.osgi.service.cm.Configuration; +import org.osgi.service.log.LogService; +import org.osgi.service.metatype.ObjectClassDefinition; + +public class CIShellPreferenceStore implements IPersistentPreferenceStore { + + private LogService log; + + private PreferenceOCD prefOCD; //could be useful if we implement some new features + private Configuration prefConf; + private Dictionary prefDict; + private Map prefDefaults; + + private boolean needsSaving = false; + + public CIShellPreferenceStore(LogService log, PreferenceOCD prefOCD, Configuration prefConf) { + this.log = log; + this.prefOCD = prefOCD; + this.prefConf = prefConf; + this.prefDict = prefConf.getProperties(); + + if (this.prefDict == null) { + this.log.log(LogService.LOG_WARNING, "The configuration dictionary for the configuration object " + + prefConf.getPid() + "is null. \r\n" + "This may be due to an error in a bundles metadata, or may" + + " be an internal error. This will likely cause errors related to preferences."); + } + + generatePrefDefaults(prefOCD); + } + + public boolean contains(String name) { + return prefDict.get(name) != null; + } + + public boolean getBoolean(String name) { + return Boolean.parseBoolean((String) this.prefDict.get(name)); + } + + public boolean getDefaultBoolean(String name) { + return Boolean.valueOf(((String) this.prefDefaults.get(name))).booleanValue(); + } + + public double getDefaultDouble(String name) { + return Double.valueOf(((String) this.prefDefaults.get(name))).doubleValue(); + } + + public float getDefaultFloat(String name) { + return Float.valueOf(((String) this.prefDefaults.get(name))).floatValue(); + } + + public int getDefaultInt(String name) { + return Integer.valueOf(((String) this.prefDefaults.get(name))).intValue(); + } + + public long getDefaultLong(String name) { + return Long.valueOf(((String) this.prefDefaults.get(name))).longValue(); + } + + public String getDefaultString(String name) { + return ((String) this.prefDefaults.get(name)); + } + + public double getDouble(String name) { + return Double.parseDouble(((String) this.prefDict.get(name))); + } + + public float getFloat(String name) { + return Float.parseFloat(((String) this.prefDict.get(name))); + } + + public int getInt(String name) { + return Integer.parseInt(((String) this.prefDict.get(name))); + } + + public long getLong(String name) { + return Long.parseLong(((String) this.prefDict.get(name))); + } + + public String getString(String name) { + String result = (String) this.prefDict.get(name); + return result; + } + + public boolean isDefault(String name) { + return prefDefaults.get(name).equals(prefDict.get(name)); + } + + public boolean needsSaving() { + return this.needsSaving; + } + + public void putValue(String name, String value) { + this.prefDict.put(name, value); + } + + + public void setToDefault(String name) { + this.needsSaving = true; + String defaultVal = (String) this.prefDefaults.get(name); + this.prefDict.put(name, defaultVal); + } + + public void setValue(String name, double value) { + this.needsSaving = true; + this.prefDict.put(name, String.valueOf(value)); + } + + public void setValue(String name, float value) { + this.needsSaving = true; + this.prefDict.put(name, String.valueOf(value)); + } + + public void setValue(String name, int value) { + this.needsSaving = true; + this.prefDict.put(name, String.valueOf(value)); + } + + public void setValue(String name, long value) { + this.needsSaving = true; + this.prefDict.put(name,String.valueOf(value)); + } + + public void setValue(String name, String value) { + this.needsSaving = true; + this.prefDict.put(name, value); + } + + public void setValue(String name, boolean value) { + this.needsSaving = true; + + this.prefDict.put(name, String.valueOf(value)); + } + + public void save() throws IOException { + this.needsSaving = false; + this.prefConf.update(this.prefDict); + } + + private void generatePrefDefaults(PreferenceOCD prefOCD) { + PreferenceAD[] prefADs = prefOCD.getPreferenceAttributeDefinitions(ObjectClassDefinition.ALL); + Map prefDefaults = new HashMap(prefADs.length); + for (int ii = 0; ii < prefADs.length; ii++) { + PreferenceAD prefAD = prefADs[ii]; + prefDefaults.put(prefAD.getID(), prefAD.getDefaultValue()[0]); + } + this.prefDefaults = prefDefaults; + } + + //We don't set defaults like this (they are defined by the default field in MetaType Attribute Definitions) + + public void setDefault(String name, double value) { + } + + public void setDefault(String name, float value) { + } + + public void setDefault(String name, int value) { + } + + public void setDefault(String name, long value) { + } + + public void setDefault(String name, String defaultObject) { + } + + public void setDefault(String name, boolean value) { + } + + //more unsupported methods + + public void removePropertyChangeListener(IPropertyChangeListener listener) { + } + + public void firePropertyChangeEvent(String name, Object oldValue, + Object newValue) { + } + + public void addPropertyChangeListener(IPropertyChangeListener listener) { + } + + + +} Added: branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/PreferenceGuiAlgorithm.java =================================================================== --- branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/PreferenceGuiAlgorithm.java (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.prefs.swt/src/org/cishell/reference/gui/prefs/swt/PreferenceGuiAlgorithm.java 2008-03-21 16:07:14 UTC (rev 664) @@ -0,0 +1,137 @@ +package org.cishell.reference.gui.prefs.swt; + +import java.util.Arrays; +import java.util.Dictionary; + +import org.cishell.framework.CIShellContext; +import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.data.Data; +import org.cishell.gui.prefgui.preferencepages.BlankPreferencePage; +import org.cishell.gui.prefgui.preferencepages.CIShellPreferencePage; +import org.cishell.reference.prefs.admin.PrefAdmin; +import org.cishell.reference.prefs.admin.PrefPage; +import org.cishell.reference.prefs.admin.PrefPageComparator; +import org.cishell.reference.prefs.admin.PreferenceOCD; +import org.eclipse.jface.preference.PreferenceDialog; +import org.eclipse.jface.preference.PreferenceManager; +import org.eclipse.jface.preference.PreferenceNode; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.osgi.service.cm.Configuration; +import org.osgi.service.log.LogService; + + +public class PreferenceGuiAlgorithm implements Algorithm { + Data[] data; + Dictionary parameters; + CIShellContext context; + + PrefAdmin prefAdmin; + + LogService log; + + public PreferenceGuiAlgorithm(Data[] data, Dictionary parameters, CIShellContext context, + PrefAdmin prefAdmin, LogService log) { + this.data = data; + this.parameters = parameters; + this.context = context; + + this.prefAdmin = prefAdmin; + this.log = log; + } + + public Data[] execute() { + PreferenceManager prefManager = new PreferenceManager(); + + addGlobalPreferences(prefManager); + addLocalPreferences(prefManager); + addParamPreferences(prefManager); + + Shell parentShell = getParentShell(); + PreferenceGUIRunnable prefGUIRunnable = new PreferenceGUIRunnable(parentShell, prefManager); + Thread preferenceGUIThread = new Thread(prefGUIRunnable); + + //We must tell SWT to run the preference dialog, instead of running it directly ourselves + parentShell.getDisplay().asyncExec(preferenceGUIThread); + + return null; + } + + private void addGlobalPreferences(PreferenceManager prefManager) { + PrefPage[] globalPrefPages = prefAdmin.getGlobalPrefPages(); + + BlankPreferencePage globalPrefPageRoot = new BlankPreferencePage(1, "General Preferences", "Contains preferences that change the workbench's functionality."); + PreferenceNode rootNode = new PreferenceNode("General Preferences Root", globalPrefPageRoot); + prefManager.addToRoot(rootNode); + + addPrefPages(globalPrefPages, rootNode); + } + + private void addLocalPreferences(PreferenceManager prefManager) { + PrefPage[] localPrefPages = prefAdmin.getLocalPrefPages(); + + BlankPreferencePage localPrefPageRoot = new BlankPreferencePage(1, + "Algorithm Preferences", "Contains preferences that modify how particular algorithms work."); + PreferenceNode rootNode = new PreferenceNode("Algorithm Preferences Root", localPrefPageRoot); + prefManager.addToRoot(rootNode); + + addPrefPages(localPrefPages, rootNode); + } + + private void addParamPreferences(PreferenceManager prefManager) { + PrefPage[] paramPrefPages = prefAdmin.getParamPrefPages(); + + BlankPreferencePage paramPrefPageRoot = new BlankPreferencePage(1, "Algorithm Parameter Preferences", + "Contains preferences that specify the default values for algorithm menus"); + PreferenceNode rootNode = new PreferenceNode("General Preferences Root", paramPrefPageRoot); + prefManager.addToRoot(rootNode); + + addPrefPages(paramPrefPages, rootNode); + } + + private Shell getParentShell() { + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow[] windows = workbench.getWorkbenchWindows(); + + //possibly a better, less seamingly arbitrary way to do this + IWorkbenchWindow window = windows[0]; + Shell parentShell = window.getShell(); + return parentShell; + } + + private void addPrefPages(PrefPage[] prefPages, PreferenceNode rootNode) { + Arrays.sort(prefPages, new PrefPageComparator()); + for (int ii = 0; ii < prefPages.length; ii++) { + PreferenceNode prefNode = makePreferenceNode(prefPages[ii]); + rootNode.add(prefNode); + } + } + + private PreferenceNode makePreferenceNode(PrefPage prefPage) { + PreferenceOCD prefOCD = prefPage.getPrefOCD(); + Configuration prefConf = prefPage.getPrefConf(); + + CIShellPreferenceStore prefStore = new CIShellPreferenceStore(this.log, prefOCD, prefConf); + CIShellPreferencePage guiPrefPage = new CIShellPreferencePage(this.log, + prefOCD, prefStore); + return new PreferenceNode(prefConf.getPid(), guiPrefPage); + } + + private class PreferenceGUIRunnable implements Runnable { + + private Shell parentShell; + private PreferenceManager prefManager; + + public PreferenceGUIRunnable(Shell parentShell, PreferenceManager prefManager) { + this.parentShell = parentShell; + this.prefManager = prefManager; + } + + public void run() { + PreferenceDialog prefDialog = new PreferenceDialog(parentShell, prefManager); + prefDialog.open(); + } + } +} Added: b... [truncated message content] |
From: <mwl...@us...> - 2008-03-21 16:06:54
|
Revision: 663 http://cishell.svn.sourceforge.net/cishell/?rev=663&view=rev Author: mwlinnem Date: 2008-03-21 09:06:04 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Initial import. Moved from NWB repository (shouldn't have been there in the first place). Added Paths: ----------- 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-03-21 16:00:39
|
Revision: 662 http://cishell.svn.sourceforge.net/cishell/?rev=662&view=rev Author: mwlinnem Date: 2008-03-21 09:00:09 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Commiting changes for user preferences. Added Paths: ----------- branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ branches/user_prefs/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/ParamMetaTypeProvider.java branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java Added: branches/user_prefs/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 (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamAD.java 2008-03-21 16:00:09 UTC (rev 662) @@ -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); + } + +} Added: branches/user_prefs/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 (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamMetaTypeProvider.java 2008-03-21 16:00:09 UTC (rev 662) @@ -0,0 +1,34 @@ +package org.cishell.reference.gui.menumanager.menu.metatypewrapper; + +import java.util.Dictionary; + +import org.osgi.service.log.LogService; +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; + } + } + +} Added: branches/user_prefs/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 (rev 0) +++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/metatypewrapper/ParamOCD.java 2008-03-21 16:00:09 UTC (rev 662) @@ -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-03-21 15:55:52
|
Revision: 661 http://cishell.svn.sourceforge.net/cishell/?rev=661&view=rev Author: mwlinnem Date: 2008-03-21 08:55:02 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Branched for user preferences. Modified Paths: -------------- branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java Added Paths: ----------- branches/user_prefs/org.cishell.reference.gui.menumanager/ Copied: branches/user_prefs/org.cishell.reference.gui.menumanager (from rev 659, trunk/clients/gui/org.cishell.reference.gui.menumanager) Modified: branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-03-14 20:03:15 UTC (rev 659) +++ branches/user_prefs/org.cishell.reference.gui.menumanager/META-INF/MANIFEST.MF 2008-03-21 15:55:02 UTC (rev 661) @@ -13,8 +13,10 @@ org.cishell.framework, org.cishell.framework.algorithm, org.cishell.framework.data, + org.cishell.framework.preference, org.cishell.reference.gui.workspace, org.cishell.service.conversion, org.cishell.service.guibuilder, + 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: branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java =================================================================== --- trunk/clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java 2008-03-14 20:03:15 UTC (rev 659) +++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/Activator.java 2008-03-21 15:55:02 UTC (rev 661) @@ -24,6 +24,8 @@ // The shared instance private static Activator plugin; + private static final int DELAY_TIME = 500; + MenuAdapter menuAdapter; /** @@ -40,13 +42,13 @@ super.start(context); while (getWorkbench() == null) { - Thread.sleep(500); + Thread.sleep(DELAY_TIME); } IWorkbenchWindow[] windows = getWorkbench().getWorkbenchWindows(); while (windows.length == 0) { - Thread.sleep(500); + Thread.sleep(DELAY_TIME); windows = getWorkbench().getWorkbenchWindows(); } Modified: branches/user_prefs/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-03-14 20:03:15 UTC (rev 659) +++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmAction.java 2008-03-21 15:55:02 UTC (rev 661) @@ -28,12 +28,8 @@ 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; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; public class AlgorithmAction extends Action implements AlgorithmProperty, DataManagerListener { @@ -44,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)); @@ -101,9 +101,9 @@ printAlgorithmInformation(); + - - scheduler.schedule(new AlgorithmWrapper(ref, bContext, ciContext, originalData, data, converters), ref); + scheduler.schedule(new AlgorithmWrapper(ref, bContext, ciContext, originalData, data, converters, ca), ref); } catch (Throwable e) { e.printStackTrace(); } Modified: branches/user_prefs/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-03-14 20:03:15 UTC (rev 659) +++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/AlgorithmWrapper.java 2008-03-21 15:55:02 UTC (rev 661) @@ -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; @@ -31,11 +32,15 @@ import org.cishell.framework.algorithm.ProgressTrackable; import org.cishell.framework.data.Data; import org.cishell.framework.data.DataProperty; +import org.cishell.framework.preference.PreferenceProperty; +import org.cishell.reference.gui.menumanager.menu.metatypewrapper.ParamMetaTypeProvider; 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; @@ -55,15 +60,20 @@ protected ProgressMonitor progressMonitor; protected Algorithm algorithm; + protected ConfigurationAdmin ca; + + //ConfigurationAdmin may be null public AlgorithmWrapper(ServiceReference ref, BundleContext bContext, CIShellContext ciContext, Data[] originalData, Data[] data, - Converter[][] converters) { + Converter[][] converters, ConfigurationAdmin ca) { this.ref = ref; this.bContext = bContext; this.ciContext = ciContext; this.originalData = originalData; this.data = data; this.converters = converters; + + this.ca = ca; this.idToLabelMap = new HashMap(); this.progressMonitor = null; @@ -111,19 +121,22 @@ } this.provider = factory.createParameters(data); - String pid = (String)ref.getProperty(Constants.SERVICE_PID); + if (this.provider != null) { + this.provider = wrapProvider(this.ref, this.provider); + } + String pid = determineParameterPID(ref, provider); this.parameters = new Hashtable(); if (provider != null) { this.parameters = builder.createGUIandWait(pid, provider); } - + if(this.parameters == null) { return new Data[0]; } algorithm = factory.createAlgorithm(data, parameters, ciContext); - + printParameters(); if (progressMonitor != null && algorithm instanceof ProgressTrackable) { @@ -165,6 +178,34 @@ } } + //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 + PreferenceProperty.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.PARAMETER_PID); + if (overridePID != null) { + return overridePID; + } else { + return (String) ref.getProperty(Constants.SERVICE_PID); + } + } + protected void printParameters() { LogService logger = getLogService(); setupIdToLabelMap(); @@ -276,4 +317,17 @@ public void setProgressMonitor(ProgressMonitor monitor) { progressMonitor = monitor; } + + private boolean hasParamDefaultPreferences(ServiceReference algRef) { + String prefsToPublish = (String) algRef.getProperty(PreferenceProperty.PREFS_PUBLISHED_KEY); + if (prefsToPublish == null) { + return true; + } + + if (prefsToPublish.contains(PreferenceProperty.PUBLISH_PARAM_DEFAULT_PREF_VALUE)) { + return true; + } else { + return false; + } + } } Modified: branches/user_prefs/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-03-14 20:03:15 UTC (rev 659) +++ branches/user_prefs/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/MenuAdapter.java 2008-03-21 15:55:02 UTC (rev 661) @@ -43,6 +43,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; @@ -55,6 +56,8 @@ /* * Bonnie's comments: * weird, why implements AlgorithmProperty? It does not define any abstract interface. + * Micah's comment, several millenia later: + * It's so you can say things like "== LOSSLESS" as oppose to "== AlgorithmProperty.LOSSLESS". */ public class MenuAdapter implements AlgorithmProperty { private IMenuManager menuBar; @@ -65,6 +68,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. @@ -118,8 +123,24 @@ } catch (InvalidSyntaxException e) { getLog().log(LogService.LOG_ERROR, "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 @@ -137,7 +158,6 @@ } else{ String pid = (String)refs[i].getProperty(PRESERVED_SERVICE_PID); -// System.out.println("pid="+pid); pidToServiceReferenceMap.put(pid.toLowerCase().trim(), refs[i]); pidToServiceReferenceMapCopy.put(pid.toLowerCase().trim(), refs[i]); } @@ -256,7 +276,6 @@ private void processAMenuNode(Element menuNode, MenuManager parentMenuBar ){ String menuName = menuNode.getAttribute(ATTR_NAME); String pid = menuNode.getAttribute(ATTR_PID); - //System.out.println(">>>pid="+pid); if (pid == null || pid.length()==0){ //check if the name is one of the preserved one //if so add the default action @@ -268,7 +287,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); @@ -292,7 +312,6 @@ //parse using builder to get DOM representation of the XML file String fullpath=System.getProperty("osgi.configuration.area") + DEFAULT_MENU_FILE_NAME; -// System.out.println(">>parse file: "+fullpath); dom = db.parse(fullpath); // printElementAttributes(dom); @@ -338,7 +357,6 @@ public void serviceChanged(ServiceEvent event) { switch (event.getType()) { case ServiceEvent.REGISTERED: -// System.out.println(">>>receive ServiceEvent.Registered"); makeMenuItem(event.getServiceReference()); break; case ServiceEvent.UNREGISTERING: @@ -356,7 +374,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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mwl...@us...> - 2008-03-21 15:52:50
|
Revision: 660 http://cishell.svn.sourceforge.net/cishell/?rev=660&view=rev Author: mwlinnem Date: 2008-03-21 08:51:40 -0700 (Fri, 21 Mar 2008) Log Message: ----------- Added Paths: ----------- branches/user_prefs/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-03-14 20:04:11
|
Revision: 659 http://cishell.svn.sourceforge.net/cishell/?rev=659&view=rev Author: bh2 Date: 2008-03-14 13:03:15 -0700 (Fri, 14 Mar 2008) Log Message: ----------- bah Modified Paths: -------------- trunk/core/org.cishell.docs/src/specification/tex/introduction.tex Modified: trunk/core/org.cishell.docs/src/specification/tex/introduction.tex =================================================================== --- trunk/core/org.cishell.docs/src/specification/tex/introduction.tex 2008-03-14 18:54:21 UTC (rev 658) +++ trunk/core/org.cishell.docs/src/specification/tex/introduction.tex 2008-03-14 20:03:15 UTC (rev 659) @@ -40,8 +40,8 @@ Herr II, and Katy B\"{o}rner on the Information Visualization Cyberinfrastructure (IVC). Thanks go out to all those who have used or contributed to IVC, CIShell, and the Network Workbench (the first project to use CIShell). Development of the -Cyberinfrastructure Shell was funded by grants two from the National Science -Foundation: NSF IIS-0238261 and NSF IIS-0513650. +Cyberinfrastructure Shell was funded by two grants from the National Science +Foundation, NSF IIS-0238261 and NSF IIS-0513650. \section{CIShell Platform Overview} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-03-14 18:54:33
|
Revision: 658 http://cishell.svn.sourceforge.net/cishell/?rev=658&view=rev Author: bh2 Date: 2008-03-14 11:54:21 -0700 (Fri, 14 Mar 2008) Log Message: ----------- Made some changes so that latex can output dvi and so i can use some tools to convert to html. things seem to be working okay except for the images. It is not liking converting the pdf images to pngs for some reason... Modified Paths: -------------- trunk/core/org.cishell.docs/src/specification/main.tex trunk/core/org.cishell.docs/src/texdoclet/src/org/wonderly/doclets/TexDoclet.java Modified: trunk/core/org.cishell.docs/src/specification/main.tex =================================================================== --- trunk/core/org.cishell.docs/src/specification/main.tex 2008-03-14 16:09:28 UTC (rev 657) +++ trunk/core/org.cishell.docs/src/specification/main.tex 2008-03-14 18:54:21 UTC (rev 658) @@ -16,16 +16,12 @@ %% % -\documentclass[pdftex,11pt,letterpaper]{report} -\usepackage[top=1in, left=1in, right=1in, bottom=1in]{geometry} -\usepackage[pdftex]{graphicx} -\DeclareGraphicsExtensions{.pdf,.png,.jpg,.mps,.eps} -\usepackage{color} +\documentclass[11pt,letterpaper]{report} -\usepackage{../mystyle} -\input{./tex/api.tex} -\packagesheader{} +\usepackage{ifpdf} +\ifpdf %PDF Specific Setup +\usepackage[pdftex]{graphicx} \usepackage[pdftex]{hyperref} \hypersetup{ pdftitle={Cyberinfrastructure Shell (CIShell) - Core Specification 1.0}, @@ -33,8 +29,19 @@ pdfauthor={Bruce W. Herr II}, pdfnewwindow=true% links in new window } +\else %DVI Specific Setup +\usepackage{graphicx} +\usepackage{hyperref} +\fi +\usepackage[top=1in, left=1in, right=1in, bottom=1in]{geometry} +\DeclareGraphicsExtensions{.pdf,.png,.jpg,.mps,.eps} +\usepackage{color} + +\usepackage{../mystyle} +\input{./tex/api.tex} + \raggedright \begin{document} Modified: trunk/core/org.cishell.docs/src/texdoclet/src/org/wonderly/doclets/TexDoclet.java =================================================================== --- trunk/core/org.cishell.docs/src/texdoclet/src/org/wonderly/doclets/TexDoclet.java 2008-03-14 16:09:28 UTC (rev 657) +++ trunk/core/org.cishell.docs/src/texdoclet/src/org/wonderly/doclets/TexDoclet.java 2008-03-14 18:54:21 UTC (rev 658) @@ -116,7 +116,7 @@ // os.println("\\documentclass[11pt]{"+docclass+"}" ); - os.println("\\newcommand{\\packagesheader}{"); + //os.println("\\newcommand{\\packagesheader}{"); os.println("%%% Start_Header"); os.println("\\def\\bl{\\mbox{}\\newline\\mbox{}\\newline{}}"); os.println("\\usepackage{ifthen}"); @@ -200,7 +200,7 @@ os.println("\\usepackage{color}"); os.println("%%% End_Header"); - os.println("}\n\n"); + //os.println("}\n\n"); // os.println("\\packagesheader{}"); /* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-03-14 16:09:37
|
Revision: 657 http://cishell.svn.sourceforge.net/cishell/?rev=657&view=rev Author: bh2 Date: 2008-03-14 09:09:28 -0700 (Fri, 14 Mar 2008) Log Message: ----------- minor fix Modified Paths: -------------- trunk/core/org.cishell.docs/src/specification/tex/introduction.tex Modified: trunk/core/org.cishell.docs/src/specification/tex/introduction.tex =================================================================== --- trunk/core/org.cishell.docs/src/specification/tex/introduction.tex 2008-03-14 15:13:09 UTC (rev 656) +++ trunk/core/org.cishell.docs/src/specification/tex/introduction.tex 2008-03-14 16:09:28 UTC (rev 657) @@ -39,11 +39,10 @@ the design of CIShell draws on previous work by Shashikant Penumarthy, Bruce W. Herr II, and Katy B\"{o}rner on the Information Visualization Cyberinfrastructure (IVC). Thanks go out to all those who have used or contributed to IVC, CIShell, -and the Network Workbench (the first project to use CIShell). +and the Network Workbench (the first project to use CIShell). Development of the +Cyberinfrastructure Shell was funded by grants two from the National Science +Foundation: NSF IIS-0238261 and NSF IIS-0513650. -Development of the Cyberinfrastructure Shell was funded by grants two from the -National Science Foundation: NSF IIS-0238261 and NSF IIS-0513650. - \section{CIShell Platform Overview} The CIShell Platform consists of Java interface definitions for algorithms, data, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-03-14 15:13:26
|
Revision: 656 http://cishell.svn.sourceforge.net/cishell/?rev=656&view=rev Author: bh2 Date: 2008-03-14 08:13:09 -0700 (Fri, 14 Mar 2008) Log Message: ----------- Updated spec based on katy's latest inputs Modified Paths: -------------- trunk/core/org.cishell.docs/src/img/cishellInteraction.dia trunk/core/org.cishell.docs/src/img/cishellInteraction.eps trunk/core/org.cishell.docs/src/img/cishellInteraction.pdf trunk/core/org.cishell.docs/src/specification/tex/algorithms.tex trunk/core/org.cishell.docs/src/specification/tex/guidefinition.tex trunk/core/org.cishell.docs/src/specification/tex/introduction.tex trunk/core/org.cishell.docs/src/specification/tex/osgidependencies.tex trunk/core/org.cishell.docs/src/specification/tex/useradjustableprefs.tex Modified: trunk/core/org.cishell.docs/src/img/cishellInteraction.dia =================================================================== (Binary files differ) Modified: trunk/core/org.cishell.docs/src/img/cishellInteraction.eps =================================================================== --- trunk/core/org.cishell.docs/src/img/cishellInteraction.eps 2008-03-13 15:51:59 UTC (rev 655) +++ trunk/core/org.cishell.docs/src/img/cishellInteraction.eps 2008-03-14 15:13:09 UTC (rev 656) @@ -1,11 +1,11 @@ %!PS-Adobe-2.0 EPSF-2.0 -%%Title: /home/bherr/workspace/org.cishell.docs/src/img/cishellInteraction.dia -%%Creator: Dia v0.96.1 -%%CreationDate: Tue Mar 11 11:32:40 2008 +%%Title: /home/bherr/cishell-1.0-workspace/org.cishell.docs/src/img/cishellInteraction.dia +%%Creator: Dia v0.95 +%%CreationDate: Fri Mar 14 10:51:55 2008 %%For: bherr %%Orientation: Portrait %%Magnification: 1.0000 -%%BoundingBox: 0 0 1257 521 +%%BoundingBox: 0 0 1255 521 %%BeginSetup %%EndSetup %%EndComments @@ -341,26 +341,20 @@ currentdict end definefont pop 28.346000 -28.346000 scale -10.163560 -24.440100 translate +10.163600 -24.440100 translate %%EndProlog 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 14.958000 16.044000 m 14.958000 18.244000 l 22.605500 18.244000 l 22.605500 16.044000 l f +n 14.958000 16.044000 m 14.958000 18.244000 l 22.508000 18.244000 l 22.508000 16.044000 l f 0.000000 0.000000 0.000000 srgb -n 14.958000 16.044000 m 14.958000 18.244000 l 22.605500 18.244000 l 22.605500 16.044000 l cp s +n 14.958000 16.044000 m 14.958000 18.244000 l 22.508000 18.244000 l 22.508000 16.044000 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 16.506750 16.546500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 18.733000 ex sub 16.694000 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(AlgorithmFactory) 15.208000 17.514000 m -dup sw 7.147500 exch sub -16 div exch 0.0 exch - gs 1 -1 sc ashow gr +(AlgorithmFactory) dup sw 2 div 18.733000 ex sub 17.694000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb @@ -368,97 +362,58 @@ 0.000000 0.000000 0.000000 srgb n 27.468000 16.045000 m 27.468000 18.245000 l 32.518000 18.245000 l 32.518000 16.045000 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 27.718000 16.547500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 29.993000 ex sub 16.695000 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(Algorithm) 27.953000 17.515000 m -dup sw 4.080000 exch sub -9 div exch 0.0 exch - gs 1 -1 sc ashow gr +(Algorithm) dup sw 2 div 29.993000 ex sub 17.695000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 0 slj 0 slc -n 27.417800 17.145000 m 23.876500 17.145000 l 23.876500 17.144000 l 22.655700 17.144000 l s +n 27.417828 17.145000 m 23.876500 17.145000 l 23.876500 17.144000 l 22.558290 17.144000 l s /Courier-latin1 ff 0.560000 scf sf -(Creates) 23.976500 16.864500 m -dup sw 2.450000 exch sub -7 div exch 0.0 exch - gs 1 -1 sc ashow gr -(n) 26.867800 16.865000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr -(1) 22.855700 16.864000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr +(Creates) 23.976500 16.994500 m gs 1 -1 sc sh gr +(n) dup sw 27.217828 ex sub 16.995000 m gs 1 -1 sc sh gr +(1) 22.758290 16.994000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 14.706000 22.187000 m 14.706000 24.387000 l 22.886000 24.387000 l 22.886000 22.187000 l f +n 14.706000 22.187000 m 14.706000 24.387000 l 22.756000 24.387000 l 22.756000 22.187000 l f 0.000000 0.000000 0.000000 srgb -n 14.706000 22.187000 m 14.706000 24.387000 l 22.886000 24.387000 l 22.886000 22.187000 l cp s +n 14.706000 22.187000 m 14.706000 24.387000 l 22.756000 24.387000 l 22.756000 22.187000 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 16.521000 22.689500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 18.731000 ex sub 22.837000 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(AlgorithmProperty) 14.956000 23.657000 m -dup sw 7.680000 exch sub -17 div exch 0.0 exch - gs 1 -1 sc ashow gr +(AlgorithmProperty) dup sw 2 div 18.731000 ex sub 23.837000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 13.008700 9.429000 m 13.008700 11.629000 l 19.193700 11.629000 l 19.193700 9.429000 l f +n 12.971200 9.441500 m 12.971200 11.641500 l 19.121200 11.641500 l 19.121200 9.441500 l f 0.000000 0.000000 0.000000 srgb -n 13.008700 9.429000 m 13.008700 11.629000 l 19.193700 11.629000 l 19.193700 9.429000 l cp s +n 12.971200 9.441500 m 12.971200 11.641500 l 19.121200 11.641500 l 19.121200 9.441500 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 13.826200 9.931500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 16.046200 ex sub 10.091500 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(DataValidator) 13.258700 10.899000 m -dup sw 5.685000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(DataValidator) dup sw 2 div 16.046200 ex sub 11.091500 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 25.944300 10.154700 m 25.944300 12.354700 l 34.036800 12.354700 l 34.036800 10.154700 l f +n 25.944300 10.154700 m 25.944300 12.354700 l 34.044300 12.354700 l 34.044300 10.154700 l f 0.000000 0.000000 0.000000 srgb -n 25.944300 10.154700 m 25.944300 12.354700 l 34.036800 12.354700 l 34.036800 10.154700 l cp s +n 25.944300 10.154700 m 25.944300 12.354700 l 34.044300 12.354700 l 34.044300 10.154700 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 27.715550 10.657200 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 29.994300 ex sub 10.804700 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(ProgressTrackable) 26.194300 11.624700 m -dup sw 7.592500 exch sub -17 div exch 0.0 exch - gs 1 -1 sc ashow gr +(ProgressTrackable) dup sw 2 div 29.994300 ex sub 11.804700 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 26.740000 6.159000 m 26.740000 8.359000 l 34.097500 8.359000 l 34.097500 6.159000 l f +n 26.740000 6.159000 m 26.740000 8.359000 l 33.990000 8.359000 l 33.990000 6.159000 l f 0.000000 0.000000 0.000000 srgb -n 26.740000 6.159000 m 26.740000 8.359000 l 34.097500 8.359000 l 34.097500 6.159000 l cp s +n 26.740000 6.159000 m 26.740000 8.359000 l 33.990000 8.359000 l 33.990000 6.159000 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 28.143750 6.661500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 30.365000 ex sub 6.809000 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(ProgressMonitor) 26.990000 7.629000 m -dup sw 6.857500 exch sub -15 div exch 0.0 exch - gs 1 -1 sc ashow gr +(ProgressMonitor) dup sw 2 div 30.365000 ex sub 7.809000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb @@ -466,46 +421,31 @@ 0.000000 0.000000 0.000000 srgb n 5.011420 17.736700 m 5.011420 19.936700 l 10.061420 19.936700 l 10.061420 17.736700 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 5.261420 18.239200 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 7.536420 ex sub 18.386700 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(Data) 6.566420 19.206700 m -dup sw 1.940000 exch sub -4 div exch 0.0 exch - gs 1 -1 sc ashow gr +(Data) dup sw 2 div 7.536420 ex sub 19.386700 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n -2.927750 17.728800 m -2.927750 19.928800 l 1.679750 19.928800 l 1.679750 17.728800 l f +n -2.927750 17.728800 m -2.927750 19.928800 l 1.672250 19.928800 l 1.672250 17.728800 l f 0.000000 0.000000 0.000000 srgb -n -2.927750 17.728800 m -2.927750 19.928800 l 1.679750 19.928800 l 1.679750 17.728800 l cp s +n -2.927750 17.728800 m -2.927750 19.928800 l 1.672250 19.928800 l 1.672250 17.728800 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<class>>) -2.199000 18.231300 m -dup sw 3.150000 exch sub -9 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<class>>) dup sw 2 div -0.627750 ex sub 18.378800 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(BasicData) -2.677750 19.198800 m -dup sw 4.107500 exch sub -9 div exch 0.0 exch - gs 1 -1 sc ashow gr +(BasicData) dup sw 2 div -0.627750 ex sub 19.378800 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd [] 0 sd 0 slc -n 16.035100 15.993800 m 16.093829 12.115748 l s +n 16.035100 15.993800 m 16.044958 12.128302 l s [] 0 sd 0 slj 0 slc -n 16.099507 11.740791 m 16.341907 12.244519 l 16.093829 12.115748 l 15.841965 12.236948 l ef -n 16.099507 11.740791 m 16.341907 12.244519 l 16.093829 12.115748 l 15.841965 12.236948 l cp s +n 16.045915 11.753303 m 16.294639 12.253939 l 16.044958 12.128302 l 15.794640 12.252664 l ef +n 16.045915 11.753303 m 16.294639 12.253939 l 16.044958 12.128302 l 15.794640 12.252664 l cp s /Courier-latin1 ff 0.560000 scf sf -( Optional) 16.068150 13.671400 m -dup sw 3.150000 exch sub -9 div exch 0.0 exch - gs 1 -1 sc ashow gr +( Optional) 16.040650 13.817650 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd [] 0 sd @@ -517,80 +457,54 @@ n 29.994075 12.493903 m 30.243965 12.993958 l 29.993993 12.868903 l 29.743965 12.993848 l ef n 29.994075 12.493903 m 30.243965 12.993958 l 29.993993 12.868903 l 29.743965 12.993848 l cp s /Courier-latin1 ff 0.560000 scf sf -( Optional) 29.993700 14.059800 m -dup sw 3.150000 exch sub -9 div exch 0.0 exch - gs 1 -1 sc ashow gr +( Optional) 29.993700 14.199800 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 0 slj 0 slc n 18.796000 22.187000 m 18.736900 22.187000 l 18.736900 18.244000 l 18.781700 18.244000 l s /Courier-latin1 ff 0.560000 scf sf -(Service Constants) 18.836900 19.935500 m -dup sw 5.950000 exch sub -17 div exch 0.0 exch - gs 1 -1 sc ashow gr +(Service Constants) 18.836900 20.065500 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 0 slj 0 slc n 26.701000 7.259000 m 24.447100 7.259000 l 24.447100 11.254700 l 25.944300 11.254700 l s -(Communications) 24.547100 8.976850 m -dup sw 4.900000 exch sub -14 div exch 0.0 exch - gs 1 -1 sc ashow gr -(1) 26.151000 6.979000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr -(1) 25.394300 10.974700 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr +/Courier-latin1 ff 0.560000 scf sf +(Communications) 24.547100 9.106850 m gs 1 -1 sc sh gr +(1) dup sw 26.501000 ex sub 7.109000 m gs 1 -1 sc sh gr +(1) dup sw 25.744300 ex sub 11.104700 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 4.410510 11.796000 m 4.410510 13.996000 l 10.980510 13.996000 l 10.980510 11.796000 l f +n 4.410510 11.796000 m 4.410510 13.996000 l 11.010510 13.996000 l 11.010510 11.796000 l f 0.000000 0.000000 0.000000 srgb -n 4.410510 11.796000 m 4.410510 13.996000 l 10.980510 13.996000 l 10.980510 11.796000 l cp s +n 4.410510 11.796000 m 4.410510 13.996000 l 11.010510 13.996000 l 11.010510 11.796000 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 5.420510 12.298500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 7.710510 ex sub 12.446000 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(CIShellContext) 4.660510 13.266000 m -dup sw 6.070000 exch sub -14 div exch 0.0 exch - gs 1 -1 sc ashow gr +(CIShellContext) dup sw 2 div 7.710510 ex sub 13.446000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 3.348670 6.167520 m 3.348670 8.367520 l 12.061170 8.367520 l 12.061170 6.167520 l f +n 3.336170 6.167520 m 3.336170 8.367520 l 12.086170 8.367520 l 12.086170 6.167520 l f 0.000000 0.000000 0.000000 srgb -n 3.348670 6.167520 m 3.348670 8.367520 l 12.061170 8.367520 l 12.061170 6.167520 l cp s +n 3.336170 6.167520 m 3.336170 8.367520 l 12.086170 8.367520 l 12.086170 6.167520 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<class>>) 6.129920 6.670020 m -dup sw 3.150000 exch sub -9 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<class>>) dup sw 2 div 7.711170 ex sub 6.817520 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(LocalCIShellContext) 3.598670 7.637520 m -dup sw 8.212500 exch sub -19 div exch 0.0 exch - gs 1 -1 sc ashow gr +(LocalCIShellContext) dup sw 2 div 7.711170 ex sub 7.817520 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd [] 0 sd 0 slj 0 slc -n 7.701548 11.258857 m 7.710510 8.828840 l 7.704920 8.828840 l 7.704920 8.417545 l s +n 7.710510 11.258854 m 7.710510 8.828840 l 7.711170 8.828840 l 7.711170 8.417545 l s [] 0 sd 0 slj 0 slc -n 7.700165 11.633854 m 7.452011 11.132936 l 7.701548 11.258857 l 7.952007 11.134780 l ef -n 7.700165 11.633854 m 7.452011 11.132936 l 7.701548 11.258857 l 7.952007 11.134780 l cp s +n 7.710510 11.633854 m 7.460510 11.133854 l 7.710510 11.258854 l 7.960510 11.133854 l ef +n 7.710510 11.633854 m 7.460510 11.133854 l 7.710510 11.258854 l 7.960510 11.133854 l cp s 0.100000 slw [] 0 sd [] 0 sd @@ -601,19 +515,13 @@ 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 4.650940 22.190100 m 4.650940 24.390100 l 10.690940 24.390100 l 10.690940 22.190100 l f +n 4.650940 22.190100 m 4.650940 24.390100 l 10.700940 24.390100 l 10.700940 22.190100 l f 0.000000 0.000000 0.000000 srgb -n 4.650940 22.190100 m 4.650940 24.390100 l 10.690940 24.390100 l 10.690940 22.190100 l cp s +n 4.650940 22.190100 m 4.650940 24.390100 l 10.700940 24.390100 l 10.700940 22.190100 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 5.395940 22.692600 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 7.675940 ex sub 22.840100 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(DataProperty) 4.900940 23.660100 m -dup sw 5.540000 exch sub -12 div exch 0.0 exch - gs 1 -1 sc ashow gr +(DataProperty) dup sw 2 div 7.675940 ex sub 23.840100 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd [] 0 sd @@ -631,75 +539,47 @@ 0 slc n 7.675940 22.190100 m 7.339530 22.190100 l 7.339530 19.936700 l 7.536420 19.936700 l s /Courier-latin1 ff 0.560000 scf sf -(Data Constants) 7.439530 20.783400 m -dup sw 4.900000 exch sub -14 div exch 0.0 exch - gs 1 -1 sc ashow gr +(Data Constants) 7.439530 20.913400 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 0 slj 0 slc n 11.062600 12.898000 m 12.164000 12.898000 l 12.164000 17.144000 l 14.958000 17.144000 l s -(given) 12.264000 14.741000 m -dup sw 1.750000 exch sub -5 div exch 0.0 exch - gs 1 -1 sc ashow gr -(n) 11.262600 12.618000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr -(1) 14.408000 16.864000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr +/Courier-latin1 ff 0.560000 scf sf +(Given) 12.264000 14.871000 m gs 1 -1 sc sh gr +(n) 11.262600 12.748000 m gs 1 -1 sc sh gr +(1) dup sw 14.758000 ex sub 16.994000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 0 slj 0 slc n 10.061400 18.836700 m 12.164000 18.836700 l 12.164000 17.144000 l 14.958000 17.144000 l s -(given) 12.264000 17.710350 m -dup sw 1.750000 exch sub -5 div exch 0.0 exch - gs 1 -1 sc ashow gr -(0..n) 10.261400 18.556700 m -dup sw 1.400000 exch sub -4 div exch 0.0 exch - gs 1 -1 sc ashow gr -(1) 14.408000 16.864000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr +/Courier-latin1 ff 0.560000 scf sf +(Given) 12.264000 17.840350 m gs 1 -1 sc sh gr +(0..n) 10.261400 18.686700 m gs 1 -1 sc sh gr +(1) dup sw 14.758000 ex sub 16.994000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n 15.656400 6.140000 m 15.656400 8.340000 l 23.778900 8.340000 l 23.778900 6.140000 l f +n 15.656400 6.140000 m 15.656400 8.340000 l 23.806400 8.340000 l 23.806400 6.140000 l f 0.000000 0.000000 0.000000 srgb -n 15.656400 6.140000 m 15.656400 8.340000 l 23.778900 8.340000 l 23.778900 6.140000 l cp s +n 15.656400 6.140000 m 15.656400 8.340000 l 23.806400 8.340000 l 23.806400 6.140000 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) 17.442650 6.642500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div 19.731400 ex sub 6.790000 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(ParameterMutator) 15.906400 7.610000 m -dup sw 7.622500 exch sub -16 div exch 0.0 exch - gs 1 -1 sc ashow gr +(ParameterMutator) dup sw 2 div 19.731400 ex sub 7.790000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd [] 0 sd 0 slc -n 19.722600 15.993800 m 19.717965 8.826803 l s +n 19.722600 15.993800 m 19.717918 8.826803 l s [] 0 sd 0 slj 0 slc -n 19.717722 8.451803 m 19.968046 8.951642 l 19.717965 8.826803 l 19.468046 8.951965 l ef -n 19.717722 8.451803 m 19.968046 8.951642 l 19.717965 8.826803 l 19.468046 8.951965 l cp s +n 19.717673 8.451803 m 19.968000 8.951640 l 19.717918 8.826803 l 19.468000 8.951967 l ef +n 19.717673 8.451803 m 19.968000 8.951640 l 19.717918 8.826803 l 19.468000 8.951967 l cp s /Courier-latin1 ff 0.560000 scf sf -( Optional) 19.720125 12.026900 m -dup sw 3.150000 exch sub -9 div exch 0.0 exch - gs 1 -1 sc ashow gr +( Optional) 19.720100 12.166900 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb @@ -707,134 +587,95 @@ 0.000000 0.000000 0.000000 srgb n -5.096060 14.242500 m -5.096060 16.442500 l -0.046060 16.442500 l -0.046060 14.242500 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) -4.846060 14.745000 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div -2.571060 ex sub 14.892500 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(LogService) -4.832310 15.712500 m -dup sw 4.522500 exch sub -10 div exch 0.0 exch - gs 1 -1 sc ashow gr +(LogService) dup sw 2 div -2.571060 ex sub 15.892500 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n -8.508560 11.530000 m -8.508560 13.730000 l -0.036060 13.730000 l -0.036060 11.530000 l f +n -8.508560 11.530000 m -8.508560 13.730000 l -0.008560 13.730000 l -0.008560 11.530000 l f 0.000000 0.000000 0.000000 srgb -n -8.508560 11.530000 m -8.508560 13.730000 l -0.036060 13.730000 l -0.036060 11.530000 l cp s +n -8.508560 11.530000 m -8.508560 13.730000 l -0.008560 13.730000 l -0.008560 11.530000 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) -6.547310 12.032500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div -4.258560 ex sub 12.180000 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(PreferencesService) -8.258560 13.000000 m -dup sw 7.972500 exch sub -18 div exch 0.0 exch - gs 1 -1 sc ashow gr +(PreferencesService) dup sw 2 div -4.258560 ex sub 13.180000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n -10.113560 6.160000 m -10.113560 8.360000 l -0.046060 8.360000 l -0.046060 6.160000 l f +n -10.113600 6.160000 m -10.113600 8.360000 l -0.163600 8.360000 l -0.163600 6.160000 l f 0.000000 0.000000 0.000000 srgb -n -10.113560 6.160000 m -10.113560 8.360000 l -0.046060 8.360000 l -0.046060 6.160000 l cp s +n -10.113600 6.160000 m -10.113600 8.360000 l -0.163600 8.360000 l -0.163600 6.160000 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) -7.354810 6.662500 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div -5.138600 ex sub 6.810000 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(DataConversionService) -9.863560 7.630000 m -dup sw 9.567500 exch sub -21 div exch 0.0 exch - gs 1 -1 sc ashow gr +(DataConversionService) dup sw 2 div -5.138600 ex sub 7.810000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 1.000000 1.000000 1.000000 srgb -n -8.008560 8.867500 m -8.008560 11.067500 l -0.056060 11.067500 l -0.056060 8.867500 l f +n -8.008560 8.867500 m -8.008560 11.067500 l -0.208560 11.067500 l -0.208560 8.867500 l f 0.000000 0.000000 0.000000 srgb -n -8.008560 8.867500 m -8.008560 11.067500 l -0.056060 11.067500 l -0.056060 8.867500 l cp s +n -8.008560 8.867500 m -8.008560 11.067500 l -0.208560 11.067500 l -0.208560 8.867500 l cp s /Courier-latin1 ff 0.560000 scf sf -(<<interface>>) -6.307310 9.370000 m -dup sw 4.550000 exch sub -13 div exch 0.0 exch - gs 1 -1 sc ashow gr +(<<interface>>) dup sw 2 div -4.108560 ex sub 9.517500 m gs 1 -1 sc sh gr /Helvetica-Bold-latin1 ff 0.700000 scf sf -(GUIBuilderService) -7.758560 10.337500 m -dup sw 7.452500 exch sub -17 div exch 0.0 exch - gs 1 -1 sc ashow gr +(GUIBuilderService) dup sw 2 div -4.108560 ex sub 10.517500 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 0 slj 0 slc n 0.002994 7.260000 m 2.047600 7.260000 l 2.047600 12.896000 l 4.410510 12.896000 l s /Courier-latin1 ff 0.560000 scf sf -(Provides Access) 2.147600 9.798000 m -dup sw 5.250000 exch sub -15 div exch 0.0 exch - gs 1 -1 sc ashow gr -(1) 0.202994 6.980000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr -(n) 3.860510 12.616000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr +(Provides Access) 2.147600 9.928000 m gs 1 -1 sc sh gr +(1) 0.202994 7.110000 m gs 1 -1 sc sh gr +(n) dup sw 4.210510 ex sub 12.746000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd [] 0 sd 0 slj 0 slc -n 0.053166 10.164762 m -1.041534 11.204562 l 0.052466 11.204562 l ef -n 0.053166 10.164762 m -1.041534 11.204562 l 0.052466 11.204562 l cp s +n 0.053166 10.164800 m -1.041530 11.204600 l 0.052466 11.204600 l ef +n 0.053166 10.164800 m -1.041530 11.204600 l 0.052466 11.204600 l cp s 0.100000 slw [] 0 sd [] 0 sd 0 slj 0 slc -n 0.043882 12.838512 m -1.050818 13.878312 l 0.043182 13.878312 l ef -n 0.043882 12.838512 m -1.050818 13.878312 l 0.043182 13.878312 l cp s +n 0.043882 12.838500 m -1.050820 13.878300 l 0.043182 13.878300 l ef +n 0.043882 12.838500 m -1.050820 13.878300 l 0.043182 13.878300 l cp s 0.100000 slw [] 0 sd [] 0 sd 0 slj 0 slc -n 0.052632 15.554762 m -1.042068 16.594562 l 0.051932 16.594562 l ef -n 0.052632 15.554762 m -1.042068 16.594562 l 0.051932 16.594562 l cp s +n 0.052632 15.554800 m -1.042070 16.594600 l 0.051932 16.594600 l ef +n 0.052632 15.554800 m -1.042070 16.594600 l 0.051932 16.594600 l cp s 0.100000 slw [] 0 sd [] 0 sd 0 slj 0 slc -n 0.061382 7.458512 m -1.033318 8.498312 l 0.060682 8.498312 l ef -n 0.061382 7.458512 m -1.033318 8.498312 l 0.060682 8.498312 l cp s +n 0.061382 7.458510 m -1.033320 8.498310 l 0.060682 8.498310 l ef +n 0.061382 7.458510 m -1.033320 8.498310 l 0.060682 8.498310 l cp s 0.100000 slw [] 0 sd 0 slj 0 slc -n -0.006049 9.967500 m 2.043610 9.967500 l 2.043610 12.896000 l 4.361082 12.896000 l s -(1) 0.193951 9.687500 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr +n -0.006049 9.967500 m 2.043610 9.967500 l 2.043610 12.896000 l 4.361080 12.896000 l s +/Courier-latin1 ff 0.560000 scf sf +(1) 0.193951 9.817500 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 0 slj 0 slc n 0.011290 12.630000 m 2.043610 12.630000 l 2.043610 12.896000 l 4.410510 12.896000 l s -(1) 0.211290 12.350000 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr +/Courier-latin1 ff 0.560000 scf sf +(1) 0.211290 12.480000 m gs 1 -1 sc sh gr 0.100000 slw [] 0 sd 0 slj 0 slc -n 0.003286 15.342500 m 2.043610 15.342500 l 2.043610 12.896000 l 4.361082 12.896000 l s -(1) 0.203286 15.062500 m -dup sw 0.350000 exch sub -1 div exch 0.0 exch - gs 1 -1 sc ashow gr +n 0.003286 15.342500 m 2.043610 15.342500 l 2.043610 12.896000 l 4.361080 12.896000 l s +/Courier-latin1 ff 0.560000 scf sf +(1) 0.203286 15.192500 m gs 1 -1 sc sh gr showpage Modified: trunk/core/org.cishell.docs/src/img/cishellInteraction.pdf =================================================================== (Binary files differ) Modified: trunk/core/org.cishell.docs/src/specification/tex/algorithms.tex =================================================================== --- trunk/core/org.cishell.docs/src/specification/tex/algorithms.tex 2008-03-13 15:51:59 UTC (rev 655) +++ trunk/core/org.cishell.docs/src/specification/tex/algorithms.tex 2008-03-14 15:13:09 UTC (rev 656) @@ -26,10 +26,10 @@ algorithm. It is the central and most important concept. Algorithms are fully defined and self-contained bits of execution. They can do many things from data conversion, data analysis, and can even spawn whole external programs if needed. -Algorithms are very well defined black boxes in that what can come into and out -of the algorithm is specified in each algorithm's service metadata and -associated \class{MetaTypeProvider}. Other than that, CIShell makes no attempt -to understand the algorithm. +Algorithms are well defined black boxes in that their input and output is +specified in each algorithm's service metadata and associated +\class{MetaTypeProvider}. Other than that, CIShell makes no attempt to understand +the algorithm. \subsubsection{Essentials} \begin{itemize} @@ -109,7 +109,7 @@ such as the format of each \class{Data} item to be input and output is provided. In addition to the mechanics of the algorithms, data such as the authors, label, urls, citation references, and description are provided. This metadata can be -searched by anyone using OSGi's service registry to find relevant algorithms. +searched by anyone to find relevant algorithms using OSGi's service registry. Each standard metadata element required by the CIShell specification is defined below and in the interface \class{AlgorithmProperty}. It defines each key string @@ -126,7 +126,7 @@ \begin{quote} \begin{description} - \item[Example 1:] service.pid = org.cishell.my.algorithm.MyAlgorithm + \item[Example 1:] service.pid = org.my.algorithm.MyAlgorithm \end{description} \end{quote} @@ -286,8 +286,8 @@ \subsection*{conversion} For converter algorithms, this metadata element specifies if any data is lost in the conversion. Possible values are ``lossy'' and ``lossless''. A -description of what type of information is lost should be explained in the -description. +description of what type of information is lost should be given in the +``description'' metadata field. \begin{quote} \begin{description} @@ -301,8 +301,8 @@ \begin{quote} \begin{description} - \item[Example 1:] authors = Bruce Herr - \item[Example 2:] authors = Bruce Herr, Weixia Huang, Katy Borner + \item[Example 1:] authors = Bruce W. Herr II + \item[Example 2:] authors = Bruce W. Herr II, Weixia Huang, Katy Borner \end{description} \end{quote} @@ -312,8 +312,8 @@ \begin{quote} \begin{description} - \item[Example 1:] implementers = Bruce Herr - \item[Example 2:] implementers = Bruce Herr, Weixia Huang, Katy Borner + \item[Example 1:] implementers = Bruce W. Herr II + \item[Example 2:] implementers = Bruce W. Herr II, Weixia Huang, Katy Borner \end{description} \end{quote} @@ -324,8 +324,8 @@ \begin{quote} \begin{description} - \item[Example 1:] integrators = Bruce Herr - \item[Example 2:] integrators = Bruce Herr, Weixia Huang, Katy Borner + \item[Example 1:] integrators = Bruce W. Herr II + \item[Example 2:] integrators = Bruce W. Herr II, Weixia Huang, Katy Borner \end{description} \end{quote} @@ -345,10 +345,10 @@ \begin{quote} \begin{description} - \item[Example 1:] reference = Herr, Bruce W., Huang, Weixia, Penumarthy, - Shashikant, Börner, Katy. (2007) Designing Highly Flexible and Usable + \item[Example 1:] reference = Herr, Bruce W. II, Huang, Weixia, Penumarthy, + Shashikant, B\"{o}rner, Katy. (2007) Designing Highly Flexible and Usable Cyberinfrastructures for Convergence. In William S. Bainbridge and Mihail C. - Roco (Eds.) Progress in Convergence – Technologies for Human Wellbeing. + Roco (Eds.) Progress in Convergence - Technologies for Human Wellbeing. Annals of the New York Academy of Sciences, Boston, MA, volume 1093, pp. 161-179. \end{description} \end{quote} @@ -359,7 +359,7 @@ \begin{quote} \begin{description} - \item[Example 1:] reference\_url = http://cishell.org/papers/06-cishell.pdf + \item[Example 1:] reference\_url = http://cishell.org/papers/07-cishell.pdf \end{description} \end{quote} Modified: trunk/core/org.cishell.docs/src/specification/tex/guidefinition.tex =================================================================== --- trunk/core/org.cishell.docs/src/specification/tex/guidefinition.tex 2008-03-13 15:51:59 UTC (rev 655) +++ trunk/core/org.cishell.docs/src/specification/tex/guidefinition.tex 2008-03-14 15:13:09 UTC (rev 656) @@ -30,11 +30,11 @@ is not tied to any specific UI, so it can be reused depending on the context (desktop application, web application, command line, etc.). -\class{MetaTypeProvider} is an interface defined in the OSGi R4 Specification -Service Compendium as part of the ``Metatype Service Specification''. A -\class{MetaTypeProvider} can be thought of as a collection of UIs. Each UI is -called an \class{ObjectClassDefinition}, which provides a UI name and description -and is a collection of parameters. Each parameter is an +\class{MetaTypeProvider} is a Java interface defined in the OSGi R4 Specification +Service Compendium as part of the ``Metatype Service Specification,'' section +105. A \class{MetaTypeProvider} can be thought of as a collection of UIs. Each UI +is called an \class{ObjectClassDefinition}, which provides a UI name and +description and is a collection of parameters. Each parameter is an \class{AttributeDefinition} which includes the type, label, description, default value, and range of valid values. Drop-down boxes can also be defined by using option labels and values with the \class{AttributeDefinition}. OSGi's Modified: trunk/core/org.cishell.docs/src/specification/tex/introduction.tex =================================================================== --- trunk/core/org.cishell.docs/src/specification/tex/introduction.tex 2008-03-13 15:51:59 UTC (rev 655) +++ trunk/core/org.cishell.docs/src/specification/tex/introduction.tex 2008-03-14 15:13:09 UTC (rev 656) @@ -41,6 +41,9 @@ (IVC). Thanks go out to all those who have used or contributed to IVC, CIShell, and the Network Workbench (the first project to use CIShell). +Development of the Cyberinfrastructure Shell was funded by grants two from the +National Science Foundation: NSF IIS-0238261 and NSF IIS-0513650. + \section{CIShell Platform Overview} The CIShell Platform consists of Java interface definitions for algorithms, data, @@ -81,8 +84,8 @@ \section{Conventions and Terms} In this specification, algorithms are referred to in three different contexts. An -abstract algorithm, is the pure idea of the algorithm with no actual source code. -It is a series of steps sometimes put into psuedo-code and often published in +abstract algorithm is the pure idea of the algorithm with no actual source code. +It is a series of steps sometimes put into pseudo-code and often published in academic journals. An \class{Algorithm} with a capital A refers to the Java class called Algorithm. And finally, an algorithm with a lowercase A refers to the bundle of code and metadata that encompasses an algorithm written to work with Modified: trunk/core/org.cishell.docs/src/specification/tex/osgidependencies.tex =================================================================== --- trunk/core/org.cishell.docs/src/specification/tex/osgidependencies.tex 2008-03-13 15:51:59 UTC (rev 655) +++ trunk/core/org.cishell.docs/src/specification/tex/osgidependencies.tex 2008-03-14 15:13:09 UTC (rev 656) @@ -27,29 +27,29 @@ \subsection*{Required Services} \begin{description} - \item[Metatype Service] as described in OSGi section 105 ``Metatype Service - Specification,'' this service is used by CIShell to find + \item[Metatype Service] is described in OSGi section 105 ``Metatype Service + Specification.'' This service is used by CIShell to find \class{MetaTypeProviders} for user interface specification, user-adjustable preferences, and input parameters. It also provides an XML format for automatically generating \class{MetaTypeProvider}s which the \class{MetaTypeService} harvests for use. - \item[Log Service] as described in OSGi section 101 ``Log Service - Specification,'' this service is used as a universal logging system for + \item[Log Service] is described in OSGi section 101 ``Log Service + Specification.'' This service is used as a universal logging system for algorithms and services. See chapter \ref{logService} for more details. - \item[Preferences Service] as described in OSGi section 106 ``Preferences - Service Specification,'' this service is used as a universal preference + \item[Preferences Service] is described in OSGi section 106 ``Preferences + Service Specification.'' This service is used as a universal preference storage system for algorithms and services. See chapter \ref{preferencesService} for more details. - \item[Configuration Admin Service] as described in OSGi section 104 - ``Configuration Admin Service Specification,'' this service is used as a + \item[Configuration Admin Service] is described in OSGi section 104 + ``Configuration Admin Service Specification.'' This service is used as a manager/provider of configuration information for bundles and services. It is - very useful for meeting the User Adjustable Preferences (section + useful for meeting the User Adjustable Preferences (section \ref{userPrefsSpec}) requirements. \end{description} \subsection*{Recommended Services} \begin{description} - \item[Declarative Services] as described in OSGi section 112 ``Declarative - Services Specification,'' this service can be used by CIShell algorithms to + \item[Declarative Services] is described in OSGi section 112 ``Declarative + Services Specification.'' This service can be used by CIShell algorithms to simplify algorithm service registration and for finding necessary auxilary services. \end{description} Modified: trunk/core/org.cishell.docs/src/specification/tex/useradjustableprefs.tex =================================================================== --- trunk/core/org.cishell.docs/src/specification/tex/useradjustableprefs.tex 2008-03-13 15:51:59 UTC (rev 655) +++ trunk/core/org.cishell.docs/src/specification/tex/useradjustableprefs.tex 2008-03-14 15:13:09 UTC (rev 656) @@ -38,7 +38,7 @@ \class{ManagedService}. See section \ref{GUISpec} for more information. \subsubsection*{Designate an OCD a Persistent ID (PID)} Then they must designate -the \class{ObjectClassDefinition} a persistent id (PID). The PID can be +the \class{ObjectClassDefinition} a unique persistent id (PID). The PID can be designated in two ways. The simplest way is by following the convention of creating a string with the associated service's ``service.pid'' and appending either ``.prefs.local'' or ``.prefs.global''. The other way is to designate @@ -65,15 +65,15 @@ \subsubsection*{Receiving Preference Data} To be notified of changes to local or global preferences, the service must implement \class{org.\-osgi.\-service.\-cm.\-ManagedService} and set in their service -metadata ``receive\_prefs=true''. When either the local or global preferences are updated, -the updated method will be passed a \class{Dictionary} of all of the id/value -pairs, including the updated ones. Local preferences will have the same ids as -the \class{AttributeDefinition}s (AD) defined in the associated OCD. The local -preferences will also have an additional id ``Bundle-Version", which contains the -version of the service's associated bundle that was used when the preference data -was last updated. Global preferences will have the same ids (plus a -``Bundle-Version'' id analagous to local preference's) from their OCD's ADs +metadata ``receive\_prefs=true''. When either the local or global preferences are +updated, the updated method will be passed a \class{Dictionary} of all of the +id/value pairs, including the updated ones. Local preferences will have the same +ids as the \class{AttributeDefinition}s (AD) defined in the associated OCD. The +local preferences will also have an additional id ``Bundle-Version", which +contains the version of the service's associated bundle that was used when the +preference data was last updated. Global preferences will have the same ids (plus +a ``Bundle-Version'' id analagous to local preference's) from their OCD's ADs prefixed by the PID of the published global preference. In this way, all global preferences published in the system will be available to anyone receiving -preference data. Note that one does not have to publish any preferences to -receive just global preference data. +preference data. Note that global preferences can be received without publishing +preferences. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-03-13 15:52:03
|
Revision: 655 http://cishell.svn.sourceforge.net/cishell/?rev=655&view=rev Author: bh2 Date: 2008-03-13 08:51:59 -0700 (Thu, 13 Mar 2008) Log Message: ----------- Re-enabled the non-compliant wizards. Also renamed them so that they better match how other wizards are called in eclipse. Modified Paths: -------------- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/plugin.xml Modified: branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/plugin.xml =================================================================== --- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/plugin.xml 2008-03-12 14:21:18 UTC (rev 654) +++ branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/plugin.xml 2008-03-13 15:51:59 UTC (rev 655) @@ -13,10 +13,9 @@ hasPages="true" icon="icons/cishell.ico" id="org.cishell.templates.wizards.java.NewJavaAlgorithmWizard" - name="Java-based algorithm" + name="Java Algorithm Project" preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective" project="true"/> -<!-- disabling until they can be updated for CIShell 1.0 <wizard canFinishEarly="false" category="cishell" @@ -24,7 +23,7 @@ hasPages="true" icon="icons/cishell.ico" id="org.cishell.templates.wizards.staticexecutable.NewStaticExecutableAlgorithmWizard" - name="Executable (command line) based algorithm" + name="Executable (command line)/non-Java Algorithm Project" preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective" project="true"/> <wizard @@ -34,28 +33,26 @@ hasPages="true" icon="icons/cishell.ico" id="org.cishell.templates.wizards.jython.NewJythonAlgorithmWizard" - name="Jython-based algorithm" + name="Jython Algorithm Project" preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective" project="true"/> <wizard + category="cishell" + class="org.cishell.templates.wizards.java.NewLibraryIntegrationWizard" + icon="icons/cishell.ico" + id="org.cishell.templates.wizards.java.NewLibraryPluginProjectWizard" + name="Existing Java Library (JAR) Integration Project" + preferredPerspectives="org.eclipse.pde.ui.PDEPerspective, org.eclipse.jdt.ui.JavaPerspective" + project="true"/> + <wizard canFinishEarly="false" category="cishell" class="org.cishell.templates.wizards.dataset.NewDatasetWizard" hasPages="true" icon="icons/cishell.ico" id="org.cishell.templates.wizards.staticexecutable.NewDatasetWizard" - name="Dataset" + name="Dataset Integration Project" preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective" project="true"/> ---> - <wizard - category="cishell" - class="org.cishell.templates.wizards.java.NewLibraryIntegrationWizard" - icon="icons/cishell.ico" - id="org.cishell.templates.wizards.java.NewLibraryPluginProjectWizard" - name="Create code libraries from existing jar files" - preferredPerspectives="org.eclipse.pde.ui.PDEPerspective, org.eclipse.jdt.ui.JavaPerspective" - project="true"> - </wizard> </extension> </plugin> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-03-12 14:21:23
|
Revision: 654 http://cishell.svn.sourceforge.net/cishell/?rev=654&view=rev Author: bh2 Date: 2008-03-12 07:21:18 -0700 (Wed, 12 Mar 2008) Log Message: ----------- Some more updates. disabled all but the java integration wizards until the other wizards are updated to cishell 1.0. If I get the Java integration tutorial done quickly I'll come back for the others. Modified Paths: -------------- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/META-INF/MANIFEST.MF branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/plugin.xml branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/templates_3.0/java_algorithm/java/$algClass$.java Modified: branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/META-INF/MANIFEST.MF =================================================================== --- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/META-INF/MANIFEST.MF 2008-03-12 13:26:40 UTC (rev 653) +++ branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/META-INF/MANIFEST.MF 2008-03-12 14:21:18 UTC (rev 654) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: CIShell Integration Wizards Bundle-SymbolicName: org.cishell.templates.wizards;singleton:=true -Bundle-Version: 0.3.0 +Bundle-Version: 0.9.5 Bundle-Activator: org.cishell.templates.wizards.Activator Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="3.2.0", Modified: branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/plugin.xml =================================================================== --- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/plugin.xml 2008-03-12 13:26:40 UTC (rev 653) +++ branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/plugin.xml 2008-03-12 14:21:18 UTC (rev 654) @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.2"?> <plugin> - <extension point="org.eclipse.ui.newWizards"> <category @@ -17,6 +16,7 @@ name="Java-based algorithm" preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective" project="true"/> +<!-- disabling until they can be updated for CIShell 1.0 <wizard canFinishEarly="false" category="cishell" @@ -47,6 +47,7 @@ name="Dataset" preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective" project="true"/> +--> <wizard category="cishell" class="org.cishell.templates.wizards.java.NewLibraryIntegrationWizard" @@ -57,5 +58,4 @@ project="true"> </wizard> </extension> - </plugin> Modified: branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java =================================================================== --- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java 2008-03-12 13:26:40 UTC (rev 653) +++ branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java 2008-03-12 14:21:18 UTC (rev 654) @@ -134,11 +134,13 @@ "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.osgi.framework;version=\"1.3.0\"", "org.osgi.service.component;version=\"1.0.0\"", "org.osgi.service.log;version=\"1.3.0\"", "org.osgi.service.metatype;version=\"1.1.0\"", - "org.osgi.service.prefs;version=\"1.1.0\"" + "org.osgi.service.prefs;version=\"1.1.0\"", + "org.osgi.service.cm;version=\"1.2.0\"" }; } Modified: branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/templates_3.0/java_algorithm/java/$algClass$.java =================================================================== --- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/templates_3.0/java_algorithm/java/$algClass$.java 2008-03-12 13:26:40 UTC (rev 653) +++ branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/templates_3.0/java_algorithm/java/$algClass$.java 2008-03-12 14:21:18 UTC (rev 654) @@ -4,6 +4,7 @@ import org.cishell.framework.CIShellContext; import org.cishell.framework.algorithm.Algorithm; +import org.cishell.framework.algorithm.AlgorithmExecutionException; import org.cishell.framework.data.Data; public class $algClass$ implements Algorithm { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bh...@us...> - 2008-03-12 13:27:24
|
Revision: 653 http://cishell.svn.sourceforge.net/cishell/?rev=653&view=rev Author: bh2 Date: 2008-03-12 06:26:40 -0700 (Wed, 12 Mar 2008) Log Message: ----------- updated the java algorithm wizard Modified Paths: -------------- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/templates_3.0/java_algorithm/OSGI-INF/component.xml Modified: branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java =================================================================== --- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java 2008-03-12 12:52:35 UTC (rev 652) +++ branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/src/org/cishell/templates/wizards/java/NewJavaAlgorithmWizard.java 2008-03-12 13:26:40 UTC (rev 653) @@ -131,9 +131,9 @@ */ public String[] getImportPackages() { return new String[]{ - "org.cishell.framework", - "org.cishell.framework.algorithm", - "org.cishell.framework.data", + "org.cishell.framework;version=\"1.0.0\"", + "org.cishell.framework.algorithm;version=\"1.0.0\"", + "org.cishell.framework.data;version=\"1.0.0\"", "org.osgi.framework;version=\"1.3.0\"", "org.osgi.service.component;version=\"1.0.0\"", "org.osgi.service.log;version=\"1.3.0\"", Modified: branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/templates_3.0/java_algorithm/OSGI-INF/component.xml =================================================================== --- branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/templates_3.0/java_algorithm/OSGI-INF/component.xml 2008-03-12 12:52:35 UTC (rev 652) +++ branches/spec_update/org.cishell.templates.wizards/org.cishell.templates.wizards/templates_3.0/java_algorithm/OSGI-INF/component.xml 2008-03-12 13:26:40 UTC (rev 653) @@ -2,8 +2,6 @@ <component name="$algFullClass$.component" immediate="false"> <implementation class="$algFullClass$Factory"/> <properties entry="OSGI-INF/algorithm.properties"/> - <reference name="LOG" interface="org.osgi.service.log.LogService"/> - <reference name="MTS" interface="org.osgi.service.metatype.MetaTypeService"/> <service> <provide interface= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |