diff options
author | Eike Stepper | 2012-04-18 17:22:44 +0000 |
---|---|---|
committer | Eike Stepper | 2012-04-18 17:22:44 +0000 |
commit | 52aa27b62af53e5058becc8a45f06d992a252bef (patch) | |
tree | c288efd9d4af3264f3346596fd6ad68558550b32 /plugins/org.eclipse.net4j/src | |
parent | 3e7b56f4756edd8e9bcf430c49ad4b684ba6aa90 (diff) | |
download | cdo-52aa27b62af53e5058becc8a45f06d992a252bef.tar.gz cdo-52aa27b62af53e5058becc8a45f06d992a252bef.tar.xz cdo-52aa27b62af53e5058becc8a45f06d992a252bef.zip |
[369685] Current linebreaks from help message of the CDOCommandProvider doesn't work under windows
https://bugs.eclipse.org/bugs/show_bug.cgi?id=369685
Diffstat (limited to 'plugins/org.eclipse.net4j/src')
-rw-r--r-- | plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java | 236 |
1 files changed, 120 insertions, 116 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java index 6bc05019bf..65ef88b5cb 100644 --- a/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java +++ b/plugins/org.eclipse.net4j/src/org/eclipse/internal/net4j/bundle/Net4jCommandProvider.java @@ -1,116 +1,120 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.internal.net4j.bundle;
-
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import org.eclipse.osgi.framework.console.CommandInterpreter;
-import org.eclipse.osgi.framework.console.CommandProvider;
-import org.eclipse.spi.net4j.AcceptorFactory;
-import org.eclipse.spi.net4j.ConnectorFactory;
-
-import org.osgi.framework.BundleContext;
-
-/**
- * @author Eike Stepper
- */
-public class Net4jCommandProvider implements CommandProvider
-{
- public Net4jCommandProvider(BundleContext bundleContext)
- {
- bundleContext.registerService(CommandProvider.class.getName(), this, null);
- }
-
- public String getHelp()
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("---Net4j commands---\n");
- buffer.append("\telements - list all managed elements\n");
- buffer.append("\tacceptors - list all active acceptors, their connectors and channels\n");
- buffer.append("\tconnectors - list all active connectors and their channels\n");
- return buffer.toString();
- }
-
- public Object _elements(CommandInterpreter interpreter)
- {
- try
- {
- for (String productGroup : getContainer().getProductGroups())
- {
- interpreter.println(productGroup);
- printFactoryTypes(interpreter, productGroup, " ");
- }
- }
- catch (Exception ex)
- {
- interpreter.printStackTrace(ex);
- }
-
- return null;
- }
-
- public Object _acceptors(CommandInterpreter interpreter)
- {
- try
- {
- printFactoryTypes(interpreter, AcceptorFactory.PRODUCT_GROUP, "");
- }
- catch (Exception ex)
- {
- interpreter.printStackTrace(ex);
- }
-
- return null;
- }
-
- public Object _connectors(CommandInterpreter interpreter)
- {
- try
- {
- printFactoryTypes(interpreter, ConnectorFactory.PRODUCT_GROUP, "");
- }
- catch (Exception ex)
- {
- interpreter.printStackTrace(ex);
- }
-
- return null;
- }
-
- protected IPluginContainer getContainer()
- {
- return IPluginContainer.INSTANCE;
- }
-
- private void printFactoryTypes(CommandInterpreter interpreter, String productGroup, String prefix)
- {
- IPluginContainer container = getContainer();
- for (String factoryType : container.getFactoryTypes(productGroup))
- {
- interpreter.println(prefix + factoryType);
- printElements(interpreter, container.getElements(productGroup, factoryType), prefix + " ");
- }
- }
-
- private void printElements(CommandInterpreter interpreter, Object[] elements, String prefix)
- {
- for (Object element : elements)
- {
- interpreter.println(prefix + element);
- if (element instanceof IContainer)
- {
- IContainer<?> container = (IContainer<?>)element;
- printElements(interpreter, container.getElements(), prefix + " ");
- }
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.internal.net4j.bundle; + +import org.eclipse.net4j.util.container.IContainer; +import org.eclipse.net4j.util.container.IPluginContainer; + +import org.eclipse.osgi.framework.console.CommandInterpreter; +import org.eclipse.osgi.framework.console.CommandProvider; +import org.eclipse.spi.net4j.AcceptorFactory; +import org.eclipse.spi.net4j.ConnectorFactory; + +import org.osgi.framework.BundleContext; + +/** + * @author Eike Stepper + */ +public class Net4jCommandProvider implements CommandProvider +{ + private static final String NEW_LINE = "\r\n"; //$NON-NLS-1$ + + private static final String INDENT = " "; //$NON-NLS-1$ + + public Net4jCommandProvider(BundleContext bundleContext) + { + bundleContext.registerService(CommandProvider.class.getName(), this, null); + } + + public String getHelp() + { + StringBuffer buffer = new StringBuffer(); + buffer.append("---Net4j commands---" + NEW_LINE); + buffer.append(INDENT + "elements - list all managed elements" + NEW_LINE); + buffer.append(INDENT + "acceptors - list all active acceptors, their connectors and channels" + NEW_LINE); + buffer.append(INDENT + "connectors - list all active connectors and their channels" + NEW_LINE); + return buffer.toString(); + } + + public Object _elements(CommandInterpreter interpreter) + { + try + { + for (String productGroup : getContainer().getProductGroups()) + { + interpreter.println(productGroup); + printFactoryTypes(interpreter, productGroup, " "); + } + } + catch (Exception ex) + { + interpreter.printStackTrace(ex); + } + + return null; + } + + public Object _acceptors(CommandInterpreter interpreter) + { + try + { + printFactoryTypes(interpreter, AcceptorFactory.PRODUCT_GROUP, ""); + } + catch (Exception ex) + { + interpreter.printStackTrace(ex); + } + + return null; + } + + public Object _connectors(CommandInterpreter interpreter) + { + try + { + printFactoryTypes(interpreter, ConnectorFactory.PRODUCT_GROUP, ""); + } + catch (Exception ex) + { + interpreter.printStackTrace(ex); + } + + return null; + } + + protected IPluginContainer getContainer() + { + return IPluginContainer.INSTANCE; + } + + private void printFactoryTypes(CommandInterpreter interpreter, String productGroup, String prefix) + { + IPluginContainer container = getContainer(); + for (String factoryType : container.getFactoryTypes(productGroup)) + { + interpreter.println(prefix + factoryType); + printElements(interpreter, container.getElements(productGroup, factoryType), prefix + " "); + } + } + + private void printElements(CommandInterpreter interpreter, Object[] elements, String prefix) + { + for (Object element : elements) + { + interpreter.println(prefix + element); + if (element instanceof IContainer) + { + IContainer<?> container = (IContainer<?>)element; + printElements(interpreter, container.getElements(), prefix + " "); + } + } + } +} |