diff options
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te')
9 files changed, 781 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/AbstractService.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/AbstractService.java new file mode 100644 index 000000000..7f1a7f8fe --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/AbstractService.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.runtime.services; + +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.tm.te.runtime.services.interfaces.IService; + +/** + * Abstract service implementation. + */ +public class AbstractService extends PlatformObject implements IService { + + private String id = null; + + /** + * Constructor. + */ + public AbstractService() { + } + + /* (non-Javadoc) + * @see org.eclipse.tm.te.runtime.interfaces.services.IService#setId(java.lang.String) + */ + @Override + public final void setId(String id) { + if (id == null) this.id = id; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.te.runtime.interfaces.services.IService#getId() + */ + @Override + public final String getId() { + return id; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/AbstractServiceManager.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/AbstractServiceManager.java new file mode 100644 index 000000000..167803720 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/AbstractServiceManager.java @@ -0,0 +1,278 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.runtime.services; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.tm.te.runtime.activator.CoreBundleActivator; +import org.eclipse.tm.te.runtime.services.interfaces.IService; + +/** + * Abstract service manager implementation. + */ +public abstract class AbstractServiceManager<ServiceClass extends IService> { + + // map for all services per id + private Map<String, List<ServiceProxy>> services = new HashMap<String, List<ServiceProxy>>(); + + /** + * Proxy to provide lazy loading of contributing plug-ins. + */ + protected class ServiceProxy { + + private IConfigurationElement configElement = null; + public String clazz; + private ServiceClass service = null; + private List<Class<? extends ServiceClass>> serviceTypes = new ArrayList<Class<? extends ServiceClass>>(); + + /** + * Constructor. + */ + protected ServiceProxy(IConfigurationElement configElement) { + Assert.isNotNull(configElement); + this.configElement = configElement; + + // Read the class attribute. If null, check for the class sub element + clazz = configElement.getAttribute("class"); //$NON-NLS-1$ + if (clazz == null) { + IConfigurationElement[] children = configElement.getChildren("class"); //$NON-NLS-1$ + // Single element definition assumed (see extension point schema) + if (children.length > 0) { + clazz = children[0].getAttribute("class"); //$NON-NLS-1$ + } + } + } + + /** + * Add a type to the proxy. Types are used unless the proxy is instantiated to provide lazy + * loading of services. After instantiated, a service will be identified only by its type + * and implementing or extending interfaces or super-types. + * + * @param serviceType The type to add. + */ + public void addType(Class<? extends ServiceClass> serviceType) { + assert serviceType != null; + if (service == null && serviceTypes != null && !serviceTypes.contains(serviceType)) { + serviceTypes.add(serviceType); + } + } + + /** + * Return the real service instance for this proxy. + */ + @SuppressWarnings("unchecked") + protected ServiceClass getService(boolean unique) { + if ((service == null || unique) && configElement != null) { + try { + Object service = configElement.createExecutableExtension("class"); //$NON-NLS-1$ + if (service instanceof IService) { + if (unique) { + return (ServiceClass) service; + } + else if (service instanceof IService) { + this.service = (ServiceClass)service; + } + else { + IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Service '" + service.getClass().getName() + "' not of type IService."); //$NON-NLS-1$ //$NON-NLS-2$ + Platform.getLog(CoreBundleActivator.getContext().getBundle()) + .log(status); + } + } + } + catch (CoreException e) { + IStatus status = new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "Cannot create service '" + clazz + "'.", e); //$NON-NLS-1$ //$NON-NLS-2$ + Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status); + } + if (serviceTypes != null) { + serviceTypes.clear(); + } + serviceTypes = null; + } + return service; + } + + /** + * Check whether this proxy holds a service that is suitable for the given type. + * + * @param serviceType The service type + * @return + */ + protected boolean isMatching(Class<? extends ServiceClass> serviceType) { + if (service != null) { + return serviceType.isInstance(service); + } + else if (configElement != null) { + if (serviceType.getClass().getName().equals(clazz)) { + return true; + } + for (Class<? extends ServiceClass> type : serviceTypes) { + if (type.equals(serviceType)) { + return true; + } + } + } + return false; + } + + public boolean equals(ServiceClass service) { + return clazz.equals(service.getClass()); + } + + public boolean equals(ServiceProxy proxy) { + return clazz.equals(proxy.clazz); + } + } + + /** + * Constructor. + */ + protected AbstractServiceManager() { + loadServices(); + } + + /** + * @param element + * @return + */ + protected ServiceProxy getServiceProxy(IConfigurationElement element) { + return new ServiceProxy(element); + } + + /** + * Returns all id's of the registered services. + * + * @return The list of id's of the registered services. + */ + public String[] getIds() { + return services.keySet().toArray(new String[services.keySet().size()]); + } + + /** + * Get a service for the id that implements at least the needed service type. If an interface + * type is given, the service with the highest implementation is returned. This may result in a + * random selection depending on the extension registration order, especially when a service + * interface is implemented two times in different hierarchy paths. If a class type is given, if + * available, the service of exactly that class is returned. Otherwise the highest + * implementation is returned. + * + * @param id The id for which a service is needed. + * @param serviceType The service type the service should at least implement or extend. + * @return The service or <code>null</code>. + */ + public ServiceClass getService(String id, Class<? extends ServiceClass> serviceType) { + return getService(id, serviceType, false); + } + + /** + * Get a service for the id that implements at least the needed service type. If an interface + * type is given, the service with the highest implementation is returned. This may result in a + * random selection depending on the extension registration order, especially when a service + * interface is implemented two times in different hierarchy paths. If a class type is given, if + * available, the service of exactly that class is returned. Otherwise the highest + * implementation is returned. + * + * @param id The id for which a service is needed. + * @param serviceType The service type the service should at least implement or extend. + * @param unique <code>true</code> if a new instance of the service is needed. + * + * @return The service or <code>null</code>. + */ + public ServiceClass getService(String id, Class<? extends ServiceClass> serviceType, boolean unique) { + assert serviceType != null; + if (id == null) { + id = ""; //$NON-NLS-1$ + } + List<ServiceProxy> proxies = services.get(id); + if (proxies != null && !proxies.isEmpty()) { + List<ServiceProxy> candidates = new ArrayList<ServiceProxy>(); + boolean isInterface = serviceType.isInterface(); + for (ServiceProxy proxy : proxies) { + if (proxy.isMatching(serviceType)) { + if (!isInterface && proxy.equals(serviceType)) { + ServiceClass service = proxy.getService(unique); + service.setId(id); + return service; + } + candidates.add(proxy); + } + } + ServiceClass service = null; + if (!candidates.isEmpty()) { + service = candidates.get(0).getService(unique); + service.setId(id); + } + + return service; + } + return null; + } + + /** + * Get a service list for the id that implements at least the needed service type. + * + * @param id The id for which a service is needed. + * @param serviceType The service type the service should at least implement or extend. + * @param unique <code>true</code> if a new instance of the service is needed. + * @return The service list or empty list. + */ + public IService[] getServices(String id, Class<? extends ServiceClass> serviceType, boolean unique) { + assert serviceType != null; + if (id == null) { + id = ""; //$NON-NLS-1$ + } + List<ServiceProxy> proxies = services.get(id); + List<IService> services = new ArrayList<IService>(); + if (proxies != null && !proxies.isEmpty()) { + List<ServiceProxy> candidates = new ArrayList<ServiceProxy>(); + for (ServiceProxy proxy : proxies) { + if (proxy.isMatching(serviceType)) { + candidates.add(proxy); + } + } + for (ServiceProxy serviceProxy : candidates) { + IService service = serviceProxy.getService(unique); + service.setId(id); + services.add(service); + } + } + return services.toArray(new IService[services.size()]); + } + + /* + * Add a service proxy to the list of available services. + */ + protected boolean addService(String id, ServiceProxy proxy) { + assert services != null && id != null && proxy != null; + List<ServiceProxy> proxies = services.get(id); + if (proxies == null) { + proxies = new ArrayList<ServiceProxy>(); + services.put(id, proxies); + } + assert proxies != null; + if (proxies.isEmpty() || !proxies.contains(proxy)) { + return proxies.add(proxy); + } + return false; + } + + /** + * Loads the contributed services into proxies (lazy loading!!) and adds them to this manager; + */ + protected abstract void loadServices(); +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/ServiceManager.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/ServiceManager.java new file mode 100644 index 000000000..b085aa4e3 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/ServiceManager.java @@ -0,0 +1,175 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.runtime.services; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.tm.te.runtime.activator.CoreBundleActivator; +import org.eclipse.tm.te.runtime.services.interfaces.IService; +import org.osgi.framework.Bundle; + +/** + * Common service manager implementation, handling the extension point + * <code>org.eclipse.tm.te.runtime.services</code>. + */ +public class ServiceManager extends AbstractServiceManager<IService> { + /* + * Thread save singleton instance creation. + */ + private static class LazyInstance { + public static ServiceManager fInstance = new ServiceManager(); + } + + /** + * Constructor. + */ + ServiceManager() { + super(); + } + + /** + * Returns the singleton instance of the service manager. + */ + public static ServiceManager getInstance() { + return LazyInstance.fInstance; + } + + /** + * Get a global unbound service that implements at least the needed service type. + * + * If an interface type is given, the service with the highest implementation is returned. + * This may result in a random selection depending on the extension registration order, + * especially when a service interface is implemented two times in different hierarchy paths. + * + * If a class type is given, if available, the service of exactly that class is returned. + * Otherwise the highest implementation is returned. + * + * @param serviceType The service type the service should at least implement or extend. + * @return The service or <code>null</code>. + */ + public IService getService(Class<? extends IService> serviceType, boolean unique) { + return super.getService("", serviceType, unique); //$NON-NLS-1$ + } + + /** + * Get a global unbound service that implements at least the needed service type. + * + * If an interface type is given, the service with the highest implementation is returned. + * This may result in a random selection depending on the extension registration order, + * especially when a service interface is implemented two times in different hierarchy paths. + * + * If a class type is given, if available, the service of exactly that class is returned. + * Otherwise the highest implementation is returned. + * + * @param serviceType The service type the service should at least implement or extend. + * @return The service or <code>null</code>. + */ + public IService getService(Class<? extends IService> serviceType) { + return super.getService("", serviceType); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see com.windriver.core.runtime.services.AbstractServiceManager#loadServices() + */ + @SuppressWarnings("unchecked") + @Override + protected void loadServices() { + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.tm.te.runtime.services"); //$NON-NLS-1$ + if (ep != null) { + IExtension[] extensions = ep.getExtensions(); + if (extensions != null) { + for (IExtension extension : extensions) { + IConfigurationElement[] configElements = extension.getConfigurationElements(); + if (configElements != null) { + for (IConfigurationElement configElement : configElements) { + // Determine the unique id to bind the service contributions to. + String id = null; + + if ("backendServices".equals(configElement.getName())) { //$NON-NLS-1$ + id = configElement.getAttribute("backendId"); //$NON-NLS-1$ + + // For a backend service declaration, the backend id is mandatory + if (id == null || "".equals(id)) { //$NON-NLS-1$ + IStatus status = new Status(IStatus.WARNING, CoreBundleActivator.getUniqueIdentifier(), + "Skipped backend service contributions from contributor '" + configElement.getDeclaringExtension().getNamespaceIdentifier() + "'." //$NON-NLS-1$ //$NON-NLS-2$ + + " Reason: Missing mandatory backend id."); //$NON-NLS-1$ + Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status); + continue; + } + } + else if ("dataSourceServices".equals(configElement.getName())) { //$NON-NLS-1$ + id = configElement.getAttribute("dataSourceId"); //$NON-NLS-1$ + + // For a data source service declaration, the data source id is mandatory + if (id == null || "".equals(id)) { //$NON-NLS-1$ + IStatus status = new Status(IStatus.WARNING, CoreBundleActivator.getUniqueIdentifier(), + "Skipped data source service contributions from contributor '" + configElement.getDeclaringExtension().getNamespaceIdentifier() + "'." //$NON-NLS-1$ //$NON-NLS-2$ + + " Reason: Missing mandatory data source id."); //$NON-NLS-1$ + Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status); + continue; + } + } + else if ("genericServices".equals(configElement.getName())) { //$NON-NLS-1$ + id = configElement.getAttribute("id"); //$NON-NLS-1$ + } + + // Normalize the id + if (id == null) id = ""; //$NON-NLS-1$ + + // Get the service contributions + IConfigurationElement[] services = configElement.getChildren("service"); //$NON-NLS-1$ + // Process the service contributions + for (IConfigurationElement service : services) { + ServiceProxy proxy = getServiceProxy(service); + IConfigurationElement[] serviceTypes = service.getChildren("serviceType"); //$NON-NLS-1$ + if (serviceTypes != null && serviceTypes.length > 0) { + for (IConfigurationElement serviceType : serviceTypes) { + try { + String type = serviceType.getAttribute("class"); //$NON-NLS-1$ + String bundleId = serviceType.getAttribute("bundleId"); //$NON-NLS-1$ + + // If a bundle id got specified, use the specified bundle to load the service class + Bundle bundle = bundleId != null ? bundle = Platform.getBundle(bundleId) : null; + // If we don't have a bundle to load from yet, fallback to the declaring bundle + if (bundle == null) bundle = Platform.getBundle(configElement.getDeclaringExtension().getNamespaceIdentifier()); + // And finally, use our own bundle to load the class. + // This fallback is expected to never be used. + if (bundle == null) bundle = CoreBundleActivator.getContext().getBundle(); + + // Try to load the service type class now. + Class<?> typeClass = bundle != null ? bundle.loadClass(type) : Class.forName(type); + proxy.addType((Class<IService>)typeClass); + } + catch (Exception e) { + IStatus status = new Status(IStatus.WARNING, CoreBundleActivator.getUniqueIdentifier(), + "Cannot create service type '" + serviceType.getAttribute("class") //$NON-NLS-1$//$NON-NLS-2$ + + "' for service '" + service.getAttribute("class") + "'.", e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status); + } + } + } + if (!addService(id, proxy)) { + IStatus status = new Status(IStatus.WARNING, CoreBundleActivator.getUniqueIdentifier(), + "Failed to bind service '" + proxy.clazz + "' to id '" + id + "'.", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + Platform.getLog(CoreBundleActivator.getContext().getBundle()).log(status); + } + } + } + } + } + } + } + } + +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/activator/CoreBundleActivator.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/activator/CoreBundleActivator.java new file mode 100644 index 000000000..26e266672 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/activator/CoreBundleActivator.java @@ -0,0 +1,71 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.runtime.services.activator;
+
+import org.eclipse.tm.te.runtime.tracing.TraceHandler;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class CoreBundleActivator implements BundleActivator {
+ // The bundle context
+ private static BundleContext context;
+ // The trace handler instance
+ private static TraceHandler traceHandler;
+
+ /**
+ * Returns the bundle context
+ *
+ * @return the bundle context
+ */
+ public static BundleContext getContext() {
+ return context;
+ }
+
+ /**
+ * Convenience method which returns the unique identifier of this plugin.
+ */
+ public static String getUniqueIdentifier() {
+ if (getContext() != null && getContext().getBundle() != null) {
+ return getContext().getBundle().getSymbolicName();
+ }
+ return null;
+ }
+
+ /**
+ * Returns the bundles trace handler.
+ *
+ * @return The bundles trace handler.
+ */
+ public static TraceHandler getTraceHandler() {
+ if (traceHandler == null) {
+ traceHandler = new TraceHandler(getUniqueIdentifier());
+ }
+ return traceHandler;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext bundleContext) throws Exception {
+ CoreBundleActivator.context = bundleContext;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext bundleContext) throws Exception {
+ CoreBundleActivator.context = null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/IService.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/IService.java new file mode 100644 index 000000000..309864681 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/IService.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.runtime.services.interfaces; + +/** + * Common service. + */ +public interface IService { + + /** + * Sets the id this service is registered to. + * <p> + * <b>Note:</b> Once set to a non-null value, the service id cannot be changed anymore. + * + * @param id The id or <code>null</code>. + */ + public void setId(String id); + + /** + * Returns the id this service is registered to. + * + * @return The id or <code>null</code> if the service id is not yet set. + */ + public String getId(); +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/ITerminalService.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/ITerminalService.java new file mode 100644 index 000000000..a9c8f5023 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/ITerminalService.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.runtime.services.interfaces; + +import org.eclipse.tm.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tm.te.runtime.interfaces.properties.IPropertiesContainer; + +/** + * Terminals service. + * <p> + * Allow to use the embedded terminals view for remote input and output. + */ +public interface ITerminalService extends IService { + + /** + * Opens the terminal console asynchronously and invokes the given callback if done. + * + * @param properties The terminal console properties. Must be not <code>null</code>. + * @param callback The target callback to invoke if finished or <code>null</code>. + */ + public void openConsole(IPropertiesContainer properties, ICallback callback); + + /** + * Close the terminal console asynchronously and invokes the given callback if done. + * + * @param properties The terminal console properties. Must be not <code>null</code>. + * @param callback The target callback to invoke if finished or <code>null</code>. + */ + public void closeConsole(IPropertiesContainer properties, ICallback callback); +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ITerminalServiceConstants.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ITerminalServiceConstants.java new file mode 100644 index 000000000..68feacd87 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/interfaces/constants/ITerminalServiceConstants.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.runtime.services.interfaces.constants; + +/** + * Defines the constants to be used with the terminal service. + */ +public interface ITerminalServiceConstants { + + /** + * Common terminal connector types. + */ + public enum ConnectorType { TELNET, SSH, SERIAL, PROCESS, STREAMS } + + /** + * Common terminal property: The unique id of the terminal console view to open. + */ + public static final String PROP_ID = "id"; //$NON-NLS-1$ + + /** + * Common terminal property: The title of the terminal console tab to open. + */ + public static final String PROP_TITLE = "title"; //$NON-NLS-1$ + + /** + * Common terminal property: Custom data object to associate with the terminal console tab. + */ + public static final String PROP_DATA = "data"; //$NON-NLS-1$ + + /** + * Common terminal property: Terminal connector type like "telnet" or "ssh". + */ + public static final String PROP_CONNECTOR_TYPE = "connector.type"; //$NON-NLS-1$ + + /** + * Optional terminal property: Specific terminal connector type ID. This + * property allows client to override the specific connector implementation + * for a given type. + */ + public static final String PROP_CONNECTOR_TYPE_ID = "connector.type.id"; //$NON-NLS-1$ + + /** + * Common terminal property: Host name or IP address the terminal server is running. + * Typical for telnet or ssh terminal consoles. + */ + public static final String PROP_IP_HOST = "ip.host"; //$NON-NLS-1$ + + /** + * Common terminal property: Port at which the terminal server is providing the console input and output. + * Typical for telnet or ssh terminal consoles. + */ + public static final String PROP_IP_PORT = "ip.port"; //$NON-NLS-1$ + + /** + * Common terminal property: Timeout to be passed to the terminal connector. The specific terminal + * connector implementation may interpret this value differently. If not + * set, the terminal connector may use a default value. + */ + public static final String PROP_TIMEOUT = "timeout"; //$NON-NLS-1$ + + /** + * Common terminal property: Process image path. Typical for process terminal consoles. + */ + public static final String PROP_PROCESS_PATH = "process.path"; //$NON-NLS-1$ + + /** + * Common terminal property: Process arguments. Typical for process terminal consoles. + */ + public static final String PROP_PROCESS_ARGS = "process.args"; //$NON-NLS-1$ + + /** + * Common terminal property: Runtime process instance. Typical for process terminal consoles. + */ + public static final String PROP_PROCESS_OBJ = "process"; //$NON-NLS-1$ + + /** + * Common terminal property: Runtime process PTY instance. Typical for process terminal consoles. + */ + public static final String PROP_PTY_OBJ = "pty"; //$NON-NLS-1$ + + /** + * Common terminal property: Flag to control if a local echo is needed from the terminal widget. + * Typical for process and streams terminal consoles. + */ + public static final String PROP_LOCAL_ECHO = "localEcho"; //$NON-NLS-1$ + + /** + * Common terminal property: Stdin streams instance. Typical for streams terminal consoles. + */ + public static final String PROP_STREAMS_STDIN = "streams.stdin"; //$NON-NLS-1$ + + /** + * Common terminal property: Stdout streams instance. Typical for streams terminal consoles. + */ + public static final String PROP_STREAMS_STDOUT = "streams.stdout"; //$NON-NLS-1$ + + /** + * Common terminal property: Stderr streams instance. Typical for streams terminal consoles. + */ + public static final String PROP_STREAMS_STDERR = "streams.stderr"; //$NON-NLS-1$ +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/nls/Messages.java b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/nls/Messages.java new file mode 100644 index 000000000..32cfb220f --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/nls/Messages.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.runtime.services.nls; + +import org.eclipse.osgi.util.NLS; + +/** + * Target Explorer Services Runtime plugin externalized strings management. + */ +public class Messages extends NLS { + + // The plug-in resource bundle name + private static final String BUNDLE_NAME = "org.eclipse.tm.te.runtime.services.nls.Messages"; //$NON-NLS-1$ + + /** + * Static constructor. + */ + static { + // Load message values from bundle file + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + // **** Declare externalized string id's down here ***** + +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/nls/Messages.properties new file mode 100644 index 000000000..9b32216a4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.runtime.services/src/org/eclipse/tm/te/runtime/services/nls/Messages.properties @@ -0,0 +1,4 @@ +# +# org.eclipse.tm.te.runtime.services +# Externalized Strings. +# |